braintree 2.98.0 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/braintree.gemspec +7 -4
  4. data/lib/braintree/account_updater_daily_report.rb +4 -4
  5. data/lib/braintree/ach_mandate.rb +1 -1
  6. data/lib/braintree/add_on_gateway.rb +1 -1
  7. data/lib/braintree/address.rb +7 -27
  8. data/lib/braintree/address_gateway.rb +8 -7
  9. data/lib/braintree/advanced_search.rb +11 -12
  10. data/lib/braintree/apple_pay.rb +4 -4
  11. data/lib/braintree/apple_pay_card.rb +18 -4
  12. data/lib/braintree/apple_pay_options.rb +4 -4
  13. data/lib/braintree/authorization_adjustment.rb +4 -4
  14. data/lib/braintree/base_module.rb +11 -1
  15. data/lib/braintree/bin_data.rb +10 -3
  16. data/lib/braintree/client_token.rb +1 -1
  17. data/lib/braintree/client_token_gateway.rb +4 -3
  18. data/lib/braintree/configuration.rb +35 -35
  19. data/lib/braintree/connected_merchant_paypal_status_changed.rb +2 -2
  20. data/lib/braintree/connected_merchant_status_transitioned.rb +2 -2
  21. data/lib/braintree/credit_card.rb +40 -86
  22. data/lib/braintree/credit_card_gateway.rb +58 -44
  23. data/lib/braintree/credit_card_verification.rb +39 -20
  24. data/lib/braintree/credit_card_verification_gateway.rb +35 -5
  25. data/lib/braintree/credit_card_verification_search.rb +2 -2
  26. data/lib/braintree/customer.rb +23 -88
  27. data/lib/braintree/customer_gateway.rb +17 -32
  28. data/lib/braintree/customer_search.rb +2 -2
  29. data/lib/braintree/descriptor.rb +1 -1
  30. data/lib/braintree/digest.rb +1 -1
  31. data/lib/braintree/disbursement.rb +7 -7
  32. data/lib/braintree/discount_gateway.rb +1 -1
  33. data/lib/braintree/dispute/evidence.rb +1 -1
  34. data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
  35. data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
  36. data/lib/braintree/dispute/transaction.rb +3 -1
  37. data/lib/braintree/dispute/transaction_details.rb +1 -1
  38. data/lib/braintree/dispute.rb +47 -6
  39. data/lib/braintree/dispute_gateway.rb +5 -10
  40. data/lib/braintree/dispute_search.rb +8 -4
  41. data/lib/braintree/document_upload.rb +3 -3
  42. data/lib/braintree/document_upload_gateway.rb +3 -3
  43. data/lib/braintree/enriched_customer_data.rb +21 -0
  44. data/lib/braintree/error_codes.rb +217 -175
  45. data/lib/braintree/error_result.rb +2 -3
  46. data/lib/braintree/errors.rb +3 -3
  47. data/lib/braintree/exceptions.rb +6 -5
  48. data/lib/braintree/exchange_rate.rb +13 -0
  49. data/lib/braintree/exchange_rate_quote.rb +24 -0
  50. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  51. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  52. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  53. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  54. data/lib/braintree/facilitated_details.rb +1 -1
  55. data/lib/braintree/facilitator_details.rb +1 -1
  56. data/lib/braintree/gateway.rb +6 -12
  57. data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +18 -5
  58. data/lib/braintree/granted_payment_instrument_update.rb +2 -2
  59. data/lib/braintree/graphql_client.rb +14 -8
  60. data/lib/braintree/http.rb +9 -10
  61. data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
  62. data/lib/braintree/local_payment_completed.rb +10 -5
  63. data/lib/braintree/local_payment_expired.rb +21 -0
  64. data/lib/braintree/local_payment_funded.rb +22 -0
  65. data/lib/braintree/local_payment_reversed.rb +19 -0
  66. data/lib/braintree/merchant.rb +4 -4
  67. data/lib/braintree/merchant_account.rb +3 -3
  68. data/lib/braintree/merchant_account_gateway.rb +10 -8
  69. data/lib/braintree/merchant_gateway.rb +1 -1
  70. data/lib/braintree/meta_checkout_card.rb +89 -0
  71. data/lib/braintree/meta_checkout_token.rb +88 -0
  72. data/lib/braintree/modification.rb +4 -4
  73. data/lib/braintree/oauth_credentials.rb +4 -4
  74. data/lib/braintree/oauth_gateway.rb +5 -5
  75. data/lib/braintree/paginated_collection.rb +2 -2
  76. data/lib/braintree/paginated_result.rb +1 -1
  77. data/lib/braintree/payment_instrument_type.rb +14 -13
  78. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  79. data/lib/braintree/payment_method_gateway.rb +52 -22
  80. data/lib/braintree/payment_method_nonce.rb +12 -7
  81. data/lib/braintree/payment_method_nonce_details.rb +40 -0
  82. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  83. data/lib/braintree/payment_method_nonce_gateway.rb +14 -3
  84. data/lib/braintree/payment_method_parser.rb +4 -7
  85. data/lib/braintree/paypal_account.rb +3 -2
  86. data/lib/braintree/paypal_account_gateway.rb +5 -5
  87. data/lib/braintree/plan.rb +22 -2
  88. data/lib/braintree/plan_gateway.rb +101 -1
  89. data/lib/braintree/processor_response_types.rb +3 -3
  90. data/lib/braintree/resource_collection.rb +10 -5
  91. data/lib/braintree/revoked_payment_method_metadata.rb +2 -2
  92. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  93. data/lib/braintree/risk_data.rb +10 -3
  94. data/lib/braintree/samsung_pay_card.rb +8 -6
  95. data/lib/braintree/sepa_direct_debit_account.rb +60 -0
  96. data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
  97. data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
  98. data/lib/braintree/settlement_batch_summary.rb +2 -2
  99. data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
  100. data/lib/braintree/sha256_digest.rb +1 -1
  101. data/lib/braintree/subscription/status_details.rb +1 -1
  102. data/lib/braintree/subscription.rb +13 -13
  103. data/lib/braintree/subscription_gateway.rb +6 -6
  104. data/lib/braintree/subscription_search.rb +1 -1
  105. data/lib/braintree/successful_result.rb +5 -4
  106. data/lib/braintree/test/authentication_id.rb +21 -0
  107. data/lib/braintree/test/credit_card.rb +9 -10
  108. data/lib/braintree/test/merchant_account.rb +1 -1
  109. data/lib/braintree/test/nonce.rb +27 -20
  110. data/lib/braintree/test/transaction_amounts.rb +2 -3
  111. data/lib/braintree/test/venmo_sdk.rb +2 -0
  112. data/lib/braintree/testing_gateway.rb +1 -1
  113. data/lib/braintree/three_d_secure_info.rb +23 -11
  114. data/lib/braintree/transaction/address_details.rb +14 -1
  115. data/lib/braintree/transaction/apple_pay_details.rb +13 -10
  116. data/lib/braintree/transaction/credit_card_details.rb +8 -1
  117. data/lib/braintree/transaction/customer_details.rb +3 -2
  118. data/lib/braintree/transaction/disbursement_details.rb +2 -1
  119. data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +6 -1
  120. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  121. data/lib/braintree/transaction/installment.rb +28 -0
  122. data/lib/braintree/transaction/local_payment_details.rb +3 -0
  123. data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
  124. data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
  125. data/lib/braintree/transaction/package_details.rb +19 -0
  126. data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
  127. data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
  128. data/lib/braintree/transaction/payment_receipt.rb +31 -0
  129. data/lib/braintree/transaction/paypal_details.rb +5 -0
  130. data/lib/braintree/transaction/samsung_pay_card_details.rb +3 -1
  131. data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
  132. data/lib/braintree/transaction/status_details.rb +1 -1
  133. data/lib/braintree/transaction/subscription_details.rb +3 -1
  134. data/lib/braintree/transaction/us_bank_account_details.rb +2 -1
  135. data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
  136. data/lib/braintree/transaction.rb +119 -128
  137. data/lib/braintree/transaction_gateway.rb +138 -64
  138. data/lib/braintree/transaction_line_item.rb +14 -11
  139. data/lib/braintree/transaction_line_item_gateway.rb +1 -1
  140. data/lib/braintree/transaction_review.rb +18 -0
  141. data/lib/braintree/transaction_search.rb +11 -7
  142. data/lib/braintree/unknown_payment_method.rb +2 -2
  143. data/lib/braintree/us_bank_account.rb +5 -5
  144. data/lib/braintree/us_bank_account_verification.rb +24 -16
  145. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  146. data/lib/braintree/us_bank_account_verification_search.rb +1 -1
  147. data/lib/braintree/util.rb +25 -10
  148. data/lib/braintree/validation_error.rb +1 -1
  149. data/lib/braintree/validation_error_collection.rb +3 -3
  150. data/lib/braintree/venmo_account.rb +4 -4
  151. data/lib/braintree/venmo_profile_data.rb +25 -0
  152. data/lib/braintree/version.rb +2 -2
  153. data/lib/braintree/visa_checkout_card.rb +8 -8
  154. data/lib/braintree/webhook_notification.rb +55 -33
  155. data/lib/braintree/webhook_notification_gateway.rb +9 -9
  156. data/lib/braintree/webhook_testing.rb +1 -1
  157. data/lib/braintree/webhook_testing_gateway.rb +569 -46
  158. data/lib/braintree/xml/generator.rb +6 -5
  159. data/lib/braintree/xml/libxml.rb +1 -1
  160. data/lib/braintree/xml/parser.rb +24 -37
  161. data/lib/braintree/xml/rexml.rb +6 -7
  162. data/lib/braintree/xml.rb +1 -1
  163. data/lib/braintree.rb +41 -24
  164. data/lib/ssl/api_braintreegateway_com.ca.crt +401 -168
  165. data/spec/integration/braintree/add_on_spec.rb +10 -10
  166. data/spec/integration/braintree/address_spec.rb +101 -178
  167. data/spec/integration/braintree/advanced_search_spec.rb +93 -93
  168. data/spec/integration/braintree/apple_pay_spec.rb +12 -12
  169. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  170. data/spec/integration/braintree/client_api/client_token_spec.rb +279 -62
  171. data/spec/integration/braintree/client_api/spec_helper.rb +99 -73
  172. data/spec/integration/braintree/credit_card_spec.rb +522 -821
  173. data/spec/integration/braintree/credit_card_verification_search_spec.rb +18 -18
  174. data/spec/integration/braintree/credit_card_verification_spec.rb +219 -30
  175. data/spec/integration/braintree/customer_search_spec.rb +28 -28
  176. data/spec/integration/braintree/customer_spec.rb +840 -757
  177. data/spec/integration/braintree/disbursement_spec.rb +2 -2
  178. data/spec/integration/braintree/discount_spec.rb +9 -9
  179. data/spec/integration/braintree/dispute_search_spec.rb +45 -9
  180. data/spec/integration/braintree/dispute_spec.rb +109 -82
  181. data/spec/integration/braintree/document_upload_spec.rb +29 -17
  182. data/spec/integration/braintree/error_codes_spec.rb +3 -3
  183. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  184. data/spec/integration/braintree/graphql_client_spec.rb +0 -2
  185. data/spec/integration/braintree/http_spec.rb +31 -33
  186. data/spec/integration/braintree/merchant_account_spec.rb +155 -156
  187. data/spec/integration/braintree/merchant_spec.rb +71 -192
  188. data/spec/integration/braintree/oauth_spec.rb +72 -72
  189. data/spec/integration/braintree/package_tracking_spec.rb +130 -0
  190. data/spec/integration/braintree/payment_method_nonce_spec.rb +173 -78
  191. data/spec/integration/braintree/payment_method_spec.rb +953 -501
  192. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +147 -234
  193. data/spec/integration/braintree/paypal_account_spec.rb +74 -72
  194. data/spec/integration/braintree/plan_spec.rb +96 -15
  195. data/spec/integration/braintree/samsung_pay_card_spec.rb +75 -73
  196. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +194 -0
  197. data/spec/integration/braintree/settlement_batch_summary_spec.rb +18 -18
  198. data/spec/integration/braintree/subscription_spec.rb +507 -513
  199. data/spec/integration/braintree/test/transaction_amounts_spec.rb +4 -4
  200. data/spec/integration/braintree/test_transaction_spec.rb +29 -29
  201. data/spec/integration/braintree/transaction_line_item_spec.rb +12 -6
  202. data/spec/integration/braintree/transaction_search_spec.rb +410 -217
  203. data/spec/integration/braintree/transaction_spec.rb +3252 -2102
  204. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +42 -278
  205. data/spec/integration/braintree/us_bank_account_spec.rb +36 -36
  206. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +25 -25
  207. data/spec/integration/braintree/us_bank_account_verification_spec.rb +41 -41
  208. data/spec/integration/braintree/visa_checkout_card_spec.rb +62 -62
  209. data/spec/integration/spec_helper.rb +22 -7
  210. data/spec/oauth_test_helper.rb +1 -1
  211. data/spec/script/httpsd.rb +6 -6
  212. data/spec/spec_helper.rb +15 -20
  213. data/spec/unit/braintree/address_spec.rb +9 -17
  214. data/spec/unit/braintree/apple_pay_card_spec.rb +110 -7
  215. data/spec/unit/braintree/base_module_spec.rb +4 -4
  216. data/spec/unit/braintree/client_token_spec.rb +6 -6
  217. data/spec/unit/braintree/configuration_spec.rb +84 -84
  218. data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
  219. data/spec/unit/braintree/credit_card_spec.rb +91 -58
  220. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +56 -0
  221. data/spec/unit/braintree/credit_card_verification_search_spec.rb +10 -10
  222. data/spec/unit/braintree/credit_card_verification_spec.rb +40 -18
  223. data/spec/unit/braintree/customer_spec.rb +102 -57
  224. data/spec/unit/braintree/digest_spec.rb +5 -6
  225. data/spec/unit/braintree/disbursement_spec.rb +14 -14
  226. data/spec/unit/braintree/dispute_search_spec.rb +6 -2
  227. data/spec/unit/braintree/dispute_spec.rb +144 -66
  228. data/spec/unit/braintree/document_upload_spec.rb +8 -8
  229. data/spec/unit/braintree/enriched_customer_data_spec.rb +41 -0
  230. data/spec/unit/braintree/error_result_spec.rb +11 -11
  231. data/spec/unit/braintree/errors_spec.rb +17 -17
  232. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  233. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  234. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  235. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  236. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  237. data/spec/unit/braintree/http_spec.rb +19 -17
  238. data/spec/unit/braintree/local_payment_completed_spec.rb +62 -8
  239. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  240. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  241. data/spec/unit/braintree/merchant_account_spec.rb +5 -5
  242. data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
  243. data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
  244. data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
  245. data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
  246. data/spec/unit/braintree/modification_spec.rb +1 -1
  247. data/spec/unit/braintree/package_tracking_spec.rb +77 -0
  248. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  249. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  250. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
  251. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  252. data/spec/unit/braintree/payment_method_spec.rb +20 -20
  253. data/spec/unit/braintree/paypal_account_spec.rb +16 -7
  254. data/spec/unit/braintree/resource_collection_spec.rb +34 -5
  255. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  256. data/spec/unit/braintree/risk_data_spec.rb +38 -8
  257. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
  258. data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
  259. data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
  260. data/spec/unit/braintree/signature_service_spec.rb +2 -2
  261. data/spec/unit/braintree/subscription_search_spec.rb +18 -18
  262. data/spec/unit/braintree/subscription_spec.rb +8 -8
  263. data/spec/unit/braintree/successful_result_spec.rb +6 -6
  264. data/spec/unit/braintree/three_d_secure_info_spec.rb +37 -17
  265. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +22 -6
  266. data/spec/unit/braintree/transaction/customer_details_spec.rb +3 -2
  267. data/spec/unit/braintree/transaction/deposit_details_spec.rb +4 -4
  268. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  269. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +36 -0
  270. data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
  271. data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
  272. data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
  273. data/spec/unit/braintree/transaction_gateway_spec.rb +150 -0
  274. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  275. data/spec/unit/braintree/transaction_spec.rb +221 -124
  276. data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
  277. data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
  278. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
  279. data/spec/unit/braintree/us_bank_account_verification_spec.rb +12 -7
  280. data/spec/unit/braintree/util_spec.rb +78 -44
  281. data/spec/unit/braintree/validation_error_collection_spec.rb +62 -62
  282. data/spec/unit/braintree/validation_error_spec.rb +4 -4
  283. data/spec/unit/braintree/venmo_profile_data_spec.rb +43 -0
  284. data/spec/unit/braintree/webhook_notification_spec.rb +434 -197
  285. data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
  286. data/spec/unit/braintree/xml/parser_spec.rb +27 -22
  287. data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
  288. data/spec/unit/braintree/xml_spec.rb +38 -38
  289. data/spec/unit/braintree_spec.rb +2 -2
  290. metadata +91 -30
  291. data/lib/braintree/amex_express_checkout_card.rb +0 -38
  292. data/lib/braintree/coinbase_account.rb +0 -34
  293. data/lib/braintree/europe_bank_account.rb +0 -36
  294. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  295. data/lib/braintree/ideal_payment.rb +0 -61
  296. data/lib/braintree/ideal_payment_gateway.rb +0 -19
  297. data/lib/braintree/masterpass_card.rb +0 -81
  298. data/lib/braintree/settlement_batch.rb +0 -0
  299. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
  300. data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
  301. data/lib/braintree/transaction/masterpass_card_details.rb +0 -47
  302. data/lib/braintree/transparent_redirect.rb +0 -40
  303. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  304. data/spec/hacks/tcp_socket.rb +0 -18
  305. data/spec/integration/braintree/coinbase_spec.rb +0 -34
  306. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  307. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  308. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -8,11 +8,16 @@ describe Braintree::UsBankAccountVerification do
