braintree 4.14.0 → 4.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) 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.rb +5 -4
  10. data/lib/braintree/transaction_gateway.rb +15 -3
  11. data/lib/braintree/transaction_search.rb +6 -5
  12. data/lib/braintree/version.rb +1 -1
  13. data/lib/braintree/webhook_notification.rb +1 -0
  14. data/lib/braintree/webhook_testing_gateway.rb +17 -0
  15. data/spec/integration/braintree/add_on_spec.rb +9 -9
  16. data/spec/integration/braintree/address_spec.rb +69 -69
  17. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  18. data/spec/integration/braintree/apple_pay_spec.rb +8 -8
  19. data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
  20. data/spec/integration/braintree/credit_card_spec.rb +223 -223
  21. data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
  22. data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
  23. data/spec/integration/braintree/customer_search_spec.rb +20 -20
  24. data/spec/integration/braintree/customer_spec.rb +313 -313
  25. data/spec/integration/braintree/disbursement_spec.rb +2 -2
  26. data/spec/integration/braintree/discount_spec.rb +9 -9
  27. data/spec/integration/braintree/dispute_spec.rb +87 -87
  28. data/spec/integration/braintree/document_upload_spec.rb +17 -17
  29. data/spec/integration/braintree/error_codes_spec.rb +2 -2
  30. data/spec/integration/braintree/http_spec.rb +28 -28
  31. data/spec/integration/braintree/merchant_account_spec.rb +127 -127
  32. data/spec/integration/braintree/merchant_spec.rb +103 -103
  33. data/spec/integration/braintree/oauth_spec.rb +61 -61
  34. data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
  35. data/spec/integration/braintree/payment_method_spec.rb +389 -389
  36. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
  37. data/spec/integration/braintree/paypal_account_spec.rb +38 -38
  38. data/spec/integration/braintree/plan_spec.rb +15 -15
  39. data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
  40. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
  41. data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
  42. data/spec/integration/braintree/subscription_spec.rb +364 -364
  43. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  44. data/spec/integration/braintree/test_transaction_spec.rb +19 -19
  45. data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
  46. data/spec/integration/braintree/transaction_search_spec.rb +198 -165
  47. data/spec/integration/braintree/transaction_spec.rb +1315 -1149
  48. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
  49. data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
  50. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
  51. data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
  52. data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
  53. data/spec/spec_helper.rb +9 -8
  54. data/spec/unit/braintree/address_spec.rb +8 -8
  55. data/spec/unit/braintree/base_module_spec.rb +4 -4
  56. data/spec/unit/braintree/client_token_spec.rb +2 -2
  57. data/spec/unit/braintree/configuration_spec.rb +57 -57
  58. data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
  59. data/spec/unit/braintree/credit_card_spec.rb +31 -29
  60. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
  61. data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
  62. data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
  63. data/spec/unit/braintree/customer_spec.rb +41 -40
  64. data/spec/unit/braintree/digest_spec.rb +5 -5
  65. data/spec/unit/braintree/disbursement_spec.rb +11 -11
  66. data/spec/unit/braintree/dispute_search_spec.rb +2 -2
  67. data/spec/unit/braintree/dispute_spec.rb +56 -56
  68. data/spec/unit/braintree/document_upload_spec.rb +8 -8
  69. data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
  70. data/spec/unit/braintree/error_result_spec.rb +5 -5
  71. data/spec/unit/braintree/errors_spec.rb +9 -9
  72. data/spec/unit/braintree/http_spec.rb +8 -8
  73. data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
  74. data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
  75. data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
  76. data/spec/unit/braintree/merchant_account_spec.rb +4 -4
  77. data/spec/unit/braintree/modification_spec.rb +1 -1
  78. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
  79. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
  80. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
  81. data/spec/unit/braintree/payment_method_spec.rb +19 -19
  82. data/spec/unit/braintree/paypal_account_spec.rb +4 -4
  83. data/spec/unit/braintree/resource_collection_spec.rb +7 -7
  84. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
  85. data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
  86. data/spec/unit/braintree/signature_service_spec.rb +2 -2
  87. data/spec/unit/braintree/subscription_search_spec.rb +17 -17
  88. data/spec/unit/braintree/subscription_spec.rb +8 -8
  89. data/spec/unit/braintree/successful_result_spec.rb +5 -5
  90. data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
  91. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
  92. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  93. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  94. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
  95. data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
  96. data/spec/unit/braintree/transaction_search_spec.rb +2 -2
  97. data/spec/unit/braintree/transaction_spec.rb +101 -93
  98. data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
  99. data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
  100. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
  101. data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
  102. data/spec/unit/braintree/util_spec.rb +27 -27
  103. data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
  104. data/spec/unit/braintree/validation_error_spec.rb +4 -4
  105. data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
  106. data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
  107. data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
  108. data/spec/unit/braintree/xml/parser_spec.rb +8 -8
  109. data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
  110. data/spec/unit/braintree/xml_spec.rb +17 -17
  111. data/spec/unit/braintree_spec.rb +2 -2
  112. metadata +3 -2
