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
@@ -7,13 +7,16 @@ describe Braintree::Dispute do
7
7
  :amount => "31.00",
8
8
  :amount_disputed => "500.00",
9
9
  :amount_won => "0.00",
10
+ :chargeback_protection_level => nil,
10
11
  :created_at => Time.utc(2009, 3, 9, 10, 50, 39),
12
+ :processor_comments => "forwarded comments",
11
13
  :date_opened => "2009-03-09",
12
14
  :date_won => "2009-04-15",
13
15
  :original_dispute_id => "original_dispute_id",
14
16
  :received_date => "2009-03-09",
15
17
  :reply_by_date => nil,
16
18
  :updated_at => Time.utc(2009, 3, 9, 10, 50, 39),
19
+ :pre_dispute_program => Braintree::Dispute::PreDisputeProgram::None,
17
20
  :evidence => [
18
21
  {
19
22
  comment: nil,
@@ -41,10 +44,18 @@ describe Braintree::Dispute do
41
44
  :amount => "31.00",
42
45
  :id => "open_disputed_transaction",
43
46
  :created_at => Time.utc(2009, 2, 9, 12, 59, 59),
47
+ :installment_count => nil,
44
48
  :order_id => nil,
45
49
  :purchase_order_number => "po",
46
50
  :payment_instrument_subtype => "Visa",
47
- }
51
+ },
52
+ :paypal_messages => [
53
+ {
54
+ :message => "message",
55
+ :sender => "seller",
56
+ :sent_at => Time.utc(2009, 3, 9, 10, 50, 39),
57
+ }
58
+ ]
48
59
  }
49
60
  end
50
61
 
@@ -67,9 +78,9 @@ describe Braintree::Dispute do
67
78
  end
68
79
 
69
80
  it "does not raise an exception if the id is a fixnum" do
70
- Braintree::Http.stub(:new).and_return double.as_null_object
71
- Braintree::Dispute.stub(:_new).and_return nil
72
- Braintree::ErrorResult.stub(:new).and_return nil
81
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
82
+ allow(Braintree::Dispute).to receive(:_new).and_return nil
83
+ allow(Braintree::ErrorResult).to receive(:new).and_return nil
73
84
 
74
85
  expect do
75
86
  Braintree::Dispute.public_send(method_name, 8675309)
@@ -98,8 +109,8 @@ describe Braintree::Dispute do
98
109
  end
99
110
 
100
111
  it "does not raise an exception if the dispute_id is a fixnum" do
101
- Braintree::Http.stub(:new).and_return double.as_null_object
102
- Braintree::Dispute.stub(:_new).and_return nil
112
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
113
+ allow(Braintree::Dispute).to receive(:_new).and_return nil
103
114
  expect do
104
115
  Braintree::Dispute.add_file_evidence(8675309, "doc_upload_id")
105
116
  end.to_not raise_error
@@ -124,8 +135,8 @@ describe Braintree::Dispute do
124
135
  end
125
136
 
126
137
  it "does not raise an exception if the document_upload_id is a fixnum" do
127
- Braintree::Http.stub(:new).and_return double.as_null_object
128
- Braintree::Dispute.stub(:_new).and_return nil
138
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
139
+ allow(Braintree::Dispute).to receive(:_new).and_return nil
129
140
  expect do
130
141
  Braintree::Dispute.add_file_evidence("dispute_id", 8675309)
131
142
  end.to_not raise_error
@@ -133,23 +144,23 @@ describe Braintree::Dispute do
133
144
 
134
145
  describe "with optional params" do
135
146
  it "does not raise an exception if the optional parameters are valid" do
136
- Braintree::Http.stub(:new).and_return double.as_null_object
147
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
137
148
  expect do
138
- Braintree::Dispute.add_file_evidence("dispute_id", { category: "GENERAL", document_id: "document_id" })
149
+ Braintree::Dispute.add_file_evidence("dispute_id", {category: "GENERAL", document_id: "document_id"})
139
150
  end.to_not raise_error
140
151
  end
141
152
 
142
153
  it "raises an exception if the optional params contain invalid keys" do
143
154
  expect do
