Testing rendering of a given layout with RSpec & Rails Testing rendering of a given layout with RSpec & Rails ruby-on-rails ruby-on-rails

Testing rendering of a given layout with RSpec & Rails


David Chelimsky posted a good answer over on the Ruby Forum:

response.should render_template("layouts/some_layout")


This works for me with edge Rails and edge RSpec on Rails:

response.layout.should == 'layouts/application'

Shouldn't be hard to turn this into a matcher suitable for you.


There's already a perfectly functional matcher for this:

response.should render_template(:layout => 'fooo')

(Rspec 2.6.4)