stripe 3.3.2 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +20 -0
  4. data/.rubocop_todo.yml +62 -0
  5. data/.travis.yml +1 -1
  6. data/Gemfile +19 -12
  7. data/History.txt +10 -0
  8. data/README.md +5 -1
  9. data/Rakefile +8 -5
  10. data/VERSION +1 -1
  11. data/bin/stripe-console +2 -2
  12. data/lib/stripe.rb +72 -74
  13. data/lib/stripe/account.rb +15 -17
  14. data/lib/stripe/alipay_account.rb +10 -7
  15. data/lib/stripe/api_operations/create.rb +1 -1
  16. data/lib/stripe/api_operations/delete.rb +1 -1
  17. data/lib/stripe/api_operations/list.rb +2 -2
  18. data/lib/stripe/api_operations/request.rb +5 -12
  19. data/lib/stripe/api_operations/save.rb +6 -6
  20. data/lib/stripe/api_resource.rb +7 -9
  21. data/lib/stripe/apple_pay_domain.rb +2 -2
  22. data/lib/stripe/application_fee.rb +5 -5
  23. data/lib/stripe/application_fee_refund.rb +5 -5
  24. data/lib/stripe/balance.rb +1 -1
  25. data/lib/stripe/balance_transaction.rb +2 -2
  26. data/lib/stripe/bank_account.rb +7 -7
  27. data/lib/stripe/bitcoin_receiver.rb +4 -2
  28. data/lib/stripe/bitcoin_transaction.rb +3 -1
  29. data/lib/stripe/card.rb +5 -5
  30. data/lib/stripe/charge.rb +18 -18
  31. data/lib/stripe/country_spec.rb +2 -2
  32. data/lib/stripe/coupon.rb +1 -1
  33. data/lib/stripe/customer.rb +23 -23
  34. data/lib/stripe/dispute.rb +3 -3
  35. data/lib/stripe/ephemeral_key.rb +4 -4
  36. data/lib/stripe/errors.rb +4 -4
  37. data/lib/stripe/event.rb +1 -1
  38. data/lib/stripe/file_upload.rb +5 -5
  39. data/lib/stripe/invoice.rb +7 -7
  40. data/lib/stripe/invoice_item.rb +1 -1
  41. data/lib/stripe/invoice_line_item.rb +1 -1
  42. data/lib/stripe/list_object.rb +14 -18
  43. data/lib/stripe/login_link.rb +3 -3
  44. data/lib/stripe/oauth.rb +15 -13
  45. data/lib/stripe/order.rb +5 -5
  46. data/lib/stripe/order_return.rb +1 -1
  47. data/lib/stripe/payout.rb +3 -3
  48. data/lib/stripe/plan.rb +1 -1
  49. data/lib/stripe/product.rb +1 -1
  50. data/lib/stripe/recipient.rb +3 -2
  51. data/lib/stripe/recipient_transfer.rb +1 -2
  52. data/lib/stripe/refund.rb +1 -1
  53. data/lib/stripe/reversal.rb +5 -5
  54. data/lib/stripe/singleton_api_resource.rb +3 -3
  55. data/lib/stripe/sku.rb +1 -1
  56. data/lib/stripe/source.rb +13 -10
  57. data/lib/stripe/stripe_client.rb +149 -169
  58. data/lib/stripe/stripe_object.rb +77 -76
  59. data/lib/stripe/subscription.rb +5 -5
  60. data/lib/stripe/subscription_item.rb +2 -2
  61. data/lib/stripe/three_d_secure.rb +1 -1
  62. data/lib/stripe/token.rb +1 -1
  63. data/lib/stripe/transfer.rb +3 -3
  64. data/lib/stripe/util.rb +77 -62
  65. data/lib/stripe/version.rb +1 -1
  66. data/lib/stripe/webhook.rb +14 -10
  67. data/stripe.gemspec +14 -14
  68. data/test/stripe/account_test.rb +69 -81
  69. data/test/stripe/alipay_account_test.rb +19 -1
  70. data/test/stripe/api_operations_test.rb +7 -7
  71. data/test/stripe/api_resource_test.rb +224 -260
  72. data/test/stripe/apple_pay_domain_test.rb +8 -8
  73. data/test/stripe/application_fee_refund_test.rb +8 -8
  74. data/test/stripe/application_fee_test.rb +3 -3
  75. data/test/stripe/balance_test.rb +2 -2
  76. data/test/stripe/bank_account_test.rb +9 -11
  77. data/test/stripe/charge_test.rb +11 -11
  78. data/test/stripe/country_spec_test.rb +4 -4
  79. data/test/stripe/coupon_test.rb +10 -10
  80. data/test/stripe/customer_card_test.rb +11 -15
  81. data/test/stripe/customer_test.rb +26 -27
  82. data/test/stripe/dispute_test.rb +8 -8
  83. data/test/stripe/ephemeral_key_test.rb +14 -14
  84. data/test/stripe/errors_test.rb +2 -2
  85. data/test/stripe/file_upload_test.rb +26 -28
  86. data/test/stripe/invoice_item_test.rb +14 -14
  87. data/test/stripe/invoice_line_item_test.rb +1 -1
  88. data/test/stripe/invoice_test.rb +37 -37
  89. data/test/stripe/list_object_test.rb +60 -76
  90. data/test/stripe/login_link_test.rb +14 -14
  91. data/test/stripe/oauth_test.rb +42 -50
  92. data/test/stripe/order_return_test.rb +5 -5
  93. data/test/stripe/order_test.rb +12 -12
  94. data/test/stripe/payout_test.rb +9 -9
  95. data/test/stripe/plan_test.rb +9 -9
  96. data/test/stripe/product_test.rb +8 -8
  97. data/test/stripe/recipient_test.rb +9 -10
  98. data/test/stripe/refund_test.rb +9 -9
  99. data/test/stripe/reversal_test.rb +10 -10
  100. data/test/stripe/sku_test.rb +8 -8
  101. data/test/stripe/source_test.rb +14 -16
  102. data/test/stripe/stripe_client_test.rb +235 -266
  103. data/test/stripe/stripe_object_test.rb +163 -147
  104. data/test/stripe/stripe_response_test.rb +4 -3
  105. data/test/stripe/subscription_item_test.rb +11 -11
  106. data/test/stripe/subscription_test.rb +14 -14
  107. data/test/stripe/three_d_secure_test.rb +2 -2
  108. data/test/stripe/transfer_test.rb +8 -8
  109. data/test/stripe/util_test.rb +59 -57
  110. data/test/stripe/webhook_test.rb +18 -16
  111. data/test/stripe_test.rb +4 -4
  112. data/test/test_data.rb +26 -26
  113. data/test/test_helper.rb +29 -25
  114. metadata +6 -10
  115. data/test/stripe/bitcoin_receiver_test.rb +0 -67
  116. data/test/stripe/bitcoin_transaction_test.rb +0 -19
  117. data/test/stripe/recipient_card_test.rb +0 -44