8
8
  :status => Braintree::UsBankAccountVerification::Status::Verified,
9
9
  :verification_method => Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
10
10
  :verification_determined_at => "2018-02-28T12:01:01Z",
11
+ :additional_processor_response => "some_invalid_processor_response",
11
12
  )
12
13
  end
13
14
 
14
15
  it "has a status" do
15
- verification.status.should == Braintree::UsBankAccountVerification::Status::Verified
16
+ expect(verification.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
17
+ end
18
+
19
+ it "has additional processor response" do
20
+ expect(verification.additional_processor_response).to eq("some_invalid_processor_response")
16
21
  end
17
22
  end
18
23
 
@@ -67,27 +72,27 @@ describe Braintree::UsBankAccountVerification do
67
72
  first = Braintree::UsBankAccountVerification._new(:id => "123")
68
73
  second = Braintree::UsBankAccountVerification._new(:id => "123")
69
74
 
70
- first.should == second
71
- second.should == first
75
+ expect(first).to eq(second)
76
+ expect(second).to eq(first)
72
77
  end
73
78
 
74
79
  it "returns false for verifications with different ids" do
75
80
  first = Braintree::UsBankAccountVerification._new(:id => "123")
76
81
  second = Braintree::UsBankAccountVerification._new(:id => "124")
77
82
 
78
- first.should_not == second
79
- second.should_not == first
83
+ expect(first).not_to eq(second)
84
+ expect(second).not_to eq(first)
80
85
  end
81
86
 
82
87
  it "returns false when comparing to nil" do
83
- Braintree::UsBankAccountVerification._new({}).should_not == nil
88
+ expect(Braintree::UsBankAccountVerification._new({})).not_to eq(nil)
84
89
  end
85
90
 
86
91
  it "returns false when comparing to non-verifications" do
87
92
  same_id_different_object = Object.new
88
93
  def same_id_different_object.id; "123"; end
89
94
  verification = Braintree::UsBankAccountVerification._new(:id => "123")
90
- verification.should_not == same_id_different_object
95
+ expect(verification).not_to eq(same_id_different_object)
91
96
  end
92
97
  end
93
98
  end
@@ -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"].should == "b"
10
- new[:a].should == "b"
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
- hash = {"a" => {"b" => {"c" => "d" }}}
15
- Braintree::Util.symbolize_keys(hash).should == {:a => {:b => {:c => "d"}}}
14
+ hash = {"a" => {"b" => {"c" => "d"}}}
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
- hash = {"a" => ["b" => {"c" => "d" }]}
20
- Braintree::Util.symbolize_keys(hash).should == {:a => [:b => {:c => "d"}]}
19
+ hash = {"a" => ["b" => {"c" => "d"}]}
20
+ expect(Braintree::Util.symbolize_keys(hash)).to eq({:a => [:b => {:c => "d"}]})
21
21
  end
22
22
  end
23
23
 
@@ -44,7 +44,7 @@ describe Braintree::Util do
44
44
  :nested_allowed => "ok",
45
45
  :nested_allowed2 => "also ok",
46
46
  :nested_invalid => "bad"
47
- }
47
+ },
48
48
  )
