title: Testing authentication with Sorcery and RSpec
body: <p>I've spent far too long messing with this before asking for help. I can't seem to get RSpec and Sorcery to play together nicely. I've read through the docs on <a href="https://github.com/NoamB/sorcery/wiki/Integration-Testing-with-Rspec,-Capybara-and-Fabricator" rel="nofollow">Integration testing with Sorcery</a> and can post the login action properly, but my tests still doesn't think the user is logged in.</p>
  
  <pre><code># spec/controllers/user_controller_spec
  describe 'user access' do
      let (:user) { create(:user) }
  
      before :each do
        login_user(user[:email], user[:password])
      end
  
      it "should log in the user" do
        controller.should be_logged_in
      end
  
  end
  </code></pre>
  
  <p>And my login_user method</p>
  
  <pre><code># spec/support/sorcery_login
  module Sorcery
    module TestHelpers
      module Rails
        def login_user email, password
          page.driver.post(sessions_path, { email: email , password: password, remember_me: false })
        end
      end
    end
  end
  </code></pre>
  
  <p>The sessions controller handles the pages properly when I use them on the generated pages just fine. I tried outputting the results of the login_user method and it appears to properly post the data. How do I persist this logged in user through the tests? Does a before :each block not work for this? I'm just not sure where it could be running wrong and I'm pretty new to testing/RSpec so I may be missing something obvious. I'd appreciate any help.</p>
  
  <p>Here's the output of the failed tests:</p>
  
  <pre><code>1) UsersController user access should log in the user
      Failure/Error: controller.should be_logged_in
      expected logged_in? to return true, got false
  </code></pre>