144
- Braintree::Dispute.add_file_evidence("dispute_id", { random_param: "" })
155
+ Braintree::Dispute.add_file_evidence("dispute_id", {random_param: ""})
145
156
  end.to raise_error(ArgumentError)
146
157
  end
147
158
 
148
159
  it "raises an exception if the param tag is not a string" do
149
- Braintree::Http.stub(:new).and_return double.as_null_object
160
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
150
161
 
151
162
  expect do
152
- Braintree::Dispute.add_file_evidence("dispute_id", { category: 3, document_id: "document_id" })
163
+ Braintree::Dispute.add_file_evidence("dispute_id", {category: 3, document_id: "document_id"})
153
164
  end.to raise_error(ArgumentError)
154
165
  end
155
166
  end
@@ -175,8 +186,8 @@ describe Braintree::Dispute do
175
186
  end
176
187
 
177
188
  it "does not raise an exception if the id is a fixnum" do
178
- Braintree::Http.stub(:new).and_return double.as_null_object
179
- Braintree::Dispute.stub(:_new).and_return nil
189
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
190
+ allow(Braintree::Dispute).to receive(:_new).and_return nil
180
191
  expect do
181
192
  Braintree::Dispute.add_text_evidence(8675309, "text evidence")
182
193
  end.to_not raise_error
@@ -196,40 +207,33 @@ describe Braintree::Dispute do
196
207
 
197
208
  describe "with optional params" do
198
209
  it "does not raise an exception if the optional parameters are valid" do
199
- Braintree::Http.stub(:new).and_return double.as_null_object
200
- expect do
201
- Braintree::Dispute.add_text_evidence("dispute_id", { content: "a", tag: "", sequence_number: 3 })
202
- end.to_not raise_error
203
- end
204
-
205
- it "does not raise an exception if the category parameter is provided" do
206
- Braintree::Http.stub(:new).and_return double.as_null_object
210
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
207
211
  expect do
208
- Braintree::Dispute.add_text_evidence("dispute_id", { content: "a", category: "", sequence_number: 3 })
212
+ Braintree::Dispute.add_text_evidence("dispute_id", {content: "a", category: "", sequence_number: 3})
209
213
  end.to_not raise_error
210
214
  end
211
215
 
212
216
  it "raises an exception if the optional params contain invalid keys" do
213
217
  expect do
214
- Braintree::Dispute.add_text_evidence("dispute_id", { random_param: "" })
218
+ Braintree::Dispute.add_text_evidence("dispute_id", {random_param: ""})
215
219
  end.to raise_error(ArgumentError)
216
220
  end
217
221
 
218
222
  it "raises an exception if sequence_number is provided and not an integer" do
219
223
  expect do
220
- Braintree::Dispute.add_text_evidence("dispute_id", { sequence_number: "abc" })
224
+ Braintree::Dispute.add_text_evidence("dispute_id", {sequence_number: "abc"})
221
225
  end.to raise_error(ArgumentError)
222
226
  end
223
227
 
224
228
  it "raises an exception if the param tag is not a string" do
225
229
  expect do
226
- Braintree::Dispute.add_text_evidence("dispute_id", { tag: 3 })
230
+ Braintree::Dispute.add_text_evidence("dispute_id", {tag: 3})
227
231
  end.to raise_error(ArgumentError)
228
232
  end
229
233
 
230
234
  it "raises an exception if the param category is not a string" do
231
235
  expect do
232
- Braintree::Dispute.add_text_evidence("dispute_id", { category: 3 })
236
+ Braintree::Dispute.add_text_evidence("dispute_id", {category: 3})
233
237
  end.to raise_error(ArgumentError)
234
238
  end
235
239
  end
@@ -277,8 +281,47 @@ describe Braintree::Dispute do
277
281
  it "converts string amount_dispute and amount_won" do
278
282
  dispute = Braintree::Dispute._new(attributes)
279
283
 