@@ -1,31 +1,31 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class ApplePayDomainTest < Test::Unit::TestCase
5
5
  should "be listable" do
6
6
  domains = Stripe::ApplePayDomain.list
7
7
  assert_requested :get, "#{Stripe.api_base}/v1/apple_pay/domains"
8
- assert domains.data.kind_of?(Array)
9
- assert domains.data[0].kind_of?(Stripe::ApplePayDomain)
8
+ assert domains.data.is_a?(Array)
9
+ assert domains.data[0].is_a?(Stripe::ApplePayDomain)
10
10
  end
11
11
 
12
12
  should "be retrievable" do
13
13
  domain = Stripe::ApplePayDomain.retrieve("apwc_123")
14
- assert_requested :get, "#{Stripe.api_base}/v1/apple_pay/domains/apwc_123"
15
- assert domain.kind_of?(Stripe::ApplePayDomain)
14
+ assert_requested :get, "#{Stripe.api_base}/v1/apple_pay/domains/apwc_123"
15
+ assert domain.is_a?(Stripe::ApplePayDomain)
16
16
  end
17
17
 
18
18
  should "be creatable" do
19
- domain = Stripe::ApplePayDomain.create(:domain_name => "example.com")
19
+ domain = Stripe::ApplePayDomain.create(domain_name: "example.com")
20
20
  assert_requested :post, "#{Stripe.api_base}/v1/apple_pay/domains"
21
- assert domain.kind_of?(Stripe::ApplePayDomain)
21
+ assert domain.is_a?(Stripe::ApplePayDomain)
22
22
  end
23
23
 
24
24
  should "be deletable" do
25
25
  domain = Stripe::ApplePayDomain.retrieve("apwc_123")
26
26
  domain = domain.delete
27
27
  assert_requested :delete, "#{Stripe.api_base}/v1/apple_pay/domains/#{domain.id}"
