title: Test nested layout helper with RSpec and Haml
body: <p>In ApplicationHelper I have such code:</p>
  
  <pre><code>def inside_layout layout = 'application', &amp;block
    @template.instance_variable_set '@content_for_layout', capture(&amp;block)
    concat \
      @template.render :file =&gt; "layouts/#{layout}", :use_full_path =&gt; true
  end
  </code></pre>
  
  <p>which behaves like this:</p>
  
  <p>application.html.haml:</p>
  
  <pre><code>!!!
  %html
    %head
      ...
    %body
      = yield
  </code></pre>
  
  <p>common_pages.html.haml:</p>
  
  <pre><code>- inside_layout do
    ...
  </code></pre>
  
  <p>Then common_pages layout render within application layout.</p>
  
  <p>How I can test this helper with RSpec?</p>
  
  <p>When I call inside_layout from spec file:</p>
  
  <pre><code>helper.inside_layout { }
  </code></pre>
  
  <p>RSpec says error:</p>
  
  <pre><code>ActionView::MissingTemplate in 'ApplicationHelper inside_layout should render nested layout within application layout'
  Missing layout layouts/application.erb in view path
  </code></pre>
  
  <p>But application works fine.</p>