[rspec-users] [rspec] Stubbing partials in view specs
zuperinfinite at gmail.com
Tue Jan 20 08:44:02 EST 2009
As a good BDDer I want to test my views in isolation. And as a good
rails programmer, I separate views into partials when needed. So,
when testing my views, I want to stub out rendering of partials in my
views. I'm working on upgrading an app from rails 2.1.2 to 2.2.2,
using the latest rspec and rspec-rails.
I used to throw template.stub!(:render) in a before(:each) block and
be done with it, but that doesn't work anymore. I can understand why,
but now I have to do something like template.stub!(:render).with
(hash_including(:partial => anything)). Except for when I'm testing a
partial, then I need to replace the anything with every partial I'm
rendering in my partial.
Is this the correct way, or is there perhaps something like
template.stub_partials :only => , :except =>  ?
More information about the rspec-users