jonathan at parkerhill.com
Sat Aug 11 06:11:19 EDT 2007
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
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 => things)
> 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 conflicting
> with other mock frameworks that ppl might choose to use.
> There is also template.stub_render(opts) in case you just want to stub
> 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
More information about the rspec-users