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

Bryan Helmkamp bhelmkamp at gmail.com
Wed Oct 18 12:26:17 EDT 2006


I think you guys are right,  I'm probably stumbling down the wrong
path.  Let me try to answer your questions about how I ended up
here....

Kevin: I want to cut off the render path because I don't want to test
my views in my controller unit tests.  Also, if I don't cut off the
render, I need my mock models to respond decently to all sorts of
queries the views would be sending them.  I don't want to have to
write those.

Chris and James:  I want my test to illustrate that my action never
calls the #render method on controller.  This means I can be sure the
default template is rendering.  So, basically, the expectation should
be:

@controller.expects(:render).never

The problem is, Rails' crafty internals call the @controller#render
method even when I don't, so that expecation will never work.

Thoughts?

-Bryan

On 10/17/06, Kevin Clark <kevin.clark at gmail.com> wrote:
> Bryan,
> I wouldn't worry about cutting off the render path. Render doesn't
> take that long generally (in comparison to db hits) and there's a few
> cool features that make it nice to test views (like being able to
> access what template and layout were rendered).
>
>
> --
> Kevin Clark
> http://glu.ttono.us
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer
>


-- 
http://www.MyCongress.org/ -- coming soon


More information about the mocha-developer mailing list