@@ -78,9 +78,9 @@ describe Braintree::Dispute do
78
78
  end
79
79
 
80
80
  it "does not raise an exception if the id is a fixnum" do
81
- Braintree::Http.stub(:new).and_return double.as_null_object
82
- Braintree::Dispute.stub(:_new).and_return nil
83
- Braintree::ErrorResult.stub(:new).and_return nil
81
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
82
+ allow(Braintree::Dispute).to receive(:_new).and_return nil
83
+ allow(Braintree::ErrorResult).to receive(:new).and_return nil
84
84
 
85
85
  expect do
86
86
  Braintree::Dispute.public_send(method_name, 8675309)
@@ -109,8 +109,8 @@ describe Braintree::Dispute do
109
109
  end
110
110
 
111
111
  it "does not raise an exception if the dispute_id is a fixnum" do
112
- Braintree::Http.stub(:new).and_return double.as_null_object
113
- Braintree::Dispute.stub(:_new).and_return nil
112
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
113
+ allow(Braintree::Dispute).to receive(:_new).and_return nil
114
114
  expect do
115
115
  Braintree::Dispute.add_file_evidence(8675309, "doc_upload_id")
116
116
  end.to_not raise_error
@@ -135,8 +135,8 @@ describe Braintree::Dispute do
135
135
  end
136
136
 
137
137
  it "does not raise an exception if the document_upload_id is a fixnum" do
138
- Braintree::Http.stub(:new).and_return double.as_null_object
139
- Braintree::Dispute.stub(:_new).and_return nil
138
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
139
+ allow(Braintree::Dispute).to receive(:_new).and_return nil
140
140
  expect do
141
141
  Braintree::Dispute.add_file_evidence("dispute_id", 8675309)
142
142
  end.to_not raise_error
@@ -144,7 +144,7 @@ describe Braintree::Dispute do
144
144
 
145
145
  describe "with optional params" do
146
146
  it "does not raise an exception if the optional parameters are valid" do
147
- Braintree::Http.stub(:new).and_return double.as_null_object
147
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
148
148
  expect do
149
149
  Braintree::Dispute.add_file_evidence("dispute_id", {category: "GENERAL", document_id: "document_id"})
150
150
  end.to_not raise_error
@@ -157,7 +157,7 @@ describe Braintree::Dispute do
157
157
  end
158
158
 
159
159
  it "raises an exception if the param tag is not a string" do
160
- Braintree::Http.stub(:new).and_return double.as_null_object
160
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
161
161
 
162
162
  expect do
163
163
  Braintree::Dispute.add_file_evidence("dispute_id", {category: 3, document_id: "document_id"})
@@ -186,8 +186,8 @@ describe Braintree::Dispute do
186
186
  end
187
187
 
188
188
  it "does not raise an exception if the id is a fixnum" do
189
- Braintree::Http.stub(:new).and_return double.as_null_object
190
- Braintree::Dispute.stub(:_new).and_return nil
189
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
190
+ allow(Braintree::Dispute).to receive(:_new).and_return nil
191
191
  expect do
192
192
  Braintree::Dispute.add_text_evidence(8675309, "text evidence")
193
193
  end.to_not raise_error
@@ -207,7 +207,7 @@ describe Braintree::Dispute do
207
207
 
208
208
  describe "with optional params" do
209
209
  it "does not raise an exception if the optional parameters are valid" do
210
- Braintree::Http.stub(:new).and_return double.as_null_object
210
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
211
211
  expect do
212
212
  Braintree::Dispute.add_text_evidence("dispute_id", {content: "a", category: "", sequence_number: 3})
213
213
  end.to_not raise_error
@@ -281,8 +281,8 @@ describe Braintree::Dispute do
281
281
  it "converts string amount_dispute and amount_won" do
282
282
  dispute = Braintree::Dispute._new(attributes)
283
283
 
284
- dispute.amount_disputed.should == 500.0
285
- dispute.amount_won.should == 0.0
284
+ expect(dispute.amount_disputed).to eq(500.0)
285
+ expect(dispute.amount_won).to eq(0.0)
286
286
  end
287
287
 
288
288
  it "returns 'Effortless Chargeback Protection tool' when initial chargeback_protection_level is effortless" do
@@ -336,74 +336,74 @@ describe Braintree::Dispute do
336
336
 
337
337
  dispute = Braintree::Dispute._new(attributes)
338
338
 
339
- dispute.send(field).should == nil
339
+ expect(dispute.send(field)).to eq(nil)
340
340
  end
341
341
  end
342
342
 
