I try to sign in user to test it in Rspec with Devise. Right now I have:
user = FactoryGirl.create(:user)
sign_in user
And I get an error
NoMethodError:
undefined method `sign_in' for #<RSpec::ExampleGroups::Authorization::WhenSignedIn::GETIndex:0x8374cc2c>
# ./spec/features/authorization_spec.rb
I have read some SO questions and some devise docs about testing(Like this)
So far I tried some various ways, but still didn't manage it to work. If neccessary I can also list them here, but they tend to new errors and complications. So what do I do to make it all work?
LONG STORY: Things I have tried:
Trying something like this:
@user ||= FactoryGirl.create :user
post_via_redirect user_session_path, 'user[email]' => @user.email, 'user[password]' => @user.password
Adding to devise and rails_helper this lines:
config.include Devise::TestHelpers, type: :controller
config.include Devise::TestHelpers, type: :view
And other ways.