braintree 4.14.0 → 4.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/account_updater_daily_report.rb +3 -3
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +4 -4
- data/lib/braintree/address_gateway.rb +5 -5
- data/lib/braintree/advanced_search.rb +10 -10
- data/lib/braintree/apple_pay.rb +3 -3
- data/lib/braintree/apple_pay_card.rb +3 -3
- data/lib/braintree/apple_pay_options.rb +3 -3
- data/lib/braintree/authorization_adjustment.rb +3 -3
- data/lib/braintree/base_module.rb +1 -1
- data/lib/braintree/bin_data.rb +2 -2
- data/lib/braintree/client_token_gateway.rb +1 -1
- data/lib/braintree/configuration.rb +22 -22
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +22 -9
- data/lib/braintree/credit_card_gateway.rb +23 -11
- data/lib/braintree/credit_card_verification.rb +3 -3
- data/lib/braintree/credit_card_verification_gateway.rb +28 -11
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +5 -9
- data/lib/braintree/customer_gateway.rb +7 -7
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +5 -5
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/dispute/paypal_message.rb +1 -1
- data/lib/braintree/dispute/status_history.rb +1 -1
- data/lib/braintree/dispute/transaction.rb +1 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +3 -3
- data/lib/braintree/dispute_gateway.rb +1 -1
- data/lib/braintree/dispute_search.rb +1 -1
- data/lib/braintree/document_upload.rb +2 -2
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +2 -2
- data/lib/braintree/error_codes.rb +4 -0
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +1 -2
- data/lib/braintree/exchange_rate.rb +2 -2
- data/lib/braintree/exchange_rate_quote.rb +3 -3
- data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
- data/lib/braintree/exchange_rate_quote_input.rb +3 -3
- data/lib/braintree/exchange_rate_quote_request.rb +3 -3
- data/lib/braintree/exchange_rate_quote_response.rb +3 -3
- data/lib/braintree/facilitated_details.rb +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/google_pay_card.rb +3 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +1 -1
- data/lib/braintree/http.rb +5 -5
- data/lib/braintree/local_payment_completed.rb +2 -2
- data/lib/braintree/local_payment_expired.rb +2 -2
- data/lib/braintree/local_payment_funded.rb +2 -2
- data/lib/braintree/local_payment_reversed.rb +2 -2
- data/lib/braintree/merchant.rb +3 -3
- data/lib/braintree/merchant_account.rb +2 -2
- data/lib/braintree/merchant_account_gateway.rb +9 -9
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +3 -3
- data/lib/braintree/oauth_credentials.rb +3 -3
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +2 -0
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
- data/lib/braintree/payment_method_gateway.rb +23 -10
- data/lib/braintree/payment_method_nonce.rb +4 -4
- data/lib/braintree/payment_method_nonce_details.rb +1 -1
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/paypal_account.rb +1 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/plan_gateway.rb +2 -2
- data/lib/braintree/resource_collection.rb +2 -2
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +1 -1
- data/lib/braintree/samsung_pay_card.rb +5 -5
- data/lib/braintree/sepa_direct_debit_account.rb +2 -2
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
- data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
- data/lib/braintree/sha256_digest.rb +1 -1
- data/lib/braintree/subscription/status_details.rb +1 -1
- data/lib/braintree/subscription.rb +2 -2
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +2 -2
- data/lib/braintree/test/credit_card.rb +7 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +4 -0
- data/lib/braintree/test/transaction_amounts.rb +2 -3
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/testing_gateway.rb +1 -1
- data/lib/braintree/three_d_secure_info.rb +1 -1
- data/lib/braintree/transaction/address_details.rb +2 -1
- data/lib/braintree/transaction/credit_card_details.rb +4 -1
- data/lib/braintree/transaction/customer_details.rb +1 -1
- data/lib/braintree/transaction/disbursement_details.rb +1 -1
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
- data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
- data/lib/braintree/transaction/package_details.rb +16 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +1 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +1 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +37 -20
- data/lib/braintree/transaction_gateway.rb +44 -15
- data/lib/braintree/transaction_line_item.rb +13 -10
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +1 -1
- data/lib/braintree/transaction_search.rb +7 -6
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +2 -2
- data/lib/braintree/us_bank_account_verification.rb +23 -15
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +3 -3
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +3 -3
- data/lib/braintree/venmo_profile_data.rb +6 -4
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +7 -7
- data/lib/braintree/webhook_notification.rb +3 -2
- data/lib/braintree/webhook_notification_gateway.rb +4 -4
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +18 -1
- data/lib/braintree/xml/generator.rb +1 -1
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +3 -3
- data/lib/braintree/xml/rexml.rb +2 -2
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +5 -1
- 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/client_api/spec_helper.rb +2 -2
- data/spec/integration/braintree/credit_card_spec.rb +227 -228
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +98 -53
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +317 -317
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_search_spec.rb +0 -1
- 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/package_tracking_spec.rb +111 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +89 -69
- data/spec/integration/braintree/payment_method_spec.rb +391 -391
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +150 -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 +12 -6
- data/spec/integration/braintree/transaction_search_spec.rb +225 -165
- data/spec/integration/braintree/transaction_spec.rb +1606 -1230
- 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 +33 -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 +11 -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 +9 -9
- 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/meta_checkout_card_details_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/package_tracking_spec.rb +74 -0
- 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 +41 -9
- 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 +12 -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 +16 -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 +14 -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
|
@@ -12,21 +12,32 @@ describe Braintree::VenmoProfileData do
|
|
12
12
|
describe "self._new" do
|
13
13
|
it "initializes the object with the appropriate attributes set" do
|
14
14
|
|
15
|
+
address = {
|
16
|
+
street_address: "a-street-address",
|
17
|
+
extended_address: "an-extended-address",
|
18
|
+
locality: "a-locality",
|
19
|
+
region: "a-region",
|
20
|
+
postal_code: "a-postal-code"
|
21
|
+
}
|
15
22
|
params = {
|
16
23
|
username: "a-username",
|
17
24
|
first_name: "a-first-name",
|
18
25
|
last_name: "a-last-name",
|
19
26
|
phone_number: "12312312343",
|
20
27
|
email: "a-email",
|
28
|
+
billing_address: address,
|
29
|
+
shipping_address: address
|
21
30
|
}
|
22
31
|
|
23
32
|
payment_method_customer_data_updated = Braintree::VenmoProfileData._new(params)
|
24
33
|
|
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.
|
34
|
+
expect(payment_method_customer_data_updated.username).to eq("a-username")
|
35
|
+
expect(payment_method_customer_data_updated.first_name).to eq("a-first-name")
|
36
|
+
expect(payment_method_customer_data_updated.last_name).to eq("a-last-name")
|
37
|
+
expect(payment_method_customer_data_updated.phone_number).to eq("12312312343")
|
38
|
+
expect(payment_method_customer_data_updated.email).to eq("a-email")
|
39
|
+
expect(payment_method_customer_data_updated.billing_address).to eq(address)
|
40
|
+
expect(payment_method_customer_data_updated.shipping_address).to eq(address)
|
30
41
|
end
|
31
42
|
end
|
32
43
|
end
|