braintree 4.14.0 → 4.15.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -22,30 +22,30 @@ describe Braintree::PaymentMethodNonceDetails do
22
22
 
23
23
  describe "#initialize" do
24
24
  it "sets attributes" do
25
- payment_method_nonce_details.bin.should == "bin"
26
- payment_method_nonce_details.card_type.should == "American Express"
27
- payment_method_nonce_details.expiration_month.should == "12"
28
- payment_method_nonce_details.expiration_year.should == "2025"
29
- payment_method_nonce_details.is_network_tokenized.should == true
30
- payment_method_nonce_details.last_two.should == "11"
31
- payment_method_nonce_details.payer_info.billing_agreement_id.should == "1234"
32
- payment_method_nonce_details.payer_info.country_code.should == "US"
33
- payment_method_nonce_details.sepa_direct_debit_account_nonce_details.bank_reference_token.should == "a-bank-reference-token"
34
- payment_method_nonce_details.sepa_direct_debit_account_nonce_details.last_4.should == "abcd"
35
- payment_method_nonce_details.sepa_direct_debit_account_nonce_details.mandate_type.should == "ONE_OFF"
36
- payment_method_nonce_details.sepa_direct_debit_account_nonce_details.merchant_or_partner_customer_id.should == "a-mp-customer-id"
25
+ expect(payment_method_nonce_details.bin).to eq("bin")
26
+ expect(payment_method_nonce_details.card_type).to eq("American Express")
27
+ expect(payment_method_nonce_details.expiration_month).to eq("12")
28
+ expect(payment_method_nonce_details.expiration_year).to eq("2025")
29
+ expect(payment_method_nonce_details.is_network_tokenized).to eq(true)
30
+ expect(payment_method_nonce_details.last_two).to eq("11")
31
+ expect(payment_method_nonce_details.payer_info.billing_agreement_id).to eq("1234")
32
+ expect(payment_method_nonce_details.payer_info.country_code).to eq("US")
33
+ expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.bank_reference_token).to eq("a-bank-reference-token")
34
+ expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.last_4).to eq("abcd")
35
+ expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.mandate_type).to eq("ONE_OFF")
36
+ expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.merchant_or_partner_customer_id).to eq("a-mp-customer-id")
37
37
  end
38
38
  end
39
39
 
40
40
  describe "inspect" do
41
41
  it "prints the attributes" do