280
- dispute.amount_disputed.should == 500.0
281
- dispute.amount_won.should == 0.0
284
+ expect(dispute.amount_disputed).to eq(500.0)
285
+ expect(dispute.amount_won).to eq(0.0)
286
+ end
287
+
288
+ it "returns 'Effortless Chargeback Protection tool' when initial chargeback_protection_level is effortless" do
289
+ attributes.merge!(:chargeback_protection_level => Braintree::Dispute::ChargebackProtectionLevel::Effortless)
290
+ dispute = Braintree::Dispute._new(attributes)
291
+
292
+ expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::Effortless)
293
+ expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::EffortlessCBP)
294
+ end
295
+
296
+ it "returns 'Chargeback Protection tool' when initial chargeback_protection_level is standard" do
297
+ attributes.merge!(:chargeback_protection_level => Braintree::Dispute::ChargebackProtectionLevel::Standard)
298
+ dispute = Braintree::Dispute._new(attributes)
299
+
300
+ expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::Standard)
301
+ expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::StandardCBP)
302
+ end
303
+
304
+ it "returns 'No Protection' when initial chargeback_protection_level is nil" do
305
+ dispute = Braintree::Dispute._new(attributes)
306
+
307
+ expect(dispute.chargeback_protection_level).to eq(nil)
308
+ expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::NoProtection)
309
+ end
310
+
311
+ it "returns 'No Protection' when initial chargeback_protection_level is empty" do
312
+ attributes.merge!(:chargeback_protection_level => "")
313
+ dispute = Braintree::Dispute._new(attributes)
314
+
315
+ expect(dispute.chargeback_protection_level).to eq("")
316
+ expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::NoProtection)
317
+ end
318
+
319
+ it "returns 'No Protection' when initial chargeback_protection_level is not_protected" do
320
+ attributes.merge!(:chargeback_protection_level => Braintree::Dispute::ChargebackProtectionLevel::NotProtected)
321
+ dispute = Braintree::Dispute._new(attributes)
322
+
323
+ expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::NotProtected)
324
+ expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::NoProtection)
282
325
  end
283
326
 
