[rspec-users] Testing render :update

Marcelo de Moraes Serpa celoserpa at gmail.com
Tue Jun 15 19:09:40 EDT 2010


Ah!

Thanks for the heads up about heads out ;)

Obrigado,

Marcelo.

On Tue, Jun 15, 2010 at 5:34 PM, David Chelimsky <dchelimsky at gmail.com>wrote:

> Por nada!
>
> ps - em inglês, a frase é "heads up" :)
>
> On Jun 15, 2010, at 5:27 PM, Marcelo de Moraes Serpa wrote:
>
> Thanks for the heads out, David :)
>
> On Mon, Jun 14, 2010 at 9:35 PM, David Chelimsky <dchelimsky at gmail.com>wrote:
>
>>
>> On Jun 14, 2010, at 7:05 PM, David Chelimsky wrote:
>>
>> > 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.
>>
>> Looks like action_pack calls render twice (the 2nd time in
>> action_controller/metal/implicit_render.rb:10:in `default_render'), so we've
>> got to stub the :render call twice:
>>
>> page = double('page')
>> controller.stub(:render)
>> controller.stub(:render).with(:update).and_yield(page)
>> page.should_receive(:replace_html).with(...)
>>
>> Bummer. It seems like this is a rails bug (render should only get called
>> once, and there is code that prevents it from being called twice, but not
>> _all_ of the time), but I'm not sure if I can make that case or not. I'll
>> try :)
>>
>> Cheers,
>> David
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
>
>
> _______________________________________________
> 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/20100615/de42b544/attachment.html>


More information about the rspec-users mailing list