Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable rendering the view in ActionController TestCase (Rails 3.0.9)

What's the proper way to disable ActionController::TestCase to actually render the views? Alternatively, what'd be the way to render the view without the layout in the tests?

Using rr, I've tried stub(@controller).render { "" }

but this broke the assert_template assertions.

Thanks!

like image 991
zoli Avatar asked Nov 05 '22 18:11

zoli


1 Answers

I had the same problem of disabling just layout, while still rendering the main view. With rspec mocks this works for me:

@controller.stub(:layout).and_return(false)

I've never used rr, but I would imagine the syntax might be as follows:

stub(@controller).layout { false }
like image 191
Sanjay Ginde Avatar answered Nov 09 '22 09:11

Sanjay Ginde