ruby-on-rails-3testcaseactioncontroller

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!


Solution

  • 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 }