Search code examples
ruby-on-railsruby-on-rails-3testingfunctional-testingrails-3-upgrade

How to test if correct layout was used in controller in Rails 3


In Rails 2 I would do

  def assert_layout(layout_name)
    assert_equal layout_name, @response.layout
  end

and:

 assert_layout 'layouts/layout_name'

This doesn't work in rails 3 anymore (undefined method `layout'). How should I change the custom assert_layout method?


Solution

  • Use assert_template 'layouts/layout_name'