343
343
  it "converts date_opened, date_won, reply_by_date, received_date from String to Date" do
344
344
  dispute = Braintree::Dispute._new(attributes.merge(:reply_by_date => "2009-03-14"))
345
345
 
346
- dispute.date_opened.should == Date.new(2009, 3, 9)
347
- dispute.date_won.should == Date.new(2009, 4, 15)
348
- dispute.received_date.should == Date.new(2009, 3, 9)
349
- dispute.reply_by_date.should == Date.new(2009, 3, 14)
346
+ expect(dispute.date_opened).to eq(Date.new(2009, 3, 9))
347
+ expect(dispute.date_won).to eq(Date.new(2009, 4, 15))
348
+ expect(dispute.received_date).to eq(Date.new(2009, 3, 9))
349
+ expect(dispute.reply_by_date).to eq(Date.new(2009, 3, 14))
350
350
  end
351
351
 
352
352
  it "converts transaction hash into a Dispute::TransactionDetails object first" do
353
353
  dispute = Braintree::Dispute._new(attributes)
354
354
 
355
- dispute.transaction_details.id.should == "open_disputed_transaction"
356
- dispute.transaction_details.amount.should == 31.00
355
+ expect(dispute.transaction_details.id).to eq("open_disputed_transaction")
356
+ expect(dispute.transaction_details.amount).to eq(31.00)
357
357
  end
358
358
 
359
359
  it "converts transaction hash into a Dispute::Transaction object" do
360
360
  dispute = Braintree::Dispute._new(attributes)
361
361
 
362
- dispute.transaction.amount.should == 31.00
363
- dispute.transaction.id.should == "open_disputed_transaction"
364
- dispute.transaction.created_at.should == Time.utc(2009, 2, 9, 12, 59, 59)
365
- dispute.transaction.installment_count.should == nil
366
- dispute.transaction.order_id.should == nil
367
- dispute.transaction.purchase_order_number.should == "po"
368
- dispute.transaction.payment_instrument_subtype.should == "Visa"
362
+ expect(dispute.transaction.amount).to eq(31.00)
363
+ expect(dispute.transaction.id).to eq("open_disputed_transaction")
364
+ expect(dispute.transaction.created_at).to eq(Time.utc(2009, 2, 9, 12, 59, 59))
365
+ expect(dispute.transaction.installment_count).to eq(nil)
366
+ expect(dispute.transaction.order_id).to eq(nil)
367
+ expect(dispute.transaction.purchase_order_number).to eq("po")
368
+ expect(dispute.transaction.payment_instrument_subtype).to eq("Visa")
369
369
  end
370
370
 
371
371
  it "converts status_history hash into an array of Dispute::StatusHistory objects" do
372
372
  dispute = Braintree::Dispute._new(attributes)
373
373
 
374
- dispute.status_history.length.should == 1
374
+ expect(dispute.status_history.length).to eq(1)
375
375
  status_history_1 = dispute.status_history.first
376
- status_history_1.status.should == Braintree::Dispute::Status::Open
377
- status_history_1.timestamp.should == Time.utc(2009, 3, 9, 10, 50, 39)
376
+ expect(status_history_1.status).to eq(Braintree::Dispute::Status::Open)
377
+ expect(status_history_1.timestamp).to eq(Time.utc(2009, 3, 9, 10, 50, 39))
378
378
  end
379
379
 
380
380
  it "converts evidence hash into an array of Dispute::Evidence objects" do
381
381
  dispute = Braintree::Dispute._new(attributes)
382
382
 
383
- dispute.evidence.length.should ==2
383
+ expect(dispute.evidence.length).to eq(2)
384
384
  evidence1 = dispute.evidence.first
385
- evidence1.comment.should == nil
386
- evidence1.created_at.should == Time.utc(2009, 3, 10, 12, 5, 20)
387
- evidence1.id.should == "evidence1"
388
- evidence1.sent_to_processor_at.should == nil
389
- evidence1.url.should == "url_of_file_evidence"
385
+ expect(evidence1.comment).to eq(nil)
386
+ expect(evidence1.created_at).to eq(Time.utc(2009, 3, 10, 12, 5, 20))
387
+ expect(evidence1.id).to eq("evidence1")
388
+ expect(evidence1.sent_to_processor_at).to eq(nil)
389
+ expect(evidence1.url).to eq("url_of_file_evidence")
390
390
 
391
391
  evidence2 = dispute.evidence.last
392
- evidence2.comment.should == "text evidence"
393
- evidence2.created_at.should == Time.utc(2009, 3, 10, 12, 5, 21)
394
- evidence2.id.should == "evidence2"
395
- evidence2.sent_to_processor_at.should == Date.new(2009, 3, 13)
396
- evidence2.url.should == nil
392
+ expect(evidence2.comment).to eq("text evidence")
393
+ expect(evidence2.created_at).to eq(Time.utc(2009, 3, 10, 12, 5, 21))
394
+ expect(evidence2.id).to eq("evidence2")
395
+ expect(evidence2.sent_to_processor_at).to eq(Date.new(2009, 3, 13))
396
+ expect(evidence2.url).to eq(nil)
397
397
  end
