spreedly 1.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/.gitignore +8 -0
  2. data/Gemfile +4 -0
  3. data/HISTORY.md +5 -0
  4. data/README.md +362 -29
  5. data/Rakefile +32 -0
  6. data/lib/certs/cacert.pem +7815 -0
  7. data/lib/spreedly.rb +24 -282
  8. data/lib/spreedly/common/errors_parser.rb +15 -0
  9. data/lib/spreedly/common/fields.rb +90 -0
  10. data/lib/spreedly/connection.rb +40 -0
  11. data/lib/spreedly/environment.rb +176 -0
  12. data/lib/spreedly/error.rb +50 -0
  13. data/lib/spreedly/gateway.rb +10 -0
  14. data/lib/spreedly/model.rb +17 -0
  15. data/lib/spreedly/payment_methods/credit_card.rb +9 -0
  16. data/lib/spreedly/payment_methods/payment_method.rb +34 -0
  17. data/lib/spreedly/payment_methods/paypal.rb +7 -0
  18. data/lib/spreedly/payment_methods/sprel.rb +7 -0
  19. data/lib/spreedly/ssl_requester.rb +65 -0
  20. data/lib/spreedly/transactions/add_payment_method.rb +16 -0
  21. data/lib/spreedly/transactions/auth_purchase.rb +17 -0
  22. data/lib/spreedly/transactions/authorization.rb +7 -0
  23. data/lib/spreedly/transactions/capture.rb +14 -0
  24. data/lib/spreedly/transactions/gateway_transaction.rb +31 -0
  25. data/lib/spreedly/transactions/purchase.rb +7 -0
  26. data/lib/spreedly/transactions/redact_payment_method.rb +14 -0
  27. data/lib/spreedly/transactions/refund.rb +14 -0
  28. data/lib/spreedly/transactions/retain_payment_method.rb +14 -0
  29. data/lib/spreedly/transactions/transaction.rb +41 -0
  30. data/lib/spreedly/transactions/void.rb +9 -0
  31. data/lib/spreedly/urls.rb +64 -0
  32. data/lib/spreedly/version.rb +1 -1
  33. data/spreedly.gemspec +29 -0
  34. data/test/credentials/credentials.yml +9 -0
  35. data/test/credentials/test_credentials.rb +43 -0
  36. data/test/helpers/assertions.rb +29 -0
  37. data/test/helpers/communication_helper.rb +31 -0
  38. data/test/helpers/creation_helper.rb +26 -0
  39. data/test/helpers/stub_response.rb +18 -0
  40. data/test/remote/remote_add_credit_card_test.rb +62 -0
  41. data/test/remote/remote_add_gateway_test.rb +30 -0
  42. data/test/remote/remote_authorize_test.rb +48 -0
  43. data/test/remote/remote_capture_test.rb +71 -0
  44. data/test/remote/remote_find_gateway_test.rb +31 -0
  45. data/test/remote/remote_find_payment_method_test.rb +29 -0
  46. data/test/remote/remote_find_transaction_test.rb +33 -0
  47. data/test/remote/remote_list_transactions_test.rb +36 -0
  48. data/test/remote/remote_purchase_test.rb +69 -0
  49. data/test/remote/remote_redact_test.rb +38 -0
  50. data/test/remote/remote_refund_test.rb +65 -0
  51. data/test/remote/remote_retain_test.rb +39 -0
  52. data/test/remote/remote_void_test.rb +64 -0
  53. data/test/test_helper.rb +23 -0
  54. data/test/unit/add_credit_card_test.rb +74 -0
  55. data/test/unit/add_gateway_test.rb +26 -0
  56. data/test/unit/authorize_test.rb +87 -0
  57. data/test/unit/capture_test.rb +91 -0
  58. data/test/unit/environment_test.rb +18 -0
  59. data/test/unit/fields_test.rb +75 -0
  60. data/test/unit/find_gateway_test.rb +28 -0
  61. data/test/unit/find_payment_method_test.rb +90 -0
  62. data/test/unit/find_transaction_test.rb +31 -0
  63. data/test/unit/list_transactions_test.rb +46 -0
  64. data/test/unit/purchase_test.rb +95 -0
  65. data/test/unit/redact_payment_method_test.rb +51 -0
  66. data/test/unit/refund_test.rb +91 -0
  67. data/test/unit/response_stubs/add_credit_card_stubs.rb +43 -0
  68. data/test/unit/response_stubs/add_gateway_stubs.rb +39 -0
  69. data/test/unit/response_stubs/authorization_stubs.rb +139 -0
  70. data/test/unit/response_stubs/capture_stubs.rb +87 -0
  71. data/test/unit/response_stubs/find_gateway_stubs.rb +38 -0
  72. data/test/unit/response_stubs/find_payment_method_stubs.rb +108 -0
  73. data/test/unit/response_stubs/find_transaction_stubs.rb +43 -0
  74. data/test/unit/response_stubs/list_transactions_stubs.rb +110 -0
  75. data/test/unit/response_stubs/purchase_stubs.rb +139 -0
  76. data/test/unit/response_stubs/redact_payment_method_stubs.rb +54 -0
  77. data/test/unit/response_stubs/refund_stubs.rb +87 -0
  78. data/test/unit/response_stubs/retain_payment_method_stubs.rb +85 -0
  79. data/test/unit/response_stubs/void_stubs.rb +79 -0
  80. data/test/unit/retain_payment_method_test.rb +44 -0
  81. data/test/unit/timeout_test.rb +20 -0
  82. data/test/unit/void_test.rb +96 -0
  83. metadata +215 -29
  84. checksums.yaml +0 -15
  85. data/lib/spreedly/common.rb +0 -44
  86. data/lib/spreedly/mock.rb +0 -221
  87. data/lib/spreedly/test_hacks.rb +0 -27
