45 lines
1.7 KiB
Ruby
45 lines
1.7 KiB
Ruby
# Feature: Sign in
|
|
# As a user
|
|
# I want to sign in
|
|
# So I can visit protected areas of the site
|
|
feature 'Sign in', :devise do
|
|
|
|
scenario 'user cannot sign in if not registered', js: true do
|
|
user = FactoryBot.build(:user)
|
|
signin(user.screen_name, user.password)
|
|
expect(page).to have_content I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'login'
|
|
end
|
|
|
|
# Scenario: User can sign in with valid credentials
|
|
# Given I exist as a user
|
|
# And I am not signed in
|
|
# When I sign in with valid credentials
|
|
# Then I see a success message
|
|
scenario 'user can sign in with valid credentials', js: true do
|
|
user = FactoryBot.create(:user)
|
|
signin(user.email, user.password)
|
|
expect(page).to have_content I18n.t 'devise.sessions.signed_in'
|
|
end
|
|
|
|
# Scenario: User cannot sign in with wrong email
|
|
# Given I exist as a user
|
|
# And I am not signed in
|
|
# When I sign in with a wrong email
|
|
# Then I see an invalid email message
|
|
scenario 'user cannot sign in with wrong email', js: true do
|
|
user = FactoryBot.create(:user)
|
|
signin('invalid@email.com', user.password)
|
|
expect(page).to have_content I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'login'
|
|
end
|
|
|
|
# Scenario: User cannot sign in with wrong password
|
|
# Given I exist as a user
|
|
# And I am not signed in
|
|
# When I sign in with a wrong password
|
|
# Then I see an invalid password message
|
|
scenario 'user cannot sign in with wrong password', js: true do
|
|
user = FactoryBot.create(:user)
|
|
signin(user.email, 'what the fuck is my p4s5w0rD again?')
|
|
expect(page).to have_content I18n.t 'devise.failure.invalid', authentication_keys: 'login'
|
|
end
|
|
end |