398
398
 
399
399
  it "converts paypal_messages hash into an array of Dispute::PayPalMessage objects" do
400
400
  dispute = Braintree::Dispute._new(attributes)
401
401
 
402
- dispute.paypal_messages.length.should == 1
402
+ expect(dispute.paypal_messages.length).to eq(1)
403
403
  paypal_message_1 = dispute.paypal_messages.first
404
- paypal_message_1.message.should == "message"
405
- paypal_message_1.sender.should == "seller"
406
- paypal_message_1.sent_at.should == Time.utc(2009, 3, 9, 10, 50, 39)
404
+ expect(paypal_message_1.message).to eq("message")
405
+ expect(paypal_message_1.sender).to eq("seller")
406
+ expect(paypal_message_1.sent_at).to eq(Time.utc(2009, 3, 9, 10, 50, 39))
407
407
  end
408
408
 
409
409
  it "handles nil evidence" do
@@ -411,7 +411,7 @@ describe Braintree::Dispute do
411
411
 
412
412
  dispute = Braintree::Dispute._new(attributes)
413
413
 
414
- dispute.evidence.should == nil
414
+ expect(dispute.evidence).to eq(nil)
415
415
  end
416
416
 
417
417
  it "handles nil paypal_messages" do
@@ -419,15 +419,15 @@ describe Braintree::Dispute do
419
419
 
420
420
  dispute = Braintree::Dispute._new(attributes)
421
421
 
422
- dispute.paypal_messages.should == nil
422
+ expect(dispute.paypal_messages).to eq(nil)
423
423
  end
424
424
 
425
425
  it "sets the older webhook fields for backwards compatibility" do
426
426
  dispute = Braintree::Dispute._new(attributes)
427
427
 
428
- dispute.amount.should == 31.00
429
- dispute.date_opened.should == Date.new(2009, 3, 9)
430
- dispute.date_won.should == Date.new(2009, 4, 15)
428
+ expect(dispute.amount).to eq(31.00)
429
+ expect(dispute.date_opened).to eq(Date.new(2009, 3, 9))
430
+ expect(dispute.date_won).to eq(Date.new(2009, 4, 15))
431
431
  end
432
432
 
433
433
  it "returns pre_dispute_program value" do
@@ -443,21 +443,21 @@ describe Braintree::Dispute do
443
443
  first = Braintree::Dispute._new(attributes)
444
444
  second = Braintree::Dispute._new(attributes)
445
445
 
446
- first.should == second
447
- second.should == first
446
+ expect(first).to eq(second)
447
+ expect(second).to eq(first)
448
448
  end
449
449
 
450
450
  it "returns false when given a dispute with a different id" do
451
451
  first = Braintree::Dispute._new(attributes)
452
452
  second = Braintree::Dispute._new(attributes.merge(:id => "1234"))
453
453
 
454
- first.should_not == second
455
- second.should_not == first
454
+ expect(first).not_to eq(second)
455
+ expect(second).not_to eq(first)
456
456
  end
457
457
 
458
458
  it "returns false when not given a dispute" do
459
459
  dispute = Braintree::Dispute._new(attributes)
460
- dispute.should_not == "not a dispute"
460
+ expect(dispute).not_to eq("not a dispute")
461
461
  end
462
462
  end
463
463
 
@@ -5,11 +5,11 @@ describe Braintree::DocumentUpload do
5
5
  it "sets attributes" do
6
6
  response = {:size => 555, :kind => "evidence_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
7
7
  document_upload = Braintree::DocumentUpload._new(response)
8
- document_upload.id.should == "my_id"
9
- document_upload.size.should == 555
10
- document_upload.name.should == "up_file.pdf"
11
- document_upload.content_type.should == "application/pdf"
12
- document_upload.kind.should == Braintree::DocumentUpload::Kind::EvidenceDocument
8
+ expect(document_upload.id).to eq("my_id")
9
+ expect(document_upload.size).to eq(555)
10
+ expect(document_upload.name).to eq("up_file.pdf")
11
+ expect(document_upload.content_type).to eq("application/pdf")
12
+ expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::EvidenceDocument)
13
13
  end
14
14
  end
15
15
 
@@ -17,19 +17,19 @@ describe Braintree::DocumentUpload do
17
17
  it "sets identity document" do
18
18
  response = {:size => 555, :kind => "identity_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
19
19
  document_upload = Braintree::DocumentUpload._new(response)
20
- document_upload.kind.should == Braintree::DocumentUpload::Kind::IdentityDocument
20
+ expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::IdentityDocument)
21
21
  end