49
49
  end.to raise_error(ArgumentError, "invalid keys: nested[nested_invalid], top_level_invalid")
50
50
  end
@@ -57,7 +57,7 @@ describe Braintree::Util do
57
57
  :custom_fields => {
58
58
  :custom_allowed => "ok",
59
59
  :custom_allowed2 => "also ok",
60
- }
60
+ },
61
61
  )
62
62
  end.to_not raise_error
63
63
  end
@@ -70,7 +70,7 @@ describe Braintree::Util do
70
70
  :custom_fields => {
71
71
  :bad_nesting => "very bad"
72
72
  }
73
- }
73
+ },
74
74
  )
75
75
  end.to raise_error(ArgumentError, "invalid keys: allowed[custom_fields][bad_nesting]")
76
76
  end
@@ -89,7 +89,7 @@ describe Braintree::Util do
89
89
  :super_deep_allowed => "yep",
90
90
  :real_deep_invalid => "nope"
91
91
  }
92
- }
92
+ },
93
93
  )
94
94
  end.to raise_error(ArgumentError, "invalid keys: nested[deeply_allowed][real_deep_invalid], nested[nested_invalid], top_level_invalid")
95
95
  end
@@ -101,7 +101,7 @@ describe Braintree::Util do
101
101
  :add_ons => {
102
102
  :update => [{:amount => 10}],
103
103
  :add => [{:amount => 5}]
104
- }
104
+ },
105
105
  )
