[rspec-users] Problems with expect_render

Matt Patterson matt-lists at reprocessed.org
Tue Sep 25 10:43:58 EDT 2007


Hi there,

I've been working with RSpec for about a week now, and the process of  
moving from a Test::Unit + Mocha setup to an RSpec + Mocha  
environment has been pretty straightforward.

Except, I'm having problems with using template.expect_render.

I have Mocha enabled with:

> config.mock_with :mocha

in spec_helper. And then I have a view spec which looks like this:

> it "should explode messily because I have made this partial name  
> up" do
>   template.expect_render(:partial => 'does_not_exist', :object =>  
> "hello")
>   render "/a/real/template"
> end

If I run this spec, it passes, which it really shouldn't. If I  
comment out the config.mock_with :mocha line and re-run the spec, it  
fails with:

> Mock 'expect_render_mock_proxy' expected :render with  
> ({:partial=>"does_not_exist", :object=>"hello"}) once, but received  
> it 0 times

Which is much better.

So, to me, this looks like a bug in rspec_on_rails.

Explanations of why I'm just doing it wrong gratefully received ;-)

Matt

-- 
   Matt Patterson | Design & Code
   <matt at reprocessed.org> | http://www.reprocessed.org/




More information about the rspec-users mailing list