22
22
 
23
23
  it "sets evidence document" do
24
24
  response = {:size => 555, :kind => "evidence_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
25
25
  document_upload = Braintree::DocumentUpload._new(response)
26
- document_upload.kind.should == Braintree::DocumentUpload::Kind::EvidenceDocument
26
+ expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::EvidenceDocument)
27
27
  end
28
28
 
29
29
  it "sets payout invoice document" do
30
30
  response = {:size => 555, :kind => "payout_invoice_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
31
31
  document_upload = Braintree::DocumentUpload._new(response)
32
- document_upload.kind.should == Braintree::DocumentUpload::Kind::PayoutInvoiceDocument
32
+ expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::PayoutInvoiceDocument)
33
33
  end
34
34
  end
35
35
  end
@@ -25,8 +25,8 @@ describe Braintree::EnrichedCustomerData do
25
25
 
26
26
  payment_method_customer_data_updated = Braintree::EnrichedCustomerData._new(params)
27
27
 
28
- payment_method_customer_data_updated.profile_data.should be_a(Braintree::VenmoProfileData)
29
- payment_method_customer_data_updated.fields_updated.should eq(["username"])
28
+ expect(payment_method_customer_data_updated.profile_data).to be_a(Braintree::VenmoProfileData)
29
+ expect(payment_method_customer_data_updated.fields_updated).to eq(["username"])
30
30
  end
31
31
  end
32
32
  end
@@ -27,7 +27,7 @@ describe Braintree::ErrorResult do
27
27
  }
28
28
  }
29
29
  result = Braintree::ErrorResult.new(:gateway, :params => "params", :errors => errors)
30
- result.inspect.should == "#<Braintree::ErrorResult params:{...} errors:<level1:[(code1) message], level1/level2:[(code2) message2]>>"
30
+ expect(result.inspect).to eq("#<Braintree::ErrorResult params:{...} errors:<level1:[(code1) message], level1/level2:[(code2) message2]>>")
31
31
  end
32
32
 
33
33
  it "includes the credit_card_verification if there is one" do
@@ -38,7 +38,7 @@ describe Braintree::ErrorResult do
38
38
  :verification => {},
39
39
  :transaction => nil,
40
40
  )
41
- result.inspect.should include("credit_card_verification: #<Braintree::CreditCardVerification status: ")
41
+ expect(result.inspect).to include("credit_card_verification: #<Braintree::CreditCardVerification status: ")
42
42
  end
43
43
 
44
44
  it "does not include the credit_card_verification if there isn't one" do
@@ -49,7 +49,7 @@ describe Braintree::ErrorResult do
49
49
  :verification => nil,
50
50
  :transaction => nil,
51
51
  )
52
- result.inspect.should_not include("credit_card_verification")
52
+ expect(result.inspect).not_to include("credit_card_verification")
53
53
  end
54
54
 
55
55
  it "includes the transaction if there is one" do
@@ -60,7 +60,7 @@ describe Braintree::ErrorResult do
60
60
  :verification => nil,
61
61
  :transaction => {},
62
62
  )
63
- result.inspect.should include("transaction: #<Braintree::Transaction id: ")
63
+ expect(result.inspect).to include("transaction: #<Braintree::Transaction id: ")
64
64
  end
65
65
 
66
66
  it "does not include the transaction if there isn't one" do
@@ -71,7 +71,7 @@ describe Braintree::ErrorResult do
71
71
  :verification => nil,
72
72
  :transaction => nil,
73
73
  )
74
- result.inspect.should_not include("transaction")
74
+ expect(result.inspect).not_to include("transaction")
75
75
  end
76
76
  end
77
77
  end
@@ -6,15 +6,15 @@ describe Braintree::Errors do
6
6
  errors = Braintree::Errors.new(
7
7
  :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
8
8
  )
9
- errors.for(:level1).size.should == 1
10
- errors.for(:level1)[0].code.should == "code1"
9
+ expect(errors.for(:level1).size).to eq(1)
10
+ expect(errors.for(:level1)[0].code).to eq("code1")
11
11
  end
12
12
 
13
13
  it "returns nil if there are no errors at the given scope" do
14
14
  errors = Braintree::Errors.new(
15
15
  :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
16
16
  )
17
- errors.for(:no_errors_here).should == nil
17
+ expect(errors.for(:no_errors_here)).to eq(nil)
18
18
  end
19
19
  end
20
20
 
@@ -23,7 +23,7 @@ describe Braintree::Errors do
23
23
  errors = Braintree::Errors.new(
24
24
  :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
25
25
  )
26
- errors.inspect.should == "#<Braintree::Errors level1:[(code1) message]>"
26
+ expect(errors.inspect).to eq("#<Braintree::Errors level1:[(code1) message]>")
27
27
  end
28
28
 
