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.
- checksums.yaml +4 -4
- data/lib/braintree/credit_card.rb +13 -0
- data/lib/braintree/credit_card_gateway.rb +15 -3
- data/lib/braintree/payment_method_gateway.rb +15 -3
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/transaction/credit_card_details.rb +3 -0
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction.rb +5 -4
- data/lib/braintree/transaction_gateway.rb +15 -3
- data/lib/braintree/transaction_search.rb +6 -5
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +1 -0
- data/lib/braintree/webhook_testing_gateway.rb +17 -0
- data/spec/integration/braintree/add_on_spec.rb +9 -9
- data/spec/integration/braintree/address_spec.rb +69 -69
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +8 -8
- data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
- data/spec/integration/braintree/credit_card_spec.rb +223 -223
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +313 -313
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_spec.rb +87 -87
- data/spec/integration/braintree/document_upload_spec.rb +17 -17
- data/spec/integration/braintree/error_codes_spec.rb +2 -2
- data/spec/integration/braintree/http_spec.rb +28 -28
- data/spec/integration/braintree/merchant_account_spec.rb +127 -127
- data/spec/integration/braintree/merchant_spec.rb +103 -103
- data/spec/integration/braintree/oauth_spec.rb +61 -61
- data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
- data/spec/integration/braintree/payment_method_spec.rb +389 -389
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
- data/spec/integration/braintree/paypal_account_spec.rb +38 -38
- data/spec/integration/braintree/plan_spec.rb +15 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
- data/spec/integration/braintree/subscription_spec.rb +364 -364
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +19 -19
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
- data/spec/integration/braintree/transaction_search_spec.rb +198 -165
- data/spec/integration/braintree/transaction_spec.rb +1315 -1149
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
- data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
- data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/braintree/address_spec.rb +8 -8
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +57 -57
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +31 -29
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
- data/spec/unit/braintree/customer_spec.rb +41 -40
- data/spec/unit/braintree/digest_spec.rb +5 -5
- data/spec/unit/braintree/disbursement_spec.rb +11 -11
- data/spec/unit/braintree/dispute_search_spec.rb +2 -2
- data/spec/unit/braintree/dispute_spec.rb +56 -56
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +9 -9
- data/spec/unit/braintree/http_spec.rb +8 -8
- data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
- data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
- data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
- data/spec/unit/braintree/merchant_account_spec.rb +4 -4
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
- data/spec/unit/braintree/payment_method_spec.rb +19 -19
- data/spec/unit/braintree/paypal_account_spec.rb +4 -4
- data/spec/unit/braintree/resource_collection_spec.rb +7 -7
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
- data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +17 -17
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +5 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
- data/spec/unit/braintree/transaction_search_spec.rb +2 -2
- data/spec/unit/braintree/transaction_spec.rb +101 -93
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
- data/spec/unit/braintree/util_spec.rb +27 -27
- data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
- data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +8 -8
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +17 -17
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +3 -2
|
@@ -6,18 +6,18 @@ describe Braintree::Util do
|
|
|
6
6
|
original = {"a" => "b", "c" => "d"}
|
|
7
7
|
new = Braintree::Util.symbolize_keys(original)
|
|
8
8
|
|
|
9
|
-
original["a"].
|
|
10
|
-
new[:a].
|
|
9
|
+
expect(original["a"]).to eq("b")
|
|
10
|
+
expect(new[:a]).to eq("b")
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it "symbolizes nested keys" do
|
|
14
14
|
hash = {"a" => {"b" => {"c" => "d"}}}
|
|
15
|
-
Braintree::Util.symbolize_keys(hash).
|
|
15
|
+
expect(Braintree::Util.symbolize_keys(hash)).to eq({:a => {:b => {:c => "d"}}})
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "symbolizes nested keys in arrays" do
|
|
19
19
|
hash = {"a" => ["b" => {"c" => "d"}]}
|
|
20
|
-
Braintree::Util.symbolize_keys(hash).
|
|
20
|
+
expect(Braintree::Util.symbolize_keys(hash)).to eq({:a => [:b => {:c => "d"}]})
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -173,41 +173,41 @@ describe Braintree::Util do
|
|
|
173
173
|
|
|
174
174
|
describe "self.replace_key" do
|
|
175
175
|
it "replaces the target key with the replacement key" do
|
|
176
|
-
Braintree::Util.replace_key(
|
|
176
|
+
expect(Braintree::Util.replace_key(
|
|
177
177
|
{:a => {:b => "some value"}},
|
|
178
178
|
:b,
|
|
179
|
-
:c).
|
|
179
|
+
:c)).to eq({:a => {:c => "some value"}})
|
|
180
180
|
end
|
|
181
181
|
|
|
182
182
|
it "returns hash with all of the original keys if the target key does not exist" do
|
|
183
|
-
Braintree::Util.replace_key(
|
|
183
|
+
expect(Braintree::Util.replace_key(
|
|
184
184
|
{:some_key => "some value"},
|
|
185
185
|
:not_found,
|
|
186
|
-
:new_key).
|
|
186
|
+
:new_key)).to eq({:some_key => "some value"})
|
|
187
187
|
end
|
|
188
188
|
end
|
|
189
189
|
|
|
190
190
|
describe "self._flatten_hash_keys" do
|
|
191
191
|
it "flattens hash keys" do
|
|
192
|
-
Braintree::Util._flatten_hash_keys(:nested => {
|
|
192
|
+
expect(Braintree::Util._flatten_hash_keys(:nested => {
|
|
193
193
|
:nested_allowed => "ok",
|
|
194
194
|
:nested_allowed2 => "also ok",
|
|
195
195
|
:nested_invalid => "bad"
|
|
196
|
-
}).
|
|
196
|
+
})).to eq(["nested[nested_allowed2]", "nested[nested_allowed]", "nested[nested_invalid]"])
|
|
197
197
|
end
|
|
198
198
|
end
|
|
199
199
|
|
|
200
200
|
describe "self._flatten_valid_keys" do
|
|
201
201
|
it "flattens hash keys" do
|
|
202
|
-
Braintree::Util._flatten_valid_keys(
|
|
202
|
+
expect(Braintree::Util._flatten_valid_keys(
|
|
203
203
|
[:top_level, {:nested => [:nested_allowed, :nested_allowed2]}],
|
|
204
|
-
).
|
|
204
|
+
)).to eq(["nested[nested_allowed2]", "nested[nested_allowed]", "top_level"])
|
|
205
205
|
end
|
|
206
206
|
|
|
207
207
|
it "allows wildcards with the :_any_key_ symbol" do
|
|
208
|
-
Braintree::Util._flatten_valid_keys(
|
|
208
|
+
expect(Braintree::Util._flatten_valid_keys(
|
|
209
209
|
[:top_level, {:nested => :_any_key_}],
|
|
210
|
-
).
|
|
210
|
+
)).to eq(["nested[_any_key_]", "top_level"])
|
|
211
211
|
end
|
|
212
212
|
end
|
|
213
213
|
|
|
@@ -215,25 +215,25 @@ describe Braintree::Util do
|
|
|
215
215
|
it "deletes the attribute from the hash" do
|
|
216
216
|
hash = {:foo => ["x"], :bar => :baz}
|
|
217
217
|
Braintree::Util.extract_attribute_as_array(hash, :foo)
|
|
218
|
-
hash.
|
|
218
|
+
expect(hash).to eq({:bar => :baz})
|
|
219
219
|
end
|
|
220
220
|
|
|
221
221
|
it "puts the attribute in an array if it's not an array" do
|
|
222
222
|
hash = {:foo => "x", :bar => :baz}
|
|
223
223
|
result = Braintree::Util.extract_attribute_as_array(hash, :foo)
|
|
224
|
-
result.
|
|
224
|
+
expect(result).to eq(["x"])
|
|
225
225
|
end
|
|
226
226
|
|
|
227
227
|
it "returns the value if it's already an array" do
|
|
228
228
|
hash = {:foo => ["one", "two"], :bar => :baz}
|
|
229
229
|
result = Braintree::Util.extract_attribute_as_array(hash, :foo)
|
|
230
|
-
result.
|
|
230
|
+
expect(result).to eq(["one", "two"])
|
|
231
231
|
end
|
|
232
232
|
|
|
233
233
|
it "returns empty array if the attribute is not in the hash" do
|
|
234
234
|
hash = {:foo => ["one", "two"], :bar => :baz}
|
|
235
235
|
result = Braintree::Util.extract_attribute_as_array(hash, :quz)
|
|
236
|
-
result.
|
|
236
|
+
expect(result).to eq([])
|
|
237
237
|
end
|
|
238
238
|
|
|
239
239
|
it "raises an UnexpectedError if nil data is provided" do
|
|
@@ -246,24 +246,24 @@ describe Braintree::Util do
|
|
|
246
246
|
describe "self.hash_to_query_string" do
|
|
247
247
|
it "generates a query string from the hash" do
|
|
248
248
|
hash = {:foo => {:key_one => "value_one", :key_two => "value_two"}}
|
|
249
|
-
Braintree::Util.hash_to_query_string(hash).
|
|
249
|
+
expect(Braintree::Util.hash_to_query_string(hash)).to eq("foo%5Bkey_one%5D=value_one&foo%5Bkey_two%5D=value_two")
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
it "works for nesting 2 levels deep" do
|
|
253
253
|
hash = {:foo => {:nested => {:key_one => "value_one", :key_two => "value_two"}}}
|
|
254
|
-
Braintree::Util.hash_to_query_string(hash).
|
|
254
|
+
expect(Braintree::Util.hash_to_query_string(hash)).to eq("foo%5Bnested%5D%5Bkey_one%5D=value_one&foo%5Bnested%5D%5Bkey_two%5D=value_two")
|
|
255
255
|
end
|
|
256
256
|
end
|
|
257
257
|
|
|
258
258
|
describe "self.parse_query_string" do
|
|
259
259
|
it "parses the query string" do
|
|
260
260
|
query_string = "foo=bar%20baz&hash=a1b2c3"
|
|
261
|
-
Braintree::Util.parse_query_string(query_string).
|
|
261
|
+
expect(Braintree::Util.parse_query_string(query_string)).to eq({:foo => "bar baz", :hash => "a1b2c3"})
|
|
262
262
|
end
|
|
263
263
|
|
|
264
264
|
it "parses the query string when a key has an empty value" do
|
|
265
265
|
query_string = "foo=bar%20baz&hash=a1b2c3&vat_number="
|
|
266
|
-
Braintree::Util.parse_query_string(query_string).
|
|
266
|
+
expect(Braintree::Util.parse_query_string(query_string)).to eq({:foo => "bar baz", :hash => "a1b2c3", :vat_number => ""})
|
|
267
267
|
end
|
|
268
268
|
end
|
|
269
269
|
|
|
@@ -388,15 +388,15 @@ describe Braintree::Util do
|
|
|
388
388
|
|
|
389
389
|
describe "self.to_big_decimal" do
|
|
390
390
|
it "returns the BigDecimal when given a BigDecimal" do
|
|
391
|
-
Braintree::Util.to_big_decimal(BigDecimal("12.34")).
|
|
391
|
+
expect(Braintree::Util.to_big_decimal(BigDecimal("12.34"))).to eq(BigDecimal("12.34"))
|
|
392
392
|
end
|
|
393
393
|
|
|
394
394
|
it "returns a BigDecimal when given a string" do
|
|
395
|
-
Braintree::Util.to_big_decimal("12.34").
|
|
395
|
+
expect(Braintree::Util.to_big_decimal("12.34")).to eq(BigDecimal("12.34"))
|
|
396
396
|
end
|
|
397
397
|
|
|
398
398
|
it "returns nil when given nil" do
|
|
399
|
-
Braintree::Util.to_big_decimal(nil).
|
|
399
|
+
expect(Braintree::Util.to_big_decimal(nil)).to be_nil
|
|
400
400
|
end
|
|
401
401
|
|
|
402
402
|
it "blows up when not given a String or BigDecimal" do
|
|
@@ -408,13 +408,13 @@ describe Braintree::Util do
|
|
|
408
408
|
|
|
409
409
|
describe "self.url_encode" do
|
|
410
410
|
it "url encodes the given text" do
|
|
411
|
-
Braintree::Util.url_encode("foo?bar").
|
|
411
|
+
expect(Braintree::Util.url_encode("foo?bar")).to eq("foo%3Fbar")
|
|
412
412
|
end
|
|
413
413
|
end
|
|
414
414
|
|
|
415
415
|
describe "self.url_decode" do
|
|
416
416
|
it "url decodes the given text" do
|
|
417
|
-
Braintree::Util.url_decode("foo%3Fbar").
|
|
417
|
+
expect(Braintree::Util.url_decode("foo%3Fbar")).to eq("foo?bar")
|
|
418
418
|
end
|
|
419
419
|
end
|
|
420
420
|
end
|
|
@@ -8,9 +8,9 @@ describe Braintree::ValidationErrorCollection do
|
|
|
8
8
|
hash = {:errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}]}
|
|
9
9
|
collection = Braintree::ValidationErrorCollection.new(hash)
|
|
10
10
|
error = collection[0]
|
|
11
|
-
error.attribute.
|
|
12
|
-
error.code.
|
|
13
|
-
error.message.
|
|
11
|
+
expect(error.attribute).to eq("some model attribute")
|
|
12
|
+
expect(error.code).to eq(1)
|
|
13
|
+
expect(error.message).to eq("bad juju")
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -23,9 +23,9 @@ describe Braintree::ValidationErrorCollection do
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
errors = Braintree::ValidationErrorCollection.new(hash)
|
|
26
|
-
errors.for(:nested).on(:number)[0].code.
|
|
27
|
-
errors.for(:nested).on(:number)[0].message.
|
|
28
|
-
errors.for(:nested).on(:number)[0].attribute.
|
|
26
|
+
expect(errors.for(:nested).on(:number)[0].code).to eq(2)
|
|
27
|
+
expect(errors.for(:nested).on(:number)[0].message).to eq("badder juju")
|
|
28
|
+
expect(errors.for(:nested).on(:number)[0].attribute).to eq("number")
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -35,7 +35,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
35
35
|
{:attribute => "name", :code => "code1", :message => "message1"},
|
|
36
36
|
{:attribute => "name", :code => "code2", :message => "message2"}
|
|
37
37
|
])
|
|
38
|
-
errors.inspect.
|
|
38
|
+
expect(errors.inspect).to eq("#<Braintree::ValidationErrorCollection errors:[(code1) message1, (code2) message2]>")
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "shows errors 1 level deep" do
|
|
@@ -47,7 +47,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
47
47
|
:errors => [{:attribute => "name", :code => "code2", :message => "message2"}]
|
|
48
48
|
},
|
|
49
49
|
)
|
|
50
|
-
errors.inspect.
|
|
50
|
+
expect(errors.inspect).to eq("#<Braintree::ValidationErrorCollection errors:[(code1) message1], level1:[(code2) message2]>")
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it "shows errors 2 levels deep" do
|
|
@@ -62,7 +62,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
)
|
|
65
|
-
errors.inspect.
|
|
65
|
+
expect(errors.inspect).to eq("#<Braintree::ValidationErrorCollection errors:[(code1) message1], level1:[(code2) message2], level1/level2:[(code3) message3]>")
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
@@ -73,16 +73,16 @@ describe Braintree::ValidationErrorCollection do
|
|
|
73
73
|
{:attribute => "name", :code => 2, :message => "contains invalid chars"},
|
|
74
74
|
{:attribute => "not name", :code => 3, :message => "is invalid"}
|
|
75
75
|
])
|
|
76
|
-
errors.on("name").size.
|
|
77
|
-
errors.on("name").map { |e| e.code }.
|
|
76
|
+
expect(errors.on("name").size).to eq(2)
|
|
77
|
+
expect(errors.on("name").map { |e| e.code }).to eq([1, 2])
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
it "has indifferent access" do
|
|
81
81
|
errors = Braintree::ValidationErrorCollection.new(:errors => [
|
|
82
82
|
{:attribute => "name", :code => 3, :message => "is too long"},
|
|
83
83
|
])
|
|
84
|
-
errors.on(:name).size.
|
|
85
|
-
errors.on(:name)[0].code.
|
|
84
|
+
expect(errors.on(:name).size).to eq(1)
|
|
85
|
+
expect(errors.on(:name)[0].code).to eq(3)
|
|
86
86
|
|
|
87
87
|
end
|
|
88
88
|
end
|
|
@@ -94,7 +94,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
94
94
|
{:attribute => "two", :code => 2, :message => "contains invalid chars"},
|
|
95
95
|
{:attribute => "thr", :code => 3, :message => "is invalid"}
|
|
96
96
|
])
|
|
97
|
-
errors.deep_size.
|
|
97
|
+
expect(errors.deep_size).to eq(3)
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
it "returns the size of nested errors as well" do
|
|
@@ -104,7 +104,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
104
104
|
:errors => [{:attribute => "number", :code => 2, :message => "badder juju"}]
|
|
105
105
|
},
|
|
106
106
|
)
|
|
107
|
-
errors.deep_size.
|
|
107
|
+
expect(errors.deep_size).to eq(2)
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
it "returns the size of multiple nestings of errors" do
|
|
@@ -122,7 +122,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
122
122
|
:errors => [{:attribute => "five", :code => 2, :message => "badder juju"}],
|
|
123
123
|
},
|
|
124
124
|
)
|
|
125
|
-
errors.deep_size.
|
|
125
|
+
expect(errors.deep_size).to eq(5)
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
|
|
@@ -142,7 +142,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
142
142
|
:errors => [{:attribute => "five", :code => 5, :message => "badder juju"}],
|
|
143
143
|
},
|
|
144
144
|
)
|
|
145
|
-
errors.deep_errors.map { |e| e.code }.sort.
|
|
145
|
+
expect(errors.deep_errors.map { |e| e.code }.sort).to eq([1, 2, 3, 4, 5])
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
|
|
@@ -159,8 +159,8 @@ describe Braintree::ValidationErrorCollection do
|
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
161
|
)
|
|
162
|
-
errors.shallow_errors.map { |e| e.code }.
|
|
163
|
-
errors.for(:nested).shallow_errors.map { |e| e.code }.
|
|
162
|
+
expect(errors.shallow_errors.map { |e| e.code }).to eq([1, 2])
|
|
163
|
+
expect(errors.for(:nested).shallow_errors.map { |e| e.code }).to eq([3])
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
it "returns an clone of the real array" do
|
|
@@ -170,7 +170,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
170
170
|
{:attribute => "two", :code => 2, :message => "bad juju"}],
|
|
171
171
|
)
|
|
172
172
|
errors.shallow_errors.pop
|
|
173
|
-
errors.shallow_errors.map { |e| e.code }.
|
|
173
|
+
expect(errors.shallow_errors.map { |e| e.code }).to eq([1, 2])
|
|
174
174
|
end
|
|
175
175
|
end
|
|
176
176
|
end
|
|
@@ -186,9 +186,9 @@ describe Braintree::ValidationErrorCollection do
|
|
|
186
186
|
}]}
|
|
187
187
|
collection = Braintree::ValidationErrorCollection.new(hash)
|
|
188
188
|
error = collection[0]
|
|
189
|
-
error.attribute.
|
|
190
|
-
error.code.
|
|
191
|
-
error.message.
|
|
189
|
+
expect(error.attribute).to eq("two")
|
|
190
|
+
expect(error.code).to eq(1)
|
|
191
|
+
expect(error.message).to eq("bad juju")
|
|
192
192
|
!error.respond_to? :untracked_param
|
|
193
193
|
end
|
|
194
194
|
end
|
|
@@ -210,9 +210,9 @@ describe Braintree::ValidationErrorCollection do
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
errors = Braintree::ValidationErrorCollection.new(hash)
|
|
213
|
-
errors.for(:nested).on(:nested_attribute)[0].code.
|
|
214
|
-
errors.for(:nested).on(:nested_attribute)[0].message.
|
|
215
|
-
errors.for(:nested).on(:nested_attribute)[0].attribute.
|
|
213
|
+
expect(errors.for(:nested).on(:nested_attribute)[0].code).to eq(2)
|
|
214
|
+
expect(errors.for(:nested).on(:nested_attribute)[0].message).to eq("badder juju")
|
|
215
|
+
expect(errors.for(:nested).on(:nested_attribute)[0].attribute).to eq("nested_attribute")
|
|
216
216
|
end
|
|
217
217
|
end
|
|
218
218
|
|
|
@@ -234,7 +234,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
234
234
|
}],
|
|
235
235
|
}
|
|
236
236
|
errors = Braintree::ValidationErrorCollection.new(hash)
|
|
237
|
-
errors.deep_size.
|
|
237
|
+
expect(errors.deep_size).to eq(3)
|
|
238
238
|
end
|
|
239
239
|
|
|
240
240
|
it "returns the size of nested errors as well" do
|
|
@@ -253,7 +253,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
errors = Braintree::ValidationErrorCollection.new(hash)
|
|
256
|
-
errors.deep_size.
|
|
256
|
+
expect(errors.deep_size).to eq(2)
|
|
257
257
|
end
|
|
258
258
|
|
|
259
259
|
it "returns the size of multiple nestings of errors" do
|
|
@@ -290,7 +290,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
errors = Braintree::ValidationErrorCollection.new(hash)
|
|
293
|
-
errors.deep_size.
|
|
293
|
+
expect(errors.deep_size).to eq(5)
|
|
294
294
|
end
|
|
295
295
|
end
|
|
296
296
|
|
|
@@ -329,7 +329,7 @@ describe Braintree::ValidationErrorCollection do
|
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
errors = Braintree::ValidationErrorCollection.new(hash)
|
|
332
|
-
errors.deep_errors.map { |e| e.code }.sort.
|
|
332
|
+
expect(errors.deep_errors.map { |e| e.code }.sort).to eq([1, 2, 3, 4, 5])
|
|
333
333
|
end
|
|
334
334
|
end
|
|
335
335
|
|
|
@@ -368,10 +368,10 @@ describe Braintree::ValidationErrorCollection do
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
errors = Braintree::ValidationErrorCollection.new(hash)
|
|
371
|
-
errors.shallow_errors.map { |e| e.code }.
|
|
372
|
-
errors.for(:nested).shallow_errors.map { |e| e.code }.
|
|
373
|
-
errors.for(:nested).for(:deeply_nested).shallow_errors.map { |e| e.code }.
|
|
374
|
-
errors.for(:nested_again).shallow_errors.map { |e| e.code }.
|
|
371
|
+
expect(errors.shallow_errors.map { |e| e.code }).to eq([1])
|
|
372
|
+
expect(errors.for(:nested).shallow_errors.map { |e| e.code }).to eq([2,3])
|
|
373
|
+
expect(errors.for(:nested).for(:deeply_nested).shallow_errors.map { |e| e.code }).to eq([4])
|
|
374
|
+
expect(errors.for(:nested_again).shallow_errors.map { |e| e.code }).to eq([5])
|
|
375
375
|
end
|
|
376
376
|
end
|
|
377
377
|
end
|
|
@@ -4,16 +4,16 @@ describe Braintree::ValidationError do
|
|
|
4
4
|
describe "initialize" do
|
|
5
5
|
it "works" do
|
|
6
6
|
error = Braintree::ValidationError.new :attribute => "some model attribute", :code => 1, :message => "bad juju"
|
|
7
|
-
error.attribute.
|
|
8
|
-
error.code.
|
|
9
|
-
error.message.
|
|
7
|
+
expect(error.attribute).to eq("some model attribute")
|
|
8
|
+
expect(error.code).to eq(1)
|
|
9
|
+
expect(error.message).to eq("bad juju")
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
describe "inspect" do
|
|
14
14
|
it "is pretty" do
|
|
15
15
|
error = Braintree::ValidationError.new :attribute => "number", :code => "123456", :message => "Number is bad juju."
|
|
16
|
-
error.inspect.
|
|
16
|
+
expect(error.inspect).to eq("#<Braintree::ValidationError (123456) Number is bad juju.>")
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -22,11 +22,11 @@ describe Braintree::VenmoProfileData do
|
|
|
22
22
|
|
|
23
23
|
payment_method_customer_data_updated = Braintree::VenmoProfileData._new(params)
|
|
24
24
|
|
|
25
|
-
payment_method_customer_data_updated.username.
|
|
26
|
-
payment_method_customer_data_updated.first_name.
|
|
27
|
-
payment_method_customer_data_updated.last_name.
|
|
28
|
-
payment_method_customer_data_updated.phone_number.
|
|
29
|
-
payment_method_customer_data_updated.email.
|
|
25
|
+
expect(payment_method_customer_data_updated.username).to eq("a-username")
|
|
26
|
+
expect(payment_method_customer_data_updated.first_name).to eq("a-first-name")
|
|
27
|
+
expect(payment_method_customer_data_updated.last_name).to eq("a-last-name")
|
|
28
|
+
expect(payment_method_customer_data_updated.phone_number).to eq("12312312343")
|
|
29
|
+
expect(payment_method_customer_data_updated.email).to eq("a-email")
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|