stripe-ruby-mock 2.5.6 → 3.1.0.rc2

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 (97) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -1
  3. data/.travis.yml +6 -9
  4. data/CHANGELOG.md +35 -0
  5. data/Gemfile +1 -0
  6. data/README.md +17 -11
  7. data/lib/stripe_mock.rb +11 -0
  8. data/lib/stripe_mock/api/client.rb +1 -1
  9. data/lib/stripe_mock/api/errors.rb +34 -28
  10. data/lib/stripe_mock/api/instance.rb +1 -1
  11. data/lib/stripe_mock/api/webhooks.rb +7 -0
  12. data/lib/stripe_mock/client.rb +2 -1
  13. data/lib/stripe_mock/data.rb +323 -13
  14. data/lib/stripe_mock/data/list.rb +42 -9
  15. data/lib/stripe_mock/instance.rb +52 -5
  16. data/lib/stripe_mock/request_handlers/account_links.rb +15 -0
  17. data/lib/stripe_mock/request_handlers/balance_transactions.rb +2 -2
  18. data/lib/stripe_mock/request_handlers/charges.rb +13 -12
  19. data/lib/stripe_mock/request_handlers/checkout.rb +15 -0
  20. data/lib/stripe_mock/request_handlers/checkout_session.rb +16 -0
  21. data/lib/stripe_mock/request_handlers/customers.rb +35 -18
  22. data/lib/stripe_mock/request_handlers/ephemeral_key.rb +1 -1
  23. data/lib/stripe_mock/request_handlers/express_login_links.rb +15 -0
  24. data/lib/stripe_mock/request_handlers/helpers/coupon_helpers.rb +14 -10
  25. data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +22 -7
  26. data/lib/stripe_mock/request_handlers/helpers/token_helpers.rb +1 -1
  27. data/lib/stripe_mock/request_handlers/invoices.rb +11 -5
  28. data/lib/stripe_mock/request_handlers/payment_intents.rb +182 -0
  29. data/lib/stripe_mock/request_handlers/payment_methods.rb +120 -0
  30. data/lib/stripe_mock/request_handlers/plans.rb +1 -1
  31. data/lib/stripe_mock/request_handlers/prices.rb +44 -0
  32. data/lib/stripe_mock/request_handlers/products.rb +44 -0
  33. data/lib/stripe_mock/request_handlers/refunds.rb +6 -3
  34. data/lib/stripe_mock/request_handlers/setup_intents.rb +93 -0
  35. data/lib/stripe_mock/request_handlers/sources.rb +12 -6
  36. data/lib/stripe_mock/request_handlers/subscription_items.rb +36 -0
  37. data/lib/stripe_mock/request_handlers/subscriptions.rb +82 -41
  38. data/lib/stripe_mock/request_handlers/tax_rates.rb +36 -0
  39. data/lib/stripe_mock/request_handlers/tokens.rb +8 -6
  40. data/lib/stripe_mock/request_handlers/validators/param_validators.rb +130 -9
  41. data/lib/stripe_mock/test_strategies/base.rb +68 -8
  42. data/lib/stripe_mock/test_strategies/live.rb +23 -12
  43. data/lib/stripe_mock/test_strategies/mock.rb +6 -2
  44. data/lib/stripe_mock/version.rb +1 -1
  45. data/lib/stripe_mock/webhook_fixtures/balance.available.json +6 -0
  46. data/lib/stripe_mock/webhook_fixtures/charge.dispute.funds_reinstated.json +88 -0
  47. data/lib/stripe_mock/webhook_fixtures/charge.dispute.funds_withdrawn.json +88 -0
  48. data/lib/stripe_mock/webhook_fixtures/charge.failed.json +166 -38
  49. data/lib/stripe_mock/webhook_fixtures/customer.created.json +1 -0
  50. data/lib/stripe_mock/webhook_fixtures/customer.updated.json +1 -0
  51. data/lib/stripe_mock/webhook_fixtures/invoice.created.json +2 -1
  52. data/lib/stripe_mock/webhook_fixtures/invoice.payment_succeeded.json +1 -1
  53. data/lib/stripe_mock/webhook_fixtures/invoice.updated.json +2 -1
  54. data/lib/stripe_mock/webhook_fixtures/payment_intent.payment_failed.json +186 -0
  55. data/lib/stripe_mock/webhook_fixtures/payment_intent.succeeded.json +164 -0
  56. data/lib/stripe_mock/webhook_fixtures/product.created.json +34 -0
  57. data/lib/stripe_mock/webhook_fixtures/product.deleted.json +34 -0
  58. data/lib/stripe_mock/webhook_fixtures/product.updated.json +38 -0
  59. data/spec/instance_spec.rb +10 -12
  60. data/spec/list_spec.rb +38 -0
  61. data/spec/server_spec.rb +6 -3
  62. data/spec/shared_stripe_examples/account_examples.rb +1 -1
  63. data/spec/shared_stripe_examples/account_link_examples.rb +16 -0
  64. data/spec/shared_stripe_examples/balance_examples.rb +6 -0
  65. data/spec/shared_stripe_examples/balance_transaction_examples.rb +3 -3
  66. data/spec/shared_stripe_examples/bank_examples.rb +3 -3
  67. data/spec/shared_stripe_examples/card_examples.rb +4 -4
  68. data/spec/shared_stripe_examples/card_token_examples.rb +17 -21
  69. data/spec/shared_stripe_examples/charge_examples.rb +32 -36
  70. data/spec/shared_stripe_examples/checkout_examples.rb +38 -0
  71. data/spec/shared_stripe_examples/coupon_examples.rb +1 -1
  72. data/spec/shared_stripe_examples/customer_examples.rb +103 -53
  73. data/spec/shared_stripe_examples/dispute_examples.rb +2 -2
  74. data/spec/shared_stripe_examples/error_mock_examples.rb +8 -7
  75. data/spec/shared_stripe_examples/express_login_link_examples.rb +12 -0
  76. data/spec/shared_stripe_examples/external_account_examples.rb +3 -3
  77. data/spec/shared_stripe_examples/invoice_examples.rb +43 -41
  78. data/spec/shared_stripe_examples/invoice_item_examples.rb +1 -1
  79. data/spec/shared_stripe_examples/payment_intent_examples.rb +147 -0
  80. data/spec/shared_stripe_examples/payment_method_examples.rb +449 -0
  81. data/spec/shared_stripe_examples/payout_examples.rb +2 -2
  82. data/spec/shared_stripe_examples/plan_examples.rb +135 -77
  83. data/spec/shared_stripe_examples/price_examples.rb +183 -0
  84. data/spec/shared_stripe_examples/product_examples.rb +155 -0
  85. data/spec/shared_stripe_examples/refund_examples.rb +41 -31
  86. data/spec/shared_stripe_examples/setup_intent_examples.rb +68 -0
  87. data/spec/shared_stripe_examples/subscription_examples.rb +546 -295
  88. data/spec/shared_stripe_examples/subscription_items_examples.rb +76 -0
  89. data/spec/shared_stripe_examples/tax_rate_examples.rb +42 -0
  90. data/spec/shared_stripe_examples/transfer_examples.rb +9 -9
  91. data/spec/shared_stripe_examples/webhook_event_examples.rb +11 -11
  92. data/spec/spec_helper.rb +7 -4
  93. data/spec/stripe_mock_spec.rb +4 -4
  94. data/spec/support/shared_contexts/stripe_validator_spec.rb +8 -0
  95. data/spec/support/stripe_examples.rb +12 -2
  96. data/stripe-ruby-mock.gemspec +8 -3
  97. metadata +81 -32
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples 'Subscription Items API' do
4
+ let(:stripe_helper) { StripeMock.create_test_helper }
5
+ let(:product) { stripe_helper.create_product(name: 'Silver Product') }
6
+ let(:plan) { stripe_helper.create_plan(product: product.id, id: 'silver_plan') }
7
+ let(:plan2) { stripe_helper.create_plan(amount: 100, id: 'one_more_1_plan', product: product.id) }
8
+ let(:customer) { Stripe::Customer.create(source: stripe_helper.generate_card_token) }
9
+ let(:subscription) { Stripe::Subscription.create(customer: customer.id, items: [{ plan: plan.id }]) }
10
+
11
+ context 'creates an item' do
12
+ it 'when required params only' do
13
+ item = Stripe::SubscriptionItem.create(plan: plan.id, subscription: subscription.id)
14
+
15
+ expect(item.id).to match(/^test_si/)
16
+ expect(item.plan.id).to eq(plan.id)
17
+ expect(item.subscription).to eq(subscription.id)
18
+ end
19
+ it 'when no subscription params' do
20
+ expect { Stripe::SubscriptionItem.create(plan: plan.id) }.to raise_error { |e|
21
+ expect(e).to be_a(Stripe::InvalidRequestError)
22
+ expect(e.param).to eq('subscription')
23
+ expect(e.message).to eq('Missing required param: subscription.')
24
+ }
25
+ end
26
+ it 'when no plan params' do
27
+ expect { Stripe::SubscriptionItem.create(subscription: subscription.id) }.to raise_error { |e|
28
+ expect(e).to be_a(Stripe::InvalidRequestError)
29
+ expect(e.param).to eq('plan')
30
+ expect(e.message).to eq('Missing required param: plan.')
31
+ }
32
+ end
33
+ end
34
+
35
+ context 'updates an item' do
36
+ let(:item) { Stripe::SubscriptionItem.create(plan: plan.id, subscription: subscription.id, quantity: 2 ) }
37
+
38
+ it 'updates plan' do
39
+ updated_item = Stripe::SubscriptionItem.update(item.id, plan: plan2.id)
40
+
41
+ expect(updated_item.plan.id).to eq(plan2.id)
42
+ end
43
+ it 'updates quantity' do
44
+ updated_item = Stripe::SubscriptionItem.update(item.id, quantity: 23)
45
+
46
+ expect(updated_item.quantity).to eq(23)
47
+ end
48
+ it 'when no existing item' do
49
+ expect { Stripe::SubscriptionItem.update('some_id') }.to raise_error { |e|
50
+ expect(e).to be_a(Stripe::InvalidRequestError)
51
+ expect(e.param).to eq('subscription_item')
52
+ expect(e.message).to eq('No such subscription_item: some_id')
53
+ }
54
+ end
55
+ end
56
+
57
+ context 'retrieves a list of items' do
58
+ before do
59
+ Stripe::SubscriptionItem.create(plan: plan.id, subscription: subscription.id, quantity: 2 )
60
+ Stripe::SubscriptionItem.create(plan: plan2.id, subscription: subscription.id, quantity: 20)
61
+ end
62
+
63
+ it 'retrieves all subscription items' do
64
+ all = Stripe::SubscriptionItem.list(subscription: subscription.id)
65
+
66
+ expect(all.count).to eq(2)
67
+ end
68
+ it 'when no subscription param' do
69
+ expect { Stripe::SubscriptionItem.list }.to raise_error { |e|
70
+ expect(e).to be_a(Stripe::InvalidRequestError)
71
+ expect(e.param).to eq('subscription')
72
+ expect(e.message).to eq('Missing required param: subscription.')
73
+ }
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples 'TaxRate API' do
4
+ context 'with created tax rate' do
5
+ let!(:rate) { Stripe::TaxRate.create }
6
+
7
+ it 'returns list of tax rates' do
8
+ rates = Stripe::TaxRate.list
9
+ expect(rates.count).to eq(1)
10
+ end
11
+
12
+ it 'retrieves tax rate' do
13
+ ret_rate = Stripe::TaxRate.retrieve(rate.id)
14
+ expect(ret_rate.id).not_to be_nil
15
+ expect(ret_rate.object).to eq('tax_rate')
16
+ expect(ret_rate.display_name).to eq('VAT')
17
+ expect(ret_rate.percentage).to eq(21.0)
18
+ expect(ret_rate.jurisdiction).to eq('EU')
19
+ expect(ret_rate.inclusive).to eq(false)
20
+ end
21
+
22
+ it 'updates tax rate' do
23
+ ret_rate = Stripe::TaxRate.update(rate.id, percentage: 30.5)
24
+ expect(ret_rate.id).not_to be_nil
25
+ expect(ret_rate.object).to eq('tax_rate')
26
+ expect(ret_rate.display_name).to eq('VAT')
27
+ expect(ret_rate.percentage).to eq(30.5)
28
+ expect(ret_rate.jurisdiction).to eq('EU')
29
+ expect(ret_rate.inclusive).to eq(false)
30
+ end
31
+ end
32
+
33
+ it 'creates tax rate' do
34
+ rate = Stripe::TaxRate.create
35
+ expect(rate.id).not_to be_nil
36
+ expect(rate.object).to eq('tax_rate')
37
+ expect(rate.display_name).to eq('VAT')
38
+ expect(rate.percentage).to eq(21.0)
39
+ expect(rate.jurisdiction).to eq('EU')
40
+ expect(rate.inclusive).to eq(false)
41
+ end
42
+ end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  shared_examples 'Transfer API' do
4
4
 
