title: Rails view Rspec tests expectations not met
body: <p>I think Rspec view tests are messing up because the links that the tests are looking for are not part of the actual view, but of the application layout header.</p>
  
  <p>For example, I have the following Rspec code:</p>
  
  <pre><code>  describe 'signups/new.html.erb' do
  
    before :each do
      render template: "signups/new", layout: "layouts/application"
    end
  
    it 'displays link to request pages not signup page' do
      rendered.should have_link("Make a new request", href: new_request_path)
      rendered.should_not have_link("Add me to the mailing list", href: new_signup_path)
    end
  </code></pre>
  
  <p>The error that I'm getting is that the link "Add me to the mailing list" has been found. Yet I assure you, in the local server this is not the case.</p>
  
  <p>What's happening in the view is below (again this is all from the layouts/application file, NOT from signups/new):</p>
  
  <pre><code>&lt;nav class="navbar navbar-inverse navbar-static-top" role="navigation"&gt;
    &lt;div class="container"&gt;
      &lt;div class="navbar-header"&gt;
        &lt;a class="navbar-brand" href="&lt;%= root_path %&gt;"&gt;Home&lt;/a&gt;
        &lt;a class="navbar-brand" href="&lt;%= new_request_path %&gt;"&gt;Make a new request&lt;/a&gt;
        &lt;% if current_page?(new_signup_path) == false %&gt;
          &lt;a class="navbar-brand" href="&lt;%= new_signup_path %&gt;"&gt;Add me to the mailing list&lt;/a&gt;
        &lt;% end %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p>Basically it's an If/Then stating that when you're in the signup page, do not show a link to send users to the signup page. Yet the Rspec is indicating that this link is present. Any thoughts on why?</p>
  
  <p>I'm thinking somehow the test is not interpolating the if/then statement, but not sure how to fix this. </p>