stripe-ruby-mock 2.5.8 → 3.0.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +6 -6
- data/README.md +8 -8
- data/lib/stripe_mock.rb +3 -0
- data/lib/stripe_mock/api/errors.rb +31 -28
- data/lib/stripe_mock/api/webhooks.rb +3 -0
- data/lib/stripe_mock/data.rb +140 -13
- data/lib/stripe_mock/instance.rb +10 -3
- data/lib/stripe_mock/request_handlers/balance_transactions.rb +2 -2
- data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +1 -1
- data/lib/stripe_mock/request_handlers/helpers/token_helpers.rb +1 -1
- data/lib/stripe_mock/request_handlers/invoices.rb +6 -1
- data/lib/stripe_mock/request_handlers/payment_intents.rb +175 -0
- data/lib/stripe_mock/request_handlers/payment_methods.rb +138 -0
- data/lib/stripe_mock/request_handlers/products.rb +1 -0
- data/lib/stripe_mock/request_handlers/setup_intents.rb +93 -0
- data/lib/stripe_mock/request_handlers/subscriptions.rb +17 -4
- data/lib/stripe_mock/request_handlers/validators/param_validators.rb +95 -9
- data/lib/stripe_mock/test_strategies/base.rb +42 -8
- data/lib/stripe_mock/test_strategies/live.rb +23 -12
- data/lib/stripe_mock/test_strategies/mock.rb +6 -2
- data/lib/stripe_mock/version.rb +1 -1
- data/lib/stripe_mock/webhook_fixtures/charge.failed.json +166 -38
- data/lib/stripe_mock/webhook_fixtures/customer.created.json +1 -0
- data/lib/stripe_mock/webhook_fixtures/customer.updated.json +1 -0
- data/lib/stripe_mock/webhook_fixtures/product.created.json +34 -0
- data/lib/stripe_mock/webhook_fixtures/product.deleted.json +34 -0
- data/lib/stripe_mock/webhook_fixtures/product.updated.json +38 -0
- data/spec/instance_spec.rb +6 -6
- data/spec/server_spec.rb +2 -1
- data/spec/shared_stripe_examples/account_examples.rb +1 -1
- data/spec/shared_stripe_examples/balance_transaction_examples.rb +3 -3
- data/spec/shared_stripe_examples/bank_examples.rb +3 -3
- data/spec/shared_stripe_examples/card_examples.rb +4 -4
- data/spec/shared_stripe_examples/charge_examples.rb +9 -22
- data/spec/shared_stripe_examples/coupon_examples.rb +1 -1
- data/spec/shared_stripe_examples/customer_examples.rb +44 -30
- data/spec/shared_stripe_examples/dispute_examples.rb +2 -2
- data/spec/shared_stripe_examples/error_mock_examples.rb +8 -7
- data/spec/shared_stripe_examples/external_account_examples.rb +3 -3
- data/spec/shared_stripe_examples/invoice_examples.rb +41 -39
- data/spec/shared_stripe_examples/invoice_item_examples.rb +1 -1
- data/spec/shared_stripe_examples/payment_intent_examples.rb +137 -0
- data/spec/shared_stripe_examples/payment_method_examples.rb +185 -0
- data/spec/shared_stripe_examples/payout_examples.rb +2 -2
- data/spec/shared_stripe_examples/plan_examples.rb +135 -92
- data/spec/shared_stripe_examples/product_examples.rb +155 -0
- data/spec/shared_stripe_examples/refund_examples.rb +25 -21
- data/spec/shared_stripe_examples/setup_intent_examples.rb +68 -0
- data/spec/shared_stripe_examples/subscription_examples.rb +281 -310
- data/spec/shared_stripe_examples/subscription_items_examples.rb +3 -2
- data/spec/shared_stripe_examples/transfer_examples.rb +6 -6
- data/spec/shared_stripe_examples/webhook_event_examples.rb +11 -11
- data/spec/spec_helper.rb +3 -4
- data/spec/stripe_mock_spec.rb +2 -2
- data/spec/support/shared_contexts/stripe_validator_spec.rb +8 -0
- data/spec/support/stripe_examples.rb +3 -0
- data/stripe-ruby-mock.gemspec +2 -2
- metadata +47 -27
- data/spec/shared_stripe_examples/product_example.rb +0 -65
@@ -2,8 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
shared_examples 'Subscription Items API' do
|
4
4
|
let(:stripe_helper) { StripeMock.create_test_helper }
|
5
|
-
let(:
|
6
|
-
let(:
|
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) }
|
7
8
|
let(:customer) { Stripe::Customer.create(source: stripe_helper.generate_card_token) }
|
8
9
|
let(:subscription) { Stripe::Subscription.create(customer: customer.id, items: [{ plan: plan.id }]) }
|
9
10
|
|
@@ -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.
|
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.
|
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
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.
|
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.
|
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: "custom", email: "#{SecureRandom.uuid}@example.com",
|
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: "custom", email: "#{SecureRandom.uuid}@example.com",
|
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.
|
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.
|
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
@@ -30,10 +30,9 @@ RSpec.configure do |c|
|
|
30
30
|
if ENV['IS_TRAVIS']
|
31
31
|
puts "Travis ruby version: #{RUBY_VERSION}"
|
32
32
|
api_key = case RUBY_VERSION
|
33
|
-
when '2.
|
34
|
-
when '2.
|
35
|
-
when '2.
|
36
|
-
when '2.3.4' then ENV['STRIPE_TEST_SECRET_KEY_D']
|
33
|
+
when '2.4.6' then ENV['STRIPE_TEST_SECRET_KEY_A']
|
34
|
+
when '2.5.5' then ENV['STRIPE_TEST_SECRET_KEY_B']
|
35
|
+
when '2.6.3' then ENV['STRIPE_TEST_SECRET_KEY_C']
|
37
36
|
end
|
38
37
|
else
|
39
38
|
api_key = ENV['STRIPE_TEST_SECRET_KEY']
|
data/spec/stripe_mock_spec.rb
CHANGED
@@ -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
|
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
|
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
|
@@ -25,6 +25,9 @@ def it_behaves_like_stripe(&block)
|
|
25
25
|
it_behaves_like 'Refund API', &block
|
26
26
|
it_behaves_like 'Transfer API', &block
|
27
27
|
it_behaves_like 'Payout API', &block
|
28
|
+
it_behaves_like 'PaymentIntent API', &block
|
29
|
+
it_behaves_like 'PaymentMethod API', &block
|
30
|
+
it_behaves_like 'SetupIntent API', &block
|
28
31
|
it_behaves_like 'Stripe Error Mocking', &block
|
29
32
|
it_behaves_like 'Customer Subscriptions', &block
|
30
33
|
it_behaves_like 'Subscription Items API', &block
|
data/stripe-ruby-mock.gemspec
CHANGED
@@ -17,11 +17,11 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
-
gem.add_dependency 'stripe', '
|
20
|
+
gem.add_dependency 'stripe', '> 5', '< 6'
|
21
21
|
gem.add_dependency 'multi_json', '~> 1.0'
|
22
22
|
gem.add_dependency 'dante', '>= 0.2.0'
|
23
23
|
|
24
|
-
gem.add_development_dependency 'rspec', '~> 3.
|
24
|
+
gem.add_development_dependency 'rspec', '~> 3.7.0'
|
25
25
|
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
26
26
|
gem.add_development_dependency 'thin', '~> 1.6.4'
|
27
27
|
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:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gilbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-17 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:
|
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:
|
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.
|
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.
|
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,10 @@ 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"
|
108
114
|
- Gemfile
|
109
115
|
- LICENSE.txt
|
110
116
|
- README.md
|
@@ -157,11 +163,14 @@ files:
|
|
157
163
|
- lib/stripe_mock/request_handlers/invoice_items.rb
|
158
164
|
- lib/stripe_mock/request_handlers/invoices.rb
|
159
165
|
- lib/stripe_mock/request_handlers/orders.rb
|
166
|
+
- lib/stripe_mock/request_handlers/payment_intents.rb
|
167
|
+
- lib/stripe_mock/request_handlers/payment_methods.rb
|
160
168
|
- lib/stripe_mock/request_handlers/payouts.rb
|
161
169
|
- lib/stripe_mock/request_handlers/plans.rb
|
162
170
|
- lib/stripe_mock/request_handlers/products.rb
|
163
171
|
- lib/stripe_mock/request_handlers/recipients.rb
|
164
172
|
- lib/stripe_mock/request_handlers/refunds.rb
|
173
|
+
- lib/stripe_mock/request_handlers/setup_intents.rb
|
165
174
|
- lib/stripe_mock/request_handlers/sources.rb
|
166
175
|
- lib/stripe_mock/request_handlers/subscription_items.rb
|
167
176
|
- lib/stripe_mock/request_handlers/subscriptions.rb
|
@@ -215,6 +224,9 @@ files:
|
|
215
224
|
- lib/stripe_mock/webhook_fixtures/plan.created.json
|
216
225
|
- lib/stripe_mock/webhook_fixtures/plan.deleted.json
|
217
226
|
- lib/stripe_mock/webhook_fixtures/plan.updated.json
|
227
|
+
- lib/stripe_mock/webhook_fixtures/product.created.json
|
228
|
+
- lib/stripe_mock/webhook_fixtures/product.deleted.json
|
229
|
+
- lib/stripe_mock/webhook_fixtures/product.updated.json
|
218
230
|
- lib/stripe_mock/webhook_fixtures/transfer.created.json
|
219
231
|
- lib/stripe_mock/webhook_fixtures/transfer.failed.json
|
220
232
|
- lib/stripe_mock/webhook_fixtures/transfer.paid.json
|
@@ -250,11 +262,14 @@ files:
|
|
250
262
|
- spec/shared_stripe_examples/extra_features_examples.rb
|
251
263
|
- spec/shared_stripe_examples/invoice_examples.rb
|
252
264
|
- spec/shared_stripe_examples/invoice_item_examples.rb
|
265
|
+
- spec/shared_stripe_examples/payment_intent_examples.rb
|
266
|
+
- spec/shared_stripe_examples/payment_method_examples.rb
|
253
267
|
- spec/shared_stripe_examples/payout_examples.rb
|
254
268
|
- spec/shared_stripe_examples/plan_examples.rb
|
255
|
-
- spec/shared_stripe_examples/
|
269
|
+
- spec/shared_stripe_examples/product_examples.rb
|
256
270
|
- spec/shared_stripe_examples/recipient_examples.rb
|
257
271
|
- spec/shared_stripe_examples/refund_examples.rb
|
272
|
+
- spec/shared_stripe_examples/setup_intent_examples.rb
|
258
273
|
- spec/shared_stripe_examples/subscription_examples.rb
|
259
274
|
- spec/shared_stripe_examples/subscription_items_examples.rb
|
260
275
|
- spec/shared_stripe_examples/tax_rate_examples.rb
|
@@ -263,6 +278,7 @@ files:
|
|
263
278
|
- spec/shared_stripe_examples/webhook_event_examples.rb
|
264
279
|
- spec/spec_helper.rb
|
265
280
|
- spec/stripe_mock_spec.rb
|
281
|
+
- spec/support/shared_contexts/stripe_validator_spec.rb
|
266
282
|
- spec/support/stripe_examples.rb
|
267
283
|
- spec/util_spec.rb
|
268
284
|
- stripe-ruby-mock.gemspec
|
@@ -276,17 +292,17 @@ require_paths:
|
|
276
292
|
- lib
|
277
293
|
required_ruby_version: !ruby/object:Gem::Requirement
|
278
294
|
requirements:
|
279
|
-
- -
|
295
|
+
- - ">="
|
280
296
|
- !ruby/object:Gem::Version
|
281
297
|
version: '0'
|
282
298
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
283
299
|
requirements:
|
284
|
-
- -
|
300
|
+
- - ">="
|
285
301
|
- !ruby/object:Gem::Version
|
286
302
|
version: '0'
|
287
303
|
requirements: []
|
288
304
|
rubyforge_project:
|
289
|
-
rubygems_version: 2.
|
305
|
+
rubygems_version: 2.6.8
|
290
306
|
signing_key:
|
291
307
|
specification_version: 4
|
292
308
|
summary: TDD with stripe
|
@@ -321,11 +337,14 @@ test_files:
|
|
321
337
|
- spec/shared_stripe_examples/extra_features_examples.rb
|
322
338
|
- spec/shared_stripe_examples/invoice_examples.rb
|
323
339
|
- spec/shared_stripe_examples/invoice_item_examples.rb
|
340
|
+
- spec/shared_stripe_examples/payment_intent_examples.rb
|
341
|
+
- spec/shared_stripe_examples/payment_method_examples.rb
|
324
342
|
- spec/shared_stripe_examples/payout_examples.rb
|
325
343
|
- spec/shared_stripe_examples/plan_examples.rb
|
326
|
-
- spec/shared_stripe_examples/
|
344
|
+
- spec/shared_stripe_examples/product_examples.rb
|
327
345
|
- spec/shared_stripe_examples/recipient_examples.rb
|
328
346
|
- spec/shared_stripe_examples/refund_examples.rb
|
347
|
+
- spec/shared_stripe_examples/setup_intent_examples.rb
|
329
348
|
- spec/shared_stripe_examples/subscription_examples.rb
|
330
349
|
- spec/shared_stripe_examples/subscription_items_examples.rb
|
331
350
|
- spec/shared_stripe_examples/tax_rate_examples.rb
|
@@ -334,5 +353,6 @@ test_files:
|
|
334
353
|
- spec/shared_stripe_examples/webhook_event_examples.rb
|
335
354
|
- spec/spec_helper.rb
|
336
355
|
- spec/stripe_mock_spec.rb
|
356
|
+
- spec/support/shared_contexts/stripe_validator_spec.rb
|
337
357
|
- spec/support/stripe_examples.rb
|
338
358
|
- spec/util_spec.rb
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_examples 'Product API' do
|
4
|
-
it 'creates a product' do
|
5
|
-
product = Stripe::Product.create(
|
6
|
-
name: 'my awesome product',
|
7
|
-
type: 'service'
|
8
|
-
)
|
9
|
-
|
10
|
-
expect(product.name).to eq 'my awesome product'
|
11
|
-
expect(product.type).to eq 'service'
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'retrieves a product' do
|
15
|
-
Stripe::Product.create(
|
16
|
-
id: 'test_prod_1',
|
17
|
-
name: 'my awesome product',
|
18
|
-
type: 'service'
|
19
|
-
)
|
20
|
-
|
21
|
-
product = Stripe::Product.retrieve('test_prod_1')
|
22
|
-
|
23
|
-
expect(product.name).to eq 'my awesome product'
|
24
|
-
expect(product.type).to eq 'service'
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'updates a product' do
|
28
|
-
Stripe::Product.create(
|
29
|
-
id: 'test_prod_1',
|
30
|
-
name: 'my awesome product',
|
31
|
-
type: 'service'
|
32
|
-
)
|
33
|
-
|
34
|
-
Stripe::Product.update('test_prod_1', name: 'my lame product')
|
35
|
-
|
36
|
-
product = Stripe::Product.retrieve('test_prod_1')
|
37
|
-
|
38
|
-
expect(product.name).to eq 'my lame product'
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'lists all products' do
|
42
|
-
2.times do |n|
|
43
|
-
Stripe::Product.create(
|
44
|
-
name: "product #{n}",
|
45
|
-
type: 'service'
|
46
|
-
)
|
47
|
-
end
|
48
|
-
|
49
|
-
products = Stripe::Product.list
|
50
|
-
|
51
|
-
expect(products.map(&:name)).to match_array ['product 0', 'product 1']
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'destroys a product', live: true do
|
55
|
-
Stripe::Product.create(
|
56
|
-
id: 'test_prod_1',
|
57
|
-
name: 'my awesome product',
|
58
|
-
type: 'service'
|
59
|
-
)
|
60
|
-
|
61
|
-
Stripe::Product.delete('test_prod_1')
|
62
|
-
|
63
|
-
expect { Stripe::Product.retrieve('test_prod_1') }. to raise_error(Stripe::InvalidRequestError)
|
64
|
-
end
|
65
|
-
end
|