Sha256: 0def9a6d08e80c0f6f929a314b33cedbc1e65748273f91102856dab49dea45a3

Contents?: true

Size: 1.69 KB

Versions: 24

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

##############################################################################
#                             OmniAuth Plugin
##############################################################################

begin
  require 'omniauth'
  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
rescue LoadError
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rspeckled-0.0.54 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.53 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.52 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.51 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.50 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.49 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.48 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.47 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.46 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.45 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.44 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.43 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.42 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.41 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.40 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.39 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.38 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.37 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.36 lib/rspeckled/plugins/omniauth.rb
rspeckled-0.0.35 lib/rspeckled/plugins/omniauth.rb