dchelimsky at gmail.com
Wed Jun 27 01:31:53 EDT 2007
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)
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.
More information about the rspec-devel