106
106
  end.to_not raise_error
107
107
  end
@@ -113,7 +113,7 @@ describe Braintree::Util do
113
113
  :add_ons => {
114
114
  :update => [{:foo => 10}],
115
115
  :add => [{:bar => 5}]
116
- }
116
+ },
117
117
  )
118
118
  end.to raise_error(ArgumentError, /invalid keys: add_ons\[add\]\[bar\], add_ons\[update\]\[foo\]/)
119
119
  end
@@ -127,7 +127,7 @@ describe Braintree::Util do
127
127
  :custom_fields => {
128
128
  :custom_allowed => "ok",
129
129
  :custom_allowed2 => "also ok",
130
- }
130
+ },
131
131
  )
132
132
  expect(response).to eq(true)
133
133
  end
@@ -147,7 +147,7 @@ describe Braintree::Util do
147
147
  :add_ons => {
148
148
  :update => [{:foo => 10}],
149
149
  :add => [{:bar => 5}]
150
- }
150
+ },
151
151
  )
152
152
  expect(response).to eq(false)
153
153
  end
@@ -165,33 +165,49 @@ describe Braintree::Util do
165
165
  :super_deep_allowed => "yep",
166
166
  :real_deep_invalid => "nope"
167
167
  }
168
- }
168
+ },
169
169
  )
