-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathsessions_spec.rb
More file actions
39 lines (31 loc) · 1.03 KB
/
sessions_spec.rb
File metadata and controls
39 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true
require 'rails_helper'
RSpec.feature 'Sessions', type: :feature do
let(:user) { create(:user) }
scenario 'User signs in successfully with email and password', :js do
# Setup
visit root_path
# Action
fill_in :signin_user_email, with: user.email
fill_in :signin_user_password, with: user.password
click_button 'Sign in'
# Expectation
expect(page).to have_content('Signed in successfully.')
expect(current_path).to eql(plans_path)
expect(page).to have_text(user.firstname)
expect(page).to have_text(user.surname)
end
scenario 'User fails sign in with email and password', :js do
# Setup
visit root_path
# Action
fill_in :signin_user_email, with: user.email
fill_in :signin_user_password, with: 'rong-password'
click_button 'Sign in'
# Expectation
expect(current_path).to eql(root_path)
expect(page).not_to have_text(user.firstname)
expect(page).not_to have_text(user.surname)
expect(page).to have_text('Error')
end
end