Module: AuthRequestHelper

Defined in:
lib/generators/rockstart/authorization/auth0/templates/spec/support/auth_request_helper.rb

Overview

Helpers for Auth0 with request specs

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/generators/rockstart/authorization/auth0/templates/spec/support/auth_request_helper.rb', line 5

def self.included(base)
  base.before(:all) do
    OmniAuth.config.test_mode = true
  end
  base.after(:each) do
    OmniAuth.config.mock_auth[:auth0] = nil
  end
end

Instance Method Details

#sign_in(resource) ⇒ Object



14
15
16
17
18
# File 'lib/generators/rockstart/authorization/auth0/templates/spec/support/auth_request_helper.rb', line 14

def (resource)
  OmniAuth.config.mock_auth[:auth0] = OmniAuth::AuthHash.new(resource.to_h)
  post "/auth/auth0"
  follow_redirect! # call the callback endpoint
end

#sign_out(_resource) ⇒ Object



20
21
22
# File 'lib/generators/rockstart/authorization/auth0/templates/spec/support/auth_request_helper.rb', line 20

def sign_out(_resource)
  delete auth_sign_out_path
end