Sha256: c25b88f336b11a66e25b2af51390786bafd41464e29a6f971cc77786983cbea3

Contents?: true

Size: 1.38 KB

Versions: 14

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

require 'rspeckled/mock_authentications/omniauth'

###
# Tell OmniAuth to just return whatever hash we want for each auth type
#
OmniAuth.configure do |config|
  config.test_mode            = true
  config.mock_auth[:facebook] = OmniAuth::MockAuthentications::Facebook.authentication
  config.mock_auth[:twitter]  = OmniAuth::MockAuthentications::Twitter.authentication
  config.mock_auth[:ebay]     = OmniAuth::MockAuthentications::Ebay.authentication
end

###
# Except we don't want OmniAuth to fake anything when doing live tests
#
RSpec.configure do |config|
  config.around(:each, :js => true) do |example|
    previous_omniauth_test_mode = OmniAuth.config.test_mode
    OmniAuth.config.test_mode   = false

    example.metadata.fetch(:mock_oauth, {}).each do |auth_type, auth_hash|
      OmniAuth.config.add_mock(auth_type, auth_hash)
    end

    example.run

    OmniAuth.config.test_mode = previous_omniauth_test_mode
  end

  config.before(:each, :type => :controller, :mock_oauth => lambda { |v| !!v }) do |example|
    request.env['omniauth.auth'] = if example.metadata[:mock_oauth].is_a? Symbol
                                     OmniAuth.config.mock_auth[example.metadata[:mock_oauth]]
                                   else
                                     OmniAuth::AuthHash.new(example.metadata[:mock_oauth])
                                   end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rspeckled-1.0.3 lib/rspeckled/plugins/omniauth.rb
rspeckled-1.0.2 lib/rspeckled/plugins/omniauth.rb
rspeckled-1.0.1 lib/rspeckled/plugins/omniauth.rb
rspeckled-1.0.0 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.64 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.63 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.62 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.61 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.60 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.59 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.58 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.57 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.56 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.55 lib/rspeckled/plugins/omniauth.rb