I keep getting Invalid email or password. error in RSpec feature test when I try to test sign in implemented using Devise.
spec/features/signing_in_spec.rb
require 'spec_helper'
feature 'Signing in' do
let!(:user) { create :user }
scenario 'signs in user with valid credentials', js: true do
visit '/users/sign_in'
fill_in 'Email', with: user.email
fill_in 'Password', with: user.password
click_button 'Sign in'
expect(page).to have_content 'Dashboard'
end
end
spec/factories/users.rb
FactoryGirl.define do
factory :user do
email '[email protected]'
password '12345678'
password_confirmation '12345678'
factory :admin do
email '[email protected]'
end
end
end
I already verified that user is saved into DB and that sing in works in development.
I actually had the same issue
this https://github.com/plataformatec/devise/wiki/How-To:-Test-with-Capybara helped me.
I had to add this file to my support folder
https://github.com/railscasts/391-testing-javascript-with-phantomjs/blob/master/checkout-after/spec/support/share_db_connection.rb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With