5
5
  it "creates a stripe transfer" do
6
- destination = Stripe::Account.create(email: "#{SecureRandom.uuid}@example.com", id: "acct_12345")
6
+ destination = Stripe::Account.create(type: "custom", email: "#{SecureRandom.uuid}@example.com", id: "acct_12345")
7
7
  transfer = Stripe::Transfer.create(amount: 100, currency: "usd", destination: destination.id)
8
8
 
9
9
  expect(transfer.id).to match /^test_tr/
@@ -31,7 +31,7 @@ shared_examples 'Transfer API' do
31
31
  end
32
32
 
33
33
  describe "listing transfers" do
34
- let(:destination) { Stripe::Account.create(email: "#{SecureRandom.uuid}@example.com", business_name: "MyCo") }
34
+ let(:destination) { Stripe::Account.create(type: "custom", email: "#{SecureRandom.uuid}@example.com", business_name: "MyCo") }
35
35
 
36
36
  before do
37
37
  3.times do
@@ -40,22 +40,22 @@ shared_examples 'Transfer API' do
40
40
  end
41
41
 
42
42
  it "without params retrieves all tripe transfers" do
43
- expect(Stripe::Transfer.all.count).to eq(3)
43
+ expect(Stripe::Transfer.list.count).to eq(3)
44
44
  end
