Module: SpreedlyCore::TestHelper

Extended by:
TestHelper
Included in:
TestHelper
Defined in:
lib/spreedly_core/test_extensions.rb

Instance Method Summary collapse

Instance Method Details

#cc_data(cc_type, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/spreedly_core/test_extensions.rb', line 9

def cc_data(cc_type, options={})

  card_numbers = {:master => [5555555555554444, 5105105105105100],
    :visa => [4111111111111111, 4012888888881881],
    :american_express => [378282246310005, 371449635398431],
    :discover => [6011111111111117, 6011000990139424]
  }
  
  card_number = options[:card_number] == :failed ? :last : :first
  number = card_numbers[cc_type].send(card_number)
  
  { :credit_card => {
      :first_name => "John",
      :last_name => "Foo",
      :card_type => cc_type,
      :number => number,
      :verification_value => 123,
      :month => 4,
      :year => Time.now.year + 1 }.merge(options[:credit_card] || {})
  }
end

#mocked_base_uri_stringObject

Return the base uri as a mocking framework would expect



32
33
34
35
36
37
38
# File 'lib/spreedly_core/test_extensions.rb', line 32

def mocked_base_uri_string
  uri = URI.parse(Base.base_uri)
  auth_params = Base.default_options[:basic_auth]
  uri.user = auth_params[:username]
  uri.password = auth_params[:password]
  uri.to_s
end