title: Using Devise's current_user in Test Unit
body: <p>In some of my controllers I need to use the group(s) that belong to my logged in user(<code>current_user.groups</code>). When I try to test; I don't seem to have this <code>current_user</code> though:</p>
  
  <pre><code>ActionView::Template::Error: undefined method `authenticate' for nil:NilClass
  </code></pre>
  
  <p>So I figured I should create that current_user with Devise.</p>
  
  <p>I've read the documentation of Devise stating I should add the following to my <strong>test_helper.rb</strong>:</p>
  
  <pre><code>class ActionController::TestCase
    include Devise::TestHelpers
      def setup
          @request.env["devise.mapping"] = Devise.mappings[:user]
          sign_in FactoryGirl.create(:user)
      end
  end
  </code></pre>
  
  <p>This doesn't seem to do the trick though; Whenever I run <code>rake test</code> I get the following errors:</p>
  
  <pre><code>  1) Error:
  ActivitiesControllerTest#test_should_create_activity:
  NameError: uninitialized constant ActionController::TestCase::FactoryGirl
      test/test_helper.rb:22:in `setup'
  </code></pre>