170
170
  expect(response).to eq(false)
171
171
  end
172
172
  end
173
173
 
174
+ describe "self.replace_key" do
175
+ it "replaces the target key with the replacement key" do
176
+ expect(Braintree::Util.replace_key(
177
+ {:a => {:b => "some value"}},
178
+ :b,
179
+ :c)).to eq({:a => {:c => "some value"}})
180
+ end
181
+
182
+ it "returns hash with all of the original keys if the target key does not exist" do
183
+ expect(Braintree::Util.replace_key(
184
+ {:some_key => "some value"},
185
+ :not_found,
186
+ :new_key)).to eq({:some_key => "some value"})
187
+ end
188
+ end
189
+
174
190
  describe "self._flatten_hash_keys" do
175
191
  it "flattens hash keys" do
176
- Braintree::Util._flatten_hash_keys(:nested => {
192
+ expect(Braintree::Util._flatten_hash_keys(:nested => {
177
193
  :nested_allowed => "ok",
178
194
  :nested_allowed2 => "also ok",
179
195
  :nested_invalid => "bad"
180
- }).should == ["nested[nested_allowed2]", "nested[nested_allowed]", "nested[nested_invalid]"]
196
+ })).to eq(["nested[nested_allowed2]", "nested[nested_allowed]", "nested[nested_invalid]"])
181
197
  end
182
198
  end
183
199
 
184
200
  describe "self._flatten_valid_keys" do
185
201
  it "flattens hash keys" do
186
- Braintree::Util._flatten_valid_keys(
187
- [:top_level, {:nested => [:nested_allowed, :nested_allowed2]}]
188
- ).should == ["nested[nested_allowed2]", "nested[nested_allowed]", "top_level"]
202
+ expect(Braintree::Util._flatten_valid_keys(
203
+ [:top_level, {:nested => [:nested_allowed, :nested_allowed2]}],
204
+ )).to eq(["nested[nested_allowed2]", "nested[nested_allowed]", "top_level"])
189
205
  end
190
206
 
191
207
  it "allows wildcards with the :_any_key_ symbol" do
192
- Braintree::Util._flatten_valid_keys(
193
- [:top_level, {:nested => :_any_key_}]
194
- ).should == ["nested[_any_key_]", "top_level"]
208
+ expect(Braintree::Util._flatten_valid_keys(
209
+ [:top_level, {:nested => :_any_key_}],
210
+ )).to eq(["nested[_any_key_]", "top_level"])
195
211
  end
196
212
  end
197
213
 
@@ -199,55 +215,55 @@ describe Braintree::Util do
199
215
  it "deletes the attribute from the hash" do
200
216
  hash = {:foo => ["x"], :bar => :baz}
201
217
  Braintree::Util.extract_attribute_as_array(hash, :foo)