284
327
  [
@@ -293,62 +336,74 @@ describe Braintree::Dispute do
293
336
 
294
337
  dispute = Braintree::Dispute._new(attributes)
295
338
 
296
- dispute.send(field).should == nil
339
+ expect(dispute.send(field)).to eq(nil)
297
340
  end
298
341
  end
299
342
 
300
343
  it "converts date_opened, date_won, reply_by_date, received_date from String to Date" do
301
344
  dispute = Braintree::Dispute._new(attributes.merge(:reply_by_date => "2009-03-14"))
302
345
 
303
- dispute.date_opened.should == Date.new(2009, 3, 9)
304
- dispute.date_won.should == Date.new(2009, 4, 15)
305
- dispute.received_date.should == Date.new(2009, 3, 9)
306
- dispute.reply_by_date.should == Date.new(2009, 3, 14)
346
+ expect(dispute.date_opened).to eq(Date.new(2009, 3, 9))
347
+ expect(dispute.date_won).to eq(Date.new(2009, 4, 15))
348
+ expect(dispute.received_date).to eq(Date.new(2009, 3, 9))
349
+ expect(dispute.reply_by_date).to eq(Date.new(2009, 3, 14))
307
350
  end
308
351
 
309
352
  it "converts transaction hash into a Dispute::TransactionDetails object first" do
310
353
  dispute = Braintree::Dispute._new(attributes)
311
354
 
312
- dispute.transaction_details.id.should == "open_disputed_transaction"
313
- dispute.transaction_details.amount.should == 31.00
355
+ expect(dispute.transaction_details.id).to eq("open_disputed_transaction")
356
+ expect(dispute.transaction_details.amount).to eq(31.00)
314
357
  end
315
358
 
316
359
  it "converts transaction hash into a Dispute::Transaction object" do
317
360
  dispute = Braintree::Dispute._new(attributes)
318
361
 
319
- dispute.transaction.amount.should == 31.00
320
- dispute.transaction.id.should == "open_disputed_transaction"
321
- dispute.transaction.order_id.should == nil
322
- dispute.transaction.purchase_order_number.should == "po"
323
- dispute.transaction.payment_instrument_subtype.should == "Visa"
362
+ expect(dispute.transaction.amount).to eq(31.00)
363
+ expect(dispute.transaction.id).to eq("open_disputed_transaction")
364
+ expect(dispute.transaction.created_at).to eq(Time.utc(2009, 2, 9, 12, 59, 59))
365
+ expect(dispute.transaction.installment_count).to eq(nil)
366
+ expect(dispute.transaction.order_id).to eq(nil)
367
+ expect(dispute.transaction.purchase_order_number).to eq("po")
368
+ expect(dispute.transaction.payment_instrument_subtype).to eq("Visa")
324
369
  end
325
370
 
326
- it "converts status_history hash into an array of Dispute::HistoryEvent objects" do
371
+ it "converts status_history hash into an array of Dispute::StatusHistory objects" do
327
372
  dispute = Braintree::Dispute._new(attributes)
328
373
 
329
- dispute.status_history.length.should == 1
374
+ expect(dispute.status_history.length).to eq(1)
330
375
  status_history_1 = dispute.status_history.first
331
- status_history_1.status.should == Braintree::Dispute::Status::Open
332
- status_history_1.timestamp.should == Time.utc(2009, 3, 9, 10, 50, 39)
376
+ expect(status_history_1.status).to eq(Braintree::Dispute::Status::Open)
377
+ expect(status_history_1.timestamp).to eq(Time.utc(2009, 3, 9, 10, 50, 39))
333
378
  end
334
379
 
335
380
  it "converts evidence hash into an array of Dispute::Evidence objects" do
336
381
  dispute = Braintree::Dispute._new(attributes)
337
382
 
338
- dispute.evidence.length.should ==2
383
+ expect(dispute.evidence.length).to eq(2)
339
384
  evidence1 = dispute.evidence.first
340
- evidence1.comment.should == nil
341
- evidence1.created_at.should == Time.utc(2009, 3, 10, 12, 5, 20)
342
- evidence1.id.should == "evidence1"
343
- evidence1.sent_to_processor_at.should == nil
344
- evidence1.url.should == "url_of_file_evidence"
385
+ expect(evidence1.comment).to eq(nil)
386
+ expect(evidence1.created_at).to eq(Time.utc(2009, 3, 10, 12, 5, 20))
387
+ expect(evidence1.id).to eq("evidence1")
388
+ expect(evidence1.sent_to_processor_at).to eq(nil)
389
+ expect(evidence1.url).to eq("url_of_file_evidence")
345
390
 
346
391
  evidence2 = dispute.evidence.last
347
- evidence2.comment.should == "text evidence"
348
- evidence2.created_at.should == Time.utc(2009, 3, 10, 12, 5, 21)
349
- evidence2.id.should == "evidence2"
350
- evidence2.sent_to_processor_at.should == Date.new(2009, 3, 13)
351
- evidence2.url.should == nil
392
+ expect(evidence2.comment).to eq("text evidence")
393
+ expect(evidence2.created_at).to eq(Time.utc(2009, 3, 10, 12, 5, 21))
394
+ expect(evidence2.id).to eq("evidence2")
395
+ expect(evidence2.sent_to_processor_at).to eq(Date.new(2009, 3, 13))
396
+ expect(evidence2.url).to eq(nil)
397
+ end
398
+
399
+ it "converts paypal_messages hash into an array of Dispute::PayPalMessage objects" do
400
+ dispute = Braintree::Dispute._new(attributes)
401
+
402
+ expect(dispute.paypal_messages.length).to eq(1)
403
+ paypal_message_1 = dispute.paypal_messages.first
404
+ expect(paypal_message_1.message).to eq("message")
405
+ expect(paypal_message_1.sender).to eq("seller")
406
+ expect(paypal_message_1.sent_at).to eq(Time.utc(2009, 3, 9, 10, 50, 39))
352
407
  end
353
408
 
354
409
  it "handles nil evidence" do
@@ -356,15 +411,30 @@ describe Braintree::Dispute do
356
411
 
357
412
  dispute = Braintree::Dispute._new(attributes)
358
413
 
359
- dispute.evidence.should == nil
414
+ expect(dispute.evidence).to eq(nil)
415
+ end
416
+
417
+ it "handles nil paypal_messages" do
418
+ attributes.delete(:paypal_messages)
419
+
420
+ dispute = Braintree::Dispute._new(attributes)
421
+
422
+ expect(dispute.paypal_messages).to eq(nil)
360
423
  end
361
424
 
362
425
  it "sets the older webhook fields for backwards compatibility" do
363
426
  dispute = Braintree::Dispute._new(attributes)
364
427
 
365
- dispute.amount.should == 31.00
366
- dispute.date_opened.should == Date.new(2009, 3, 9)
367
- dispute.date_won.should == Date.new(2009, 4, 15)
428
+ expect(dispute.amount).to eq(31.00)
429
+ expect(dispute.date_opened).to eq(Date.new(2009, 3, 9))
430
+ expect(dispute.date_won).to eq(Date.new(2009, 4, 15))
431
+ end
432
+
433
+ it "returns pre_dispute_program value" do
434
+ attributes.merge!(:pre_dispute_program => Braintree::Dispute::PreDisputeProgram::VisaRdr)
435
+ dispute = Braintree::Dispute._new(attributes)
436
+
437
+ expect(dispute.pre_dispute_program).to eq(Braintree::Dispute::PreDisputeProgram::VisaRdr)
368
438
  end
369
439
  end
370
440
 
@@ -373,21 +443,29 @@ describe Braintree::Dispute do
373
443
  first = Braintree::Dispute._new(attributes)
374
444
  second = Braintree::Dispute._new(attributes)
375
445
 
376
- first.should == second
377
- second.should == first
446
+ expect(first).to eq(second)
447
+ expect(second).to eq(first)
378
448
  end
379
449
 
380
450
  it "returns false when given a dispute with a different id" do
381
451
  first = Braintree::Dispute._new(attributes)
382
452
  second = Braintree::Dispute._new(attributes.merge(:id => "1234"))
383
453
 
384
- first.should_not == second
385
- second.should_not == first
454
+ expect(first).not_to eq(second)
455
+ expect(second).not_to eq(first)
386
456
  end
387
457
 
388
458
  it "returns false when not given a dispute" do
389
459
  dispute = Braintree::Dispute._new(attributes)
390
- dispute.should_not == "not a dispute"
460
+ expect(dispute).not_to eq("not a dispute")
461
+ end
462
+ end
463
+
464
+ describe "comments" do
465
+ let(:dispute) { Braintree::Dispute._new(attributes) }
466
+
467
+ it "#processor_comments" do
468
+ expect(dispute.processor_comments).to eq(attributes[:processor_comments])
391
469
  end
392
470
  end
393
471
 
@@ -5,11 +5,11 @@ describe Braintree::DocumentUpload do
5
5
  it "sets attributes" do
6
6
  response = {:size => 555, :kind => "evidence_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
7
7
  document_upload = Braintree::DocumentUpload._new(response)
8
- document_upload.id.should == "my_id"
9
- document_upload.size.should == 555
10
- document_upload.name.should == "up_file.pdf"
11
- document_upload.content_type.should == "application/pdf"
12
- document_upload.kind.should == Braintree::DocumentUpload::Kind::EvidenceDocument
8
+ expect(document_upload.id).to eq("my_id")
9
+ expect(document_upload.size).to eq(555)
10
+ expect(document_upload.name).to eq("up_file.pdf")
11
+ expect(document_upload.content_type).to eq("application/pdf")
12
+ expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::EvidenceDocument)
13
13
  end
14
14
  end
15
15
 
@@ -17,19 +17,19 @@ describe Braintree::DocumentUpload do
17
17
  it "sets identity document" do
18
18
  response = {:size => 555, :kind => "identity_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
19
19
  document_upload = Braintree::DocumentUpload._new(response)
20
- document_upload.kind.should == Braintree::DocumentUpload::Kind::IdentityDocument
20
+ expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::IdentityDocument)
21
21
  end
22
22
 
23
23
  it "sets evidence document" do
24
24
  response = {:size => 555, :kind => "evidence_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
25
25
  document_upload = Braintree::DocumentUpload._new(response)
26
- document_upload.kind.should == Braintree::DocumentUpload::Kind::EvidenceDocument
26
+ expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::EvidenceDocument)
27
27
  end
28
28
 
29
29
  it "sets payout invoice document" do
30
30
  response = {:size => 555, :kind => "payout_invoice_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
31
31
  document_upload = Braintree::DocumentUpload._new(response)
32
- document_upload.kind.should == Braintree::DocumentUpload::Kind::PayoutInvoiceDocument
32
+ expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::PayoutInvoiceDocument)
33
33
  end
34
34
  end
35
35
  end
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::EnrichedCustomerData do
4
+ describe "self.new" do
5
+ it "is protected" do
6
+ expect do
7
+ Braintree::EnrichedCustomerData.new
8
+ end.to raise_error(NoMethodError, /protected method .new/)
9
+ end
10
+ end
11
+
12
+ describe "self._new" do
13
+ it "initializes the object with the appropriate attributes set" do
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
+ }
22
+ params = {
23
+ fields_updated: ["username"],
24
+ profile_data: {
25
+ username: "a-username",
26
+ first_name: "a-first-name",
27
+ last_name: "a-last-name",
28
+ phone_number: "a-phone-number",
29
+ email: "a-email",
30
+ billing_address: address,
31
+ shipping_address: address,
32
+ },
33
+ }
34
+
35
+ payment_method_customer_data_updated = Braintree::EnrichedCustomerData._new(params)
36
+
37
+ expect(payment_method_customer_data_updated.profile_data).to be_a(Braintree::VenmoProfileData)
38
+ expect(payment_method_customer_data_updated.fields_updated).to eq(["username"])
39
+ end
40
+ end
41
+ end
@@ -5,12 +5,12 @@ describe Braintree::ErrorResult do
5
5
  it "ignores data other than params, errors, and message" do
