vendredi 10 juillet 2015

assert_select delete test not working when view has delete

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:
UsersIndexTest#test_index_as_admin_including_pagination_and_delete_links [/Users/joseph/Documents/Safsy/Website/Safsy/Safsy/test/integration/users_index_test.rb:15]:
Expected at least 1 element matching "delete", found 0..
Expected 0 to be >= 1.

The test. Line 15 is assert_select 'delete'

  test "index as admin including pagination and delete links" do
    log_in_as(@admin)
    get users_path
    assert_template 'users/index'
    assert_select 'div.pagination'
    assert_select 'delete'
  end

User index view

<h1>All users</h1>

<%= will_paginate %>

<ul class="users">
  <% @users.each do |user| %>
    <li>
      <%= link_to user.username, user_url(user.id) %>
      <% if current_user.admin? && !current_user?(user) %>
        | <%= link_to "delete", user, method: :delete,
                                    data: { confirm: "You sure?" } %>
        <% end %>
    </li>
  <% end %>
</ul>

<%= will_paginate %>

Aucun commentaire:

Enregistrer un commentaire