Skip to content

Commit

Permalink
Add testing of data field on payment method
Browse files Browse the repository at this point in the history
  • Loading branch information
jzellman committed Sep 14, 2011
1 parent c6f511e commit b983946
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions lib/spreedly_core/test_extensions.rb
Expand Up @@ -28,9 +28,14 @@ def cc_data(cc_type, options={})

module SpreedlyCore
class PaymentMethod
def self.create_test_token(cc_data={})

# Call spreedly core to create a test token.
# pass_through_data will be added as the "data" field.
#
def self.create_test_token(cc_data={}, pass_through_data=nil)
data = cc_data.merge(:redirect_url => "http://example.com",
:api_login => SpreedlyCore::Base.login)
:api_login => SpreedlyCore::Base.login,
:data => pass_through_data)

response = self.post("/payment_methods", :body => data, :no_follow => true)
rescue HTTParty::RedirectionTooDeep => e
Expand Down
6 changes: 4 additions & 2 deletions test/spreedly_core_test.rb
Expand Up @@ -12,9 +12,11 @@ def setup
end

def given_a_payment_method(cc_card=:master, card_options={})
token = SpreedlyCore::PaymentMethod.create_test_token(cc_data(cc_card, card_options))
token = SpreedlyCore::PaymentMethod.
create_test_token(cc_data(cc_card, card_options), "customer-42")
assert payment_method = SpreedlyCore::PaymentMethod.find(token)
assert token, payment_method.token
assert_equal "customer-42", payment_method.data
assert_equal token, payment_method.token
payment_method
end

Expand Down

0 comments on commit b983946

Please sign in to comment.