28
- assert domain.kind_of?(Stripe::ApplePayDomain)
28
+ assert domain.is_a?(Stripe::ApplePayDomain)
29
29
  end
30
30
  end
31
31
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class ApplicationFeeRefundTest < Test::Unit::TestCase
@@ -11,25 +11,25 @@ module Stripe
11
11
 
12
12
  # notably this *doesn't* make an API call
13
13
  assert_not_requested :get,
14
- "#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds"
14
+ "#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds"
15
15
 
16
- assert refunds.data.kind_of?(Array)
17
- assert refunds.first.kind_of?(Stripe::ApplicationFeeRefund)
16
+ assert refunds.data.is_a?(Array)
17
+ assert refunds.first.is_a?(Stripe::ApplicationFeeRefund)
18
18
  end
19
19
 
20
20
  should "be creatable" do
21
21
  refund = @fee.refunds.create
22
22
  assert_requested :post,
23
- "#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds"
24
- assert refund.kind_of?(Stripe::ApplicationFeeRefund)
23
+ "#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds"
24
+ assert refund.is_a?(Stripe::ApplicationFeeRefund)
25
25
  end
26
26
 
27
27
  should "be saveable" do
28
28
  refund = @fee.refunds.first
29
- refund.metadata['key'] = 'value'
29
+ refund.metadata["key"] = "value"
30
30
  refund.save
31
31
  assert_requested :post,
32
- "#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds/#{refund.id}"
32
+ "#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds/#{refund.id}"
33
33
  end
34
34
  end
35
35
  end
@@ -1,12 +1,12 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class ApplicationFeeTest < Test::Unit::TestCase
5
5
  should "be listable" do
6
6
  fees = Stripe::ApplicationFee.list
7
7
  assert_requested :get, "#{Stripe.api_base}/v1/application_fees"
8
- assert fees.data.kind_of?(Array)
9
- assert fees.data[0].kind_of?(Stripe::ApplicationFee)
8
+ assert fees.data.is_a?(Array)
9
+ assert fees.data[0].is_a?(Stripe::ApplicationFee)
10
10
  end
11
11
  end
12
12
  end
@@ -1,11 +1,11 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class BalanceTest < Test::Unit::TestCase
5
5
  should "be retrievable" do
6
6
  balance = Stripe::Balance.retrieve
7
7
  assert_requested :get, "#{Stripe.api_base}/v1/balance"
8
- assert balance.kind_of?(Stripe::Balance)
8
+ assert balance.is_a?(Stripe::Balance)
9
9
  end
10
10
  end
11
11
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class BankAccountTest < Test::Unit::TestCase
@@ -9,27 +9,25 @@ module Stripe
9
9
  id: "ba_123"
10
10
  )
11
11
  assert_equal "/v1/accounts/acct_123/external_accounts/ba_123",
12
- bank_account.resource_url
12
+ bank_account.resource_url
13
13
  end
14
14
 
15
15
  should "return a customer URL" do
16
16
  bank_account = Stripe::BankAccount.construct_from(
17
17
  customer: "cus_123",
18
- id: "ba_123",
18
+ id: "ba_123"
19
19
  )
20
20
  assert_equal "/v1/customers/cus_123/sources/ba_123",
21
- bank_account.resource_url
21
+ bank_account.resource_url
22
22
  end
23
23
  end
24
24
 
25
25
  context "#verify" do
26
- should 'verify the account' do
27
- bank_account = Stripe::BankAccount.construct_from({
28
- customer: "cus_123",
29
- id: "ba_123",
30
- })
31
- bank_account = bank_account.verify(amounts: [1,2])
32
- assert bank_account.kind_of?(Stripe::BankAccount)
26
+ should "verify the account" do
27
+ bank_account = Stripe::BankAccount.construct_from(customer: "cus_123",
28
+ id: "ba_123")
29
+ bank_account = bank_account.verify(amounts: [1, 2])
30
+ assert bank_account.is_a?(Stripe::BankAccount)
33
31
  end
34
32
  end
35
33
  end
@@ -1,48 +1,48 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class ChargeTest < Test::Unit::TestCase
5
5
  should "be listable" do
6
6
  charges = Stripe::Charge.list
7
7
  assert_requested :get, "#{Stripe.api_base}/v1/charges"
8
- assert charges.data.kind_of?(Array)
9
- assert charges.data[0].kind_of?(Stripe::Charge)
8
+ assert charges.data.is_a?(Array)
9
+ assert charges.data[0].is_a?(Stripe::Charge)
10
10
  end
