Skip to content

Instantly share code, notes, and snippets.

@vicmaster
Created January 19, 2015 23:10
Show Gist options
  • Save vicmaster/8578f33bff9e1f89cfa0 to your computer and use it in GitHub Desktop.
Save vicmaster/8578f33bff9e1f89cfa0 to your computer and use it in GitHub Desktop.
Mocking Twitter 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.config.mock_auth[:twitter] = OmniAuth::AuthHash.new({
  :provider => 'twitter',
  :uid => '123545'
  # etc.
})

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