Module: Spree::TestingSupport::AuthHelpers

Defined in:
lib/spree/testing_support/auth_helpers.rb

Instance Method Summary collapse

Instance Method Details

#log_in(email:, password:, remember_me: true, locale: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/spree/testing_support/auth_helpers.rb', line 12

def (email:, password:, remember_me: true, locale: nil)
  visit spree.(locale: locale)

  fill_in Spree.t(:email), with: email
  fill_in Spree.t(:password), with: password

  # Regression test for #1257
  first('label', text: Spree.t(:remember_me)).click if remember_me
  click_button 

  expect(page).to have_content Spree.t(:logged_in_successfully)
end

#log_outObject



25
26
27
28
29
30
# File 'lib/spree/testing_support/auth_helpers.rb', line 25

def log_out
  show_user_menu
  click_link logout_button

  expect(page).to have_content 'Signed out successfully'
end

#login_buttonObject



4
5
6
# File 'lib/spree/testing_support/auth_helpers.rb', line 4

def 
  Spree.version.to_f == 4.1 ? Spree.t(:log_in) : Spree.t(:login)
end

#logout_buttonObject



8
9
10
# File 'lib/spree/testing_support/auth_helpers.rb', line 8

def logout_button
  Spree.version.to_f == 4.1 ? Spree.t('nav_bar.log_out') : Spree.t(:logout).upcase
end

#show_user_accountObject



36
37
38
39
40
41
# File 'lib/spree/testing_support/auth_helpers.rb', line 36

def 
  within '#nav-bar' do
    show_user_menu
    click_link Spree.t(:my_account).upcase
  end
end

#show_user_menuObject



32
33
34
# File 'lib/spree/testing_support/auth_helpers.rb', line 32

def show_user_menu
  find("button[aria-label='#{Spree.t('nav_bar.show_user_menu')}']").click
end