42
- payment_method_nonce_details.inspect.should == %(#<PaymentMethodNonceDetails bin: "bin", card_type: "American Express", expiration_month: "12", expiration_year: "2025", is_network_tokenized: true, last_two: "11", payer_info: #<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: "1234", country_code: "US", email: nil, first_name: nil, last_name: nil, payer_id: nil>, sepa_direct_debit_account_nonce_details: #<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">>)
42
+ expect(payment_method_nonce_details.inspect).to eq(%(#<PaymentMethodNonceDetails bin: "bin", card_type: "American Express", expiration_month: "12", expiration_year: "2025", is_network_tokenized: true, last_two: "11", payer_info: #<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: "1234", country_code: "US", email: nil, first_name: nil, last_name: nil, payer_id: nil>, sepa_direct_debit_account_nonce_details: #<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">>))
43
43
  end
44
44
  end
45
45
 
46
46
  describe "is_network_tokenized" do
47
47
  it "is aliased to is_network_tokenized?" do
48
- payment_method_nonce_details.is_network_tokenized?.should == true
48
+ expect(payment_method_nonce_details.is_network_tokenized?).to eq(true)
49
49
  end
50
50
  end
51
51
  end
@@ -5,11 +5,11 @@ describe Braintree::PaymentMethod do
5
5
  it "handles an unknown payment method type" do
6
6
  unknown_response = {:unknown_payment_method => {:token => 1234, :default => true}}
7
7
  http_instance = double(:get => unknown_response)
8
- Braintree::Http.stub(:new).and_return(http_instance)
8
+ allow(Braintree::Http).to receive(:new).and_return(http_instance)
9
9
  unknown_payment_method = Braintree::PaymentMethod.find("UNKNOWN_PAYMENT_METHOD_TOKEN")
10
10
 
11
- unknown_payment_method.token.should == 1234
12
- unknown_payment_method.default?.should be(true)
11
+ expect(unknown_payment_method.token).to eq(1234)
12
+ expect(unknown_payment_method.default?).to be(true)
13
13
  end
14
14
  end
15
15
 
@@ -17,27 +17,27 @@ describe Braintree::PaymentMethod do
17
17
  it "handles an unknown payment method type" do
18
18
  unknown_response = {:unknown_payment_method => {:token => 1234, :default => true}}
19
19
  http_instance = double(:put => unknown_response)
20
- Braintree::Http.stub(:new).and_return(http_instance)
20
+ allow(Braintree::Http).to receive(:new).and_return(http_instance)
21
21
  result = Braintree::PaymentMethod.update(:unknown,
22
22
  {:options => {:make_default => true}})
23
23
 
24
- result.should be_success
25
- result.payment_method.token.should == 1234
26
- result.payment_method.should be_instance_of(Braintree::UnknownPaymentMethod)
24
+ expect(result).to be_success
25
+ expect(result.payment_method.token).to eq(1234)
26
+ expect(result.payment_method).to be_instance_of(Braintree::UnknownPaymentMethod)
27
27
  end
28
28
  end
29
29
 
30
30
  describe "delete" do
31
31
  let(:http_stub) { double("http_stub").as_null_object }
32
32
  it "accepts revoke_all_grants option with value true" do
33
- Braintree::Http.stub(:new).and_return http_stub
34
- http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=true")
33
+ allow(Braintree::Http).to receive(:new).and_return http_stub
34
+ expect(http_stub).to receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=true")
35
35
  Braintree::PaymentMethod.delete("some_token", {:revoke_all_grants => true})
36
36
  end
37
37
 
38
38
  it "accepts revoke_all_grants option with value false" do
39
- Braintree::Http.stub(:new).and_return http_stub
40
- http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=false")
39
+ allow(Braintree::Http).to receive(:new).and_return http_stub
40
+ expect(http_stub).to receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=false")
41
41
  Braintree::PaymentMethod.delete("some_token", {:revoke_all_grants => false})
42
42
  end
43
43
 
@@ -48,8 +48,8 @@ describe Braintree::PaymentMethod do
48
48
  end
49
49
 
50
50
  it "accepts just the token, revoke_all_grants is optional" do
51
- Braintree::Http.stub(:new).and_return http_stub
52
- http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token")
51
+ allow(Braintree::Http).to receive(:new).and_return http_stub
52
+ expect(http_stub).to receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token")
53
53
  Braintree::PaymentMethod.delete("some_token")
54
54
  end
55
55
  end
@@ -59,8 +59,8 @@ describe Braintree::PaymentMethod do
59
59
  now = Time.now
60
60
  paypal_account = Braintree::PayPalAccount._new(:gateway, :updated_at => now, :created_at => now)
61
61
 
62
- paypal_account.created_at.should == now
63
- paypal_account.updated_at.should == now
62
+ expect(paypal_account.created_at).to eq(now)
63
+ expect(paypal_account.updated_at).to eq(now)
64
64
  end
65
65
  end
66
66
 
@@ -84,21 +84,21 @@ describe Braintree::PaymentMethod do
84
84
  end
85
85
 
86
86
  it "does not raise an error if token does not respond to strip" do
87
- Braintree::Http.stub(:new).and_return double.as_null_object
87
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
88
88
  expect do
89
89
  Braintree::PaymentMethod.grant(8675309, :allow_vaulting => false)
90
90
  end.to_not raise_error
91
91
  end
92
92
 
93
93
  it "accepts all options as hash map" do
94
- Braintree::Http.stub(:new).and_return double.as_null_object
94
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
95
95
  expect do
96
96
  Braintree::PaymentMethod.grant("$dummyToken", :allow_vaulting => false, :include_billing_postal_code => true)
97
97
  end.to_not raise_error
98
98
  end
99
99
 
100
100
  it "accepts only token as parameter" do
101
- Braintree::Http.stub(:new).and_return double.as_null_object
101
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
102
102
  expect do
103
103
  Braintree::PaymentMethod.grant("$dummyToken")
104
104
  end.to_not raise_error
@@ -126,7 +126,7 @@ describe Braintree::PaymentMethod do
126
126
  end
127
127
 
128
128
  it "does not raise an error if token does not respond to strip" do
129
- Braintree::Http.stub(:new).and_return double.as_null_object
129
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
130
130
  expect do
131
131
  Braintree::PaymentMethod.revoke(8675309)
132
132
  end.to_not raise_error
@@ -24,11 +24,11 @@ describe Braintree::PayPalAccount do
24
24
 
25
25
  describe "default?" do
26
26
  it "is true if the paypal account is the default payment method for the customer" do
27
- Braintree::PayPalAccount._new(:gateway, :default => true).default?.should == true
27
+ expect(Braintree::PayPalAccount._new(:gateway, :default => true).default?).to eq(true)
28
28
  end
29
29
 
30
30
  it "is false if the paypal account is not the default payment methodfor the customer" do
31
- Braintree::PayPalAccount._new(:gateway, :default => false).default?.should == false
31
+ expect(Braintree::PayPalAccount._new(:gateway, :default => false).default?).to eq(false)
32
32
  end
33
33
  end
34
34
 
@@ -37,8 +37,8 @@ describe Braintree::PayPalAccount do
37
37
  now = Time.now
38
38
  paypal_account = Braintree::PayPalAccount._new(:gateway, :updated_at => now, :created_at => now)
39
39
 
40
- paypal_account.created_at.should == now
41
- paypal_account.updated_at.should == now
40
+ expect(paypal_account.created_at).to eq(now)
41
+ expect(paypal_account.updated_at).to eq(now)
42
42
  end
43
43
  end
44
44
  end
@@ -10,11 +10,11 @@ describe "Braintree::ResourceCollection" do
10
10
 
11
11
  count = 0
12
12
  collection.each_with_index do |item, index|
13
- item.should == values[index]
13
+ expect(item).to eq(values[index])
14
14
  count += 1
15
15
  end
16
16
 
17
- count.should == 5
17
+ expect(count).to eq(5)
18
18
  end
19
19
  end
20
20
 
@@ -25,7 +25,7 @@ describe "Braintree::ResourceCollection" do
25
25
  ids.map { |id| values[id] }
26
26
  end
27
27
 
28
- collection.first.should == nil
28
+ expect(collection.first).to eq(nil)
29
29
  end
30
30
 
31
31
  context "with results" do
@@ -38,11 +38,11 @@ describe "Braintree::ResourceCollection" do
38
38
  end
39
39
 
40
40
  it "returns the first occourence" do
41
- collection.first.should == "a"
41
+ expect(collection.first).to eq("a")
42
42
  end
43
43
 
44
44
  it "returns the first N occourences" do
45
- collection.first(4).should == ["a","b","c","d"]
45
+ expect(collection.first(4)).to eq(["a","b","c","d"])
46
46
  end
47
47
  end
48
48
  end
@@ -50,12 +50,12 @@ describe "Braintree::ResourceCollection" do
50
50
  describe "#ids" do
51
51
  it "returns a list of the resource collection ids" do
52
52
  collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2})
53
- collection.ids.should == [0,1,2,3,4]
53
+ expect(collection.ids).to eq([0,1,2,3,4])
54
54
  end
55
55
  end
56
56
 
57
57
  it "returns an empty array when the collection is empty" do
58
58
  collection = Braintree::ResourceCollection.new(:search_results => {:page_size => 2})
59
- collection.ids.should == []
59
+ expect(collection.ids).to eq([])
60
60
  end
61
61
  end
@@ -23,7 +23,7 @@ describe Braintree::SepaDirectDebitAccountNonceDetails do
23
23
 
24
24
  describe "inspect" do
25
25
  it "prints the attributes" do
26
- subject.inspect.should == %(#<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">)
26
+ expect(subject.inspect).to eq(%(#<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">))
27
27
  end
28
28
  end
29
29
  end
@@ -5,7 +5,7 @@ describe Braintree::SHA256Digest do
5
5
  it "returns the sha256 hmac of the input string (test case 6 from RFC 2202)" do
6
6
  key = "secret-key"
7
7
  message = "secret-message"
8
- Braintree::SHA256Digest.hexdigest(key, message).should == "68e7f2ecab71db67b1aca2a638f5122810315c3013f27c2196cd53e88709eecc"
8
+ expect(Braintree::SHA256Digest.hexdigest(key, message)).to eq("68e7f2ecab71db67b1aca2a638f5122810315c3013f27c2196cd53e88709eecc")
9
9
  end
10
10
  end
11
11
  end
@@ -11,13 +11,13 @@ describe Braintree::SignatureService do
11
11
  it "signs the data with its key" do
12
12
  service = Braintree::SignatureService.new("my_key", FakeDigest)
13
13
 
14
- service.sign(:foo => "foo bar").should == "foo=foo+bar_signed_with_my_key|foo=foo+bar"
14
+ expect(service.sign(:foo => "foo bar")).to eq("foo=foo+bar_signed_with_my_key|foo=foo+bar")
15
15
  end
16
16
  end
17
17
 
18
18
  describe "hash" do
19
19
  it "hashes the string with its key" do
20
- Braintree::SignatureService.new("my_key", FakeDigest).hash("foo").should == "foo_signed_with_my_key"
20
+ expect(Braintree::SignatureService.new("my_key", FakeDigest).hash("foo")).to eq("foo_signed_with_my_key")
21
21
  end
22
22
  end
23
23
  end
@@ -6,14 +6,14 @@ module Braintree
6
6
  it "allows Active, Canceled, Expired, and PastDue" do
7
7
  search = SubscriptionSearch.new
8
8
 
9
- lambda do
9
+ expect do
10
10
  search.status.in(
11
11
  Subscription::Status::Active,
12
12
  Subscription::Status::Canceled,
13
13
  Subscription::Status::Expired,
14
14
  Subscription::Status::PastDue,
15
15
  )
16
- end.should_not raise_error
16
+ end.not_to raise_error
17
17
  end
18
18
  end
19
19
 
@@ -22,14 +22,14 @@ module Braintree
22
22
  search = SubscriptionSearch.new
23
23
  search.in_trial_period.is true
24
24
 
25
- search.to_hash.should == {:in_trial_period => [true]}
25
+ expect(search.to_hash).to eq({:in_trial_period => [true]})
26
26
  end
27
27
 
28
28
  it "allows false" do
29
29
  search = SubscriptionSearch.new
30
30
  search.in_trial_period.is false
31
31
 
32
- search.to_hash.should == {:in_trial_period => [false]}
32
+ expect(search.to_hash).to eq({:in_trial_period => [false]})
33
33
  end
34
34
  end
35
35
 
@@ -38,14 +38,14 @@ module Braintree
38
38
  search = SubscriptionSearch.new
39
39
  search.days_past_due.is "30"
40
40
 
41
- search.to_hash.should == {:days_past_due => {:is => "30"}}
41
+ expect(search.to_hash).to eq({:days_past_due => {:is => "30"}})
42
42
  end
43
43
 
44
44
  it "coverts ints to strings" do
45
45
  search = SubscriptionSearch.new
46
46
  search.days_past_due.is 30
47
47
 
48
- search.to_hash.should == {:days_past_due => {:is => "30"}}
48
+ expect(search.to_hash).to eq({:days_past_due => {:is => "30"}})
49
49
  end
50
50
  end
51
51
 
@@ -54,7 +54,7 @@ module Braintree
54
54
  search = SubscriptionSearch.new
55
55
  search.merchant_account_id.in "ma_id1", "ma_id2"
56
56
 
57
- search.to_hash.should == {:merchant_account_id => ["ma_id1", "ma_id2"]}
57
+ expect(search.to_hash).to eq({:merchant_account_id => ["ma_id1", "ma_id2"]})
58
58
  end
59
59
  end
60
60
 
@@ -63,63 +63,63 @@ module Braintree
63
63
  search = SubscriptionSearch.new
64
64
  search.plan_id.starts_with "plan_"
65
65
 
66
- search.to_hash.should == {:plan_id => {:starts_with => "plan_"}}
66
+ expect(search.to_hash).to eq({:plan_id => {:starts_with => "plan_"}})
67
67
  end
68
68
 
69
69
  it "ends_with" do
70
70
  search = SubscriptionSearch.new
71
71
  search.plan_id.ends_with "_id"
72
72
 
73
- search.to_hash.should == {:plan_id => {:ends_with => "_id"}}
73
+ expect(search.to_hash).to eq({:plan_id => {:ends_with => "_id"}})
74
74
  end
75
75
 
76
76
  it "is" do
77
77
  search = SubscriptionSearch.new
78
78
  search.plan_id.is "p_id"
79
79
 
80
- search.to_hash.should == {:plan_id => {:is => "p_id"}}
80
+ expect(search.to_hash).to eq({:plan_id => {:is => "p_id"}})
81
81
  end
82
82
 
83
83
  it "is_not" do
84
84
  search = SubscriptionSearch.new
85
85
  search.plan_id.is_not "p_id"
86
86
 
87
- search.to_hash.should == {:plan_id => {:is_not => "p_id"}}
87
+ expect(search.to_hash).to eq({:plan_id => {:is_not => "p_id"}})
88
88
  end
89
89
 
90
90
  it "contains" do
91
91
  search = SubscriptionSearch.new
92
92
  search.plan_id.contains "p_id"
93
93
 
94
- search.to_hash.should == {:plan_id => {:contains => "p_id"}}
94
+ expect(search.to_hash).to eq({:plan_id => {:contains => "p_id"}})
95
95
  end
96
96
 
97
97
  it "in" do
98
98
  search = SubscriptionSearch.new
99
99
  search.plan_id.in ["plan1", "plan2"]
100
100
 
101
- search.to_hash.should == {:plan_id => ["plan1", "plan2"]}
101
+ expect(search.to_hash).to eq({:plan_id => ["plan1", "plan2"]})
102
102
  end
103
103
  end
104
104
 
105
105
  context "days_past_due" do
106
106
  it "is a range node" do
107
107
  search = SubscriptionSearch.new
108
- search.days_past_due.should be_kind_of(Braintree::AdvancedSearch::RangeNode)
108
+ expect(search.days_past_due).to be_kind_of(Braintree::AdvancedSearch::RangeNode)
109
109
  end
110
110
  end
111
111
 
112
112
  context "billing_cycles_remaining" do
113
113
  it "is a range node" do
114
114
  search = SubscriptionSearch.new
115
- search.billing_cycles_remaining.should be_kind_of(Braintree::AdvancedSearch::RangeNode)
115
+ expect(search.billing_cycles_remaining).to be_kind_of(Braintree::AdvancedSearch::RangeNode)
116
116
  end
117
117
  end
118
118
 
119
119
  context "created_at" do
120
120
  it "is a range node" do
121
121
  search = SubscriptionSearch.new
122
- search.created_at.should be_kind_of(Braintree::AdvancedSearch::RangeNode)
122
+ expect(search.created_at).to be_kind_of(Braintree::AdvancedSearch::RangeNode)
123
123
  end
124
124
  end
125
125
 
@@ -128,7 +128,7 @@ module Braintree
128
128
  search = SubscriptionSearch.new
129
129
  search.id.is "s_id"
130
130
 
131
- search.to_hash.should == {:id => {:is => "s_id"}}
131
+ expect(search.to_hash).to eq({:id => {:is => "s_id"}})
132
132
  end
133
133
  end
134
134
  end
@@ -11,8 +11,8 @@ describe Braintree::Subscription do
11
11
 
12
12
  context "price" do
13
13
  it "accepts price as either a String or a BigDecimal" do
14
- Braintree::Subscription._new(:gateway, default_params.merge(:price => "12.34")).price.should == BigDecimal("12.34")
15
- Braintree::Subscription._new(:gateway, default_params.merge(:price => BigDecimal("12.34"))).price.should == BigDecimal("12.34")
14
+ expect(Braintree::Subscription._new(:gateway, default_params.merge(:price => "12.34")).price).to eq(BigDecimal("12.34"))
15
+ expect(Braintree::Subscription._new(:gateway, default_params.merge(:price => BigDecimal("12.34"))).price).to eq(BigDecimal("12.34"))
16
16
  end
17
17
 
18
18
  it "blows up if price is not a string or BigDecimal" do
@@ -42,7 +42,7 @@ describe Braintree::Subscription do
42
42
  end
43
43
 
44
44
  it "does not raise an error if subscription id does not respond to strip" do
45
- Braintree::Http.stub(:new).and_return double(:get => {:subscription => default_params})
45
+ allow(Braintree::Http).to receive(:new).and_return double(:get => {:subscription => default_params})
46
46
  expect do
47
47
  Braintree::Subscription.find(8675309)
48
48
  end.to_not raise_error
@@ -51,11 +51,11 @@ describe Braintree::Subscription do
51
51
 
52
52
  describe "self.search" do
53
53
  it "only allows specified values for status" do
54
- lambda do
54
+ expect do
55
55
  Braintree::Subscription.search do |search|
56
56
  search.status.in "Hammer"
57
57
  end
58
- end.should raise_error(ArgumentError)
58
+ end.to raise_error(ArgumentError)
59
59
  end
60
60
  end
61
61
 
@@ -63,18 +63,18 @@ describe Braintree::Subscription do
63
63
  it "returns true for subscriptions with the same id" do
64
64
  subscription1 = Braintree::Subscription._new(:gateway, default_params.merge(:id => "123"))
65
65
  subscription2 = Braintree::Subscription._new(:gateway, default_params.merge(:id => "123"))
66
- subscription1.should == subscription2
66
+ expect(subscription1).to eq(subscription2)
67
67
  end
68
68
 
69
69
  it "returns false for subscriptions with different ids" do
70
70
  subscription1 = Braintree::Subscription._new(:gateway, default_params.merge(:id => "123"))
71
71
  subscription2 = Braintree::Subscription._new(:gateway, default_params.merge(:id => "not_123"))
72
- subscription1.should_not == subscription2
72
+ expect(subscription1).not_to eq(subscription2)
73
73
  end
74
74
 
75
75
  it "returns false if not comparing to a subscription" do
76
76
  subscription = Braintree::Subscription._new(:gateway, default_params.merge(:id => "123"))
77
- subscription.should_not == "not a subscription"
77
+ expect(subscription).not_to eq("not a subscription")
78
78
  end
79
79
  end
80
80
  end
@@ -7,21 +7,21 @@ describe Braintree::SuccessfulResult do
7
7
  :transaction => "transaction_value",
8
8
  :credit_card => "credit_card_value",
9
9
  )
10
- result.success?.should == true
11
- result.transaction.should == "transaction_value"
12
- result.credit_card.should == "credit_card_value"
10
+ expect(result.success?).to eq(true)
11
+ expect(result.transaction).to eq("transaction_value")
12
+ expect(result.credit_card).to eq("credit_card_value")
13
13
  end
14
14
 
15
15
  it "can be initialized without any values" do
16
16
  result = Braintree::SuccessfulResult.new
17
- result.success?.should == true
17
+ expect(result.success?).to eq(true)
18
18
  end
19
19
  end
20
20
 
21
21
  describe "inspect" do
22
22
  it "is pretty" do
23
23
  result = Braintree::SuccessfulResult.new(:transaction => "transaction_value")
24
- result.inspect.should == "#<Braintree::SuccessfulResult transaction:\"transaction_value\">"
24
+ expect(result.inspect).to eq("#<Braintree::SuccessfulResult transaction:\"transaction_value\">")
25
25
  end
26
26
  end
27
27
  end
@@ -29,41 +29,41 @@ describe Braintree::ThreeDSecureInfo do
29
29
 
30
30
  describe "#initialize" do
31
31
  it "sets attributes" do
32
- three_d_secure_info.acs_transaction_id.should == "acs_id"
33
- three_d_secure_info.cavv.should == "cavvvalue"
34
- three_d_secure_info.ds_transaction_id.should == "dstrxid"
35
- three_d_secure_info.eci_flag.should == "06"
36
- three_d_secure_info.enrolled.should == "Y"
37
- three_d_secure_info.liability_shift_possible.should == true
38
- three_d_secure_info.liability_shifted.should == true
39
- three_d_secure_info.pares_status.should == "Y"
40
- three_d_secure_info.status.should == "authenticate_successful"
41
- three_d_secure_info.three_d_secure_authentication_id.should == "auth_id"
42
- three_d_secure_info.three_d_secure_transaction_id.should == "trans_id"
43
- three_d_secure_info.three_d_secure_version.should == "1.0.2"
44
- three_d_secure_info.xid.should == "xidvalue"
45
- three_d_secure_info.lookup[:trans_status].should == "lookupstatus"
46
- three_d_secure_info.lookup[:trans_status_reason].should == "lookupstatusreason"
47
- three_d_secure_info.authentication[:trans_status].should == "authstatus"
48
- three_d_secure_info.authentication[:trans_status_reason].should == "authstatusreason"
32
+ expect(three_d_secure_info.acs_transaction_id).to eq("acs_id")
33
+ expect(three_d_secure_info.cavv).to eq("cavvvalue")
34
+ expect(three_d_secure_info.ds_transaction_id).to eq("dstrxid")
35
+ expect(three_d_secure_info.eci_flag).to eq("06")
36
+ expect(three_d_secure_info.enrolled).to eq("Y")
37
+ expect(three_d_secure_info.liability_shift_possible).to eq(true)
38
+ expect(three_d_secure_info.liability_shifted).to eq(true)
39
+ expect(three_d_secure_info.pares_status).to eq("Y")
40
+ expect(three_d_secure_info.status).to eq("authenticate_successful")
41
+ expect(three_d_secure_info.three_d_secure_authentication_id).to eq("auth_id")
42
+ expect(three_d_secure_info.three_d_secure_transaction_id).to eq("trans_id")
43
+ expect(three_d_secure_info.three_d_secure_version).to eq("1.0.2")
44
+ expect(three_d_secure_info.xid).to eq("xidvalue")
45
+ expect(three_d_secure_info.lookup[:trans_status]).to eq("lookupstatus")
46
+ expect(three_d_secure_info.lookup[:trans_status_reason]).to eq("lookupstatusreason")
47
+ expect(three_d_secure_info.authentication[:trans_status]).to eq("authstatus")
48
+ expect(three_d_secure_info.authentication[:trans_status_reason]).to eq("authstatusreason")
49
49
  end
50
50
  end
51
51
 
52
52
  describe "inspect" do
53
53
  it "prints the attributes" do
54
- three_d_secure_info.inspect.should == %(#<ThreeDSecureInfo acs_transaction_id: "acs_id", authentication: {:trans_status=>"authstatus", :trans_status_reason=>"authstatusreason"}, cavv: "cavvvalue", ds_transaction_id: "dstrxid", eci_flag: "06", enrolled: "Y", liability_shift_possible: true, liability_shifted: true, lookup: {:trans_status=>"lookupstatus", :trans_status_reason=>"lookupstatusreason"}, pares_status: "Y", status: "authenticate_successful", three_d_secure_authentication_id: "auth_id", three_d_secure_transaction_id: "trans_id", three_d_secure_version: "1.0.2", xid: "xidvalue">)
54
+ expect(three_d_secure_info.inspect).to eq(%(#<ThreeDSecureInfo acs_transaction_id: "acs_id", authentication: {:trans_status=>"authstatus", :trans_status_reason=>"authstatusreason"}, cavv: "cavvvalue", ds_transaction_id: "dstrxid", eci_flag: "06", enrolled: "Y", liability_shift_possible: true, liability_shifted: true, lookup: {:trans_status=>"lookupstatus", :trans_status_reason=>"lookupstatusreason"}, pares_status: "Y", status: "authenticate_successful", three_d_secure_authentication_id: "auth_id", three_d_secure_transaction_id: "trans_id", three_d_secure_version: "1.0.2", xid: "xidvalue">))
55
55
  end
56
56
  end
57
57
 
58
58
  describe "liability_shifted" do
59
59
  it "is aliased to liability_shifted?" do
60
- three_d_secure_info.liability_shifted?.should == true
60
+ expect(three_d_secure_info.liability_shifted?).to eq(true)
61
61
  end
62
62
  end
63
63
 
64
64
  describe "liability_shift_possible" do
65
65
  it "is aliased to liability_shift_possible?" do
66
- three_d_secure_info.liability_shift_possible?.should == true
66
+ expect(three_d_secure_info.liability_shift_possible?).to eq(true)
67
67
  end
68
68
  end
69
69
  end
@@ -7,7 +7,7 @@ describe Braintree::Transaction::CreditCardDetails do
7
7
  :expiration_month => "08",
8
8
  :expiration_year => "2009",
9
9
  )
10
- details.expiration_date.should == "08/2009"
10
+ expect(details.expiration_date).to eq("08/2009")
11
11
  end
12
12
  end
13
13
 
@@ -34,7 +34,7 @@ describe Braintree::Transaction::CreditCardDetails do
34
34
  :image_url => "example.com/visa.png",
35
35
  :unique_number_identifier => "abc123",
36
36
  )
37
- details.inspect.should == %(#<token: "token", bin: "123456", last_4: "6789", card_type: "Visa", expiration_date: "05/2012", cardholder_name: "The Cardholder", customer_location: "US", prepaid: "Yes", healthcare: "No", durbin_regulated: "No", debit: "Yes", commercial: "Unknown", payroll: "Unknown", product_id: "Unknown", country_of_issuance: "Lilliput", issuing_bank: "Gulliver Bank", image_url: "example.com/visa.png", unique_number_identifier: "abc123">)
37
+ expect(details.inspect).to eq(%(#<token: "token", bin: "123456", last_4: "6789", card_type: "Visa", expiration_date: "05/2012", cardholder_name: "The Cardholder", customer_location: "US", prepaid: "Yes", healthcare: "No", durbin_regulated: "No", debit: "Yes", commercial: "Unknown", payroll: "Unknown", product_id: "Unknown", country_of_issuance: "Lilliput", issuing_bank: "Gulliver Bank", image_url: "example.com/visa.png", unique_number_identifier: "abc123">))
38
38
  end
39
39
  end
40
40
 
@@ -43,7 +43,7 @@ describe Braintree::Transaction::CreditCardDetails do
43
43
  details = Braintree::Transaction::CreditCardDetails.new(
44
44
  :bin => "510510", :last_4 => "5100",
45
45
  )
46
- details.masked_number.should == "510510******5100"
46
+ expect(details.masked_number).to eq("510510******5100")
47
47
  end
48
48
  end
49
49
 
@@ -52,14 +52,14 @@ describe Braintree::Transaction::CreditCardDetails do
52
52
  details = Braintree::Transaction::CreditCardDetails.new(
53
53
  :is_network_tokenized => true,
54
54
  )
55
- details.is_network_tokenized?.should == true
55
+ expect(details.is_network_tokenized?).to eq(true)
56
56
  end
57
57
 
58
58
  it "returns false if is_network_tokenized is false" do
59
59
  details = Braintree::Transaction::CreditCardDetails.new(
60
60
  :is_network_tokenized => false,
61
61
  )
62
- details.is_network_tokenized?.should == false
62
+ expect(details.is_network_tokenized?).to eq(false)
63
63
  end
64
64
  end
65
65
  end
@@ -13,7 +13,7 @@ describe Braintree::Transaction::CustomerDetails do
13
13
  :phone => "6145551234",
14
14
  :fax => "3125551234",
15
15
  )
16
- details.inspect.should == %(#<id: "id", first_name: "Amy", last_name: "Smith", email: "amy.smith@example.com", company: "Smith Co.", website: "http://www.example.com", phone: "6145551234", fax: "3125551234">)
16
+ expect(details.inspect).to eq(%(#<id: "id", first_name: "Amy", last_name: "Smith", email: "amy.smith@example.com", company: "Smith Co.", website: "http://www.example.com", phone: "6145551234", fax: "3125551234">))
17
17
  end
18
18
  end
19
19
  end
@@ -6,13 +6,13 @@ describe Braintree::Transaction::DisbursementDetails do
6
6
  details = Braintree::Transaction::DisbursementDetails.new(
7
7
  :disbursement_date => Date.new(2013, 4, 1).to_s,
8
8
  )
9
- details.valid?.should == true
9
+ expect(details.valid?).to eq(true)
10
10
  end
11
11
  it "returns true if disbursement details are initialized" do
12
12
  details = Braintree::Transaction::DisbursementDetails.new(
13
13
  :disbursement_date => nil,
14
14
  )
15
- details.valid?.should == false
15
+ expect(details.valid?).to eq(false)
16
16
  end
17
17
  end
18
18
  end