On Jun 14, 2010, at 6:40 PM, Marcelo de Moraes Serpa wrote:

> Hey guys.
> 
> I would like to test the following behavior:
> 
>        render :update do |page|
>             page.replace_html 'errors', :partial => 'signup_errors', :locals 
> => { :errors => 'errors'}
>           end
>         }
> 
> I'm doing:
> 
> controller.should_receive(:render).with(:update)
> 
> But I am not sure on how to test the block. Maybe checking out what is the 
> class of the page var and setting up an expection on it?

Hmmm. The common idiom for this is:

page = double('page')
controller.stub(:render).with(:update).and_yield(page)
page.should_receive(:replace_html).with(...)

This does not seem to work with rspec-2/rails-3. Don't know why yet (won't be 
able to look for a bit), but my guess is that something (like rspec :) ) is 
adding render() to the controller even later than this stub does. I'll follow 
up if I learn something.

HTH,
David
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to