Question: 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 [Integration testing with Sorcery](https://github.com/NoamB/sorcery/wiki/Integration-Testing-with-Rspec,-Capybara-and-Fabricator) and can post the login action properly, but my tests still doesn't think the user is logged in.

```
# 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

```

And my login\_user method

```
# 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

```

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.

Here's the output of the failed tests:

```
1) UsersController user access should log in the user
    Failure/Error: controller.should be_logged_in
    expected logged_in? to return true, got false

```

Answer: 
Did you try adding to spec/spec\_helpers.

```
RSpec.configure do |config|
  # ...
  config.include Sorcery::TestHelpers::Rails::Controller
end

```

Nota that you need to include `Sorcery::TestHelpers::Rails::Controller`, not just `Sorcery::TestHelpers::Rails`.

Then you will be able to `login_user` from any controller specs like:

```
describe CategoriesController do

  before do
    @user = FactoryGirl::create(:user)
  end

  describe "GET 'index'" do
    it "returns http success" do
      login_user
      get 'index'
      expect(response).to be_success
    end
  end
end

```
The way you pass a password is probably wrong. It may be encrypted at this point. In provided example I will try to do this at first:

```
describe 'user access' do
    let (:user) { create(:user, password: 'secret') }

    before :each do
      login_user(user[:email], 'secret')
    end

    it "should log in the user" do
      controller.should be_logged_in
    end
end

```