Module: Omniauth::Rails::Test::RequestHelpers
- Defined in:
- lib/omniauth/rails/test/request_helpers.rb
Instance Method Summary collapse
- #authenticated? ⇒ Boolean
-
#sign_in(email) ⇒ Object
Another option for mocking this, is to use something like this: before do Rails.application.env_config = OmniAuth.config.mock_auth end.
Instance Method Details
#authenticated? ⇒ Boolean
18 19 20 21 |
# File 'lib/omniauth/rails/test/request_helpers.rb', line 18 def authenticated? get "/private" response.status == 200 end |
#sign_in(email) ⇒ Object
Another option for mocking this, is to use something like this: before do
Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:google_oauth2]
end
11 12 13 14 15 16 |
# File 'lib/omniauth/rails/test/request_helpers.rb', line 11 def sign_in(email) fake_session = {} data_store = Omniauth::Rails::AuthenticationDataStore.new(fake_session) data_store.set("email", email) allow(AuthenticationDataStore).to receive(:new).and_return(data_store) end |