45
45
 
46
46
  it "accepts a limit param" do
47
- expect(Stripe::Transfer.all(limit: 2).count).to eq(2)
47
+ expect(Stripe::Transfer.list(limit: 2).count).to eq(2)
48
48
  end
49
49
 
50
50
  it "filters the search to a specific destination" do
51
- d2 = Stripe::Account.create(email: "#{SecureRandom.uuid}@example.com", business_name: "MyCo")
51
+ d2 = Stripe::Account.create(type: "custom", email: "#{SecureRandom.uuid}@example.com", business_name: "MyCo")
52
52
  Stripe::Transfer.create(amount: "100", currency: "usd", destination: d2.id)
53
53
 
54
- expect(Stripe::Transfer.all(destination: d2.id).count).to eq(1)
54
+ expect(Stripe::Transfer.list(destination: d2.id).count).to eq(1)
55
55
  end
56
56
 
57
57
  it "disallows unknown parameters" do
58
- expect { Stripe::Transfer.all(recipient: "foo") }.to raise_error {|e|
58
+ expect { Stripe::Transfer.list(recipient: "foo") }.to raise_error {|e|
59
59
  expect(e).to be_a Stripe::InvalidRequestError
60
60
  expect(e.param).to eq("recipient")
61
61
  expect(e.message).to eq("Received unknown parameter: recipient")
@@ -104,7 +104,7 @@ shared_examples 'Transfer API' do
104
104
  end
105
105
 
106
106
  it "when amount is not integer", live: true do
107
- dest = Stripe::Account.create(type: "standard", email: "#{SecureRandom.uuid}@example.com", business_name: "Alex Smith")
107
+ dest = Stripe::Account.create(type: "custom", email: "#{SecureRandom.uuid}@example.com", requested_capabilities: ['card_payments', 'platform_payments'])
108
108
  expect { Stripe::Transfer.create(amount: '400.2',
109
109
  currency: 'usd',
110
110
  destination: dest.id,
@@ -116,7 +116,7 @@ shared_examples 'Transfer API' do
116
116
  end
117
117
 
118
118
  it "when amount is negative", live: true do
119
- dest = Stripe::Account.create(type: "standard", email: "#{SecureRandom.uuid}@example.com", business_name: "Alex Smith")
119
+ dest = Stripe::Account.create(type: "custom", email: "#{SecureRandom.uuid}@example.com", requested_capabilities: ['card_payments', 'platform_payments'])
120
120
  expect { Stripe::Transfer.create(amount: '-400',
121
121
  currency: 'usd',
122
122
  destination: dest.id,
@@ -168,7 +168,7 @@ shared_examples 'Webhook Events API' do
168
168
  expect(invoice_item_created_event).to be_a(Stripe::Event)
169
169
  expect(invoice_item_created_event).to_not be_nil
170
170
 
171
- events = Stripe::Event.all
171
+ events = Stripe::Event.list
172
172
 
173
173
  expect(events.count).to eq(5)
174
174
  expect(events.map &:id).to include(customer_created_event.id, plan_created_event.id, coupon_created_event.id, invoice_created_event.id, invoice_item_created_event.id)
@@ -196,7 +196,7 @@ shared_examples 'Webhook Events API' do
196
196
  expect(invoice_item_created_event).to be_a(Stripe::Event)
197
197
  expect(invoice_item_created_event).to_not be_nil
198
198
 
199
- events = Stripe::Event.all(limit: 3)
199
+ events = Stripe::Event.list(limit: 3)
200
200
 
201
201
  expect(events.count).to eq(3)
202
202
  expect(events.map &:id).to include(invoice_item_created_event.id, invoice_created_event.id, coupon_created_event.id)
@@ -204,9 +204,9 @@ shared_examples 'Webhook Events API' do
204
204
  end
205
205
 
206
206
  end
207
-
208
- describe 'Subscription events' do
209
- it "Checks for billing items in customer.subscription.created" do
207
+
208
+ describe 'Subscription events' do
209
+ it "Checks for billing items in customer.subscription.created" do
210
210
  subscription_created_event = StripeMock.mock_webhook_event('customer.subscription.created')
211
211
  expect(subscription_created_event).to be_a(Stripe::Event)
212
212
  expect(subscription_created_event.id).to_not be_nil
@@ -216,7 +216,7 @@ shared_examples 'Webhook Events API' do
216
216
  expect(subscription_created_event.data.object.items.data.first.id).to eq('si_00000000000000')
217
217
  end
218
218
 
219
- it "Checks for billing items in customer.subscription.deleted" do
219
+ it "Checks for billing items in customer.subscription.deleted" do
220
220
  subscription_deleted_event = StripeMock.mock_webhook_event('customer.subscription.deleted')
221
221
  expect(subscription_deleted_event).to be_a(Stripe::Event)
222
222
  expect(subscription_deleted_event.id).to_not be_nil
@@ -225,8 +225,8 @@ shared_examples 'Webhook Events API' do
225
225
  expect(subscription_deleted_event.data.object.items.data.first).to respond_to(:plan)
226
226
  expect(subscription_deleted_event.data.object.items.data.first.id).to eq('si_00000000000000')
227
227
  end
228
-
229
- it "Checks for billing items in customer.subscription.updated" do
228
+
229
+ it "Checks for billing items in customer.subscription.updated" do
230
230
  subscription_updated_event = StripeMock.mock_webhook_event('customer.subscription.updated')
231
231
  expect(subscription_updated_event).to be_a(Stripe::Event)
232
232
  expect(subscription_updated_event.id).to_not be_nil
@@ -235,8 +235,8 @@ shared_examples 'Webhook Events API' do
235
235
  expect(subscription_updated_event.data.object.items.data.first).to respond_to(:plan)
236
236
  expect(subscription_updated_event.data.object.items.data.first.id).to eq('si_00000000000000')
237
237
  end
238
-
239
- it "Checks for billing items in customer.subscription.trial_will_end" do
238
+
239
+ it "Checks for billing items in customer.subscription.trial_will_end" do
240
240
  subscription_trial_will_end_event = StripeMock.mock_webhook_event('customer.subscription.trial_will_end')
241
241
  expect(subscription_trial_will_end_event).to be_a(Stripe::Event)
242
242
  expect(subscription_trial_will_end_event.id).to_not be_nil
@@ -247,7 +247,7 @@ shared_examples 'Webhook Events API' do
247
247
  end
248
248
  end
249
249
 
250
- describe 'Invoices events' do
250
+ describe 'Invoices events' do
251
251
  it "Checks for billing items in invoice.payment_succeeded" do
252
252
  invoice_payment_succeeded = StripeMock.mock_webhook_event('invoice.payment_succeeded')
253
253
  expect(invoice_payment_succeeded).to be_a(Stripe::Event)
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,9 @@ require 'rspec'
5
5
  require 'stripe'
6
6
  require 'stripe_mock'
7
7
  require 'stripe_mock/server'
8
+ require 'dotenv'
9
+
10
+ Dotenv.load('.env')
8
11
 
9
12
  # Requires supporting ruby files with custom matchers and macros, etc,
10
13
  # in spec/support/ and its subdirectories.
@@ -30,10 +33,10 @@ RSpec.configure do |c|
30
33
  if ENV['IS_TRAVIS']
31
34
  puts "Travis ruby version: #{RUBY_VERSION}"
32
35
  api_key = case RUBY_VERSION
33
- when '2.0.0' then ENV['STRIPE_TEST_SECRET_KEY_A']
34
- when '2.1.10' then ENV['STRIPE_TEST_SECRET_KEY_B']
35
- when '2.2.7' then ENV['STRIPE_TEST_SECRET_KEY_C']
36
- when '2.3.4' then ENV['STRIPE_TEST_SECRET_KEY_D']
36
+ when '2.4.6' then ENV['STRIPE_TEST_SECRET_KEY_A']
37
+ when '2.5.5' then ENV['STRIPE_TEST_SECRET_KEY_B']
38
+ when '2.6.3' then ENV['STRIPE_TEST_SECRET_KEY_C']
39
+ when '2.7.0' then ENV['STRIPE_TEST_SECRET_KEY_D']
37
40
  end
38
41
  else
39
42
  api_key = ENV['STRIPE_TEST_SECRET_KEY']
@@ -18,14 +18,14 @@ describe StripeMock do
18
18
  StripeMock.start
19
19
  Stripe::StripeClient.active_client.execute_request(:xtest, '/', api_key: 'abcde') # no error
20
20
  StripeMock.stop
21
- expect { Stripe::StripeClient.active_client.execute_request(:x, '/', api_key: 'abcde') }.to raise_error ArgumentError
21
+ expect { Stripe::StripeClient.active_client.execute_request(:x, '/', api_key: 'abcde') }.to raise_error Stripe::APIError
22
22
  end
23
23
 
24
24
  it "reverts overriding stripe's execute_request method in other threads" do
25
25
  StripeMock.start
26
26
  Thread.new { Stripe::StripeClient.active_client.execute_request(:xtest, '/', api_key: 'abcde') }.join # no error
27
27
  StripeMock.stop
28
- expect { Thread.new { Stripe::StripeClient.active_client.execute_request(:x, '/', api_key: 'abcde') }.join }.to raise_error ArgumentError
28
+ expect { Thread.new { Stripe::StripeClient.active_client.execute_request(:x, '/', api_key: 'abcde') }.join }.to raise_error Stripe::APIError
29
29
  end
30
30
 
31
31
  it "does not persist data between mock sessions" do
@@ -35,8 +35,8 @@ describe StripeMock do
35
35
  StripeMock.stop
36
36
  StripeMock.start
37
37
 
38
- expect(StripeMock.instance.customers[:x]).to be_nil
39
- expect(StripeMock.instance.customers.keys.length).to eq(0)
38
+ expect(StripeMock.instance.customers[''][:x]).to be_nil
39
+ expect(StripeMock.instance.customers[''].keys.length).to eq(0)
40
40
  StripeMock.stop
41
41
  end
42
42
 
@@ -0,0 +1,8 @@
1
+
2
+ class StripeValidator
3
+ include StripeMock::RequestHandlers::ParamValidators
4
+ end
5
+
6
+ RSpec.shared_context "stripe validator", shared_context: :metadata do
7
+ let(:stripe_validator) { StripeValidator.new }
8
+ end
@@ -1,4 +1,3 @@
1
-
2
1
  def require_stripe_examples
3
2
  Dir["./spec/shared_stripe_examples/**/*.rb"].each {|f| require f}
4
3
  Dir["./spec/integration_examples/**/*.rb"].each {|f| require f}
@@ -6,6 +5,7 @@ end
6
5
 
7
6
  def it_behaves_like_stripe(&block)
8
7
  it_behaves_like 'Account API', &block
8
+ it_behaves_like 'Account Link API', &block
9
9
  it_behaves_like 'Balance API', &block
10
10
  it_behaves_like 'Balance Transaction API', &block
11
11
  it_behaves_like 'Bank Account Token Mocking', &block
@@ -13,6 +13,7 @@ def it_behaves_like_stripe(&block)
13
13
  it_behaves_like 'Card API', &block
14
14
  it_behaves_like 'Charge API', &block
15
15
  it_behaves_like 'Bank API', &block
16
+ it_behaves_like 'Express Login Link API', &block
16
17
  it_behaves_like 'External Account API', &block
17
18
  it_behaves_like 'Coupon API', &block
18
19
  it_behaves_like 'Customer API', &block
@@ -21,15 +22,24 @@ def it_behaves_like_stripe(&block)
21
22
  it_behaves_like 'Invoice API', &block
22
23
  it_behaves_like 'Invoice Item API', &block
23
24
  it_behaves_like 'Plan API', &block
25
+ it_behaves_like 'Price API', &block
26
+ it_behaves_like 'Product API', &block
24
27
  it_behaves_like 'Recipient API', &block
25
28
  it_behaves_like 'Refund API', &block
26
29
  it_behaves_like 'Transfer API', &block
27
30
  it_behaves_like 'Payout API', &block
31
+ it_behaves_like 'PaymentIntent API', &block
32
+ it_behaves_like 'PaymentMethod API', &block
33
+ it_behaves_like 'SetupIntent API', &block
28
34
  it_behaves_like 'Stripe Error Mocking', &block
29
- it_behaves_like 'Customer Subscriptions', &block
35
+ it_behaves_like 'Customer Subscriptions with plans', &block
36
+ it_behaves_like 'Customer Subscriptions with prices', &block
37
+ it_behaves_like 'Subscription Items API', &block
30
38
  it_behaves_like 'Webhook Events API', &block
31
39
  it_behaves_like 'Country Spec API', &block
32
40
  it_behaves_like 'EphemeralKey API', &block
41
+ it_behaves_like 'TaxRate API', &block
42
+ it_behaves_like 'Checkout API', &block
33
43
 
34
44
  # Integration tests
35
45
  it_behaves_like 'Multiple Customer Cards'
@@ -10,18 +10,23 @@ Gem::Specification.new do |gem|
10
10
  gem.license = "MIT"
11
11
  gem.authors = ["Gilbert"]
12
12
  gem.email = "gilbertbgarza@gmail.com"
13
- gem.homepage = "https://github.com/rebelidealist/stripe-ruby-mock"
13
+ gem.homepage = "https://github.com/stripe-ruby-mock/stripe-ruby-mock"
14
+ gem.metadata = {
15
+ "bug_tracker_uri" => "https://github.com/stripe-ruby-mock/stripe-ruby-mock/issues",
16
+ "changelog_uri" => "https://github.com/stripe-ruby-mock/stripe-ruby-mock/blob/master/CHANGELOG.md",
17
+ "source_code_uri" => "https://github.com/stripe-ruby-mock/stripe-ruby-mock"
18
+ }
14
19
 
15
20
  gem.files = `git ls-files`.split($/)
16
21
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
22
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
23
  gem.require_paths = ['lib']
19
24
 
20
- gem.add_dependency 'stripe', '>= 2.0.3'
25
+ gem.add_dependency 'stripe', '> 5', '< 6'
21
26
  gem.add_dependency 'multi_json', '~> 1.0'
22
27
  gem.add_dependency 'dante', '>= 0.2.0'
23
28
 
24
- gem.add_development_dependency 'rspec', '~> 3.1.0'
29
+ gem.add_development_dependency 'rspec', '~> 3.7.0'
25
30
  gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
26
31
  gem.add_development_dependency 'thin', '~> 1.6.4'
27
32
  end
metadata CHANGED
@@ -1,97 +1,103 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-ruby-mock
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.6
4
+ version: 3.1.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilbert
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-29 00:00:00.000000000 Z
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stripe
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.3
19
+ version: '5'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - '>='
27
+ - - ">"
28
+ - !ruby/object:Gem::Version
29
+ version: '5'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 2.0.3
32
+ version: '6'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: multi_json
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ~>
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
39
  version: '1.0'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ~>
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
46
  version: '1.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: dante
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - '>='
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
53
  version: 0.2.0
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - '>='
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
60
  version: 0.2.0
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rspec
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - ~>
65
+ - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: 3.1.0
67
+ version: 3.7.0
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - ~>
72
+ - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: 3.1.0
74
+ version: 3.7.0
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: rubygems-tasks
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - ~>
79
+ - - "~>"
74
80
  - !ruby/object:Gem::Version
75
81
  version: '0.2'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - ~>
86
+ - - "~>"
81
87
  - !ruby/object:Gem::Version
82
88
  version: '0.2'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: thin
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - ~>
93
+ - - "~>"
88
94
  - !ruby/object:Gem::Version
89
95
  version: 1.6.4
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - ~>
100
+ - - "~>"
95
101
  - !ruby/object:Gem::Version
96
102
  version: 1.6.4
97
103
  description: A drop-in library to test stripe without hitting their servers
@@ -101,10 +107,11 @@ executables:
101
107
  extensions: []
102
108
  extra_rdoc_files: []
103
109
  files:
104
- - .env
105
- - .gitignore
106
- - .rspec
107
- - .travis.yml
110
+ - ".env"
111
+ - ".gitignore"
112
+ - ".rspec"
113
+ - ".travis.yml"
114
+ - CHANGELOG.md
108
115
  - Gemfile
109
116
  - LICENSE.txt
110
117
  - README.md
@@ -135,17 +142,21 @@ files:
135
142
  - lib/stripe_mock/errors/unstarted_state_error.rb
136
143
  - lib/stripe_mock/errors/unsupported_request_error.rb
137
144
  - lib/stripe_mock/instance.rb
145
+ - lib/stripe_mock/request_handlers/account_links.rb
138
146
  - lib/stripe_mock/request_handlers/accounts.rb
139
147
  - lib/stripe_mock/request_handlers/balance.rb
140
148
  - lib/stripe_mock/request_handlers/balance_transactions.rb
141
149
  - lib/stripe_mock/request_handlers/cards.rb
142
150
  - lib/stripe_mock/request_handlers/charges.rb
151
+ - lib/stripe_mock/request_handlers/checkout.rb
152
+ - lib/stripe_mock/request_handlers/checkout_session.rb
143
153
  - lib/stripe_mock/request_handlers/country_spec.rb
144
154
  - lib/stripe_mock/request_handlers/coupons.rb
145
155
  - lib/stripe_mock/request_handlers/customers.rb
146
156
  - lib/stripe_mock/request_handlers/disputes.rb
147
157
  - lib/stripe_mock/request_handlers/ephemeral_key.rb
148
158
  - lib/stripe_mock/request_handlers/events.rb
159
+ - lib/stripe_mock/request_handlers/express_login_links.rb
149
160
  - lib/stripe_mock/request_handlers/external_accounts.rb
150
161
  - lib/stripe_mock/request_handlers/helpers/bank_account_helpers.rb
151
162
  - lib/stripe_mock/request_handlers/helpers/card_helpers.rb
@@ -157,12 +168,19 @@ files:
157
168
  - lib/stripe_mock/request_handlers/invoice_items.rb
158
169
  - lib/stripe_mock/request_handlers/invoices.rb
159
170
  - lib/stripe_mock/request_handlers/orders.rb
171
+ - lib/stripe_mock/request_handlers/payment_intents.rb
172
+ - lib/stripe_mock/request_handlers/payment_methods.rb
160
173
  - lib/stripe_mock/request_handlers/payouts.rb
161
174
  - lib/stripe_mock/request_handlers/plans.rb
175
+ - lib/stripe_mock/request_handlers/prices.rb
176
+ - lib/stripe_mock/request_handlers/products.rb
162
177
  - lib/stripe_mock/request_handlers/recipients.rb
163
178
  - lib/stripe_mock/request_handlers/refunds.rb
179
+ - lib/stripe_mock/request_handlers/setup_intents.rb
164
180
  - lib/stripe_mock/request_handlers/sources.rb
181
+ - lib/stripe_mock/request_handlers/subscription_items.rb
165
182
  - lib/stripe_mock/request_handlers/subscriptions.rb
183
+ - lib/stripe_mock/request_handlers/tax_rates.rb
166
184
  - lib/stripe_mock/request_handlers/tokens.rb
167
185
  - lib/stripe_mock/request_handlers/transfers.rb
168
186
  - lib/stripe_mock/request_handlers/validators/param_validators.rb
@@ -180,6 +198,8 @@ files:
180
198
  - lib/stripe_mock/webhook_fixtures/balance.available.json
181
199
  - lib/stripe_mock/webhook_fixtures/charge.dispute.closed.json
182
200
  - lib/stripe_mock/webhook_fixtures/charge.dispute.created.json
201
+ - lib/stripe_mock/webhook_fixtures/charge.dispute.funds_reinstated.json
202
+ - lib/stripe_mock/webhook_fixtures/charge.dispute.funds_withdrawn.json
183
203
  - lib/stripe_mock/webhook_fixtures/charge.dispute.updated.json
184
204
  - lib/stripe_mock/webhook_fixtures/charge.failed.json
185
205
  - lib/stripe_mock/webhook_fixtures/charge.refunded.json
@@ -207,9 +227,14 @@ files:
207
227
  - lib/stripe_mock/webhook_fixtures/invoiceitem.created.json
208
228
  - lib/stripe_mock/webhook_fixtures/invoiceitem.deleted.json
209
229
  - lib/stripe_mock/webhook_fixtures/invoiceitem.updated.json
230
+ - lib/stripe_mock/webhook_fixtures/payment_intent.payment_failed.json
231
+ - lib/stripe_mock/webhook_fixtures/payment_intent.succeeded.json
210
232
  - lib/stripe_mock/webhook_fixtures/plan.created.json
211
233
  - lib/stripe_mock/webhook_fixtures/plan.deleted.json
212
234
  - lib/stripe_mock/webhook_fixtures/plan.updated.json
235
+ - lib/stripe_mock/webhook_fixtures/product.created.json
236
+ - lib/stripe_mock/webhook_fixtures/product.deleted.json
237
+ - lib/stripe_mock/webhook_fixtures/product.updated.json
213
238
  - lib/stripe_mock/webhook_fixtures/transfer.created.json
214
239
  - lib/stripe_mock/webhook_fixtures/transfer.failed.json
215
240
  - lib/stripe_mock/webhook_fixtures/transfer.paid.json
@@ -228,6 +253,7 @@ files:
228
253
  - spec/readme_spec.rb
229
254
  - spec/server_spec.rb
230
255
  - spec/shared_stripe_examples/account_examples.rb
256
+ - spec/shared_stripe_examples/account_link_examples.rb
231
257
  - spec/shared_stripe_examples/balance_examples.rb
232
258
  - spec/shared_stripe_examples/balance_transaction_examples.rb
233
259
  - spec/shared_stripe_examples/bank_examples.rb
@@ -235,51 +261,63 @@ files:
235
261
  - spec/shared_stripe_examples/card_examples.rb
236
262
  - spec/shared_stripe_examples/card_token_examples.rb
237
263
  - spec/shared_stripe_examples/charge_examples.rb
264
+ - spec/shared_stripe_examples/checkout_examples.rb
238
265
  - spec/shared_stripe_examples/country_specs_examples.rb
239
266
  - spec/shared_stripe_examples/coupon_examples.rb
240
267
  - spec/shared_stripe_examples/customer_examples.rb
241
268
  - spec/shared_stripe_examples/dispute_examples.rb
242
269
  - spec/shared_stripe_examples/ephemeral_key_examples.rb
243
270
  - spec/shared_stripe_examples/error_mock_examples.rb
271
+ - spec/shared_stripe_examples/express_login_link_examples.rb
244
272
  - spec/shared_stripe_examples/external_account_examples.rb
245
273
  - spec/shared_stripe_examples/extra_features_examples.rb
246
274
  - spec/shared_stripe_examples/invoice_examples.rb
247
275
  - spec/shared_stripe_examples/invoice_item_examples.rb
276
+ - spec/shared_stripe_examples/payment_intent_examples.rb
277
+ - spec/shared_stripe_examples/payment_method_examples.rb
248
278
  - spec/shared_stripe_examples/payout_examples.rb
249
279
  - spec/shared_stripe_examples/plan_examples.rb
280
+ - spec/shared_stripe_examples/price_examples.rb
281
+ - spec/shared_stripe_examples/product_examples.rb
250
282
  - spec/shared_stripe_examples/recipient_examples.rb
251
283
  - spec/shared_stripe_examples/refund_examples.rb
284
+ - spec/shared_stripe_examples/setup_intent_examples.rb
252
285
  - spec/shared_stripe_examples/subscription_examples.rb
286
+ - spec/shared_stripe_examples/subscription_items_examples.rb
287
+ - spec/shared_stripe_examples/tax_rate_examples.rb
253
288
  - spec/shared_stripe_examples/transfer_examples.rb
254
289
  - spec/shared_stripe_examples/validation_examples.rb
255
290
  - spec/shared_stripe_examples/webhook_event_examples.rb
256
291
  - spec/spec_helper.rb
257
292
  - spec/stripe_mock_spec.rb
293
+ - spec/support/shared_contexts/stripe_validator_spec.rb
258
294
  - spec/support/stripe_examples.rb
259
295
  - spec/util_spec.rb
260
296
  - stripe-ruby-mock.gemspec
261
- homepage: https://github.com/rebelidealist/stripe-ruby-mock
297
+ homepage: https://github.com/stripe-ruby-mock/stripe-ruby-mock
262
298
  licenses:
263
299
  - MIT
264
- metadata: {}
265
- post_install_message:
300
+ metadata:
301
+ bug_tracker_uri: https://github.com/stripe-ruby-mock/stripe-ruby-mock/issues
302
+ changelog_uri: https://github.com/stripe-ruby-mock/stripe-ruby-mock/blob/master/CHANGELOG.md
303
+ source_code_uri: https://github.com/stripe-ruby-mock/stripe-ruby-mock
304
+ post_install_message:
266
305
  rdoc_options: []
267
306
  require_paths:
268
307
  - lib
269
308
  required_ruby_version: !ruby/object:Gem::Requirement
270
309
  requirements:
271
- - - '>='
310
+ - - ">="
272
311
  - !ruby/object:Gem::Version
273
312
  version: '0'
274
313
  required_rubygems_version: !ruby/object:Gem::Requirement
275
314
  requirements:
276
- - - '>='
315
+ - - ">"
277
316
  - !ruby/object:Gem::Version
278
- version: '0'
317
+ version: 1.3.1
279
318
  requirements: []
280
- rubyforge_project:
281
- rubygems_version: 2.0.14.1
282
- signing_key:
319
+ rubygems_version: 3.0.9
320
+ signing_key:
283
321
  specification_version: 4
284
322
  summary: TDD with stripe
285
323
  test_files:
@@ -296,6 +334,7 @@ test_files:
296
334
  - spec/readme_spec.rb
297
335
  - spec/server_spec.rb
298
336
  - spec/shared_stripe_examples/account_examples.rb
337
+ - spec/shared_stripe_examples/account_link_examples.rb
299
338
  - spec/shared_stripe_examples/balance_examples.rb
300
339
  - spec/shared_stripe_examples/balance_transaction_examples.rb
301
340
  - spec/shared_stripe_examples/bank_examples.rb
@@ -303,25 +342,35 @@ test_files:
303
342
  - spec/shared_stripe_examples/card_examples.rb
304
343
  - spec/shared_stripe_examples/card_token_examples.rb
305
344
  - spec/shared_stripe_examples/charge_examples.rb
345
+ - spec/shared_stripe_examples/checkout_examples.rb
306
346
  - spec/shared_stripe_examples/country_specs_examples.rb
307
347
  - spec/shared_stripe_examples/coupon_examples.rb
308
348
  - spec/shared_stripe_examples/customer_examples.rb
309
349
  - spec/shared_stripe_examples/dispute_examples.rb
310
350
  - spec/shared_stripe_examples/ephemeral_key_examples.rb
311
351
  - spec/shared_stripe_examples/error_mock_examples.rb
352
+ - spec/shared_stripe_examples/express_login_link_examples.rb
312
353
  - spec/shared_stripe_examples/external_account_examples.rb
313
354
  - spec/shared_stripe_examples/extra_features_examples.rb
314
355
  - spec/shared_stripe_examples/invoice_examples.rb
315
356
  - spec/shared_stripe_examples/invoice_item_examples.rb
357
+ - spec/shared_stripe_examples/payment_intent_examples.rb
358
+ - spec/shared_stripe_examples/payment_method_examples.rb
316
359
  - spec/shared_stripe_examples/payout_examples.rb
317
360
  - spec/shared_stripe_examples/plan_examples.rb
361
+ - spec/shared_stripe_examples/price_examples.rb
362
+ - spec/shared_stripe_examples/product_examples.rb
318
363
  - spec/shared_stripe_examples/recipient_examples.rb
319
364
  - spec/shared_stripe_examples/refund_examples.rb
365
+ - spec/shared_stripe_examples/setup_intent_examples.rb
320
366
  - spec/shared_stripe_examples/subscription_examples.rb
367
+ - spec/shared_stripe_examples/subscription_items_examples.rb
368
+ - spec/shared_stripe_examples/tax_rate_examples.rb
321
369
  - spec/shared_stripe_examples/transfer_examples.rb
322
370
  - spec/shared_stripe_examples/validation_examples.rb
323
371
  - spec/shared_stripe_examples/webhook_event_examples.rb
324
372
  - spec/spec_helper.rb
325
373
  - spec/stripe_mock_spec.rb
374
+ - spec/support/shared_contexts/stripe_validator_spec.rb
326
375
  - spec/support/stripe_examples.rb
327
376
  - spec/util_spec.rb