main
 1require 'rails_helper'
 2
 3describe "the signin process", type: :feature do
 4  let!(:user) { create(:user, password: 'password') }
 5  let(:login_page) { LoginPage.new }
 6  let(:dashboard_page) { DashboardPage.new }
 7
 8  context "when the credentials are correct" do
 9    it 'signs the user in' do
10      login_page.visit_page.login_with(email: user.email, password: 'password')
11      expect(dashboard_page).to be_on_page
12    end
13  end
14
15  context "when the password is incorrect" do
16    it 'displays an error' do
17      login_page.visit_page.login_with(email: user.email, password: 'wrong')
18      expect(login_page).to be_on_page
19      expect(login_page).to have_error(:invalid_credentials)
20    end
21  end
22
23  context "when the email is unknown" do
24    it 'displays an error' do
25      login_page.visit_page.login_with(email: 'test@example.com', password: 'password')
26      expect(login_page).to be_on_page
27      expect(login_page).to have_error(:invalid_credentials)
28    end
29  end
30end