11
11
 
12
12
  should "be retrievable" do
13
13
  charge = Stripe::Charge.retrieve("ch_123")
14
14
  assert_requested :get, "#{Stripe.api_base}/v1/charges/ch_123"
15
- assert charge.kind_of?(Stripe::Charge)
15
+ assert charge.is_a?(Stripe::Charge)
16
16
  end
17
17
 
18
18
  should "be creatable" do
19
19
  charge = Stripe::Charge.create(
20
20
  amount: 100,
21
21
  currency: "USD",
22
- source: "src_123",
22
+ source: "src_123"
23
23
  )
24
24
  assert_requested :post, "#{Stripe.api_base}/v1/charges"
25
- assert charge.kind_of?(Stripe::Charge)
25
+ assert charge.is_a?(Stripe::Charge)
26
26
  end
27
27
 
28
28
  should "be saveable" do
29
29
  charge = Stripe::Charge.retrieve("ch_123")
30
- charge.metadata['key'] = 'value'
30
+ charge.metadata["key"] = "value"
31
31
  charge.save
32
32
  assert_requested :post, "#{Stripe.api_base}/v1/charges/#{charge.id}"
33
33
  end
34
34
 
35
35
  should "be updateable" do
36
- charge = Stripe::Charge.update("ch_123", metadata: {foo: 'bar'})
36
+ charge = Stripe::Charge.update("ch_123", metadata: { foo: "bar" })
37
37
  assert_requested :post, "#{Stripe.api_base}/v1/charges/ch_123"
38
- assert charge.kind_of?(Stripe::Charge)
38
+ assert charge.is_a?(Stripe::Charge)
39
39
  end
40
40
 
41
41
  context "#mark_as_fraudulent" do
42
42
  should "charges should be able to be marked as fraudulent" do
43
43
  charge = Stripe::Charge.retrieve("ch_123")
44
44
  charge = charge.mark_as_fraudulent
45
- assert charge.kind_of?(Stripe::Charge)
45
+ assert charge.is_a?(Stripe::Charge)
46
46
  end
47
47
  end
48
48
 
@@ -50,7 +50,7 @@ module Stripe
50
50
  should "charges should be able to be marked as safe" do
51
51
  charge = Stripe::Charge.retrieve("ch_123")
52
52
  charge = charge.mark_as_safe
53
- assert charge.kind_of?(Stripe::Charge)
53
+ assert charge.is_a?(Stripe::Charge)
54
54
  end
55
55
  end
56
56
  end
@@ -1,18 +1,18 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class CountrySpecTest < Test::Unit::TestCase
5
5
  should "be listable" do
6
6
  c = Stripe::CountrySpec.list
7
7
  assert_requested :get, "#{Stripe.api_base}/v1/country_specs"
8
- assert c.data.kind_of?(Array)
9
- assert c.data[0].kind_of?(Stripe::CountrySpec)
8
+ assert c.data.is_a?(Array)
9
+ assert c.data[0].is_a?(Stripe::CountrySpec)
10
10
  end
11
11
 
12
12
  should "be retrievable" do
13
13
  s = Stripe::CountrySpec.retrieve("US")
14
14
  assert_requested :get, "#{Stripe.api_base}/v1/country_specs/US"
15
- assert(s.kind_of?(Stripe::CountrySpec))
15
+ assert(s.is_a?(Stripe::CountrySpec))
16
16
  end
17
17
  end
18
18
  end
@@ -1,42 +1,42 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class CouponTest < Test::Unit::TestCase
5
5
  should "be listable" do
6
6
  coupons = Stripe::Coupon.list
7
7
  assert_requested :get, "#{Stripe.api_base}/v1/coupons"
8
- assert coupons.data.kind_of?(Array)
9
- assert coupons.first.kind_of?(Stripe::Coupon)
8
+ assert coupons.data.is_a?(Array)
9
+ assert coupons.first.is_a?(Stripe::Coupon)
10
10
  end
11
11
 
12
12
  should "be retrievable" do
13
13
  coupon = Stripe::Coupon.retrieve("25OFF")
14
14
  assert_requested :get, "#{Stripe.api_base}/v1/coupons/25OFF"
15
- assert coupon.kind_of?(Stripe::Coupon)
15
+ assert coupon.is_a?(Stripe::Coupon)
16
16
  end
17
17
 
18
18
  should "be creatable" do
