title: Rails 3 with Devise and rspec: Warden test helpers unreliable
body: <p>I have an application using rails 3.2 and Devise. I have a request test suite using rspec and Capybara.</p>
  
  <p>I have attempted to shift to using the Warden test helpers in my sign in helper rather than having Capybara fill in the sign in form and submit it. Due to the size and complexity of my test suite, this results in over a minute and a half of savings in my test runtimes.</p>
  
  <p>In my configuration is:</p>
  
  <pre><code>RSpec.configure do |config|
    config.include Warden::Test::Helpers, :type =&gt; :request
    config.after :each do
      Warden.test_reset!
    end
  end
  </code></pre>
  
  <p>And in a Context:</p>
  
  <pre><code>let!(:current_user) { FactoryGirl.create(:user) }
  
  background do
    login_as(current_user, :scope =&gt; :user)
  end
  </code></pre>
  
  <p>However, when running the test suite using these configurations nearly every test run has a different randomly failing request spec due to the page presenting as though the user were not logged in. (Specifically, links controlled by a <code>user_signed_in?</code> conditional)</p>
  
  <p>My question: Has anyone else encountered such unreliability and how can it be mitigated?</p>