vendredi 10 juillet 2015

Test Error Expected at least 1 element matching "login_path"

I have an integration test that isn't working. It seems very straight forward why it won't work but i tried to fix it for about 2 hours and can't.

Seems very straight forward. I can't see whats wrong with this. Any clues?

The Error when i run rake test

  1) Failure:
UsersLoginTest#test_login_with_valid_information_followed_by_logout [/Users/josephkonop/Documents/Safsy/Website/Safsy/Safsy/test/integration/users_login_test.rb:32]:
Expected at least 1 element matching "a[href="/login"]", found 0..
Expected 0 to be >= 1.

The test. Line 32 is assert_select "a[href=?]", login_path

  test "login with valid information followed by logout" do
    get login_path
    post login_path, sessions: { email: @user.email, password: 'password' }
    assert is_logged_in?
    assert_redirected_to @user
    follow_redirect!
    assert_template 'users/show'
    assert_select "a[href=?]", login_path, count: 0
    assert_select "a[href=?]", logout_path
    assert_select "a[href=?]", user_path(@user)
    delete logout_path
    assert_not is_logged_in?
    assert_redirected_to root_url
    assert_select "a[href=?]", login_path
    assert_select "a[href=?]", signup_path
    assert_select "a[href=?]", logout_path,      count: 0
    assert_select "a[href=?]", user_path(@user), count: 0
  end

My _header where the login button is

      <ul class="nav navbar-nav navbar-right">   
        <% if logged_in? %>
          <li><%= link_to "Users", users_path %></li>
          <li><%= link_to "Dash", users_path %></li>
          </li>
          <ul class="nav navbar-nav">
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Items<span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><%= link_to "New Item", new_item_path %></li>
                <li><%= link_to "Edit Items", user_items_path %></li>
                <li><a href="#">Mass Upload Items</a></li>
                <li><a href="#">Upload Item Images</a></li>
              </ul>
            </li>
          </ul>
          <ul class="nav navbar-nav">
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Profile<span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><%= link_to "View Profile", user_path(current_user) %></li>
                <li><%= link_to "Edit Profile", edit_user_path(current_user) %></li>
              </ul>
            </li>
          </ul>
          <li><%= link_to "Messages", users_path %></li>
          <li><%= link_to "Log out", logout_path, method: "delete" %></li>
        <% else %>
          <li><%= link_to "Log In", login_path %></li>
          <li><a href="#">Sign Up</a></li>
        <% end %>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</header>

Aucun commentaire:

Enregistrer un commentaire