[mocha-developer] Mocking the rendering of a Rails template

Chris Roos chrisjroos at gmail.com
Tue Oct 17 17:49:51 EDT 2006

On 10/17/06, Bryan Helmkamp <bhelmkamp at gmail.com> wrote:
> Hello all,
> I'm having difficulty setting up mocks such that I can verify that
> Rails was going to render the right template file (for example
> new.rhtml) and stop Rails from performing the actual rendering.
> After peeking at Rails' internals, I tried two techniques as illustrated here:
> http://pastie.caboo.se/18197
> Neither worked.
> I think the first one failed because Rails doesn't setup
> response.template to be an instance of ActionView::Base until after
> the controller processing is called.
> I have no idea what is going on with the second attempt.  It's hitting
> a mock, but I have no idea where that mock is coming from.  Logically,
> it probably is coming from the any_instance magic, but in that case it
> should be expecting the render_file call.  Thoughts?
> What am I doing wrong in the second case?  Is there another way I
> could mock this?
I'm wondering how you've arrived in this situation.  It seems to me
that you may be trying to test rails code, rather than your own code
(but that may be due to the simplified example given).

Can you explain exactly what you'd like your tests to illustrate?


More information about the mocha-developer mailing list