19
19
  coupon = Stripe::Coupon.create(
20
20
  percent_off: 25,
21
- duration: 'repeating',
21
+ duration: "repeating",
22
22
  duration_in_months: 3,
23
- id: '25OFF'
23
+ id: "25OFF"
24
24
  )
25
25
  assert_requested :post, "#{Stripe.api_base}/v1/coupons"
26
- assert coupon.kind_of?(Stripe::Coupon)
26
+ assert coupon.is_a?(Stripe::Coupon)
27
27
  end
28
28
 
29
29
  should "be saveable" do
30
30
  coupon = Stripe::Coupon.retrieve("25OFF")
31
- coupon.metadata['key'] = 'value'
31
+ coupon.metadata["key"] = "value"
32
32
  coupon.save
33
33
  assert_requested :post, "#{Stripe.api_base}/v1/coupons/#{coupon.id}"
34
34
  end
35
35
 
36
36
  should "be updateable" do
37
- coupon = Stripe::Coupon.update("25OFF", metadata: { key: 'value' })
37
+ coupon = Stripe::Coupon.update("25OFF", metadata: { key: "value" })
38
38
  assert_requested :post, "#{Stripe.api_base}/v1/coupons/25OFF"
39
- assert coupon.kind_of?(Stripe::Coupon)
39
+ assert coupon.is_a?(Stripe::Coupon)
40
40
  end
41
41
  end
42
42
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class CustomerCardTest < Test::Unit::TestCase
@@ -8,7 +8,7 @@ module Stripe
8
8
 
9
9
  should "be listable" do
10
10
  sources = @customer.sources.list
11
- assert sources.data.kind_of?(Array)
11
+ assert sources.data.is_a?(Array)
12
12
  # because of the terrible :wildcard nature of sources, the API stub
13
13
  # cannot currently replace this response with anything meaningful so we
14
14
  # don't assert on the type of individual items like we do in other tests
@@ -16,29 +16,25 @@ module Stripe
16
16
 
17
17
  should "be creatable" do
18
18
  card = @customer.sources.create(
19
- source: "tok_123",
19
+ source: "tok_123"
20
20
  )
21
21
  assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources"
22
- assert card.kind_of?(Stripe::BankAccount)
22
+ assert card.is_a?(Stripe::BankAccount)
23
23
  end
24
24
 
25
25
  should "be deletable" do
26
- card = Stripe::Card.construct_from({
27
- customer: @customer.id,
28
- id: "card_123"
29
- })
26
+ card = Stripe::Card.construct_from(customer: @customer.id,
27
+ id: "card_123")
30
28
  card = card.delete
31
29
  assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/card_123"
32
- assert card.kind_of?(Stripe::Card)
30
+ assert card.is_a?(Stripe::Card)
33
31
  end
34
32
 
35
33
  should "be saveable" do
36
- card = Stripe::Card.construct_from({
37
- customer: @customer.id,
38
- id: "card_123",
39
- metadata: {},
40
- })
41
- card.metadata['key'] = 'value'
34
+ card = Stripe::Card.construct_from(customer: @customer.id,
35
+ id: "card_123",
36
+ metadata: {})
37
+ card.metadata["key"] = "value"
42
38
  card.save
43
39
  assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/card_123"
44
40
  end
@@ -1,51 +1,51 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class CustomerTest < Test::Unit::TestCase
5
5
  should "be listable" do
6
6
  customers = Stripe::Customer.list
7
7
  assert_requested :get, "#{Stripe.api_base}/v1/customers"
8
- assert customers.data.kind_of?(Array)
9
- assert customers.first.kind_of?(Stripe::Customer)
8
+ assert customers.data.is_a?(Array)
9
+ assert customers.first.is_a?(Stripe::Customer)
10
10
  end
11
11
 
12
12
  should "be retrievable" do
13
13
  customer = Stripe::Customer.retrieve("cus_123")
14
14
  assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_123"
15
- assert customer.kind_of?(Stripe::Customer)
15
+ assert customer.is_a?(Stripe::Customer)
16
16
  end
17
17
 
18
18
  should "be creatable" do
19
19
  customer = Stripe::Customer.create
20
20
  assert_requested :post, "#{Stripe.api_base}/v1/customers"
21
- assert customer.kind_of?(Stripe::Customer)
21
+ assert customer.is_a?(Stripe::Customer)
22
22
  end
23
23
 
24
24
  should "be saveable" do
25
25
  customer = Stripe::Customer.retrieve("cus_123")
