title: How to access (devise) current_user in a rspec feature test?
body: <p>In the devise documentation they give tips on how you can have access to current_user when testing a controller:</p>
  
  <p><a href="https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29">https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29</a></p>
  
  <p>However, what about when doing a feature test? I am trying to test a create method of one of my controllers, and in that controller is used the current_user variable.</p>
  
  <p>The problem is that the macro suggested in devise uses the @request variable, and it is nil for a feature spec. What is a workaround?</p>
  
  <p>EDIT:</p>
  
  <p>This is what I have so far for my current spec:</p>
  
  <pre><code>feature 'As a user I manage the orders of the system' do
    scenario 'User is logged in ad an admin' do
      user = create(:user)
      order = create(:order, user: user)
      visit orders_path
      #Expectations
    end
  end
  </code></pre>
  
  <p>The problem is that in my <code>OrdersController</code> I have a <code>current_user.orders</code> call, and since <code>current_user</code> is not defined, it will redirect me to <code>/users/sign_in</code>.</p>
  
  <p>I have defined this under <code>/spec/features/manage_orders.rb</code></p>