stripe-ruby-mock 2.5.2 → 2.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/stripe_mock/api/client.rb +2 -2
- data/lib/stripe_mock/api/instance.rb +6 -6
- data/lib/stripe_mock/request_handlers/charges.rb +1 -1
- data/lib/stripe_mock/version.rb +1 -1
- data/spec/shared_stripe_examples/charge_examples.rb +17 -0
- data/spec/stripe_mock_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e81f8b287a3ea9c2c80e4376f24a61e93dc7c0e
|
4
|
+
data.tar.gz: b8da1c4bfe60eacb520828cf2ea86341bff536ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a8fc8faa377c537d8c67893b1d71b65ed21e241827e4a391ca73fbc46333a66e6fb7bfb011e9f83a47d7019f6a75bdc738c04e42dc7e78a5b3ef7d1d46349e2
|
7
|
+
data.tar.gz: 028228088b4f8848c7fadae70fdcaf10a939975e08cad0b2efb45547f172ad0e79c7b79a7ff8d56687d41fba09311812c1240a9dffdebb6d0073e1a09872ff72
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ module StripeMock
|
|
8
8
|
return false if @state == 'live'
|
9
9
|
return @client unless @client.nil?
|
10
10
|
|
11
|
-
|
11
|
+
Stripe::StripeClient.send(:define_method, :execute_request) { |*args| StripeMock.redirect_to_mock_server(*args) }
|
12
12
|
@client = StripeMock::Client.new(port)
|
13
13
|
@state = 'remote'
|
14
14
|
@client
|
@@ -18,7 +18,7 @@ module StripeMock
|
|
18
18
|
return false unless @state == 'remote'
|
19
19
|
@state = 'ready'
|
20
20
|
|
21
|
-
|
21
|
+
restore_stripe_execute_request_method
|
22
22
|
@client.clear_server_data if opts[:clear_server_data] == true
|
23
23
|
@client.cleanup
|
24
24
|
@client = nil
|
@@ -2,18 +2,18 @@ module StripeMock
|
|
2
2
|
|
3
3
|
@state = 'ready'
|
4
4
|
@instance = nil
|
5
|
-
@
|
5
|
+
@original_execute_request_method = Stripe::StripeClient.instance_method(:execute_request)
|
6
6
|
|
7
7
|
def self.start
|
8
8
|
return false if @state == 'live'
|
9
|
-
@instance = Instance.new
|
10
|
-
|
9
|
+
@instance = instance = Instance.new
|
10
|
+
Stripe::StripeClient.send(:define_method, :execute_request) { |*args| instance.mock_request(*args) }
|
11
11
|
@state = 'local'
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.stop
|
15
15
|
return unless @state == 'local'
|
16
|
-
|
16
|
+
restore_stripe_execute_request_method
|
17
17
|
@instance = nil
|
18
18
|
@state = 'ready'
|
19
19
|
end
|
@@ -28,8 +28,8 @@ module StripeMock
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def self.
|
32
|
-
Stripe::StripeClient.
|
31
|
+
def self.restore_stripe_execute_request_method
|
32
|
+
Stripe::StripeClient.send(:define_method, :execute_request, @original_execute_request_method)
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.instance; @instance; end
|
@@ -160,7 +160,7 @@ module StripeMock
|
|
160
160
|
end
|
161
161
|
|
162
162
|
def allowed_params(params)
|
163
|
-
allowed = [:description, :metadata, :receipt_email, :fraud_details, :shipping]
|
163
|
+
allowed = [:description, :metadata, :receipt_email, :fraud_details, :shipping, :destination]
|
164
164
|
|
165
165
|
# This is a workaround for the way the Stripe API sends params even when they aren't modified.
|
166
166
|
# Stipe will include those params even when they aren't modified.
|
data/lib/stripe_mock/version.rb
CHANGED
@@ -257,6 +257,23 @@ shared_examples 'Charge API' do
|
|
257
257
|
expect(updated.fraud_details.to_hash).to eq(charge.fraud_details.to_hash)
|
258
258
|
end
|
259
259
|
|
260
|
+
it "updates a stripe charge with no changes" do
|
261
|
+
original = Stripe::Charge.create({
|
262
|
+
amount: 777,
|
263
|
+
currency: 'USD',
|
264
|
+
source: stripe_helper.generate_card_token,
|
265
|
+
description: 'Original description',
|
266
|
+
destination: {
|
267
|
+
account: "acct_SOMEBOGUSID",
|
268
|
+
amount: 150
|
269
|
+
}
|
270
|
+
})
|
271
|
+
|
272
|
+
expect {
|
273
|
+
updated = original.save
|
274
|
+
}.not_to raise_error
|
275
|
+
end
|
276
|
+
|
260
277
|
it "marks a charge as safe" do
|
261
278
|
original = Stripe::Charge.create({
|
262
279
|
amount: 777,
|
data/spec/stripe_mock_spec.rb
CHANGED
@@ -8,6 +8,12 @@ describe StripeMock do
|
|
8
8
|
StripeMock.stop
|
9
9
|
end
|
10
10
|
|
11
|
+
it "overrides stripe's execute_request method in other threads" do
|
12
|
+
StripeMock.start
|
13
|
+
Thread.new { Stripe::StripeClient.active_client.execute_request(:xtest, '/', api_key: 'abcde') }.join # no error
|
14
|
+
StripeMock.stop
|
15
|
+
end
|
16
|
+
|
11
17
|
it "reverts overriding stripe's request method" do
|
12
18
|
StripeMock.start
|
13
19
|
Stripe::StripeClient.active_client.execute_request(:xtest, '/', api_key: 'abcde') # no error
|
@@ -15,6 +21,13 @@ describe StripeMock do
|
|
15
21
|
expect { Stripe::StripeClient.active_client.execute_request(:x, '/', api_key: 'abcde') }.to raise_error ArgumentError
|
16
22
|
end
|
17
23
|
|
24
|
+
it "reverts overriding stripe's execute_request method in other threads" do
|
25
|
+
StripeMock.start
|
26
|
+
Thread.new { Stripe::StripeClient.active_client.execute_request(:xtest, '/', api_key: 'abcde') }.join # no error
|
27
|
+
StripeMock.stop
|
28
|
+
expect { Thread.new { Stripe::StripeClient.active_client.execute_request(:x, '/', api_key: 'abcde') }.join }.to raise_error ArgumentError
|
29
|
+
end
|
30
|
+
|
18
31
|
it "does not persist data between mock sessions" do
|
19
32
|
StripeMock.start
|
20
33
|
StripeMock.instance.customers[:x] = 9
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe-ruby-mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gilbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stripe
|