6
6
  # so that we can add more data into the response in the future without breaking the client lib
7
7
  expect do
8
- result = Braintree::ErrorResult.new(
8
+ Braintree::ErrorResult.new(
9
9
  :gateway,
10
10
  :params => "params",
11
11
  :errors => {:errors => []},
12
12
  :extra => "is ignored",
13
- :message => "foo bar"
13
+ :message => "foo bar",
14
14
  )
15
15
  end.to_not raise_error
16
16
  end
@@ -27,7 +27,7 @@ describe Braintree::ErrorResult do
27
27
  }
28
28
  }
29
29
  result = Braintree::ErrorResult.new(:gateway, :params => "params", :errors => errors)
30
- result.inspect.should == "#<Braintree::ErrorResult params:{...} errors:<level1:[(code1) message], level1/level2:[(code2) message2]>>"
30
+ expect(result.inspect).to eq("#<Braintree::ErrorResult params:{...} errors:<level1:[(code1) message], level1/level2:[(code2) message2]>>")
31
31
  end
32
32
 
33
33
  it "includes the credit_card_verification if there is one" do
@@ -36,9 +36,9 @@ describe Braintree::ErrorResult do
36
36
  :params => "params",
37
37
  :errors => {},
38
38
  :verification => {},
39
- :transaction => nil
39
+ :transaction => nil,
40
40
  )
