Note that there are some explanatory texts on larger screens.

plurals
  1. POrspec render_views ignores layouts? want to test static cached page does not display flash message
    primarykey
    data
    text
    <p>I'm trying to test that "static" pages (they're ERB, but get cached), generated through rails, don't render any stray flash notices left over by the authentication system (Devise) or wherever else.</p> <p>I've tried writing this controller spec, but it appears that response.body only renders the template, not its layouts?</p> <pre><code> describe "so that static caching can be used" do render_views specify "flash notices are not rendered" do # edit: the following flash lines don't do anything # it's not the right flash object, this one is intended for # inspecting after request not setting before request flash[:notice] = "flash boo" flash[:error] = "flash boo" flash[:alert] = "flash boo" get :show, :page =&gt; 'privacy_policy' response.body.should have_content('flash boo') end end class StaticPagesController &lt; ApplicationController layout 'master' def show response.headers['Cache-Control'] = "public, max-age=#{6.hours}" render "static_pages/#{params[:page]}" end end </code></pre> <p>I've tried changing to a layout which does render flash notices, and even inserting the text into the layout template, but can't make the spec fail. </p> <p>Is there a way to ask rspec to render the template with the appropriate layouts as well?</p> <p>Is a controller spec the wrong way to try and do this? It seems out of place, as it's more to do with which layouts are being used, and their contents, but the rendering process starts at the controller, it receives the result, and I can manipulate the flash hash contents before rendering.</p> <p>Versions: rails (3.0.10), rspec-rails (2.6.1), rspec-core (2.6.4)</p> <p>Thanks, Nick</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload