[rspec-users] RSpec Controller Testing - render_templte Issue

Rails Learner lists at ruby-forum.com
Mon Jul 12 12:44:16 EDT 2010


Hi!

I am writing controller specs and getting a weird expectation failure.
Here is the example. Please read the comments for details:

   it 'renders children/_show partial' do
      post :create, :child => @child

      # The line "response.should render_template('children/_show')"
gives
      # me error:
      # ChildrenController when the enrollment form data is valid
renders
      # children/_show partial' FAILED
      # expected "children/_show", got
"children/_show_print_layout.html.erb"
      response.should render_template('children/_show')


      # This is weird. _show partial contains a button 'Print Form' and
next #assertion passes, but the one above fails.
      response.should have_selector( 'input',
                                     :type => 'submit',
                                     :value => 'Print Form' )
      response.should be_success
    end

Many Thanks!
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list