Module: G5Authenticatable::Test::FeatureHelpers

Defined in:
lib/g5_authenticatable/test/feature_helpers.rb

Overview

Helpers for feature specs

Instance Method Summary collapse

Instance Method Details

#stub_g5_invalid_credentialsObject



17
18
19
# File 'lib/g5_authenticatable/test/feature_helpers.rb', line 17

def stub_g5_invalid_credentials
  OmniAuth.config.mock_auth[:g5] = :invalid_credentials
end

#stub_g5_omniauth(user, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/g5_authenticatable/test/feature_helpers.rb', line 7

def stub_g5_omniauth(user, options = {})
  OmniAuth.config.mock_auth[:g5] = OmniAuth::AuthHash.new({
    uid: user.uid,
    provider: 'g5',
    info: basic_auth_info(user),
    credentials: { token: user.g5_access_token },
    extra: extra_auth_info(user)
  }.merge(options))
end

#visit_path_and_login_with(path, user) ⇒ Object



21
22
23
24
25
# File 'lib/g5_authenticatable/test/feature_helpers.rb', line 21

def (path, user)
  stub_g5_omniauth(user)
  stub_valid_access_token(user.g5_access_token)
  visit path
end