The sign in spec that was generated with the rails 4 template is failing, and it seems like what is being returned in the test environment should make the spec pass.
spec:
Sign in user cannot sign in if not registered
Is looking for "Invalid Email or Password" on the page. When I try to login in with invalid credentials this message is definitely displayed in the flash messages. Also, you can see that the page content returned by capybara in the test env has the text 'Invalid Email or Password'. See below:
1) Sign in user cannot sign in if not registered
Failure/Error: expect(page).to have_content I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'email'
expected to find text "Invalid email or password." in "Toggle navigation Home About Sign in Sign up × Invalid Email or password. Sign in Sign up Email Forgot password? Password Remember me"
# ./spec/features/users/sign_in_spec.rb:13:in `block (2 levels) in <top (required)>'
2) Sign in user cannot sign in with wrong email
Failure/Error: expect(page).to have_content I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'email'
expected to find text "Invalid email or password." in "Toggle navigation Home About Sign in Sign up × Invalid Email or password. Sign in Sign up Email Forgot password? Password Remember me"
# ./spec/features/users/sign_in_spec.rb:35:in `block (2 levels) in <top (required)>'
3) Sign in user cannot sign in with wrong password
Failure/Error: expect(page).to have_content I18n.t 'devise.failure.invalid', authentication_keys: 'email'
expected to find text "Invalid email or password." in "Toggle navigation Home About Sign in Sign up × Invalid Email or password. Sign in Sign up Email Forgot password? Password Remember me"
# ./spec/features/users/sign_in_spec.rb:46:in `block (2 levels) in <top (required)>'
UPDATE:
I tried changing from this:
expect(page).to have_content I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'email'
to this:
expect(page).to have_selector('#flash_alert', visible: true, text: "Invalid Email or Password.")
But now the test fails like so:
1) Sign in user cannot sign in if not registered
Failure/Error: expect(page).to have_selector('#flash_alert', visible: true, text: "Invalid Email or Password.")
expected to find css "#flash_alert" with text "Invalid Email or Password." but there were no matches. Also found "Invalid Email or password.", which matched the selector but not all filters.