jonathan at parkerhill.com
Sat Aug 11 08:00:01 EDT 2007
oops, my bad
this works (asserts pass, and partial not called)
template.expect_render(:partial => 'bar/foo')
so does this:
template.stub_render(:partial => 'bar/foo')
neither case seems to try to render the partial
On Aug 11, 2007, at 6:11 AM, Jonathan Linowes wrote:
> Hi, I'd like to stub out a partial call but not sure how.
> I tried something like this
> it "should render partial foo" do
> render "/layouts/bar.html.erb"
> response.should render("bar/foo")
> but the partial is still getting called
> On Jun 27, 2007, at 1:31 AM, David Chelimsky wrote:
>> I just added a couple of methods to ActionView::Base in Spec::Rails
>> (as of r2136) that lets you do this in view examples:
>> describe '/things/index.html.erb' do
>> it "should render _thing with a collection of things" do
>> assigns[:things] = things = [Object.new]
>> template.expect_render(:partial => 'thing', :collection =>
>> render '/things/index.html.erb'
>> This solves two big problems - mocking nested partials and mocking
>> :object and :collection in partials.
>> template.expect_render wraps part of 'spec/mocks', but not the whole
>> framework - so we get the expectation matching benefit w/o
>> with other mock frameworks that ppl might choose to use.
>> There is also template.stub_render(opts) in case you just want to
>> the render w/o verification.
>> I would LOVE it if some of you would try this method out and provide
>> feedback before we release it. Please feel to ask any questions about
>> this on this list.
>> rspec-users mailing list
>> rspec-users at rubyforge.org
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users