[rspec-devel] template.expect_render

Matt Patterson matt-lists at reprocessed.org
Wed Sep 26 13:17:49 EDT 2007


I've been chasing down a problem with template.expect_render where,  
if you're using mocha, the expectations don't get verified.

I have a spec like this:

> describe "/complex/view" do
>   it "should create entries with titles" do
>     template.expect_render(:partial => 'nonsense')
>
>     render "/complex/view"
>   end
> end

Which passes when it should fail.

This spec, however, fails as it ought:

> describe "/complex/view" do
>   it "should create entries with titles" do
>     template.expect_render(:partial => 'nonsense')
>
>     render "/complex/view"
>
>     template.verify_rendered
>   end
> end

I'm pleased to note that it's been fixed in trunk. The big change I  
could see was a shift from calling after and remove_after on  
Spec::DSL::Behaviour to calling them on Spec::DSL::Example. I'm  
intrigued by what changed here, because the problem clearly was that  
template.verify_rendered wasn't being called after the spec ran...

Can anyone shed some light on this? It would help my knowledge of the  
internals no end...

Thanks,

Matt


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




More information about the rspec-devel mailing list