On Wed, Mar 18, 2009 at 4:35 PM, Nick Hoffman <n...@deadorange.com> wrote: > Hey there Evgeny. My response is inline. > >> I call a partial inside another partial. >> _mother.haml contains: >> render :partial => "children/child" > >> In mother_spec.rb file I am trying to stub the render call. >> Here is a working version: >> ============= >> template.should_receive(:render) >> template.stub!(:render) >> >> render :partial => 'mother' >> ============ > > If you set a method expectation on an object (IE: > template.should_receive(:render) ), you don't need to stub the method > (IE: template.stub!(:render) isn't needed). > >> I would prefer to specify that the partial I am stubbing is "children/ >> child", >> however the following code doesn't work for me: >> =========== >> template.stub!(:render).with(hash_including(:partial => 'children/ >> child')) >> template.expect_render(:partial => 'children/child') >> >> render :partial => 'mother' >> >> : Mock 'render_proxy' expected :render with ({:partial=>"children/ >> child"}) once, but received it 0 times >> =========== >> Is it possible to stub the render call with specific partial name? > > What I said above about method expectations and method stubs also > applies here. You should remove the call to #stub! . > > However, I'd be inclined to use #should_receive rather than #expect_render : > > template.should_receive(:render).with :partial => 'children/child' > render :partial => 'mother' > > I haven't written many view specs though, so maybe we're supposed to > use #expect_render .
#expect_render is deprecated prior to 1.2 and it has been removed 1.2. You don't want to use that. :) > > I hope that helps. Cheers, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users