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

2

7

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?

Minardi answered 5/8, 2011 at 16:29 Comment(0)
M
11

Use assert_template 'layouts/layout_name'

Mcandrew answered 5/8, 2011 at 17:43 Comment(0)
W
2

Also I've found that if you're doing a test for nil layout you have to do the following...

assert_template :layout => nil
Wolof answered 4/5, 2013 at 14:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.