Add login & user tests
This commit is contained in:
34
spec/features/login_spec.rb
Normal file
34
spec/features/login_spec.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.feature "Login", type: :feature do
|
||||
context "visiting the login page" do
|
||||
let!(:user) { create(:user) }
|
||||
|
||||
it "should log in the user with the correct credentials" do
|
||||
visit '/'
|
||||
fill_in "Email address", with: user.email_address
|
||||
fill_in "Password", with: user.password
|
||||
click_button "Sign in"
|
||||
|
||||
expect(page).not_to have_content("Login")
|
||||
end
|
||||
|
||||
it "should fail to log in the user with an incorrect email address" do
|
||||
visit '/'
|
||||
fill_in "Email address", with: Faker::Internet.unique.email
|
||||
fill_in "Password", with: user.password
|
||||
click_button "Sign in"
|
||||
|
||||
expect(page).to have_content("Login")
|
||||
end
|
||||
|
||||
it "should fail to log in the user with an incorrect password" do
|
||||
visit '/'
|
||||
fill_in "Email address", with: user.email_address
|
||||
fill_in "Password", with: Faker::Internet.unique.password
|
||||
click_button "Sign in"
|
||||
|
||||
expect(page).to have_content("Login")
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user