Module: Omniauth::Rails::Test::RequestHelpers

Defined in:
lib/omniauth/rails/test/request_helpers.rb

Instance Method Summary collapse

Instance Method Details

#authenticated?Boolean

Returns:

  • (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 (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