Is it possible to test the use of a given layout using RSpec with Rails, for example I\'d like a matcher that does the following:
response.should use_layout(
Shoulda Matchers provides a matcher for this scenario. (Documentation) This seems to work:
expect(response).to render_with_layout('my_layout')
it produces appropriate failure messages like:
Expected to render with the "calendar_layout" layout, but rendered with "application", "application"
Tested with rails 4.2
, rspec 3.3
and shoulda-matchers 2.8.0
Edit: shoulda-matchers provides this method. Shoulda::Matchers::ActionController::RenderWithLayoutMatcher