braintree 4.13.0 → 4.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/credit_card.rb +13 -0
  3. data/lib/braintree/credit_card_gateway.rb +15 -3
  4. data/lib/braintree/payment_method_gateway.rb +15 -3
  5. data/lib/braintree/test/nonce.rb +1 -0
  6. data/lib/braintree/test/venmo_sdk.rb +2 -0
  7. data/lib/braintree/transaction/credit_card_details.rb +3 -0
  8. data/lib/braintree/transaction/local_payment_details.rb +2 -0
  9. data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
  10. data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
  11. data/lib/braintree/transaction/payment_receipt.rb +31 -0
  12. data/lib/braintree/transaction/us_bank_account_details.rb +1 -0
  13. data/lib/braintree/transaction.rb +7 -4
  14. data/lib/braintree/transaction_gateway.rb +15 -3
  15. data/lib/braintree/transaction_search.rb +6 -5
  16. data/lib/braintree/version.rb +1 -1
  17. data/lib/braintree/webhook_notification.rb +1 -0
  18. data/lib/braintree/webhook_testing_gateway.rb +17 -0
  19. data/lib/braintree.rb +3 -0
  20. data/spec/integration/braintree/add_on_spec.rb +9 -9
  21. data/spec/integration/braintree/address_spec.rb +69 -69
  22. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  23. data/spec/integration/braintree/apple_pay_spec.rb +8 -8
  24. data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
  25. data/spec/integration/braintree/credit_card_spec.rb +223 -223
  26. data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
  27. data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
  28. data/spec/integration/braintree/customer_search_spec.rb +20 -20
  29. data/spec/integration/braintree/customer_spec.rb +313 -313
  30. data/spec/integration/braintree/disbursement_spec.rb +2 -2
  31. data/spec/integration/braintree/discount_spec.rb +9 -9
  32. data/spec/integration/braintree/dispute_spec.rb +87 -87
  33. data/spec/integration/braintree/document_upload_spec.rb +17 -17
  34. data/spec/integration/braintree/error_codes_spec.rb +2 -2
  35. data/spec/integration/braintree/http_spec.rb +28 -28
  36. data/spec/integration/braintree/merchant_account_spec.rb +127 -127
  37. data/spec/integration/braintree/merchant_spec.rb +103 -103
  38. data/spec/integration/braintree/oauth_spec.rb +61 -61
  39. data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
  40. data/spec/integration/braintree/payment_method_spec.rb +389 -389
  41. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
  42. data/spec/integration/braintree/paypal_account_spec.rb +38 -38
  43. data/spec/integration/braintree/plan_spec.rb +15 -15
  44. data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
  45. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
  46. data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
  47. data/spec/integration/braintree/subscription_spec.rb +364 -364
  48. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  49. data/spec/integration/braintree/test_transaction_spec.rb +19 -19
  50. data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
  51. data/spec/integration/braintree/transaction_search_spec.rb +198 -165
  52. data/spec/integration/braintree/transaction_spec.rb +1319 -1151
  53. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
  54. data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
  55. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
  56. data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
  57. data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
  58. data/spec/spec_helper.rb +9 -8
  59. data/spec/unit/braintree/address_spec.rb +8 -8
  60. data/spec/unit/braintree/base_module_spec.rb +4 -4
  61. data/spec/unit/braintree/client_token_spec.rb +2 -2
  62. data/spec/unit/braintree/configuration_spec.rb +57 -57
  63. data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
  64. data/spec/unit/braintree/credit_card_spec.rb +31 -29
  65. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
  66. data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
  67. data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
  68. data/spec/unit/braintree/customer_spec.rb +41 -40
  69. data/spec/unit/braintree/digest_spec.rb +5 -5
  70. data/spec/unit/braintree/disbursement_spec.rb +11 -11
  71. data/spec/unit/braintree/dispute_search_spec.rb +2 -2
  72. data/spec/unit/braintree/dispute_spec.rb +56 -56
  73. data/spec/unit/braintree/document_upload_spec.rb +8 -8
  74. data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
  75. data/spec/unit/braintree/error_result_spec.rb +5 -5
  76. data/spec/unit/braintree/errors_spec.rb +9 -9
  77. data/spec/unit/braintree/http_spec.rb +8 -8
  78. data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
  79. data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
  80. data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
  81. data/spec/unit/braintree/merchant_account_spec.rb +4 -4
  82. data/spec/unit/braintree/modification_spec.rb +1 -1
  83. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
  84. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
  85. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
  86. data/spec/unit/braintree/payment_method_spec.rb +19 -19
  87. data/spec/unit/braintree/paypal_account_spec.rb +4 -4
  88. data/spec/unit/braintree/resource_collection_spec.rb +7 -7
  89. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
  90. data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
  91. data/spec/unit/braintree/signature_service_spec.rb +2 -2
  92. data/spec/unit/braintree/subscription_search_spec.rb +17 -17
  93. data/spec/unit/braintree/subscription_spec.rb +8 -8
  94. data/spec/unit/braintree/successful_result_spec.rb +5 -5
  95. data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
  96. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
  97. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  98. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  99. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
  100. data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
  101. data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
  102. data/spec/unit/braintree/transaction_search_spec.rb +2 -2
  103. data/spec/unit/braintree/transaction_spec.rb +101 -93
  104. data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
  105. data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
  106. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
  107. data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
  108. data/spec/unit/braintree/util_spec.rb +27 -27
  109. data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
  110. data/spec/unit/braintree/validation_error_spec.rb +4 -4
  111. data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
  112. data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
  113. data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
  114. data/spec/unit/braintree/xml/parser_spec.rb +8 -8
  115. data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
  116. data/spec/unit/braintree/xml_spec.rb +17 -17
  117. data/spec/unit/braintree_spec.rb +2 -2
  118. metadata +7 -2
