diff options
Diffstat (limited to 'spec/features/login_spec.rb')
| -rw-r--r-- | spec/features/login_spec.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/spec/features/login_spec.rb b/spec/features/login_spec.rb index 3eb9ad4..42f65a8 100644 --- a/spec/features/login_spec.rb +++ b/spec/features/login_spec.rb @@ -3,28 +3,28 @@ require 'rails_helper' describe "the signin process", type: :feature do let!(:user) { create(:user, password: 'password') } let(:login_page) { LoginPage.new } + let(:dashboard_page) { DashboardPage.new } context "when the credentials are correct" do it 'signs the user in' do - login_page.login_with(email: user.email, password: 'password') - expect(page).to have_content("Dashboard") - expect(current_path).to eql(root_path) + login_page.visit_page.login_with(email: user.email, password: 'password') + expect(dashboard_page).to be_on_page end end context "when the password is incorrect" do it 'displays an error' do - login_page.login_with(email: user.email, password: 'wrong') - expect(page).to have_content(I18n.translate(:invalid_credentials)) - expect(current_path).to eql(new_session_path) + login_page.visit_page.login_with(email: user.email, password: 'wrong') + expect(login_page).to be_on_page + expect(login_page).to have_error(:invalid_credentials) end end context "when the email is unknown" do it 'displays an error' do - login_page.login_with(email: 'test@example.com', password: 'password') - expect(page).to have_content(I18n.translate(:invalid_credentials)) - expect(current_path).to eql(new_session_path) + login_page.visit_page.login_with(email: 'test@example.com', password: 'password') + expect(login_page).to be_on_page + expect(login_page).to have_error(:invalid_credentials) end end end |