41
- result.inspect.should include("credit_card_verification: #<Braintree::CreditCardVerification status: ")
41
+ expect(result.inspect).to include("credit_card_verification: #<Braintree::CreditCardVerification amount: ")
42
42
  end
43
43
 
44
44
  it "does not include the credit_card_verification if there isn't one" do
@@ -47,9 +47,9 @@ describe Braintree::ErrorResult do
47
47
  :params => "params",
48
48
  :errors => {},
49
49
  :verification => nil,
50
- :transaction => nil
50
+ :transaction => nil,
51
51
  )
52
- result.inspect.should_not include("credit_card_verification")
52
+ expect(result.inspect).not_to include("credit_card_verification")
53
53
  end
54
54
 
55
55
  it "includes the transaction if there is one" do
@@ -58,9 +58,9 @@ describe Braintree::ErrorResult do
58
58
  :params => "params",
59
59
  :errors => {},
60
60
  :verification => nil,
61
- :transaction => {}
61
+ :transaction => {},
62
62
  )
63
- result.inspect.should include("transaction: #<Braintree::Transaction id: ")
63
+ expect(result.inspect).to include("transaction: #<Braintree::Transaction id: ")
64
64
  end
65
65
 
66
66
  it "does not include the transaction if there isn't one" do
@@ -69,9 +69,9 @@ describe Braintree::ErrorResult do
69
69
  :params => "params",
