title: Rspec tests for administrative 'delete' links fail. Michael Hartl's ROR 3.2 Tutorial - Chapter 9.4.2
body: <p>I am following Michael's ROR tutorial and creating user authentication system. There is an admin privilige, which allows users to delete other users. Special 'delete' links appear on the users listing page when logged in as a priviliged admin user.
  My App works fine but rspec tests are failing for a reason unknown to me.</p>
  
  <p>I've separated the tests to another file <code>spec/requests/sat_spec.rb</code> and I am trying to use pry gem to debug it, but no success so far.</p>
  
  <pre><code>describe "delete links" do
    describe "as admin user" do
      let(:admin) { FactoryGirl.create(:admin) }
      before do
        sign_in admin
        visit users_path
        binding.pry          
      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    
  end
  </code></pre>
  
  <p>Test Failures:</p>
  
  <pre><code>1) separated admin tests delete links as admin user 
   Failure/Error: it { should have_link('delete', href: user_path(User.first)) }
     expected link "delete" to return something
   # ./spec/requests/sat_spec.rb:25:in `block (4 levels) in &lt;top (required)&gt;'
  
  2) separated admin tests delete links as admin user 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/sat_spec.rb:28:in `block (5 levels) in &lt;top (required)&gt;'
   # ./spec/requests/sat_spec.rb:28:in `block (4 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>What might by the problem here or <strong>more importantly how to debug it?</strong></p>
  
  <p>You can fork my code here <a href="https://github.com/tomek-rusilko/miniatury_katalog_2">https://github.com/tomek-rusilko/miniatury_katalog_2</a></p>