[rspec-users] controller.expect_render has me beat!

sinclair bain rspec.user at gmail.com
Fri Sep 14 22:35:48 EDT 2007


Hi,

A controller has a method with the following


 def update
    ...
    if @config.update_attributes ( params[:new_config] )
      redirect_to :action => :index
    else
    *  render :action => :edit, :id => params[:id]      # this line here*
    end
  ...
end


The example has the following


  it 'should render the "edit" config url on an unsuccessful save' do
    @config.should_receive(:update_attributes).once.and_return(false)
    c*ontroller.expect_render( :action => :edit, :id => 1 ).once           #
 my prob*
    do_update
  end


This fails with
...
Mock 'expect_render_mock_proxy' expected :render with ({:action=>:edit,
:id=>1}) once, but received it 0 times


I have tried
    controller.expect_render( :action => :edit ).once


Am I using #expect_render correctly?


Thanks for all and any help!


Cheers!
sinclair
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070914/ab198e3f/attachment.html 


More information about the rspec-users mailing list