70
70
  :errors => {},
71
71
  :verification => nil,
72
- :transaction => nil
72
+ :transaction => nil,
73
73
  )
74
- result.inspect.should_not include("transaction")
74
+ expect(result.inspect).not_to include("transaction")
75
75
  end
76
76
  end
77
77
  end
@@ -4,26 +4,26 @@ describe Braintree::Errors do
4
4
  describe "for" do
5
5
  it "accesses errors for the given scope" do
6
6
  errors = Braintree::Errors.new(
7
- :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
7
+ :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
8
8
  )
9
- errors.for(:level1).size.should == 1
10
- errors.for(:level1)[0].code.should == "code1"
9
+ expect(errors.for(:level1).size).to eq(1)
10
+ expect(errors.for(:level1)[0].code).to eq("code1")
11
11
  end
12
12
 
13
13
  it "returns nil if there are no errors at the given scope" do
14
14
  errors = Braintree::Errors.new(
15
- :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
15
+ :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
16
16
  )
17
- errors.for(:no_errors_here).should == nil
17
+ expect(errors.for(:no_errors_here)).to eq(nil)
18
18
  end
19
19
  end
20
20
 
21
21
  describe "inspect" do
22
22
  it "is better than the default inspect" do
23
23
  errors = Braintree::Errors.new(
24
- :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
24
+ :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
25
25
  )
26
- errors.inspect.should == "#<Braintree::Errors level1:[(code1) message]>"
26
+ expect(errors.inspect).to eq("#<Braintree::Errors level1:[(code1) message]>")
27
27
  end
28
28
 
29
29
  it "shows errors 2 levels deep" do
@@ -33,9 +33,9 @@ describe Braintree::Errors do
33
33
  :level2 => {
34
34
  :errors => [{:code => "code2", :attribute => "attr2", :message => "message2"}],
35
35
  }
36
- }
36
+ },
37
37
  )
38
- errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2]>"
38
+ expect(errors.inspect).to eq("#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2]>")
39
39
  end
40
40
 
41
41
  it "shows errors 3 levels deep" do
@@ -48,9 +48,9 @@ describe Braintree::Errors do
48
48
  :errors => [{:code => "code3", :attribute => "attr3", :message => "message3"}],
49
49
  }
50
50
  }
51
- }
51
+ },
52
52
  )
53
- errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2], level1/level2/level3:[(code3) message3]>"
53
+ expect(errors.inspect).to eq("#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2], level1/level2/level3:[(code3) message3]>")
54
54
  end
55
55
  end
56
56
 
@@ -65,18 +65,18 @@ describe Braintree::Errors do
65
65
  {:code => "3", :attribute => "attr3", :message => "message3"}
66
66
  ],
67
67
  }
68
- }
68
+ },
69
69
  )
70
- errors.map { |e| e.code }.sort.should == %w[1 2 3]
70
+ expect(errors.map { |e| e.code }.sort).to eq(%w[1 2 3])
71
71
  end
72
72
  end
73
73
 
74
74
  describe "size" do
75
75
  it "returns the number of validation errors at the first level if only has one level" do
76
76
  errors = Braintree::Errors.new(
77
- :level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]}
77
+ :level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]},
78
78
  )
79
- errors.size.should == 1
79
+ expect(errors.size).to eq(1)
80
80
  end
81
81
 
82
82
  it "returns the total number of validation errors in the hierarchy" do
@@ -89,9 +89,9 @@ describe Braintree::Errors do
89
89
  {:code => "3", :attribute => "attr3", :message => "message3"}
90
90
  ],
91
91
  }
92
- }
92
+ },
93
93
  )
94
- errors.size.should == 3
94
+ expect(errors.size).to eq(3)
95
95
  end
96
96
  end
97
97
  end