title: Authentication Pages spec with valid information tests failing
body: <p>I am following Michael Hart'l RoR Tutorial but seem to have a problem getting the authentication_pages test "with valid information" to pass in chapter 8.</p>
  
  <p>Specifically, the test complains that the relevant links are missing from the page, even though when I actually visit the page, they are there just fine. In fact, even when I hard these links into every page, the tests complain that the relevant links are not present.</p>
  
  <p>The tests are below: the failing ones are the ones 'with valid information' - everything apart from the           it { should have_title(user.name) }</p>
  
  <pre><code>    require 'spec_helper'
  
  describe "AuthenticationPages" do
  
      subject {page}
  
      describe "signin page" do
          before {visit signin_path}
          it {should have_content("Sign in")}
          it {should have_title("Sign in")}
  
          describe "with invalid information" do
              before {click_button('Sign in')}
              it {should have_title('Sign in')}
              it {should have_selector("div.alert.alert-error", text: "Invalid")}
  
  
              describe "after visiting another page" do
                  before {click_link "Home"}
                  it {should_not have_selector("div.alert.alert-error", text: "Invalid")}
              end
          end
  
      **describe "with valid information" do
        let(:user) { FactoryGirl.create(:user) }
        before do
          fill_in "Email",    with: user.email.upcase
          fill_in "Password", with: user.password
          click_button "Sign in"
        end
  
        it { should have_title(user.name) }
        it { should have_link('Profile',     href: user_path(user)) }
        it { should have_link('Sign out',    href: signout_path) }
        it { should_not have_link('Sign in', href: signin_path) }
        it { should have_content('This is the user page')}**
      end
    end
  end
  </code></pre>
  
  <p>Here's the error message:</p>
  
  <pre><code>......................................FFFF
  
  Failures:
  
    1) AuthenticationPages signin page with valid information should have link "Sign out", {:href=&gt;"/signout"}
       Failure/Error: it { should have_link('Sign out',    href: signout_path) }
         expected #has_link?("Sign out", {:href=&gt;"/signout"}) to return true, got false
       # ./spec/requests/authentication_pages_spec.rb:34:in `block (4 levels) in &lt;top (required)&gt;'
  
    2) AuthenticationPages signin page with valid information should have content "This is the user page"
       Failure/Error: it { should have_content('This is the user page')}
         expected #has_content?("This is the user page") to return true, got false
       # ./spec/requests/authentication_pages_spec.rb:36:in `block (4 levels) in &lt;top (required)&gt;'
  
    3) AuthenticationPages signin page with valid information should not have link "Sign in", {:href=&gt;"/signin"}
       Failure/Error: it { should_not have_link('Sign in', href: signin_path) }
         expected #has_link?("Sign in", {:href=&gt;"/signin"}) to return false, got true
       # ./spec/requests/authentication_pages_spec.rb:35:in `block (4 levels) in &lt;top (required)&gt;'
  
    4) AuthenticationPages signin page with valid information should have link "Profile", {:href=&gt;"/users/1"}
       Failure/Error: it { should have_link('Profile',     href: user_path(user)) }
         expected #has_link?("Profile", {:href=&gt;"/users/1"}) to return true, got false
       # ./spec/requests/authentication_pages_spec.rb:33:in `block (4 levels) in &lt;top (required)&gt;'
  
  Finished in 0.74198 seconds
  42 examples, 4 failures
  
  Failed examples:
  
  rspec ./spec/requests/authentication_pages_spec.rb:34 # AuthenticationPages signin page with valid information should have link "Sign out", {:href=&gt;"/signout"}
  rspec ./spec/requests/authentication_pages_spec.rb:36 # AuthenticationPages signin page with valid information should have content "This is the user page"
  rspec ./spec/requests/authentication_pages_spec.rb:35 # AuthenticationPages signin page with valid information should not have link "Sign in", {:href=&gt;"/signin"}
  rspec ./spec/requests/authentication_pages_spec.rb:33 # AuthenticationPages signin page with valid information should have link "Profile", {:href=&gt;"/users/1"}
  </code></pre>
  
  <p>Here's a screenshot of the page after signin
  <img src="https://i.stack.imgur.com/lXhgs.png" alt="enter image description here"></p>
  
  <p>One of the catches is that I can't sign out now!! (i haven't got to the bit of the tutorial where you actually enable sign out yet).</p>
  
  <p>Here's the markup in _header_html.erb which provides the header to the application:</p>
  
  <pre><code>&lt;header class="navbar navbar-fixed-top navbar-inverse"&gt;
    &lt;div class="navbar-inner"&gt;
      &lt;div class="container"&gt;
        &lt;%= link_to "sample app", root_path, id: "logo" %&gt;
        &lt;nav&gt;
          &lt;ul class="nav pull-right"&gt;
            &lt;li&gt;&lt;%= link_to "Home", root_path %&gt;&lt;/li&gt;
            &lt;li&gt;&lt;%= link_to "Help", help_path %&gt;&lt;/li&gt;
            &lt;% if signed_in? %&gt;
              &lt;li&gt;&lt;%= link_to "Users", '#' %&gt;&lt;/li&gt;
              &lt;li id="fat-menu" class="dropdown"&gt;
                &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown"&gt;
                  Account &lt;b class="caret"&gt;&lt;/b&gt;
                &lt;/a&gt;
                &lt;ul class="dropdown-menu"&gt;
                  &lt;li&gt;&lt;%= link_to "Profile", current_user %&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;%= link_to "Settings", '#' %&gt;&lt;/li&gt;
                  &lt;li class="divider"&gt;&lt;/li&gt;
                  &lt;li&gt;
                    &lt;%= link_to "Sign out", signout_path, method: "delete" %&gt;
                  &lt;/li&gt;
                &lt;/ul&gt;
              &lt;/li&gt;
            &lt;% else %&gt;
              &lt;li&gt;&lt;%= link_to "Sign in", signin_path %&gt;&lt;/li&gt;
            &lt;% end %&gt;
          &lt;/ul&gt;
        &lt;/nav&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/header&gt;
  </code></pre>