#508 √ resolved
Sven Fuchs

Recent changes in ActionPack break controller specs

Reported by Sven Fuchs | August 23rd, 2008 @ 10:56 PM | in 1.1.5

[re-posting this here as requested on the mailinglist]

Trying to port an existing app to current Rails edge I've seen similar things yesterday. I've also updated RSpec/Rails to recent edge.

Here are two workarounds I've come up with for two of the problems. I'm not sure if they cause other problems themselves, but maybe they're still useful as a hint.

http://pastie.org/private/5ueehx...

I don't feel familiar enough with RSpec's guts to provide a patch.

#render_partial on ActionView::Base seems to break because the method signature has changed.

#render on ControllerExampleGroup seems to break because #render_file apparently has been removed.

Comments and changes to this ticket

  • David Chelimsky

    David Chelimsky August 23rd, 2008 @ 10:59 PM

    • → Assigned user changed from “” to “David Chelimsky”
    • → State changed from “new” to “open”

    I'm working on this now.

    I've resolved (locally only) the issue with render_partial, but there are a few other problems that have emerged as well. Will follow up soon, hopefully with a fix for all.

    Cheers, David

  • David Chelimsky

    David Chelimsky August 24th, 2008 @ 05:52 PM

    • → Milestone changed from “No-Milestone-Assigned” to “1.1.5”
    • → State changed from “open” to “resolved”

    render_partial now accepts an options hash instead of 3 separate args.

    Fixed in http://github.com/dchelimsky/rsp...>

  • Sven Fuchs

    Sven Fuchs August 25th, 2008 @ 01:19 PM

    Thanks David!

    We still see a lot of specs failing that previously (Rails 2.1) passed and these failures still seem to be related to RSpec/Rails.

    One pattern is:

    
    # controller
    class AccountController < BaseController
      layout 'simple'
      def new
        # ...
      end
    end
    
    # spec
    response.should render_template('new')
    

    This previously (Rails 2.1) passed, now fails with:

    
    'AccountController GET to :new renders new' FAILED
    expected "new", got "layouts/simple"
    

    ALSO we're seeing specs breaking like this:

    
    # view
    <% if @article.accept_comments? %>
      <%= render :partial => 'comments/form' %>
    <% end %>
    
    # spec
    describe "with an article that does not accept comments" do
      it "should not render the comments/form partial" do
        @article.should_receive(:accept_comments?).and_return false
        template.should_not_receive(:render).with hash_including(:partial => 'comments/form')
        render "sections/show"
      end
    end
    

    This previously (Rails 2.1) passed, now fails with:

    
    Spec::Mocks::MockExpectationError in 'Section views: show view with an article that does not accept comments should not render the comments/form partial'
    Mock 'Article' expected :accept_comments? with (any args) once, but received it 0 times
    ./spec/views/section_views_spec.rb:48:
    

    Curiously when I comment out the second line in the example body the spec then passes:

    
    # spec
    describe "with an article that does not accept comments" do
      it "should not render the comments/form partial" do
        @article.should_receive(:accept_comments?).and_return false
        # template.should_not_receive(:render).with hash_including(:partial => 'comments/form')
        render "sections/show"
      end
    end
    

    So apparently template.should_not_receive(...).with ... seems to prevent the view to be rendered at all?

  • David Chelimsky

    David Chelimsky August 25th, 2008 @ 03:18 PM

    Sven - I opened (and fixed/closed) #509 for the issue with layouts.

    Would you kindly enter separate tickets for the other two so they stay on the radar? They are separate issues and each should be in its own ticket.

    Thanks, David

  • Sven Fuchs

    Sven Fuchs August 25th, 2008 @ 04:28 PM

    Hi David,

    sure thing.

    I'm not totally sure what you mean by "the other two", but I've added #510 and #511

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Behaviour Driven Development for Ruby.

Shared Ticket Bins

People watching this ticket