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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87b7b9bf58b67006fc280c125219f07faea77268
4
- data.tar.gz: aa24705b3dcf69d0aacdac60f53e7e66a218939a
3
+ metadata.gz: 0e81f8b287a3ea9c2c80e4376f24a61e93dc7c0e
4
+ data.tar.gz: b8da1c4bfe60eacb520828cf2ea86341bff536ac
5
5
  SHA512:
6
- metadata.gz: 84ed5f9ecccbff291acb4aa5b3ce65470867c2fbf876cf336001cac17893429f5ba97f4b7d2bf16c27d56036094f9a0cf60dabc8d048ea80f06be9bedf19a187
7
- data.tar.gz: 26babda5f4790e6495339cab1ae83fb999b22073f6edb435baa4d4d7ae965db33744cc1f8946f33213ec4c085e8113d7f191ddae33906a9f5b41113fb2a977be
6
+ metadata.gz: 5a8fc8faa377c537d8c67893b1d71b65ed21e241827e4a391ca73fbc46333a66e6fb7bfb011e9f83a47d7019f6a75bdc738c04e42dc7e78a5b3ef7d1d46349e2
7
+ data.tar.gz: 028228088b4f8848c7fadae70fdcaf10a939975e08cad0b2efb45547f172ad0e79c7b79a7ff8d56687d41fba09311812c1240a9dffdebb6d0073e1a09872ff72
data/README.md CHANGED
@@ -12,7 +12,7 @@ This gem has unexpectedly grown in popularity and I've gotten pretty busy, so I'
12
12
 
13
13
  In your gemfile:
14
14
 
15
- gem 'stripe-ruby-mock', '~> 2.5.2', :require => 'stripe_mock'
15
+ gem 'stripe-ruby-mock', '~> 2.5.3', :require => 'stripe_mock'
16
16
 
17
17
  ## Features
18
18
 
@@ -8,7 +8,7 @@ module StripeMock
8
8
  return false if @state == 'live'
9
9
  return @client unless @client.nil?
10
10
 
11
- alias_stripe_method :execute_request, StripeMock.method(:redirect_to_mock_server)
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
- alias_stripe_method :request, @original_request_method
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
- @original_request_method = Stripe::StripeClient.active_client.method(:execute_request)
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
- alias_stripe_method :execute_request, @instance.method(:mock_request)
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
- alias_stripe_method :execute_request, @original_request_method
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.alias_stripe_method(new_name, method_object)
32
- Stripe::StripeClient.active_client.define_singleton_method(new_name) {|*args| method_object.call(*args) }
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.
@@ -1,4 +1,4 @@
1
1
  module StripeMock
2
2
  # stripe-ruby-mock version
3
- VERSION = "2.5.2"
3
+ VERSION = "2.5.3"
4
4
  end
@@ -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,
@@ -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.2
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-12 00:00:00.000000000 Z
11
+ date: 2018-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stripe