[rspec-users] Problems with expect_render

David Chelimsky dchelimsky at gmail.com
Tue Sep 25 11:06:19 EDT 2007


On 9/25/07, Matt Patterson <matt-lists at reprocessed.org> wrote:
> 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:

It is not documented as such, but expect_render does not work with
mocha. It uses rspec's underlying mock framework.

Please feel free to submit a feature request for this.

Cheers,
David

>
> > 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/
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list