title: getting past authentication with capybara in rails application
body: <p>I'm trying to use capybara on a ruby on rails application to do some content testing, as well I'm using the devise gem to implement user authentication. I'm having trouble logging into my application to perform my test cases. </p>
  
  <p>Initially, my scenario was as follows: </p>
  
  <pre><code>scenario "User arrives at main page" do 
      visit "purchase_orders#index"
      page.should have_content("All")
      # some more tests and checks
  end
  </code></pre>
  
  <p>Where purchase_orders#index is the authenticated root, where a user's purchase orders are shown.
  But when I was running the tests, I was getting the following error : </p>
  
  <pre><code>expected to find text "All" in "Log in to manage your orders * Email * Password Forgot your password? Remember me Sign up • Didn't receive confirmation instructions? About Us • Contact Us • 
  </code></pre>
  
  <p>which tells me that its not getting past the log in page. I next tried adding the following to my scenario, before running the tests, to make it log in: </p>
  
  <pre><code>    visit "purchase_orders#index"
      fill_in('Email', :with =&gt; 'username@gmail.com')
      fill_in('Password', :with =&gt; 'password')
      click_button('Log in')
  </code></pre>
  
  <p>where username and password are actual created accounts, but again it fails and doesn't get past the sign in page. Finally, I tried adding a before(:each) method, as follows, to attempt to sign users in for test cases: </p>
  
  <pre><code>    before(:each) do
      visit "users/sessions#new"
      fill_in('Email', :with =&gt; 'nico.dubus17@gmail.com')
      fill_in('Password', :with =&gt; 'password')
      click_button('Log in')
  end
  </code></pre>
  
  <p>which, again, did not work for me. So my question is: What is the best practice and syntax for getting past the sign in page, and into the actual application? I've looked for documentation and answers on this, but haven't found anything. </p>
  
  <p>Thank you!</p>