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

s.ross cwdinfo at gmail.com
Sat Sep 15 01:44:58 EDT 2007


Look at your test.log and you can see exactly what was rendered. That  
should explain why the example is failing. This works best if you can  
silence the logs for all examples other than the one you are testing.

On Sep 14, 2007, at 7:35 PM, sinclair bain wrote:

> 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)
>     controller.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
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070914/8999f848/attachment-0001.html 


More information about the rspec-users mailing list