@@ -20,11 +20,12 @@ describe Braintree::CreditCard do
20
20
  :expiration_year,
21
21
  :number,
22
22
  :token,
23
- :venmo_sdk_payment_method_code,
23
+ :venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
24
24
  :device_data,
25
25
  :payment_method_nonce,
26
26
  {:external_vault=>[:network_transaction_id]},
27
- {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
27
+ {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
28
+ :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
28
29
  {:billing_address => [
29
30
  :company,
30
31
  :country_code_alpha2,
@@ -66,11 +67,12 @@ describe Braintree::CreditCard do
66
67
  :expiration_year,
67
68
  :number,
68
69
  :token,
69
- :venmo_sdk_payment_method_code,
70
+ :venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
70
71
  :device_data,
71
72
  :payment_method_nonce,
72
73
  {:external_vault=>[:network_transaction_id]},
73
- {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
74
+ {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
75
+ :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
74
76
  {:billing_address => [
75
77
  :company,
76
78
  :country_code_alpha2,
@@ -106,31 +108,31 @@ describe Braintree::CreditCard do
106
108
  first = Braintree::CreditCard._new(:gateway, :token => 123)
107
109
  second = Braintree::CreditCard._new(:gateway, :token => 123)
108
110
 
109
- first.should == second
110
- second.should == first
111
+ expect(first).to eq(second)
112
+ expect(second).to eq(first)
111
113
  end
112
114
 
113
115
  it "returns false if given a credit card with a different token" do
114
116
  first = Braintree::CreditCard._new(:gateway, :token => 123)
115
117
  second = Braintree::CreditCard._new(:gateway, :token => 124)
116
118
 
117
- first.should_not == second
118
- second.should_not == first
119
+ expect(first).not_to eq(second)
120
+ expect(second).not_to eq(first)
119
121
  end
120
122
 
121
123
  it "returns false if not given a credit card" do
122
124
  credit_card = Braintree::CreditCard._new(:gateway, :token => 123)
123
- credit_card.should_not == "not a credit card"
125
+ expect(credit_card).not_to eq("not a credit card")
124
126
  end
125
127
  end
126
128
 
127
129
  describe "default?" do
128
130
  it "is true if the credit card is the default credit card for the customer" do
129
- Braintree::CreditCard._new(:gateway, :default => true).default?.should == true
131
+ expect(Braintree::CreditCard._new(:gateway, :default => true).default?).to eq(true)
130
132
  end
131
133
 
132
134
  it "is false if the credit card is not the default credit card for the customer" do
133
- Braintree::CreditCard._new(:gateway, :default => false).default?.should == false
135
+ expect(Braintree::CreditCard._new(:gateway, :default => false).default?).to eq(false)
134
136
  end
135
137
  end
136
138
 
@@ -154,7 +156,7 @@ describe Braintree::CreditCard do
154
156
  end
155
157
 
156
158
  it "does not raise an error if address_id does not respond to strip" do
157
- Braintree::Http.stub(:new).and_return double.as_null_object
159
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
158
160
  expect do
159
161
  Braintree::CreditCard.find(8675309)
160
162
  end.to_not raise_error
@@ -164,7 +166,7 @@ describe Braintree::CreditCard do
164
166
  describe "inspect" do
165
167
  it "includes the token first" do
166
168
  output = Braintree::CreditCard._new(:gateway, :token => "cc123").inspect
167
- output.should include("#<Braintree::CreditCard token: \"cc123\",")
169
+ expect(output).to include("#<Braintree::CreditCard token: \"cc123\",")
168
170
  end
169
171
 
170
172
  it "includes all customer attributes" do
@@ -183,18 +185,18 @@ describe Braintree::CreditCard do
183
185
  :is_network_tokenized => false,
184
186
  )
185
187
  output = credit_card.inspect
186
- output.should include(%q(bin: "411111"))
187
- output.should include(%q(card_type: "Visa"))
188
- output.should include(%q(cardholder_name: "John Miller"))
188
+ expect(output).to include(%q(bin: "411111"))
189
+ expect(output).to include(%q(card_type: "Visa"))
190
+ expect(output).to include(%q(cardholder_name: "John Miller"))
189
191
 
190
- output.should include(%q(customer_id: "cid1"))
191
- output.should include(%q(expiration_month: "01"))
192
- output.should include(%q(expiration_year: "2020"))
193
- output.should include(%q(last_4: "1111"))
194
- output.should include(%q(token: "tok1"))
195
- output.should include(%Q(updated_at: #{credit_card.updated_at.inspect}))
196
- output.should include(%Q(created_at: #{credit_card.created_at.inspect}))
197
- output.should include(%q(is_network_tokenized?: false))
192
+ expect(output).to include(%q(customer_id: "cid1"))
193
+ expect(output).to include(%q(expiration_month: "01"))
194
+ expect(output).to include(%q(expiration_year: "2020"))
195
+ expect(output).to include(%q(last_4: "1111"))
196
+ expect(output).to include(%q(token: "tok1"))
197
+ expect(output).to include(%Q(updated_at: #{credit_card.updated_at.inspect}))
198
+ expect(output).to include(%Q(created_at: #{credit_card.created_at.inspect}))
199
+ expect(output).to include(%q(is_network_tokenized?: false))
198
200
  end
199
201
  end
200
202
 
@@ -205,7 +207,7 @@ describe Braintree::CreditCard do
205
207
  :bin => "510510",
206
208
  :last_4 => "5100",
207
209
  )
208
- credit_card.masked_number.should == "510510******5100"
210
+ expect(credit_card.masked_number).to eq("510510******5100")
209
211
  end
210
212
  end
211
213
 
@@ -217,7 +219,7 @@ describe Braintree::CreditCard do
217
219
  :last_4 => "5100",
218
220
  :is_network_tokenized => true,
219
221
  )
220
- credit_card.is_network_tokenized?.should == true
222
+ expect(credit_card.is_network_tokenized?).to eq(true)
221
223
  end
222
224
 
223
225
  it "returns false" do
@@ -227,7 +229,7 @@ describe Braintree::CreditCard do
227
229
  :last_4 => "5100",
228
230
  :is_network_tokenized => false,
229
231
  )
230
- credit_card.is_network_tokenized?.should == false
232
+ expect(credit_card.is_network_tokenized?).to eq(false)
231
233
  end
232
234
  end
233
235
 
@@ -253,12 +255,12 @@ describe Braintree::CreditCard do
253
255
  verification1 = {:created_at => Time.now, :id => 123}
254
256
  verification2 = {:created_at => Time.now - 3600, :id => 456}
255
257
  credit_card = Braintree::CreditCard._new(Braintree::Configuration.gateway, {:verifications => [verification1, verification2]})
256
- credit_card.verification.id.should == 123
258
+ expect(credit_card.verification.id).to eq(123)
257
259
  end
258
260
 
259
261
  it "picks nil if verifications are empty" do
260
262
  credit_card = Braintree::CreditCard._new(Braintree::Configuration.gateway, {})
261
- credit_card.verification.should be_nil
263
+ expect(credit_card.verification).to be_nil
262
264
  end
263
265
  end
264
266
  end
@@ -14,38 +14,38 @@ describe Braintree::CreditCardVerificationGateway do
14
14
  it "creates a credit card verification gateway" do
15
15
  result = Braintree::CreditCardVerificationGateway.new(gateway)
16
16
 
17
- result.inspect.should include("merchant_id")
18
- result.inspect.should include("public_key")
19
- result.inspect.should include("private_key")
17
+ expect(result.inspect).to include("merchant_id")
18
+ expect(result.inspect).to include("public_key")
19
+ expect(result.inspect).to include("private_key")
20
20
  end
21
21
 
22
22
  it "creates a credit card verification gateway signature" do
23
23
  result = Braintree::CreditCardVerificationGateway._create_signature
24
- result.inspect.should include("credit_card")
25
- result.inspect.should include("credit_card")
26
- result.inspect.should include("cardholder_name")
27
- result.inspect.should include("cvv")
28
- result.inspect.should include("expiration_date")
29
- result.inspect.should include("expiration_month")
30
- result.inspect.should include("expiration_year")
31
- result.inspect.should include("number")
32
- result.inspect.should include("billing_address")
33
- result.inspect.should include("intended_transaction_source")
34
- result.inspect.should include("options")
35
- result.inspect.should include("amount")
36
- result.inspect.should include("merchant_account_id")
37
- result.inspect.should include("account_type")
38
- result.inspect.should include("payment_method_nonce")
39
- result.inspect.should include("three_d_secure_authentication_id")
40
- result.inspect.should include("three_d_secure_pass_thru")
41
- result.inspect.should include("eci_flag")
42
- result.inspect.should include("cavv")
43
- result.inspect.should include("xid")
44
- result.inspect.should include("three_d_secure_version")
45
- result.inspect.should include("authentication_response")
46
- result.inspect.should include("directory_response")
47
- result.inspect.should include("cavv_algorithm")
48
- result.inspect.should include("ds_transaction_id")
24
+ expect(result.inspect).to include("credit_card")
25
+ expect(result.inspect).to include("credit_card")
26
+ expect(result.inspect).to include("cardholder_name")
27
+ expect(result.inspect).to include("cvv")
28
+ expect(result.inspect).to include("expiration_date")
29
+ expect(result.inspect).to include("expiration_month")
30
+ expect(result.inspect).to include("expiration_year")
31
+ expect(result.inspect).to include("number")
32
+ expect(result.inspect).to include("billing_address")
33
+ expect(result.inspect).to include("intended_transaction_source")
34
+ expect(result.inspect).to include("options")
35
+ expect(result.inspect).to include("amount")
36
+ expect(result.inspect).to include("merchant_account_id")
37
+ expect(result.inspect).to include("account_type")
38
+ expect(result.inspect).to include("payment_method_nonce")
39
+ expect(result.inspect).to include("three_d_secure_authentication_id")
40
+ expect(result.inspect).to include("three_d_secure_pass_thru")
41
+ expect(result.inspect).to include("eci_flag")
42
+ expect(result.inspect).to include("cavv")
43
+ expect(result.inspect).to include("xid")
44
+ expect(result.inspect).to include("three_d_secure_version")
45
+ expect(result.inspect).to include("authentication_response")
46
+ expect(result.inspect).to include("directory_response")
47
+ expect(result.inspect).to include("cavv_algorithm")
48
+ expect(result.inspect).to include("ds_transaction_id")
49
49
  end
50
50
  end
51
51
  end
@@ -7,11 +7,11 @@ module Braintree
7
7
  it "allows All card types" do
8
8
  search = CreditCardVerificationSearch.new
9
9
 
10
- lambda do
10
+ expect do
11
11
  search.credit_card_card_type.in(
12
12
  *Braintree::CreditCard::CardType::All,
13
13
  )
14
- end.should_not raise_error
14
+ end.not_to raise_error
15
15
  end
16
16
  end
17
17
 
@@ -20,7 +20,7 @@ module Braintree
20
20
  search = CreditCardVerificationSearch.new
21
21
  search.id.is "v_id"
22
22
 
23
- search.to_hash.should == {:id => {:is => "v_id"}}
23
+ expect(search.to_hash).to eq({:id => {:is => "v_id"}})
24
24
  end
25
25
  end
26
26
 
@@ -29,7 +29,7 @@ module Braintree
29
29
  search = CreditCardVerificationSearch.new
30
30
  search.ids.in("id1","id2")
31
31
 
32
- search.to_hash.should == {:ids => ["id1", "id2"]}
32
+ expect(search.to_hash).to eq({:ids => ["id1", "id2"]})
33
33
  end
34
34
  end
35
35
 
@@ -38,7 +38,7 @@ module Braintree
38
38
  search = CreditCardVerificationSearch.new
39
39
  search.credit_card_cardholder_name.is "v_cardholder_name"
40
40
 
41
- search.to_hash.should == {:credit_card_cardholder_name => {:is => "v_cardholder_name"}}
41
+ expect(search.to_hash).to eq({:credit_card_cardholder_name => {:is => "v_cardholder_name"}})
42
42
  end
43
43
  end
44
44
 
@@ -47,7 +47,7 @@ module Braintree
47
47
  search = CreditCardVerificationSearch.new
48
48
  search.credit_card_expiration_date.is_not "v_credit_card_expiration_date"
49
49
 
50
- search.to_hash.should == {:credit_card_expiration_date => {:is_not => "v_credit_card_expiration_date"}}
50
+ expect(search.to_hash).to eq({:credit_card_expiration_date => {:is_not => "v_credit_card_expiration_date"}})
51
51
  end
52
52
  end
53
53
 
@@ -57,7 +57,7 @@ module Braintree
57
57
 
58
58
  search.credit_card_number.starts_with "v_credit_card_bin"
59
59
 
60
- search.to_hash.should == {:credit_card_number => {:starts_with => "v_credit_card_bin"}}
60
+ expect(search.to_hash).to eq({:credit_card_number => {:starts_with => "v_credit_card_bin"}})
61
61
  end
62
62
 
63
63
  it "ends with" do
@@ -65,14 +65,14 @@ module Braintree
65
65
 
66
66
  search.credit_card_number.ends_with "v_credit_card_last_4"
67
67
 
68
- search.to_hash.should == {:credit_card_number => {:ends_with => "v_credit_card_last_4"}}
68
+ expect(search.to_hash).to eq({:credit_card_number => {:ends_with => "v_credit_card_last_4"}})
69
69
  end
70
70
  end
71
71
 
72
72
  context "created_at" do
73
73
  it "is a range node" do
74
74
  search = CreditCardVerificationSearch.new
75
- search.created_at.should be_kind_of(Braintree::AdvancedSearch::RangeNode)
75
+ expect(search.created_at).to be_kind_of(Braintree::AdvancedSearch::RangeNode)
76
76
  end
77
77
  end
78
78
  end
@@ -18,7 +18,7 @@ describe Braintree::CreditCardVerification do
18
18
  :network_response_text => "Do not Honor",
19
19
  )
20
20
 
21
- verification.inspect.should == %(#<Braintree::CreditCardVerification status: "verified", processor_response_code: "2000", processor_response_text: "Do Not Honor", amount: "12.45", currency_iso_code: "USD", cvv_response_code: "I", avs_error_response_code: "I", avs_postal_code_response_code: "I", avs_street_address_response_code: "I", network_response_code: "05", network_response_text: "Do not Honor", merchant_account_id: "some_id", gateway_rejection_reason: nil, id: nil, credit_card: nil, billing: nil, created_at: nil>)
21
+ expect(verification.inspect).to eq(%(#<Braintree::CreditCardVerification status: "verified", processor_response_code: "2000", processor_response_text: "Do Not Honor", amount: "12.45", currency_iso_code: "USD", cvv_response_code: "I", avs_error_response_code: "I", avs_postal_code_response_code: "I", avs_street_address_response_code: "I", network_response_code: "05", network_response_text: "Do not Honor", merchant_account_id: "some_id", gateway_rejection_reason: nil, id: nil, credit_card: nil, billing: nil, created_at: nil>))
22
22
  end
23
23
 
24
24
  it "has a status" do
@@ -33,13 +33,13 @@ describe Braintree::CreditCardVerification do
33
33
  :merchant_account_id => "some_id",
34
34
  )
35
35
 
36
- verification.status.should == Braintree::CreditCardVerification::Status::Verified
36
+ expect(verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
37
37
  end
38
38
  end
39
39
 
40
40
  it "accepts amount as either a String or BigDecimal" do
41
- Braintree::CreditCardVerification._new(:amount => "12.34").amount.should == BigDecimal("12.34")
42
- Braintree::CreditCardVerification._new(:amount => BigDecimal("12.34")).amount.should == BigDecimal("12.34")
41
+ expect(Braintree::CreditCardVerification._new(:amount => "12.34").amount).to eq(BigDecimal("12.34"))
42
+ expect(Braintree::CreditCardVerification._new(:amount => BigDecimal("12.34")).amount).to eq(BigDecimal("12.34"))
43
43
  end
44
44
 
45
45
  it "accepts network_transaction_id" do
@@ -88,27 +88,27 @@ describe Braintree::CreditCardVerification do
88
88
  first = Braintree::CreditCardVerification._new(:id => 123)
89
89
  second = Braintree::CreditCardVerification._new(:id => 123)
90
90
 
91
- first.should == second
92
- second.should == first
91
+ expect(first).to eq(second)
92
+ expect(second).to eq(first)
93
93
  end
94
94
 
95
95
  it "returns false for verifications with different ids" do
96
96
  first = Braintree::CreditCardVerification._new(:id => 123)
97
97
  second = Braintree::CreditCardVerification._new(:id => 124)
98
98
 
99
- first.should_not == second
100
- second.should_not == first
99
+ expect(first).not_to eq(second)
100
+ expect(second).not_to eq(first)
101
101
  end
102
102
 
103
103
  it "returns false when comparing to nil" do
104
- Braintree::CreditCardVerification._new({}).should_not == nil
104
+ expect(Braintree::CreditCardVerification._new({})).not_to eq(nil)
105
105
  end
106
106
 
107
107
  it "returns false when comparing to non-verifications" do
108
108
  same_id_different_object = Object.new
109
109
  def same_id_different_object.id; 123; end
110
110
  verification = Braintree::CreditCardVerification._new(:id => 123)
111
- verification.should_not == same_id_different_object
111
+ expect(verification).not_to eq(same_id_different_object)
112
112
  end
113
113
  end
114
114
 
@@ -123,17 +123,17 @@ describe Braintree::CreditCardVerification do
123
123
  :transaction_risk_score => "12",
124
124
  })
125
125
 
126
- verification.risk_data.id.should == "123"
127
- verification.risk_data.decision.should == "WOO YOU WON $1000 dollars"
128
- verification.risk_data.decision_reasons.should == ["reason"]
129
- verification.risk_data.device_data_captured.should == true
130
- verification.risk_data.fraud_service_provider.should == "paypal_fraud_protection"
131
- verification.risk_data.transaction_risk_score.should == "12"
126
+ expect(verification.risk_data.id).to eq("123")
127
+ expect(verification.risk_data.decision).to eq("WOO YOU WON $1000 dollars")
128
+ expect(verification.risk_data.decision_reasons).to eq(["reason"])
129
+ expect(verification.risk_data.device_data_captured).to eq(true)
130
+ expect(verification.risk_data.fraud_service_provider).to eq("paypal_fraud_protection")
131
+ expect(verification.risk_data.transaction_risk_score).to eq("12")
132
132
  end
133
133
 
134
134
  it "handles a nil risk_data" do
135
135
  verification = Braintree::CreditCardVerification._new(:risk_data => nil)
136
- verification.risk_data.should be_nil
136
+ expect(verification.risk_data).to be_nil
137
137
  end
138
138
  end
139
139
 
@@ -4,7 +4,7 @@ describe Braintree::Customer do
4
4
  describe "inspect" do
5
5
  it "includes the id first" do
6
6
  output = Braintree::Customer._new(:gateway, {:first_name => "Dan", :id => "1234"}).inspect
7
- output.should include("#<Braintree::Customer id: \"1234\",")
7
+ expect(output).to include("#<Braintree::Customer id: \"1234\",")
8
8
  end
9
9
 
10
10
  it "includes all customer attributes" do
@@ -21,19 +21,19 @@ describe Braintree::Customer do
21
21
  :updated_at => Time.now,
22
22
  )
23
23
  output = customer.inspect
24
- output.should include(%q(company: "Company"))
25
- output.should include(%q(email: "e@mail.com"))
26
- output.should include(%q(fax: "483-438-5821"))
27
- output.should include(%q(first_name: "Patrick"))
28
- output.should include(%q(last_name: "Smith"))
29
- output.should include(%q(phone: "802-483-5932"))
30
- output.should include(%q(website: "patrick.smith.com"))
31
- output.should include(%q(addresses: []))
32
- output.should include(%q(credit_cards: []))
33
- output.should include(%q(paypal_accounts: []))
34
- output.should include(%q(tax_identifiers: []))
35
- output.should include(%Q(created_at: #{customer.created_at.inspect}))
36
- output.should include(%Q(updated_at: #{customer.updated_at.inspect}))
24
+ expect(output).to include(%q(company: "Company"))
25
+ expect(output).to include(%q(email: "e@mail.com"))
26
+ expect(output).to include(%q(fax: "483-438-5821"))
27
+ expect(output).to include(%q(first_name: "Patrick"))
28
+ expect(output).to include(%q(last_name: "Smith"))
29
+ expect(output).to include(%q(phone: "802-483-5932"))
30
+ expect(output).to include(%q(website: "patrick.smith.com"))
31
+ expect(output).to include(%q(addresses: []))
32
+ expect(output).to include(%q(credit_cards: []))
33
+ expect(output).to include(%q(paypal_accounts: []))
34
+ expect(output).to include(%q(tax_identifiers: []))
35
+ expect(output).to include(%Q(created_at: #{customer.created_at.inspect}))
36
+ expect(output).to include(%Q(updated_at: #{customer.updated_at.inspect}))
37
37
  end
38
38
  end
39
39
 
@@ -59,7 +59,7 @@ describe Braintree::Customer do
59
59
  end
60
60
 
61
61
  it "does not raise an exception if the id is a fixnum" do
62
- Braintree::Http.stub(:new).and_return double.as_null_object
62
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
63
63
  expect do
64
64
  Braintree::Customer.find(8675309)
65
65
  end.to_not raise_error
@@ -97,11 +97,12 @@ describe Braintree::Customer do
97
97
  :expiration_year,
98
98
  :number,
99
99
  :token,
100
- :venmo_sdk_payment_method_code,
100
+ :venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
101
101
  :device_data,
102
102
  :payment_method_nonce,
103
103
  {:external_vault=>[:network_transaction_id]},
104
- {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
104
+ {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
105
+ :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
105
106
  {:billing_address => [
106
107
  :company,
107
108
  :country_code_alpha2,
@@ -190,7 +191,7 @@ describe Braintree::Customer do
190
191
  :expiration_year,
191
192
  :number,
192
193
  :token,
193
- :venmo_sdk_payment_method_code,
194
+ :venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
194
195
  :device_data,
195
196
  :payment_method_nonce,
196
197
  {:external_vault=>[:network_transaction_id]},
@@ -200,7 +201,7 @@ describe Braintree::Customer do
200
201
  :verification_merchant_account_id,
201
202
  :verify_card,
202
203
  :verification_amount,
203
- :venmo_sdk_session,
204
+ :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
204
205
  :fail_on_duplicate_payment_method,
205
206
  :verification_account_type,
206
207
  :verification_currency_iso_code,
@@ -271,21 +272,21 @@ describe Braintree::Customer do
271
272
  first = Braintree::Customer._new(:gateway, :id => 123)
272
273
  second = Braintree::Customer._new(:gateway, :id => 123)
273
274
 
274
- first.should == second
275
- second.should == first
275
+ expect(first).to eq(second)
276
+ expect(second).to eq(first)
276
277
  end
277
278
 
278
279
  it "returns false when given a customer with a different id" do
279
280
  first = Braintree::Customer._new(:gateway, :id => 123)
280
281
  second = Braintree::Customer._new(:gateway, :id => 124)
281
282
 
282
- first.should_not == second
283
- second.should_not == first
283
+ expect(first).not_to eq(second)
284
+ expect(second).not_to eq(first)
284
285
  end
285
286
 
286
287
  it "returns false when not given a customer" do
287
288
  customer = Braintree::Customer._new(:gateway, :id => 123)
288
- customer.should_not == "not a customer"
289
+ expect(customer).not_to eq("not a customer")
289
290
  end
290
291
  end
291
292
 
@@ -307,25 +308,25 @@ describe Braintree::Customer do
307
308
  ],
308
309
  )
309
310
 
310
- customer.credit_cards.size.should == 2
311
- customer.credit_cards[0].token.should == "credit_card_1"
312
- customer.credit_cards[1].token.should == "credit_card_2"
311
+ expect(customer.credit_cards.size).to eq(2)
312
+ expect(customer.credit_cards[0].token).to eq("credit_card_1")
313
+ expect(customer.credit_cards[1].token).to eq("credit_card_2")
313
314
 
314
- customer.paypal_accounts.size.should == 2
315
- customer.paypal_accounts[0].token.should == "paypal_1"
316
- customer.paypal_accounts[1].token.should == "paypal_2"
315
+ expect(customer.paypal_accounts.size).to eq(2)
316
+ expect(customer.paypal_accounts[0].token).to eq("paypal_1")
317
+ expect(customer.paypal_accounts[1].token).to eq("paypal_2")
317
318
 
318
- customer.sepa_direct_debit_accounts.size.should == 2
319
- customer.sepa_direct_debit_accounts[0].token.should == "sepa_debit_1"
320
- customer.sepa_direct_debit_accounts[1].token.should == "sepa_debit_2"
319
+ expect(customer.sepa_direct_debit_accounts.size).to eq(2)
320
+ expect(customer.sepa_direct_debit_accounts[0].token).to eq("sepa_debit_1")
321
+ expect(customer.sepa_direct_debit_accounts[1].token).to eq("sepa_debit_2")
321
322
 
322
- customer.payment_methods.count.should == 6
323
- customer.payment_methods.map(&:token).should include("credit_card_1")
324
- customer.payment_methods.map(&:token).should include("credit_card_2")
325
- customer.payment_methods.map(&:token).should include("paypal_1")
326
- customer.payment_methods.map(&:token).should include("paypal_2")
327
- customer.payment_methods.map(&:token).should include("sepa_debit_1")
328
- customer.payment_methods.map(&:token).should include("sepa_debit_2")
323
+ expect(customer.payment_methods.count).to eq(6)
324
+ expect(customer.payment_methods.map(&:token)).to include("credit_card_1")
325
+ expect(customer.payment_methods.map(&:token)).to include("credit_card_2")
326
+ expect(customer.payment_methods.map(&:token)).to include("paypal_1")
327
+ expect(customer.payment_methods.map(&:token)).to include("paypal_2")
328
+ expect(customer.payment_methods.map(&:token)).to include("sepa_debit_1")
329
+ expect(customer.payment_methods.map(&:token)).to include("sepa_debit_2")
329
330
  end
330
331
  end
331
332
 
@@ -6,13 +6,13 @@ describe Braintree::Digest do
6
6
  original_key = Braintree::Configuration.private_key
7
7
  private_key = "\xaa" * 80
8
8
  data = "Test Using Larger Than Block-Size Key - Hash Key First"
9
- Braintree::Digest.hexdigest(private_key, data).should == "aa4ae5e15272d00e95705637ce8a3b55ed402112"
9
+ expect(Braintree::Digest.hexdigest(private_key, data)).to eq("aa4ae5e15272d00e95705637ce8a3b55ed402112")
10
10
  end
11
11
 
12
12
  it "returns the sha1 hmac of the input string (test case 7 from RFC 2202)" do
13
13
  private_key = "\xaa" * 80
14
14
  data = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"
15
- Braintree::Digest.hexdigest(private_key, data).should == "e8e99d0f45237d786d6bbaa7965c7808bbff1a91"
15
+ expect(Braintree::Digest.hexdigest(private_key, data)).to eq("e8e99d0f45237d786d6bbaa7965c7808bbff1a91")
16
16
  end
17
17
 
18
18
  it "doesn't blow up if message is nil" do
@@ -22,15 +22,15 @@ describe Braintree::Digest do
22
22
 
23
23
  describe "self.secure_compare" do
24
24
  it "returns true if two strings are equal" do
25
- Braintree::Digest.secure_compare("A_string", "A_string").should be(true)
25
+ expect(Braintree::Digest.secure_compare("A_string", "A_string")).to be(true)
26
26
  end
27
27
 
28
28
  it "returns false if two strings are different and the same length" do
29
- Braintree::Digest.secure_compare("A_string", "A_strong").should be(false)
29
+ expect(Braintree::Digest.secure_compare("A_string", "A_strong")).to be(false)
30
30
  end
31
31
 
32
32
  it "returns false if one is a prefix of the other" do
33
- Braintree::Digest.secure_compare("A_string", "A_string_that_is_longer").should be(false)
33
+ expect(Braintree::Digest.secure_compare("A_string", "A_string_that_is_longer")).to be(false)
34
34
  end
35
35
  end
36
36
  end
@@ -31,15 +31,15 @@ describe Braintree::Disbursement do
31
31
  :success => false,
32
32
  )
33
33
 
34
- disbursement.inspect.should include('id: "123456"')
35
- disbursement.inspect.should include('amount: "100.0"')
36
- disbursement.inspect.should include('exception_message: "invalid_account_number"')
37
- disbursement.inspect.should include("disbursement_date: 2013-04-10")
38
- disbursement.inspect.should include('follow_up_action: "update"')
39
- disbursement.inspect.should include("merchant_account: #<Braintree::MerchantAccount: ")
40
- disbursement.inspect.should include('transaction_ids: ["sub_merchant_transaction"]')
41
- disbursement.inspect.should include("retry: false")
42
- disbursement.inspect.should include("success: false")
34
+ expect(disbursement.inspect).to include('id: "123456"')
35
+ expect(disbursement.inspect).to include('amount: "100.0"')
36
+ expect(disbursement.inspect).to include('exception_message: "invalid_account_number"')
37
+ expect(disbursement.inspect).to include("disbursement_date: 2013-04-10")
38
+ expect(disbursement.inspect).to include('follow_up_action: "update"')
39
+ expect(disbursement.inspect).to include("merchant_account: #<Braintree::MerchantAccount: ")
40
+ expect(disbursement.inspect).to include('transaction_ids: ["sub_merchant_transaction"]')
41
+ expect(disbursement.inspect).to include("retry: false")
42
+ expect(disbursement.inspect).to include("success: false")
43
43
  end
44
44
  end
45
45
 
@@ -58,7 +58,7 @@ describe Braintree::Disbursement do
58
58
  :success => false,
59
59
  :disbursement_date => "2013-04-10",
60
60
  )
61
- disbursement.success?.should == false
61
+ expect(disbursement.success?).to eq(false)
62
62
 
63
63
  disbursement = Braintree::Disbursement._new(
64
64
  :gateway,
@@ -73,7 +73,7 @@ describe Braintree::Disbursement do
73
73
  :success => true,
74
74
  :disbursement_date => "2013-04-10",
75
75
  )
76
- disbursement.success?.should == true
76
+ expect(disbursement.success?).to eq(true)
77
77
  end
78
78
  end
79
79
 
@@ -5,14 +5,14 @@ describe Braintree::DisputeSearch do
5
5
  search = Braintree::DisputeSearch.new
6
6
  search.id.is "dispute1"
7
7
  search.id.is "dispute2"
8
- search.to_hash.should == {:id => {:is => "dispute2"}}
8
+ expect(search.to_hash).to eq({:id => {:is => "dispute2"}})
9
9
  end
10
10
 
11
11
  it "overrides previous 'in' with new 'in' for the same field" do
12
12
  search = Braintree::DisputeSearch.new
13
13
  search.status.in Braintree::Dispute::Status::Open
14
14
  search.status.in Braintree::Dispute::Status::Won
15
- search.to_hash.should == {:status => [Braintree::Dispute::Status::Won]}
15
+ expect(search.to_hash).to eq({:status => [Braintree::Dispute::Status::Won]})
16
16
  end
17
17
 
18
18
  [