202
- hash.should == {:bar => :baz}
218
+ expect(hash).to eq({:bar => :baz})
203
219
  end
204
220
 
205
221
  it "puts the attribute in an array if it's not an array" do
206
222
  hash = {:foo => "x", :bar => :baz}
207
223
  result = Braintree::Util.extract_attribute_as_array(hash, :foo)
208
- result.should == ["x"]
224
+ expect(result).to eq(["x"])
209
225
  end
210
226
 
211
227
  it "returns the value if it's already an array" do
212
228
  hash = {:foo => ["one", "two"], :bar => :baz}
213
229
  result = Braintree::Util.extract_attribute_as_array(hash, :foo)
214
- result.should == ["one", "two"]
230
+ expect(result).to eq(["one", "two"])
215
231
  end
216
232
 
217
233
  it "returns empty array if the attribute is not in the hash" do
218
234
  hash = {:foo => ["one", "two"], :bar => :baz}
219
235
  result = Braintree::Util.extract_attribute_as_array(hash, :quz)
220
- result.should == []
236
+ expect(result).to eq([])
221
237
  end
222
238
 
223
- it "raises an UnexpectedError if nil data is provided" do
224
- expect do
225
- Braintree::Util.extract_attribute_as_array(nil, :abc)
226
- end.to raise_error(Braintree::UnexpectedError, /Unprocessable entity due to an invalid request/)
227
- end
239
+ it "raises an UnexpectedError if nil data is provided" do
240
+ expect do
241
+ Braintree::Util.extract_attribute_as_array(nil, :abc)
242
+ end.to raise_error(Braintree::UnexpectedError, /Unprocessable entity due to an invalid request/)
243
+ end
228
244
  end
229
245
 
230
246
  describe "self.hash_to_query_string" do
231
247
  it "generates a query string from the hash" do
232
248
  hash = {:foo => {:key_one => "value_one", :key_two => "value_two"}}
233
- Braintree::Util.hash_to_query_string(hash).should == "foo%5Bkey_one%5D=value_one&foo%5Bkey_two%5D=value_two"
249
+ expect(Braintree::Util.hash_to_query_string(hash)).to eq("foo%5Bkey_one%5D=value_one&foo%5Bkey_two%5D=value_two")
234
250
  end
235
251
 
236
252
  it "works for nesting 2 levels deep" do
237
253
  hash = {:foo => {:nested => {:key_one => "value_one", :key_two => "value_two"}}}
238
- Braintree::Util.hash_to_query_string(hash).should == "foo%5Bnested%5D%5Bkey_one%5D=value_one&foo%5Bnested%5D%5Bkey_two%5D=value_two"
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")
239
255
  end
240
256
  end
241
257
 
242
258
  describe "self.parse_query_string" do
243
259
  it "parses the query string" do
244
260
  query_string = "foo=bar%20baz&hash=a1b2c3"
245
- Braintree::Util.parse_query_string(query_string).should == {:foo => "bar baz", :hash => "a1b2c3"}
261
+ expect(Braintree::Util.parse_query_string(query_string)).to eq({:foo => "bar baz", :hash => "a1b2c3"})
246
262
  end
247
263
 
248
264
  it "parses the query string when a key has an empty value" do
249
265
  query_string = "foo=bar%20baz&hash=a1b2c3&vat_number="
250
- Braintree::Util.parse_query_string(query_string).should == {:foo => "bar baz", :hash => "a1b2c3", :vat_number => ""}
266
+ expect(Braintree::Util.parse_query_string(query_string)).to eq({:foo => "bar baz", :hash => "a1b2c3", :vat_number => ""})
251
267
  end
252
268
  end
253
269
 
@@ -259,7 +275,7 @@ describe Braintree::Util do
259
275
  "UNSUPPORTED_CLIENT" => Braintree::UpgradeRequiredError,
260
276
  "RESOURCE_LIMIT" => Braintree::TooManyRequestsError,
261
277
  "INTERNAL" => Braintree::ServerError,
262
- "SERVICE_AVAILABILITY" => Braintree::DownForMaintenanceError,
278
+ "SERVICE_AVAILABILITY" => Braintree::ServiceUnavailableError,
263
279
  }
264
280
 
265
281
  errors.each do |graphQLError, exception|
@@ -321,6 +337,18 @@ describe Braintree::Util do
321
337
  end.to raise_error(Braintree::AuthorizationError)
322
338
  end
323
339
 
340
+ it "raises a NotFoundError if resource is not found" do
341
+ expect do
342
+ Braintree::Util.raise_exception_for_status_code(404)
343
+ end.to raise_error(Braintree::NotFoundError)
344
+ end
345
+
346
+ it "raises a RequestTimeoutError if the request times out" do
347
+ expect do
348
+ Braintree::Util.raise_exception_for_status_code(408)
349
+ end.to raise_error(Braintree::RequestTimeoutError)
350
+ end
351
+
324
352
  it "raises an UpgradeRequired if the client library is EOL'd" do
325
353
  expect do
326
354
  Braintree::Util.raise_exception_for_status_code(426)
@@ -339,10 +367,16 @@ describe Braintree::Util do
339
367
  end.to raise_error(Braintree::ServerError)
340
368
  end
341
369
 
342
- it "raises a DownForMaintenanceError if the server is down for maintenance" do
370
+ it "raises a ServiceUnavailableError if the server is unavailable" do
343
371
  expect do
344
372
  Braintree::Util.raise_exception_for_status_code(503)