26
- customer.metadata['key'] = 'value'
26
+ customer.metadata["key"] = "value"
27
27
  customer.save
28
28
  assert_requested :post, "#{Stripe.api_base}/v1/customers/#{customer.id}"
29
29
  end
30
30
 
31
31
  should "be updateable" do
32
- customer = Stripe::Customer.update("cus_123", metadata: { key: 'value' })
32
+ customer = Stripe::Customer.update("cus_123", metadata: { key: "value" })
33
33
  assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123"
34
- assert customer.kind_of?(Stripe::Customer)
34
+ assert customer.is_a?(Stripe::Customer)
35
35
  end
36
36
 
37
37
  should "be deletable" do
38
38
  customer = Stripe::Customer.retrieve("cus_123")
39
39
  customer = customer.delete
40
40
  assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{customer.id}"
41
- assert customer.kind_of?(Stripe::Customer)
41
+ assert customer.is_a?(Stripe::Customer)
42
42
  end
43
43
 
44
44
  context "#create_subscription" do
45
45
  should "create a new subscription" do
46
46
  customer = Stripe::Customer.retrieve("cus_123")
47
- subscription = customer.create_subscription({:plan => 'silver'})
48
- assert subscription.kind_of?(Stripe::Subscription)
47
+ subscription = customer.create_subscription(plan: "silver")
48
+ assert subscription.is_a?(Stripe::Subscription)
49
49
  end
50
50
  end
51
51
 
@@ -53,7 +53,7 @@ module Stripe
53
53
  should "create a new invoice" do
54
54
  customer = Stripe::Customer.retrieve("cus_123")
55
55
  invoice = customer.create_upcoming_invoice
56
- assert invoice.kind_of?(Stripe::Invoice)
56
+ assert invoice.is_a?(Stripe::Invoice)
57
57
  end
58
58
  end
59
59
 
@@ -62,11 +62,11 @@ module Stripe
62
62
  customer = Stripe::Customer.retrieve("cus_123")
63
63
 
64
64
  # deprecated API and not in schema
65
- stub_request(:post, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription").
66
- with(body: { plan: "silver" }).
67
- to_return(body: JSON.generate({ object: "subscription" }))
68
- subscription = customer.update_subscription({:plan => 'silver'})
69
- assert subscription.kind_of?(Stripe::Subscription)
65
+ stub_request(:post, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription")
66
+ .with(body: { plan: "silver" })
67
+ .to_return(body: JSON.generate(object: "subscription"))
68
+ subscription = customer.update_subscription(plan: "silver")
69
+ assert subscription.is_a?(Stripe::Subscription)
70
70
  end
71
71
  end
72
72
 
@@ -75,11 +75,11 @@ module Stripe
75
75
  customer = Stripe::Customer.retrieve("cus_123")
76
76
 
77
77
  # deprecated API and not in schema
78
- stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription").
79
- with(query: { at_period_end: "true" }).
80
- to_return(body: JSON.generate({ object: "subscription" }))
81
- subscription = customer.cancel_subscription({:at_period_end => 'true'})
82
- assert subscription.kind_of?(Stripe::Subscription)
78
+ stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription")
79
+ .with(query: { at_period_end: "true" })
80
+ .to_return(body: JSON.generate(object: "subscription"))
81
+ subscription = customer.cancel_subscription(at_period_end: "true")
82
+ assert subscription.is_a?(Stripe::Subscription)
83
83
  end
84
84
  end
85
85
 
@@ -87,10 +87,10 @@ module Stripe
87
87
  should "delete a discount" do
88
88
  customer = Stripe::Customer.retrieve("cus_123")
89
89
 
90
- stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/discount").
91
- to_return(body: JSON.generate({ object: "customer" }))
90
+ stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/discount")
91
+ .to_return(body: JSON.generate(object: "customer"))
92
92
  discount = customer.delete_discount
93
- assert discount.kind_of?(Stripe::Customer)
93
+ assert discount.is_a?(Stripe::Customer)
94
94
  end
95
95
  end
96
96
 
@@ -104,11 +104,10 @@ module Stripe
104
104
  should "allow setting source with hash and set flag" do
105
105
  c = Stripe::Customer.new("test_customer")
106
106
  c.source = {
107
- :object => 'card'
107
+ object: "card",
108
108
  }
109
109
  assert_equal true, c.source.save_with_parent
110
110
  end
111
111
  end
112
112
  end
113
113
  end
114
-