[rspec-users] expect_render(...).and_return('x')

David Chelimsky dchelimsky at gmail.com
Fri Jan 25 08:42:27 EST 2008


On Jan 25, 2008 7:19 AM, Rob Holland <rob.holland at gmail.com> wrote:
> David,
>
> Thanks for looking at the problem.
>
> > The trick here is that render :partial is NOT getting called on the
> > controller - it's getting called on the template that is yielded to
> > render :update.
>
> I think I follow, still getting my head around that.
>
> > Here's the way I would handle this: http://pastie.caboo.se/143246
>
> I gave that a go, but the render :update line then triggers:
>
> Mock 'expect_render_mock_proxy' asked to yield
> |[#<Spec::Mocks::Mock:0x126ad08 @name="template">]| but no block was
> passed

Yeah - I was playing around w/ this locally and ran into the same
thing. I had made the change in rspec but not committed it yet. As of
trunk r3256, the block does get passed to the mock proxy.

That said, I've thought about this a bit more and realize that using
this approach gives up being able to use should have_rjs, which you
may not want to do.

It's kind of a catch 22. You can either isolate the controller from
the views or not, but you can't isolate it from 1/2 the views in a
given request. At least not with a bunch of magic that doesn't yet
exist in rspec. To be honest, I'm not sure it should.

Cheers,
David

>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list