I am stuck and cannot figure out where I am going wrong. I have found similar topics but no solutions to these errors:

1) User pages delete links as an admin user admin visiting index page

```
 Failure/Error: it { should have_link('delete', href: user_path(User.first)) }
   expected link "delete" to return something
 # ./spec/requests/user_pages_spec.rb:127:in `block (5 levels) in <top (required)>'

```

2) User pages delete links as an admin user admin visiting index page should be able to delete another user

```
 Failure/Error: expect { click_link('delete') }.to change(User, :count).by(-1)
 Capybara::ElementNotFound:
   no link with title, id or text 'delete' found
 # (eval):2:in `click_link'
 # ./spec/requests/user_pages_spec.rb:129:in `block (6 levels) in <top (required)>'
 # ./spec/requests/user_pages_spec.rb:129:in `block (5 levels) in <top (required)>'

```

Test Code

```
describe "delete links" do

  it { should_not have_link('delete') }
  describe "as an admin user" do
    let(:admin) { FactoryGirl.create(:admin) }
      before do
        sign_in admin
        visit users_path
      end

      it { should have_link('delete', href: user_path(User.first)) }
      it "should be able to delete another user" do
      expect { click_link('delete') }.to change(User, :count).by(-1)
    end
    it { should_not have_link('delete', href: user_path(admin)) }
  end
end

```

Controller:

```
 def
   User.find(params[:id]).destroy
    flash[:success] = "User destroyed."
    redirect_to users_url
  end

```

Index:

```
<% provide(:title, 'All users') %>
<h1>All users</h1>

<%= will_paginate %>

<ul class="users">
  <%= render @users %>
</ul>

<%= will_paginate %>

```

Partial

```
<li>
  <%= gravatar_for user, size: 52 %>
  <%= link_to user.name, user %>
  <% if current_user.admin? && !current_user?(user) %>
    | <%= link_to "delete", user, method: :delete,
                                  data: { confirm: "You sure?" } %>
  <% end %>
</li>

```

Any guidance/help would be greatly appreciated....