vicmaster
1/20/2015 - 8:49 AM

Mocking Facebook Omniauth

Mocking Facebook 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[:facebook] = {
    'user_info' => {
      'name' => 'Mario Brothers',
      'image' => '',
      'email' => 'dpsk@email.ru' },
    'uid' => '123545',
    'provider' => 'facebook',
    'credentials' => {'token' => 'token'}
  }

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.