345
- end.to raise_error(Braintree::DownForMaintenanceError)
373
+ end.to raise_error(Braintree::ServiceUnavailableError)
374
+ end
375
+
376
+ it "raises a GatewayTimeoutError if the gateway times out" do
377
+ expect do
378
+ Braintree::Util.raise_exception_for_status_code(504)
379
+ end.to raise_error(Braintree::GatewayTimeoutError)
346
380
  end
347
381
 
348
382
  it "raises an UnexpectedError if some other code is returned" do
@@ -354,15 +388,15 @@ describe Braintree::Util do
354
388
 
355
389
  describe "self.to_big_decimal" do
356
390
  it "returns the BigDecimal when given a BigDecimal" do
357
- Braintree::Util.to_big_decimal(BigDecimal("12.34")).should == BigDecimal("12.34")
391
+ expect(Braintree::Util.to_big_decimal(BigDecimal("12.34"))).to eq(BigDecimal("12.34"))
358
392
  end
359
393
 
360
394
  it "returns a BigDecimal when given a string" do
361
- Braintree::Util.to_big_decimal("12.34").should == BigDecimal("12.34")
395
+ expect(Braintree::Util.to_big_decimal("12.34")).to eq(BigDecimal("12.34"))
362
396
  end
363
397
 
364
398
  it "returns nil when given nil" do
365
- Braintree::Util.to_big_decimal(nil).should be_nil
399
+ expect(Braintree::Util.to_big_decimal(nil)).to be_nil
366
400
  end
367
401
 
368
402
  it "blows up when not given a String or BigDecimal" do
@@ -374,13 +408,13 @@ describe Braintree::Util do
374
408
 
375
409
  describe "self.url_encode" do
376
410
  it "url encodes the given text" do
377
- Braintree::Util.url_encode("foo?bar").should == "foo%3Fbar"
411
+ expect(Braintree::Util.url_encode("foo?bar")).to eq("foo%3Fbar")
378
412
  end
379
413
  end
380
414
 
381
415
  describe "self.url_decode" do
382
416
  it "url decodes the given text" do
383
- Braintree::Util.url_decode("foo%3Fbar").should == "foo?bar"
417
+ expect(Braintree::Util.url_decode("foo%3Fbar")).to eq("foo?bar")
384
418
  end
385
419
  end
386
420
  end
@@ -5,27 +5,27 @@ describe Braintree::ValidationErrorCollection do
5
5
  context "blue response" do
6
6
  describe "initialize" do
7
7
  it "builds an error object given an array of hashes" do
8
- hash = {:errors => [{ :attribute => "some model attribute", :code => 1, :message => "bad juju" }]}
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.should == "some model attribute"
12
- error.code.should == 1
13
- error.message.should == "bad juju"
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
 
17
17
  describe "for" do
18
18
  it "provides access to nested errors" do
19
19
  hash = {
20
- :errors => [{ :attribute => "some model attribute", :code => 1, :message => "bad juju" }],
20
+ :errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}],
21
21
  :nested => {
22
- :errors => [{ :attribute => "number", :code => 2, :message => "badder juju"}]
22
+ :errors => [{:attribute => "number", :code => 2, :message => "badder juju"}]
23
23
  }
24
24
  }
25
25
  errors = Braintree::ValidationErrorCollection.new(hash)
26
- errors.for(:nested).on(:number)[0].code.should == 2
27
- errors.for(:nested).on(:number)[0].message.should == "badder juju"
28
- errors.for(:nested).on(:number)[0].attribute.should == "number"
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.should == "#<Braintree::ValidationErrorCollection errors:[(code1) message1, (code2) message2]>"
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
@@ -45,9 +45,9 @@ describe Braintree::ValidationErrorCollection do
45
45
  ],
46
46
  :level1 => {
47
47
  :errors => [{:attribute => "name", :code => "code2", :message => "message2"}]
48
- }
48
+ },
49
49
  )
50
- errors.inspect.should == "#<Braintree::ValidationErrorCollection errors:[(code1) message1], level1:[(code2) message2]>"
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
@@ -60,9 +60,9 @@ describe Braintree::ValidationErrorCollection do
60
60
  :level2 => {
61
61
  :errors => [{:attribute => "name", :code => "code3", :message => "message3"}],
62
62
  }
63
- }
63
+ },
64
64
  )
65
- errors.inspect.should == "#<Braintree::ValidationErrorCollection errors:[(code1) message1], level1:[(code2) message2], level1/level2:[(code3) message3]>"
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.should == 2
77
- errors.on("name").map{ |e| e.code }.should == [1, 2]
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
- { :attribute => "name", :code => 3, :message => "is too long" },
82
+ {:attribute => "name", :code => 3, :message => "is too long"},
83
83
  ])
84
- errors.on(:name).size.should == 1
85
- errors.on(:name)[0].code.should == 3
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,35 +94,35 @@ 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.should == 3
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
101
101
  errors = Braintree::ValidationErrorCollection.new(
102
- :errors => [{ :attribute => "some model attribute", :code => 1, :message => "bad juju" }],
102
+ :errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}],
103
103
  :nested => {
104
- :errors => [{ :attribute => "number", :code => 2, :message => "badder juju"}]
105
- }
104
+ :errors => [{:attribute => "number", :code => 2, :message => "badder juju"}]
105
+ },
106
106
  )