@@ -0,0 +1,39 @@
1
+ require 'test_helper'
2
+
3
+ class RemoteRetainTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @environment = Spreedly::Environment.new(remote_test_environment_key, remote_test_access_secret)
7
+ end
8
+
9
+ def test_invalid_login
10
+ assert_invalid_login do |environment|
11
+ environment.retain_payment_method('payment_method_token')
12
+ end
13
+ end
14
+
15
+ def test_payment_method_token_token_not_found
16
+ assert_raise_with_message(Spreedly::NotFoundError, "Unable to find the specified payment method.") do
17
+ @environment.retain_payment_method('unknown_token')
18
+ end
19
+ end
20
+
21
+ def test_successful_retain
22
+ card_token = create_card_on(@environment, retained: false).token
23
+
24
+ transaction = @environment.retain_payment_method(card_token)
25
+ assert transaction.succeeded?
26
+ assert_equal "Succeeded!", transaction.message
27
+ assert_equal 'retained', transaction.payment_method.storage_state
28
+ end
29
+
30
+ def test_failed_retain
31
+ card_token = create_card_on(@environment).token
32
+ @environment.redact_payment_method(card_token)
33
+
34
+ transaction = @environment.retain_payment_method(card_token)
35
+ assert !transaction.succeeded?
36
+ assert_equal "The payment method has been redacted. Therefore, it cannot be retained.", transaction.message
37
+ end
38
+
39
+ end
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ class RemoteVoidTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @environment = Spreedly::Environment.new(remote_test_environment_key, remote_test_access_secret)
7
+ end
8
+
9
+ def test_invalid_login
10
+ assert_invalid_login do |environment|
11
+ environment.void_transaction('transaction_token')
12
+ end
13
+ end
14
+
15
+ def test_transaction_token_not_found
16
+ assert_raise_with_message(Spreedly::NotFoundError, "Unable to find the specified reference transaction.") do
17
+ @environment.void_transaction('unknown_transaction')
18
+ end
19
+ end
20
+
21
+ def test_needs_succeeded_reference
22
+ gateway_token = @environment.add_gateway(:test).token
23
+ card_token = create_failed_card_on(@environment).token
24
+ transaction = @environment.purchase_on_gateway(gateway_token, card_token, 144)
25
+ assert !transaction.succeeded?
26
+
27
+ assert_raise_with_message(Spreedly::TransactionCreationError, "The reference transaction did not succeed. Only successful reference transactions are permitted.") do
28
+ @environment.void_transaction(transaction.token)
29
+ end
30
+ end
31
+
32
+ def test_successful_void
33
+ gateway_token = @environment.add_gateway(:test).token
34
+ card_token = create_card_on(@environment).token
35
+ purchase = @environment.purchase_on_gateway(gateway_token, card_token, 144)
36
+ assert purchase.succeeded?
37
+
38
+ void = @environment.void_transaction(purchase.token)
39
+ assert void.succeeded?
40
+ assert_equal "Succeeded!", void.message
41
+ assert_equal gateway_token, void.gateway_token
42
+ end
43
+
44
+ def test_optional_arguments
45
+ gateway_token = @environment.add_gateway(:test).token
46
+ card_token = create_card_on(@environment).token
47
+ purchase = @environment.purchase_on_gateway(gateway_token, card_token, 144)
48
+ assert purchase.succeeded?
49
+
50
+ void = @environment.void_transaction(purchase.token, order_id: "8675",
51
+ description: "SuperDuper",
52
+ ip: "183.128.100.103",
53
+ merchant_name_descriptor: "Real Stuff",
54
+ merchant_location_descriptor: "Raleigh")
55
+
56
+ assert void.succeeded?
57
+ assert_equal "8675", void.order_id
58
+ assert_equal "SuperDuper", void.description
59
+ assert_equal "183.128.100.103", void.ip
60
+ assert_equal "Real Stuff", void.merchant_name_descriptor
61
+ assert_equal "Raleigh", void.merchant_location_descriptor
62
+ end
63
+
64
+ end
@@ -0,0 +1,23 @@
1
+
2
+ require 'test/unit'
3
+ require 'mocha/setup'
4
+ require 'awesome_print'
5
+ require 'logger'
6
+ require 'log_buddy'
7
+ require 'spreedly'
8
+ require 'credentials/test_credentials'
9
+ require 'helpers/stub_response'
10
+ require 'helpers/creation_helper'
11
+ require 'helpers/assertions'
12
+ require 'helpers/communication_helper'
13
+
14
+ LogBuddy.init(use_awesome_print: true, logger: Logger.new(nil))
15
+
16
+
17
+ Test::Unit::TestCase.class_eval do
18
+ include Spreedly::TestCredentials
19
+ include Spreedly::CreationHelper
20
+ include Spreedly::Assertions
21
+ include Spreedly::CommunicationHelper
22
+ end
23
+
@@ -0,0 +1,74 @@
1
+ require 'test_helper'
2
+ require 'unit/response_stubs/add_credit_card_stubs'
3
+
4
+ class AddCreditCreditCardTest < Test::Unit::TestCase
5
+
6
+ include AddCreditCardStubs
7
+
8
+ def setup
9
+ @environment = Spreedly::Environment.new("key", "secret")
10
+ end
11
+
12
+ def test_successful_add_credit_card
13
+ t = add_card_using(successful_add_credit_card_response)
14
+
15
+ assert_kind_of(Spreedly::AddPaymentMethod, t)
16
+ assert_kind_of(Spreedly::CreditCard, t.payment_method)
17
+
18
+ assert_equal '6wxjN6HcDik8e3mAhBaaoVGSImH', t.token
19
+ assert !t.retained?
20
+ assert t.succeeded?
21
+ assert_equal Time.parse("2013-08-02T18:04:45Z"), t.created_at
22
+ assert_equal Time.parse("2013-08-02T18:04:45Z"), t.updated_at
23
+ assert_equal 'Succeeded!', t.message
24
+
25
+ assert_equal "AXaBXfVUqhaGMg8ytf8isiMAAL9", t.payment_method.token
26
+ assert_equal "Eland Venture", t.payment_method.full_name
27
+ assert_equal "Don't test everything here, since find_payment_method tests it all.", t.payment_method.data
28
+ end
29
+
30
+ def test_request_body_params
31
+ body = get_request_body(successful_add_credit_card_response) do
32
+ @environment.add_credit_card(full_card_details)
33
+ end
34
+
35
+ payment_method = body.xpath('./payment_method')
36
+ assert_xpaths_in payment_method,
37
+ [ './data', 'talent: Late' ],
38
+ [ './email', 'leavenworth@free.com' ],
39
+ [ './retained', 'true' ]
40
+
41
+ card = body.xpath('./payment_method/credit_card')
42
+ assert_xpaths_in card,
43
+ [ './first_name', 'Leavenworth' ],
44
+ [ './last_name', 'Smedry' ],
45
+ [ './number', '9555555555554444' ],
46
+ [ './month', '3' ],
47
+ [ './year', '2021' ],
48
+ [ './address1', '10 Dragon Lane' ],
49
+ [ './address2', 'Suite 9' ],
50
+ [ './city', 'Tuki Tuki' ],
51
+ [ './state', 'Mokia' ],
52
+ [ './zip', '1122' ],
53
+ [ './country', 'Free Kingdoms' ],
54
+ [ './phone_number', '81Ab' ]
55
+ end
56
+
57
+ private
58
+ def add_card_using(response)
59
+ @environment.stubs(:raw_ssl_request).returns(response)
60
+ @environment.add_credit_card(ignored: "Because response is stubbed")
61
+ end
62
+
63
+ def full_card_details
64
+ {
65
+ email: 'leavenworth@free.com', number: '9555555555554444', month: 3, year: 2021,
66
+ last_name: 'Smedry', first_name: 'Leavenworth', data: "talent: Late",
67
+ address1: '10 Dragon Lane', address2: 'Suite 9', city: 'Tuki Tuki', state: 'Mokia',
68
+ zip: '1122', country: 'Free Kingdoms', phone_number: '81Ab', retained: true
69
+ }
70
+ end
71
+
72
+ end
73
+
74
+
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+ require 'unit/response_stubs/add_gateway_stubs'
3
+
4
+ class AddGatewayTest < Test::Unit::TestCase
5
+
6
+ include AddGatewayStubs
7
+
8
+ def setup
9
+ @environment = Spreedly::Environment.new("key", "secret")
10
+ end
11
+
12
+ def test_add_test_gateway
13
+ @environment.stubs(:raw_ssl_request).returns(successful_add_test_gateway_response)
14
+
15
+ gateway = @environment.add_gateway(:test)
16
+ assert_equal "4dFb93AiRDEJ18MS9xDGMyu22uO", gateway.token
17
+ assert_equal "test", gateway.gateway_type
18
+ assert_equal "retained", gateway.state
19
+ assert_equal "Test", gateway.name
20
+ end
21
+
22
+ # TODO
23
+ # Tests coming for characteristics, payment_methods, and gateway_specific_fields.
24
+ # We'll also soon handle adding other types of gateways.
25
+
26
+ end
@@ -0,0 +1,87 @@
1
+ require 'test_helper'
2
+ require 'unit/response_stubs/authorization_stubs'
3
+
4
+ class AuthorizeTest < Test::Unit::TestCase
5
+
6
+ include AuthorizationStubs
7
+
8
+ def setup
9
+ @environment = Spreedly::Environment.new("key", "secret")
10
+ end
11
+
12
+ def test_successful_authorize
13
+ t = authorize_using(successful_authorize_response)
14
+
15
+ assert_kind_of(Spreedly::Authorization, t)
16
+ assert_equal 'NjsT1PRC5pHyz89H01bj1t2AVNo', t.token
17
+ assert_equal 345, t.amount
18
+ assert t.on_test_gateway?
19
+ assert_equal Time.parse("2013-08-05 13:11:28 UTC"), t.created_at
20
+ assert_equal Time.parse("2013-08-05 13:11:28 UTC"), t.updated_at
21
+ assert_equal 'USD', t.currency_code
22
+ assert t.succeeded?
23
+ assert_equal 'succeeded', t.state
24
+ assert_equal '99a1', t.order_id
25
+ assert_equal '182.129.106.102', t.ip
26
+ assert_equal 'LotsOCoffee', t.description
27
+ assert_equal 'My Writeoff Inc.', t.merchant_name_descriptor
28
+ assert_equal 'Tax Free Zone', t.merchant_location_descriptor
29
+ assert_equal 'YjWxOjbpeieXsZFdAsbhM2DFgLe', t.gateway_token
30
+
31
+ assert_equal 'Nh2Vw0kAoSQvcJDpK52q4dZlrVJ', t.payment_method.token
32
+ assert_equal 'Forthrast', t.payment_method.last_name
33
+
34
+ assert t.response.success
35
+ assert_equal 'Successful authorize', t.response.message
36
+ end
37
+
38
+ def test_failed_authorize
39
+ t = authorize_using(failed_authorize_response)
40
+
41
+ assert_kind_of(Spreedly::Authorization, t)
42
+ assert_equal 'PHuCG2kfgyr92CgKuqlblFbgZJP', t.token
43
+ assert_equal 2391, t.amount
44
+ assert !t.succeeded?
45
+ assert_equal 'gateway_processing_failed', t.state
46
+
47
+ assert_equal 'The eagle may have perished.', t.response.error_detail
48
+ end
49
+
50
+ def test_request_body_params
51
+ body = get_request_body(successful_authorize_response) do
52
+ @environment.authorize_on_gateway("TheGatewayToken", "TheCardToken", 2001, all_possible_options)
53
+ end
54
+
55
+ transaction = body.xpath('./transaction')
56
+ assert_xpaths_in transaction,
57
+ [ './amount', '2001' ],
58
+ [ './currency_code', 'CAD' ],
59
+ [ './payment_method_token', 'TheCardToken' ],
60
+ [ './order_id', '8669' ],
61
+ [ './description', 'Gold Farmin' ],
62
+ [ './ip', '183.128.100.102' ],
63
+ [ './merchant_name_descriptor', 'TRain' ],
64
+ [ './merchant_location_descriptor', 'British Colombia' ],
65
+ [ './retain_on_success', 'true' ]
66
+ end
67
+
68
+
69
+ private
70
+ def authorize_using(response)
71
+ @environment.stubs(:raw_ssl_request).returns(response)
72
+ @environment.authorize_on_gateway("IgnoredGatewayTokenSinceResponseIsStubbed", "IgnoredPaymentMethodTokenSinceResponseIsStubbed", 5921)
73
+ end
74
+
75
+ def all_possible_options
76
+ {
77
+ currency_code: "CAD",
78
+ order_id: "8669",
79
+ description: "Gold Farmin",
80
+ ip: "183.128.100.102",
81
+ merchant_name_descriptor: "TRain",
82
+ merchant_location_descriptor: "British Colombia",
83
+ retain_on_success: true
84
+ }
85
+ end
86
+
87
+ end
@@ -0,0 +1,91 @@
1
+ require 'test_helper'
2
+ require 'unit/response_stubs/capture_stubs'
3
+
4
+ class CaptureTest < Test::Unit::TestCase
5
+
6
+ include CaptureStubs
7
+
8
+ def setup
9
+ @environment = Spreedly::Environment.new("key", "secret")
10
+ end
11
+
12
+ def test_successful_capture
13
+ t = capture_using(successful_capture_response)
14
+
15
+ assert_kind_of(Spreedly::Capture, t)
16
+ assert_equal 'T41uDjYsxGybSsp7RHuRTohMjg2', t.token
17
+ assert_equal 801, t.amount
18
+ assert t.on_test_gateway?
19
+ assert_equal Time.parse("2013-08-05 13:58:50 UTC"), t.created_at
20
+ assert_equal Time.parse("2013-08-05 13:58:50 UTC"), t.updated_at
21
+ assert_equal 'USD', t.currency_code
22
+ assert t.succeeded?
23
+ assert_equal 'succeeded', t.state
24
+ assert_equal '99a1', t.order_id
25
+ assert_equal '182.129.106.102', t.ip
26
+ assert_equal 'LotsOCoffee', t.description
27
+ assert_equal 'My Writeoff Inc.', t.merchant_name_descriptor
28
+ assert_equal 'Tax Free Zone', t.merchant_location_descriptor
29
+ assert_equal 'SoPblCOGDwaRyym68XGWeRiCy1C', t.gateway_token
30
+ assert_equal 'PH6U2tyFWtDSVp88bNW2nnGy5rk', t.reference_token
31
+
32
+ assert t.response.success
33
+ assert_equal 'Successful capture', t.response.message
34
+ end
35
+
36
+ def test_failed_capture
37
+ t = capture_using(failed_capture_response)
38
+
39
+ assert_kind_of(Spreedly::Capture, t)
40
+ assert_equal 'Z4XAoSG11rd4zo9p9sRxpstKufX', t.token
41
+ assert_equal 44, t.amount
42
+ assert !t.succeeded?
43
+ assert_equal 'gateway_processing_failed', t.state
44
+
45
+ assert_equal 'The eagle has hit the window.', t.response.error_detail
46
+ end
47
+
48
+ def test_empty_request_body_params
49
+ body = get_request_body(successful_capture_response) do
50
+ @environment.capture_transaction("TheAuthorizationToken")
51
+ end
52
+
53
+ assert_nil body.root
54
+ end
55
+
56
+ def test_request_body_params
57
+ body = get_request_body(successful_capture_response) do
58
+ @environment.capture_transaction("TheAuthorizationToken", all_possible_options)
59
+ end
60
+
61
+ transaction = body.xpath('./transaction')
62
+ assert_xpaths_in transaction,
63
+ [ './amount', '29' ],
64
+ [ './currency_code', 'CAD' ],
65
+ [ './order_id', '8668' ],
66
+ [ './description', 'Gold Farmin' ],
67
+ [ './ip', '183.128.100.102' ],
68
+ [ './merchant_name_descriptor', 'TRain' ],
69
+ [ './merchant_location_descriptor', 'British Colombia' ]
70
+ end
71
+
72
+
73
+ private
74
+ def capture_using(response)
75
+ @environment.stubs(:raw_ssl_request).returns(response)
76
+ @environment.capture_transaction("IgnoredTokenSinceResponseIsStubbed")
77
+ end
78
+
79
+ def all_possible_options
80
+ {
81
+ amount: 29,
82
+ currency_code: "CAD",
83
+ order_id: "8668",
84
+ description: "Gold Farmin",
85
+ ip: "183.128.100.102",
86
+ merchant_name_descriptor: "TRain",
87
+ merchant_location_descriptor: "British Colombia"
88
+ }
89
+ end
90
+
91
+ end
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ class EnvironmentTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @environment = Spreedly::Environment.new("TheKey", "TheAccessSecret")
7
+ end
8
+
9
+ def test_currency_code_defaults_to_usd
10
+ assert_equal "USD", @environment.currency_code
11
+ end
12
+
13
+ def test_currency_code_can_be_overridden
14
+ environment = Spreedly::Environment.new("TheKey", "TheAccessSecret", currency_code: "EUR")
15
+ assert_equal "EUR", environment.currency_code
16
+ end
17
+
18
+ end
@@ -0,0 +1,75 @@
1
+ require 'test_helper'
2
+
3
+ class FieldsTest < Test::Unit::TestCase
4
+
5
+ class ModelWithFields
6
+ include Spreedly::Fields
7
+ field :message, :amount, :on_test_gateway, :updated_at, :succeeded
8
+ end
9
+
10
+ class ModelWithTypedFields
11
+ include Spreedly::Fields
12
+ field :message
13
+ field :succeeded, :on_test_gateway, type: :boolean
14
+ field :amount, type: :integer
15
+ field :updated_at, type: :date_time
16
+ end
17
+
18
+ def setup
19
+ @model = ModelWithFields.new
20
+ @typed_model = ModelWithTypedFields.new
21
+ end
22
+
23
+ def test_defaults_to_nil
24
+ assert_nil @model.message
25
+ assert_nil @model.amount
26
+ assert_nil @model.on_test_gateway
27
+ assert_nil @model.updated_at
28
+ assert_nil @model.succeeded
29
+ end
30
+
31
+ def test_defaults_to_nil_for_typed_fields
32
+ assert_nil @typed_model.message
33
+ assert_nil @typed_model.amount
34
+ assert_nil @typed_model.on_test_gateway
35
+ assert_nil @typed_model.on_test_gateway?
36
+ assert_nil @typed_model.updated_at
37
+ assert_nil @typed_model.succeeded
38
+ assert_nil @typed_model.succeeded?
39
+ end
40
+
41
+ def test_initialize_fields_for_strings
42
+ @model.initialize_fields(Nokogiri::XML(xml))
43
+ assert_equal "The eagle flies at dawn.", @model.message
44
+ assert_equal "5148", @model.amount
45
+ assert_equal "true", @model.on_test_gateway
46
+ assert_equal "2013-07-31T19:51:57Z", @model.updated_at
47
+ assert_equal "false", @model.succeeded
48
+ end
49
+
50
+ def test_initialize_fields_for_typed_fields
51
+ @typed_model.initialize_fields(Nokogiri::XML(xml))
52
+ assert_equal "The eagle flies at dawn.", @typed_model.message
53
+ assert_equal 5148, @typed_model.amount
54
+ assert_equal true, @typed_model.on_test_gateway
55
+ assert_equal true, @typed_model.on_test_gateway?
56
+ assert_equal Time.parse("2013-07-31T19:51:57Z"), @typed_model.updated_at
57
+ assert_equal false, @typed_model.succeeded
58
+ assert_equal false, @typed_model.succeeded?
59
+ end
60
+
61
+
62
+ private
63
+ def xml
64
+ <<-XML
65
+ <the_model>
66
+ <amount>5148</amount>
67
+ <on_test_gateway>true</on_test_gateway>
68
+ <updated_at>2013-07-31T19:51:57Z</updated_at>
69
+ <succeeded>false</succeeded>
70
+ <message>The eagle flies at dawn.</message>
71
+ </the_model>
72
+ XML
73
+ end
74
+
75
+ end