Skip to content

Instantly share code, notes, and snippets.

@vicmaster
Last active August 29, 2015 14:13
Show Gist options
  • Save vicmaster/bd3e84fd55d0fb3f60d3 to your computer and use it in GitHub Desktop.
Save vicmaster/bd3e84fd55d0fb3f60d3 to your computer and use it in GitHub Desktop.
Mocking Gmail Omniauth

The mock_auth configuration allows you to set per-provider (or default) authentication hashes to return during integration testing. You can set it like so:

  OmniAuth.configure do |config|
    config.test_mode = true
    config.add_mock(:default, {
      :info => {
                  :email => 'foobar@crowdint.com',
                  :name => 'foo',
                  :password => 'qwerty123',
                  :is_admin => true
               }
    })
  end

You can set the :default key to return a hash for providers that haven't been specified. Once you set the mock auth hash and turn on test mode, all requests to OmniAuth will return an auth hash from the mock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment