[rspec-users] Driving Out A View - Layouts and Sessions?

Lee Lee.Longmore at googlemail.com
Fri Jun 5 11:40:07 EDT 2009


I am driving out a view and I want to test that a link is displayed.

The link_to code for the link is included in the layout for the view
rather than the view template itself.

Here's my example:

  it "should display a link to create a new zone" do
    render "contexts/index.html.erb", :layout => "layouts/
contexts.html.erb"
    response.should contain("sign out")
  end

Firstly, my experiments suggest that the layout is only rendered if
the :layout attribute is included in the call to render. Is my
understanding correct?

Secondly, the link_to code only executes if the session contains a
piece of data (member id). How do I set up the session data in my view
spec?

Thanks.


More information about the rspec-users mailing list