stripe-ruby-mock 4.0.0 → 5.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/.github/workflows/rspec_tests.yml +16 -16
- data/Appraisals +7 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +2 -0
- data/README.md +9 -3
- data/bin/stripe-mock-server +1 -0
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/stripe_12.gemfile +13 -0
- data/gemfiles/stripe_12.gemfile.lock +60 -0
- data/gemfiles/stripe_13.gemfile +13 -0
- data/gemfiles/stripe_13.gemfile.lock +60 -0
- data/lib/stripe_mock/api/client.rb +12 -4
- data/lib/stripe_mock/api/instance.rb +5 -3
- data/lib/stripe_mock/client.rb +2 -3
- data/lib/stripe_mock/compat.rb +29 -0
- data/lib/stripe_mock/data.rb +61 -9
- data/lib/stripe_mock/instance.rb +47 -4
- data/lib/stripe_mock/request_handlers/checkout_session.rb +12 -11
- data/lib/stripe_mock/request_handlers/helpers/coupon_helpers.rb +1 -0
- data/lib/stripe_mock/request_handlers/invoices.rb +8 -2
- data/lib/stripe_mock/request_handlers/payment_intents.rb +1 -1
- data/lib/stripe_mock/request_handlers/payment_methods.rb +5 -1
- data/lib/stripe_mock/request_handlers/payouts.rb +10 -3
- data/lib/stripe_mock/request_handlers/subscriptions.rb +1 -1
- data/lib/stripe_mock/request_handlers/tax_ids.rb +66 -0
- data/lib/stripe_mock/server.rb +9 -4
- data/lib/stripe_mock/test_strategies/base.rb +0 -1
- data/lib/stripe_mock/util.rb +6 -0
- data/lib/stripe_mock/version.rb +1 -1
- data/lib/stripe_mock.rb +2 -1
- data/spec/instance_spec.rb +7 -2
- data/spec/list_spec.rb +1 -1
- data/spec/server_spec.rb +12 -3
- data/spec/shared_stripe_examples/account_examples.rb +1 -1
- data/spec/shared_stripe_examples/checkout_session_examples.rb +0 -5
- data/spec/shared_stripe_examples/customer_examples.rb +1 -1
- data/spec/shared_stripe_examples/payment_intent_examples.rb +13 -13
- data/spec/shared_stripe_examples/payment_method_examples.rb +10 -0
- data/spec/shared_stripe_examples/payout_examples.rb +26 -6
- data/spec/shared_stripe_examples/product_examples.rb +3 -0
- data/spec/shared_stripe_examples/setup_intent_examples.rb +5 -1
- data/spec/shared_stripe_examples/subscription_examples.rb +1 -1
- data/spec/shared_stripe_examples/transfer_examples.rb +10 -3
- data/spec/spec_helper.rb +1 -0
- data/spec/stripe_mock_spec.rb +35 -13
- data/stripe-ruby-mock.gemspec +2 -1
- metadata +33 -8
@@ -98,10 +98,17 @@ shared_examples 'Transfer API' do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
it "cancels a stripe transfer" do
|
101
|
-
|
102
|
-
|
101
|
+
if StripeMock::Compat.stripe_gte_13?
|
102
|
+
original = Stripe::Transfer.create(amount: "100", currency: "usd")
|
103
|
+
res, api_key = Stripe::APIRequestor.active_requestor.execute_request(:post, "/v1/transfers/#{original.id}/cancel", :api)
|
103
104
|
|
104
|
-
|
105
|
+
expect(res.status).to eq("canceled")
|
106
|
+
else
|
107
|
+
original = Stripe::Transfer.create(amount: "100", currency: "usd")
|
108
|
+
res, api_key = Stripe::StripeClient.active_client.execute_request(:post, "/v1/transfers/#{original.id}/cancel", api_key: 'api_key')
|
109
|
+
|
110
|
+
expect(res.data[:status]).to eq("canceled")
|
111
|
+
end
|
105
112
|
end
|
106
113
|
|
107
114
|
it "cannot retrieve a transfer that doesn't exist" do
|
data/spec/spec_helper.rb
CHANGED
data/spec/stripe_mock_spec.rb
CHANGED
@@ -4,28 +4,50 @@ describe StripeMock do
|
|
4
4
|
|
5
5
|
it "overrides stripe's request method" do
|
6
6
|
StripeMock.start
|
7
|
-
|
7
|
+
if StripeMock::Compat.stripe_gte_13?
|
8
|
+
StripeMock::Compat.active_client.send(StripeMock::Compat.method, :xtest, '/', :api, {}, {}, []) # no error
|
9
|
+
else
|
10
|
+
StripeMock::Compat.active_client.send(StripeMock::Compat.method, :xtest, '/', api_key: 'abcde') # no error
|
11
|
+
end
|
8
12
|
StripeMock.stop
|
9
13
|
end
|
10
14
|
|
11
15
|
it "overrides stripe's execute_request method in other threads" do
|
12
16
|
StripeMock.start
|
13
|
-
|
17
|
+
if StripeMock::Compat.stripe_gte_13?
|
18
|
+
Thread.new { StripeMock::Compat.active_client.send(StripeMock::Compat.method, :xtest, '/', :api, {}, {}, []) }.join # no error
|
19
|
+
else
|
20
|
+
Thread.new { StripeMock::Compat.active_client.send(StripeMock::Compat.method,:xtest, '/', api_key: 'abcde') }.join # no error
|
21
|
+
end
|
14
22
|
StripeMock.stop
|
15
23
|
end
|
16
24
|
|
17
25
|
it "reverts overriding stripe's request method" do
|
18
|
-
StripeMock.
|
19
|
-
|
20
|
-
|
21
|
-
|
26
|
+
if StripeMock::Compat.stripe_gte_13?
|
27
|
+
StripeMock.start
|
28
|
+
StripeMock::Compat.active_client.send(StripeMock::Compat.method, :xtest, '/', :api, {}, {}, []) # no error
|
29
|
+
StripeMock.stop
|
30
|
+
expect { StripeMock::Compat.active_client.send(StripeMock::Compat.method, :x, '/', :api, {}, {}, []) }.to raise_error Stripe::APIError
|
31
|
+
else
|
32
|
+
StripeMock.start
|
33
|
+
StripeMock::Compat.active_client.send(StripeMock::Compat.method, :xtest, '/', api_key: 'abcde') # no error
|
34
|
+
StripeMock.stop
|
35
|
+
expect { StripeMock::Compat.active_client.send(StripeMock::Compat.method, :x, '/', api_key: 'abcde') }.to raise_error Stripe::APIError
|
36
|
+
end
|
22
37
|
end
|
23
38
|
|
24
39
|
it "reverts overriding stripe's execute_request method in other threads" do
|
25
|
-
StripeMock.
|
26
|
-
|
27
|
-
|
28
|
-
|
40
|
+
if StripeMock::Compat.stripe_gte_13?
|
41
|
+
StripeMock.start
|
42
|
+
Thread.new { StripeMock::Compat.active_client.send(StripeMock::Compat.method, :xtest, '/', :api, {}, {}, []) }.join # no error
|
43
|
+
StripeMock.stop
|
44
|
+
expect { Thread.new { StripeMock::Compat.active_client.send(StripeMock::Compat.method, :x, '/', :api, {}, {}, []) }.join }.to raise_error Stripe::APIError
|
45
|
+
else
|
46
|
+
StripeMock.start
|
47
|
+
Thread.new { StripeMock::Compat.active_client.send(StripeMock::Compat.method, :xtest, '/', api_key: 'abcde') }.join # no error
|
48
|
+
StripeMock.stop
|
49
|
+
expect { Thread.new { StripeMock::Compat.active_client.send(StripeMock::Compat.method, :x, '/', api_key: 'abcde') }.join }.to raise_error Stripe::APIError
|
50
|
+
end
|
29
51
|
end
|
30
52
|
|
31
53
|
it "does not persist data between mock sessions" do
|
@@ -79,11 +101,11 @@ describe StripeMock do
|
|
79
101
|
|
80
102
|
it "cannot be toggled when already started" do
|
81
103
|
StripeMock.start
|
82
|
-
expect { StripeMock.toggle_live(true) }.to raise_error
|
104
|
+
expect { StripeMock.toggle_live(true) }.to raise_error(RuntimeError, "You cannot toggle StripeMock live when it has already started.")
|
83
105
|
StripeMock.stop
|
84
106
|
|
85
107
|
StripeMock.instance_variable_set(:@state, 'remote')
|
86
|
-
expect { StripeMock.toggle_live(true) }.to raise_error
|
108
|
+
expect { StripeMock.toggle_live(true) }.to raise_error(RuntimeError, "You cannot toggle StripeMock live when it has already started.")
|
87
109
|
end
|
88
110
|
end
|
89
111
|
|
@@ -104,7 +126,7 @@ describe StripeMock do
|
|
104
126
|
end
|
105
127
|
|
106
128
|
it "throws an error on an unknown strategy" do
|
107
|
-
expect { StripeMock.create_test_helper(:lol) }.to raise_error
|
129
|
+
expect { StripeMock.create_test_helper(:lol) }.to raise_error(RuntimeError, "Invalid test helper strategy: :lol")
|
108
130
|
end
|
109
131
|
|
110
132
|
it "can configure the default strategy" do
|
data/stripe-ruby-mock.gemspec
CHANGED
@@ -22,9 +22,10 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
23
23
|
gem.require_paths = ['lib']
|
24
24
|
|
25
|
-
gem.add_dependency 'stripe', '> 5', '<
|
25
|
+
gem.add_dependency 'stripe', '> 5', '< 14'
|
26
26
|
gem.add_dependency 'multi_json', '~> 1.0'
|
27
27
|
gem.add_dependency 'dante', '>= 0.2.0'
|
28
|
+
gem.add_dependency 'drb', '>= 2.0.4', '< 3'
|
28
29
|
|
29
30
|
gem.add_development_dependency 'rspec', '~> 3.13.0'
|
30
31
|
gem.add_development_dependency 'thin', '~> 1.8.1'
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe-ruby-mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gilbert
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: stripe
|
@@ -19,7 +18,7 @@ dependencies:
|
|
19
18
|
version: '5'
|
20
19
|
- - "<"
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
21
|
+
version: '14'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +28,7 @@ dependencies:
|
|
29
28
|
version: '5'
|
30
29
|
- - "<"
|
31
30
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
31
|
+
version: '14'
|
33
32
|
- !ruby/object:Gem::Dependency
|
34
33
|
name: multi_json
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,6 +57,26 @@ dependencies:
|
|
58
57
|
- - ">="
|
59
58
|
- !ruby/object:Gem::Version
|
60
59
|
version: 0.2.0
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: drb
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.0.4
|
67
|
+
- - "<"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 2.0.4
|
77
|
+
- - "<"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '3'
|
61
80
|
- !ruby/object:Gem::Dependency
|
62
81
|
name: rspec
|
63
82
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,12 +116,18 @@ files:
|
|
97
116
|
- ".github/workflows/rspec_tests.yml"
|
98
117
|
- ".gitignore"
|
99
118
|
- ".rspec"
|
119
|
+
- Appraisals
|
100
120
|
- CHANGELOG.md
|
101
121
|
- Gemfile
|
102
122
|
- LICENSE.txt
|
103
123
|
- README.md
|
104
124
|
- Rakefile
|
105
125
|
- bin/stripe-mock-server
|
126
|
+
- gemfiles/.bundle/config
|
127
|
+
- gemfiles/stripe_12.gemfile
|
128
|
+
- gemfiles/stripe_12.gemfile.lock
|
129
|
+
- gemfiles/stripe_13.gemfile
|
130
|
+
- gemfiles/stripe_13.gemfile.lock
|
106
131
|
- lib/stripe_mock.rb
|
107
132
|
- lib/stripe_mock/api/account_balance.rb
|
108
133
|
- lib/stripe_mock/api/bank_tokens.rb
|
@@ -118,6 +143,7 @@ files:
|
|
118
143
|
- lib/stripe_mock/api/test_helpers.rb
|
119
144
|
- lib/stripe_mock/api/webhooks.rb
|
120
145
|
- lib/stripe_mock/client.rb
|
146
|
+
- lib/stripe_mock/compat.rb
|
121
147
|
- lib/stripe_mock/data.rb
|
122
148
|
- lib/stripe_mock/data/list.rb
|
123
149
|
- lib/stripe_mock/error_queue.rb
|
@@ -167,6 +193,7 @@ files:
|
|
167
193
|
- lib/stripe_mock/request_handlers/sources.rb
|
168
194
|
- lib/stripe_mock/request_handlers/subscription_items.rb
|
169
195
|
- lib/stripe_mock/request_handlers/subscriptions.rb
|
196
|
+
- lib/stripe_mock/request_handlers/tax_ids.rb
|
170
197
|
- lib/stripe_mock/request_handlers/tax_rates.rb
|
171
198
|
- lib/stripe_mock/request_handlers/tokens.rb
|
172
199
|
- lib/stripe_mock/request_handlers/transfers.rb
|
@@ -329,7 +356,6 @@ metadata:
|
|
329
356
|
bug_tracker_uri: https://github.com/stripe-ruby-mock/stripe-ruby-mock/issues
|
330
357
|
changelog_uri: https://github.com/stripe-ruby-mock/stripe-ruby-mock/blob/master/CHANGELOG.md
|
331
358
|
source_code_uri: https://github.com/stripe-ruby-mock/stripe-ruby-mock
|
332
|
-
post_install_message:
|
333
359
|
rdoc_options: []
|
334
360
|
require_paths:
|
335
361
|
- lib
|
@@ -344,8 +370,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
344
370
|
- !ruby/object:Gem::Version
|
345
371
|
version: '0'
|
346
372
|
requirements: []
|
347
|
-
rubygems_version: 3.
|
348
|
-
signing_key:
|
373
|
+
rubygems_version: 3.6.7
|
349
374
|
specification_version: 4
|
350
375
|
summary: TDD with stripe
|
351
376
|
test_files:
|