<p>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:</p>

<pre><code>response.should use_layout('my_layout_name')
</code></pre>

<p>I found a use_layout matcher when Googling but it doesn't work as neither the response or controller seem to have a layout property that matcher was looking for.</p>

I found an example of
how to write a
```
use_layout
```
matcher
that will do just that.  Here's the code in case that link goes away:
```
```
# in spec_helper.rb

class UseLayout
   def initialize(expected)
     @expected = 'layouts/' + expected
   end
   def matches?(controller)
     @actual = controller.layout
     #@actual.equal?(@expected)
     @actual == @expected
   end
   def failure_message
     return "use_layout expected #{@expected.inspect}, got # 
{@actual.inspect}", @expected, @actual
   end
   def negeative_failure_message
     return "use_layout expected #{@expected.inspect} not to equal # 
{@actual.inspect}", @expected, @actual
   end
end

def use_layout(expected)
   UseLayout.new(expected)
end

# in controller spec
   response.should use_layout("application")
```
```