29
29
  it "shows errors 2 levels deep" do
@@ -35,7 +35,7 @@ describe Braintree::Errors do
35
35
  }
36
36
  },
37
37
  )
38
- errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2]>"
38
+ expect(errors.inspect).to eq("#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2]>")
39
39
  end
40
40
 
41
41
  it "shows errors 3 levels deep" do
@@ -50,7 +50,7 @@ describe Braintree::Errors do
50
50
  }
51
51
  },
52
52
  )
53
- errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2], level1/level2/level3:[(code3) message3]>"
53
+ expect(errors.inspect).to eq("#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2], level1/level2/level3:[(code3) message3]>")
54
54
  end
55
55
  end
56
56
 
@@ -67,7 +67,7 @@ describe Braintree::Errors do
67
67
  }
68
68
  },
69
69
  )
70
- errors.map { |e| e.code }.sort.should == %w[1 2 3]
70
+ expect(errors.map { |e| e.code }.sort).to eq(%w[1 2 3])
71
71
  end
72
72
  end
73
73
 
@@ -76,7 +76,7 @@ describe Braintree::Errors do
76
76
  errors = Braintree::Errors.new(
77
77
  :level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]},
78
78
  )
79
- errors.size.should == 1
79
+ expect(errors.size).to eq(1)
80
80
  end
81
81
 
82
82
  it "returns the total number of validation errors in the hierarchy" do
@@ -91,7 +91,7 @@ describe Braintree::Errors do
91
91
  }
92
92
  },
93
93
  )
94
- errors.size.should == 3
94
+ expect(errors.size).to eq(3)
95
95
  end
96
96
  end
97
97
  end
@@ -15,7 +15,7 @@ END
15
15
  [Braintree] <last-name>Doe</last-name>
16
16
  [Braintree] </customer>
17
17
  END
18
- Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).should == expected_xml
18
+ expect(Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml)).to eq(expected_xml)
19
19
  end
20
20
 
21
21
  it "sanitizes credit card number and cvv" do
@@ -38,7 +38,7 @@ END
38
38
  [Braintree] <encrypted-card-data>***</encrypted-card-data>
39
39
  [Braintree] </customer>
40
40
  END
41
- Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).should == expected_xml
41
+ expect(Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml)).to eq(expected_xml)
42
42
  end
43
43
 
44
44
  it "sanitizes credit card number and cvv with newlines" do
@@ -59,7 +59,7 @@ END
59
59
  [Braintree] <cvv>***</cvv>
60
60
  [Braintree] </customer>
61
61
  END
62
- Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).should == expected_xml
62
+ expect(Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml)).to eq(expected_xml)
63
63
  end
64
64
  end
65
65
 
@@ -80,7 +80,7 @@ END
80
80
  :start => nil,
81
81
  )
82
82
 
83
- Net::HTTP.should_receive(:new).with(nil, nil, "localhost", 8080, "user", "test").and_return(net_http_instance)
83
+ expect(Net::HTTP).to receive(:new).with(nil, nil, "localhost", 8080, "user", "test").and_return(net_http_instance)
84
84
 
85
85
  http._http_do("GET", "/plans")
86
86
  end
@@ -99,7 +99,7 @@ END
99
99
  :start => nil,
100
100
  )
101
101
 
102
- Net::HTTP.should_receive(:new).with(nil, nil, "localhost", 8080, nil, nil).and_return(net_http_instance)
102
+ expect(Net::HTTP).to receive(:new).with(nil, nil, "localhost", 8080, nil, nil).and_return(net_http_instance)
103
103
 
104
104
  http._http_do("GET", "/plans")
105
105
  end
@@ -114,7 +114,7 @@ END
114
114
  :start => nil,
115
115
  )
116
116
 
117
- Net::HTTP.should_receive(:new).with(nil, nil).and_return(net_http_instance)
117
+ expect(Net::HTTP).to receive(:new).with(nil, nil).and_return(net_http_instance)
118
118
 
119
119
  http._http_do("GET", "/plans")
120
120
  end
@@ -185,13 +185,13 @@ END
185
185
 
186
186
  describe "_build_query_string" do
187
187
  it "returns an empty string for empty query params" do
188
- Braintree::Http.new(:config)._build_query_string({}).should == ""
188
+ expect(Braintree::Http.new(:config)._build_query_string({})).to eq("")
189
189
  end
190
190
 
191
191
  it "returns a proper query string for non-nested hashes" do
192
192
  query_params = {:one => 1, :two => 2}
193
193
 
194
- Braintree::Http.new(:config)._build_query_string(query_params).should =~ /^\?(one=1&two=2|two=2&one=1)$/
194
+ expect(Braintree::Http.new(:config)._build_query_string(query_params)).to match(/^\?(one=1&two=2|two=2&one=1)$/)
195
195
  end
196
196
 
