summaryrefslogtreecommitdiff
path: root/features/steps/shared/authentication.rb
blob: 5c3e724746b069db1bc79bf401820e1f9d18f665 (plain)
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
require Rails.root.join('spec', 'support', 'login_helpers')

module SharedAuthentication
  include Spinach::DSL
  include LoginHelpers

  step 'I sign in as a user' do
    login_as :user
  end

  step 'I sign in as an admin' do
    login_as :admin
  end

  step 'I sign in as "John Doe"' do
    login_with(user_exists("John Doe"))
  end

  step 'I sign in as "Mary Jane"' do
    login_with(user_exists("Mary Jane"))
  end

  step 'I should be redirected to sign in page' do
    expect(current_path).to eq new_user_session_path
  end

  step "I logout" do
    logout
  end

  step "I logout directly" do
    logout_direct
  end

  def current_user
    @user || User.reorder(nil).first
  end
end