107
- errors.deep_size.should == 2
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
111
111
  errors = Braintree::ValidationErrorCollection.new(
112
112
  :errors => [
113
- { :attribute => "one", :code => 1, :message => "bad juju" },
114
- { :attribute => "two", :code => 1, :message => "bad juju" }],
113
+ {:attribute => "one", :code => 1, :message => "bad juju"},
114
+ {:attribute => "two", :code => 1, :message => "bad juju"}],
115
115
  :nested => {
116
- :errors => [{ :attribute => "three", :code => 2, :message => "badder juju"}],
116
+ :errors => [{:attribute => "three", :code => 2, :message => "badder juju"}],
117
117
  :nested_again => {
118
- :errors => [{ :attribute => "four", :code => 2, :message => "badder juju"}]
118
+ :errors => [{:attribute => "four", :code => 2, :message => "badder juju"}]
119
119
  }
120
120
  },
121
121
  :same_level => {
122
- :errors => [{ :attribute => "five", :code => 2, :message => "badder juju"}],
123
- }
122
+ :errors => [{:attribute => "five", :code => 2, :message => "badder juju"}],
123
+ },
124
124
  )
125
- errors.deep_size.should == 5
125
+ expect(errors.deep_size).to eq(5)
126
126
  end
127
127
  end
128
128
 
@@ -130,19 +130,19 @@ describe Braintree::ValidationErrorCollection do
130
130
  it "returns errors from all levels" do
131
131
  errors = Braintree::ValidationErrorCollection.new(
132
132
  :errors => [
133
- { :attribute => "one", :code => 1, :message => "bad juju" },
134
- { :attribute => "two", :code => 2, :message => "bad juju" }],
133
+ {:attribute => "one", :code => 1, :message => "bad juju"},
134
+ {:attribute => "two", :code => 2, :message => "bad juju"}],
135
135
  :nested => {
136
- :errors => [{ :attribute => "three", :code => 3, :message => "badder juju"}],
136
+ :errors => [{:attribute => "three", :code => 3, :message => "badder juju"}],
137
137
  :nested_again => {
138
- :errors => [{ :attribute => "four", :code => 4, :message => "badder juju"}]
138
+ :errors => [{:attribute => "four", :code => 4, :message => "badder juju"}]
139
139
  }
140
140
  },
141
141
  :same_level => {
142
- :errors => [{ :attribute => "five", :code => 5, :message => "badder juju"}],
143
- }
142
+ :errors => [{:attribute => "five", :code => 5, :message => "badder juju"}],
143
+ },
144
144
  )
145
- errors.deep_errors.map { |e| e.code }.sort.should == [1, 2, 3, 4, 5]
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
 
@@ -150,27 +150,27 @@ describe Braintree::ValidationErrorCollection do
150
150
  it "returns errors on one level" do
151
151
  errors = Braintree::ValidationErrorCollection.new(
152
152
  :errors => [
153
- { :attribute => "one", :code => 1, :message => "bad juju" },
154
- { :attribute => "two", :code => 2, :message => "bad juju" }],
153
+ {:attribute => "one", :code => 1, :message => "bad juju"},
154
+ {:attribute => "two", :code => 2, :message => "bad juju"}],
155
155
  :nested => {
156
- :errors => [{ :attribute => "three", :code => 3, :message => "badder juju"}],
156
+ :errors => [{:attribute => "three", :code => 3, :message => "badder juju"}],
157
157
  :nested_again => {
158
- :errors => [{ :attribute => "four", :code => 4, :message => "badder juju"}]
158
+ :errors => [{:attribute => "four", :code => 4, :message => "badder juju"}]
159
159
  }
160
- }
160
+ },
161
161
  )
162
- errors.shallow_errors.map {|e| e.code}.should == [1, 2]
163
- errors.for(:nested).shallow_errors.map {|e| e.code}.should == [3]
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
167
167
  errors = Braintree::ValidationErrorCollection.new(
168
168
  :errors => [
169
- { :attribute => "one", :code => 1, :message => "bad juju" },
170
- { :attribute => "two", :code => 2, :message => "bad juju" }]
169
+ {:attribute => "one", :code => 1, :message => "bad juju"},
170
+ {:attribute => "two", :code => 2, :message => "bad juju"}],
171
171
  )
172
172
  errors.shallow_errors.pop
173
- errors.shallow_errors.map {|e| e.code}.should == [1, 2]
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.should == "two"
190
- error.code.should == 1
191
- error.message.should == "bad juju"
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.should == 2
214
- errors.for(:nested).on(:nested_attribute)[0].message.should == "badder juju"
215
- errors.for(:nested).on(:nested_attribute)[0].attribute.should == "nested_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.should == 3
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.should == 2
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.should == 5
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.should == [1, 2, 3, 4, 5]
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}.should == [1]
372
- errors.for(:nested).shallow_errors.map {|e| e.code}.should == [2,3]
373
- errors.for(:nested).for(:deeply_nested).shallow_errors.map {|e| e.code}.should == [4]
374
- errors.for(:nested_again).shallow_errors.map {|e| e.code}.should == [5]
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.should == "some model attribute"
8
- error.code.should == 1
9
- error.message.should == "bad juju"
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.should == "#<Braintree::ValidationError (123456) Number is bad juju.>"
16
+ expect(error.inspect).to eq("#<Braintree::ValidationError (123456) Number is bad juju.>")
17
17
  end
18
18
  end
19
19
  end