197
197
  it "raises ArgumentError for nested hashes" do
@@ -24,13 +24,13 @@ describe Braintree::LocalPaymentCompleted do
24
24
  }
25
25
  local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
26
26
 
27
- local_payment_completed.payment_id.should eq("a-payment-id")
28
- local_payment_completed.payer_id.should eq("a-payer-id")
29
- local_payment_completed.payment_method_nonce.should eq("a-nonce")
30
- local_payment_completed.transaction.id.should eq("a-transaction-id")
31
- local_payment_completed.transaction.amount.should eq(31.0)
32
- local_payment_completed.transaction.order_id.should eq("an-order-id")
33
- local_payment_completed.transaction.status.should eq(Braintree::Transaction::Status::Authorized)
27
+ expect(local_payment_completed.payment_id).to eq("a-payment-id")
28
+ expect(local_payment_completed.payer_id).to eq("a-payer-id")
29
+ expect(local_payment_completed.payment_method_nonce).to eq("a-nonce")
30
+ expect(local_payment_completed.transaction.id).to eq("a-transaction-id")
31
+ expect(local_payment_completed.transaction.amount).to eq(31.0)
32
+ expect(local_payment_completed.transaction.order_id).to eq("an-order-id")
33
+ expect(local_payment_completed.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
34
34
  end
35
35
 
36
36
  it "initializes the object with the appropriate attributes set if no transaction is provided" do
@@ -41,10 +41,10 @@ describe Braintree::LocalPaymentCompleted do
41
41
  }
42
42
  local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
43
43
 
44
- local_payment_completed.payment_id.should eq("a-payment-id")
45
- local_payment_completed.payer_id.should eq("a-payer-id")
46
- local_payment_completed.payment_method_nonce.should eq("a-nonce")
47
- local_payment_completed.transaction.should be_nil
44
+ expect(local_payment_completed.payment_id).to eq("a-payment-id")
45
+ expect(local_payment_completed.payer_id).to eq("a-payer-id")
46
+ expect(local_payment_completed.payment_method_nonce).to eq("a-nonce")
47
+ expect(local_payment_completed.transaction).to be_nil
48
48
  end
49
49
  end
50
50
  end
@@ -17,8 +17,8 @@ describe Braintree::LocalPaymentExpired do
17
17
  }
18
18
  local_payment_expired = Braintree::LocalPaymentExpired._new(params)
19
19
 
20
- local_payment_expired.payment_id.should eq("a-payment-id")
21
- local_payment_expired.payment_context_id.should eq("a-payment-context-id")
20
+ expect(local_payment_expired.payment_id).to eq("a-payment-id")
21
+ expect(local_payment_expired.payment_context_id).to eq("a-payment-context-id")
22
22
  end
23
23
  end
24
24
  end
@@ -23,12 +23,12 @@ describe Braintree::LocalPaymentFunded do
23
23
  }
24
24
  local_payment_funded = Braintree::LocalPaymentFunded._new(params)
25
25
 
26
- local_payment_funded.payment_id.should eq("a-payment-id")
27
- local_payment_funded.payment_context_id.should eq("a-payment-context-id")
28
- local_payment_funded.transaction.id.should eq("a-transaction-id")
29
- local_payment_funded.transaction.amount.should eq(31.0)
30
- local_payment_funded.transaction.order_id.should eq("an-order-id")
31
- local_payment_funded.transaction.status.should eq(Braintree::Transaction::Status::Settled)
26
+ expect(local_payment_funded.payment_id).to eq("a-payment-id")
27
+ expect(local_payment_funded.payment_context_id).to eq("a-payment-context-id")
28
+ expect(local_payment_funded.transaction.id).to eq("a-transaction-id")
29
+ expect(local_payment_funded.transaction.amount).to eq(31.0)
30
+ expect(local_payment_funded.transaction.order_id).to eq("an-order-id")
31
+ expect(local_payment_funded.transaction.status).to eq(Braintree::Transaction::Status::Settled)
32
32
  end
33
33
  end
34
34
  end
@@ -5,7 +5,7 @@ describe Braintree::MerchantAccount do
5
5
  it "is a string representation of the merchant account" do
6
6
  account = Braintree::MerchantAccount._new(nil, :id => "merchant_account", :status => "active", :master_merchant_account => nil)
7
7
 
8
- account.inspect.should == "#<Braintree::MerchantAccount: id: \"merchant_account\", status: \"active\", master_merchant_account: nil>"
8
+ expect(account.inspect).to eq("#<Braintree::MerchantAccount: id: \"merchant_account\", status: \"active\", master_merchant_account: nil>")
9
9
  end
10
10
 
11
11
  it "handles a master merchant account" do
@@ -17,16 +17,16 @@ describe Braintree::MerchantAccount do
17
17
  )
18
18
 
