[rspec-users] view.should render_template best practices?

Evgeniy Dolzhenko dolzenko at gmail.com
Wed Nov 17 03:15:38 EST 2010


I'm sorry for introducing the confusion, but `view.stub!(:render)` won't work,
I should've read the list more attention
http://groups.google.com/group/rspec/browse_thread/thread/1590942f2827f55

On Wed, Nov 17, 2010 at 10:01 AM, Evgeniy Dolzhenko <dolzenko at gmail.com> wrote:
> render_template matcher is to be used after the view is rendered.
> In your case something like
>  view.stub!(:render).with(:partial => "event_list", :locals =>
> {:calendar => @calendar})
>  should do the trick
>
> On Tuesday, November 16, 2010, Matt Darby <mdarby at dynamix-ltd.com> wrote:
>> I've been looking for the definitive answer for months now, and the
>> RSpec book doesn't touch on it at all:
>>
>> How do we now handle stubbing out rendering of partials in view specs
>> in RSpec2?
>>
>> I have a large (35K+ lines of views and related specs) that I'm trying
>> to upgrade to Rails3/RSpec2. My views use partials pretty extensively
>> and this issue is a huge blocker for me.
>>
>>
>> before do
>>   view.should render_template("event_list", :locals => {:calendar =>
>> @calendar})
>> end
>>
>> causes all my related specs fail with:
>>
>> expecting <"event_list"> but rendering with <"">.
>> Expected block to return true value.
>>
>>
>> Any advice?
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
>


More information about the rspec-users mailing list