Sha256: aebb710d0da7655af1717547ac0a5404d9661284d38fb384b00fd0ac5b6db480

Contents?: true

Size: 597 Bytes

Versions: 4

Compression:

Stored size: 597 Bytes

Contents

require 'singleton'

class IntegrationTest
  include Singleton
  
  attr_accessor :enabled
  
  def initialize
    enabled = false
    clear_mocks
  end
  
  def clear_mocks
    @mock = {}
  end
  
  def mock provider, mock
    @mock[provider.to_sym] = mock
  end
  
  def mock_authorization_from_user provider
    [302, {"location" => provider.redirect_path}, []]
  end
  
  def mock_fetch_contacts provider
    result = @mock[provider.class_name.to_sym] || []
    if result.is_a? Array
      result
    elsif result.is_a? Hash
      [result]
    else
      raise result.to_s
    end
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
omnicontacts-0.2.3 lib/omnicontacts/integration_test.rb
omnicontacts-0.2.2 lib/omnicontacts/integration_test.rb
omnicontacts-0.2.1 lib/omnicontacts/integration_test.rb
omnicontacts-0.2.0 lib/omnicontacts/integration_test.rb