19
19
  master_merchant_account = "#<Braintree::MerchantAccount: id: \"master_merchant_account\", status: \"active\", master_merchant_account: nil>"
20
- account.inspect.should == "#<Braintree::MerchantAccount: id: \"merchant_account\", status: \"active\", master_merchant_account: #{master_merchant_account}>"
20
+ expect(account.inspect).to eq("#<Braintree::MerchantAccount: id: \"merchant_account\", status: \"active\", master_merchant_account: #{master_merchant_account}>")
21
21
  end
22
22
  end
23
23
 
24
24
  describe "default?" do
25
25
  it "is an alias of default" do
26
26
  account = Braintree::MerchantAccount._new(nil, :default => false)
27
- account.default?.should == false
27
+ expect(account.default?).to eq(false)
28
28
  account = Braintree::MerchantAccount._new(nil, :default => true)
29
- account.default?.should == true
29
+ expect(account.default?).to eq(true)
30
30
  end
31
31
  end
32
32
  end
@@ -2,6 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
3
  describe Braintree::Modification do
4
4
  it "converts string amount" do
5
- Braintree::Modification._new(:amount => "100.00").amount.should == BigDecimal("100.00")
5
+ expect(Braintree::Modification._new(:amount => "100.00").amount).to eq(BigDecimal("100.00"))
6
6
  end
7
7
  end
@@ -34,12 +34,12 @@ describe Braintree::PaymentMethodCustomerDataUpdatedMetadata do
34
34
 
35
35
  payment_method_customer_data_updated = Braintree::PaymentMethodCustomerDataUpdatedMetadata._new(:gateway, params)
36
36
 
37
- payment_method_customer_data_updated.token.should eq("a-token")
38
- payment_method_customer_data_updated.datetime_updated.should eq("2022-01-01T21:28:37Z")
39
- payment_method_customer_data_updated.payment_method.should be_a(Braintree::VenmoAccount)
40
- payment_method_customer_data_updated.enriched_customer_data.profile_data.first_name.should eq("a-first-name")
41
- payment_method_customer_data_updated.enriched_customer_data.profile_data.last_name.should eq("a-last-name")
42
- payment_method_customer_data_updated.enriched_customer_data.fields_updated.should eq(["username"])
37
+ expect(payment_method_customer_data_updated.token).to eq("a-token")
38
+ expect(payment_method_customer_data_updated.datetime_updated).to eq("2022-01-01T21:28:37Z")
39
+ expect(payment_method_customer_data_updated.payment_method).to be_a(Braintree::VenmoAccount)
40
+ expect(payment_method_customer_data_updated.enriched_customer_data.profile_data.first_name).to eq("a-first-name")
41
+ expect(payment_method_customer_data_updated.enriched_customer_data.profile_data.last_name).to eq("a-last-name")
42
+ expect(payment_method_customer_data_updated.enriched_customer_data.fields_updated).to eq(["username"])
43
43
  end
44
44
  end
45
45
  end
@@ -14,18 +14,18 @@ describe Braintree::PaymentMethodNonceDetailsPayerInfo do
14
14
 
15
15
  describe "#initialize" do
16
16
  it "sets attributes" do
17
- payment_method_nonce_details_payer_info.billing_agreement_id.should == "billing-agreement-id"
18
- payment_method_nonce_details_payer_info.country_code.should == "US"
19
- payment_method_nonce_details_payer_info.email.should == "test@example.com"
20
- payment_method_nonce_details_payer_info.first_name.should == "First"
21
- payment_method_nonce_details_payer_info.last_name.should == "Last"
22
- payment_method_nonce_details_payer_info.payer_id.should == "payer-id"
17
+ expect(payment_method_nonce_details_payer_info.billing_agreement_id).to eq("billing-agreement-id")
18
+ expect(payment_method_nonce_details_payer_info.country_code).to eq("US")
19
+ expect(payment_method_nonce_details_payer_info.email).to eq("test@example.com")
20
+ expect(payment_method_nonce_details_payer_info.first_name).to eq("First")
21
+ expect(payment_method_nonce_details_payer_info.last_name).to eq("Last")
22
+ expect(payment_method_nonce_details_payer_info.payer_id).to eq("payer-id")
23
23
  end
24
24
  end
25
25
 
26
26
  describe "inspect" do
27
27
  it "prints the attributes" do
28
- payment_method_nonce_details_payer_info.inspect.should == %(#<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: \"billing-agreement-id\", country_code: \"US\", email: \"test@example.com\", first_name: \"First\", last_name: \"Last\", payer_id: \"payer-id\">)
28
+ expect(payment_method_nonce_details_payer_info.inspect).to eq(%(#<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: \"billing-agreement-id\", country_code: \"US\", email: \"test@example.com\", first_name: \"First\", last_name: \"Last\", payer_id: \"payer-id\">))
29
29
  end
30
30
  end
31
31
  end