title: Configuring Warden for use in RSpec controller specs
body: <p>I was able to use Devise's <code>sign_in</code> method to log in a user in my controller specs. But now that I'm removing Devise from my application, I'm not quite sure how to get similar functionality working with just Warden on its own.</p>
  
  <p>How should I go about setting up <code>spec/spec_helper.rb</code> and related <code>spec/support/*.rb</code> files to get Warden running within controller specs sufficiently?</p>
  
  <p>I've tried setting up a file at <code>spec/support/warden.rb</code> with these contents:</p>
  
  <pre><code>RSpec.configure do |config|
    config.include Warden::Test::Helpers
  
    config.after do
      Warden.test_reset!
    end
  end
  </code></pre>
  
  <p>Then I have <code>before</code> calls similar to this to authenticate a <code>user</code> factory:</p>
  
  <pre><code>before { login_as FactoryGirl.create(:user) }
  </code></pre>
  
  <p>But here is the error that I keep seeing:</p>
  
  <pre><code>NameError:
    undefined method `user' for nil:NilClass
  </code></pre>
  
  <p>This error traces back to my <code>authenticate_user!</code> method in the controller:</p>
  
  <pre><code>def authenticate_user!
    redirect_to login_path, notice: "You need to sign in or sign up before continuing." if env['warden'].user.nil?
  end
  </code></pre>
  
  <p>I'd appreciate any guidance that anyone could provide.</p>