stripe-ruby-mock 2.2.2 → 2.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a3f469690e470da019f337118d96a77c8c79e94
4
- data.tar.gz: 814f1be8eb9b4705d71cd4fa499471a013e721ca
3
+ metadata.gz: bba43dc6fa6783116ffe44184f71d0dfde22dfd7
4
+ data.tar.gz: 3edc82d06fc617bc52edc782c78f5f88add7c032
5
5
  SHA512:
6
- metadata.gz: 5d239d1dee0fb1d15899117d338474425d582645a1d3672e5dc0cb878b65ce4731df1aa5c38038b822fab7de268d8f5b7e522ceadc6eeeec5a95dca5bce12a26
7
- data.tar.gz: 0f92c4bc3175302ac010f34bf27357dd2e2f48080e3b8463edb1972a5a6d07a667583452878b44ce1713e05643cf3f7ed340faac6ee40c706c47611ac625d38b
6
+ metadata.gz: 98260ded2e2586fae954ccb8c5a27c42e408a6d9493b40175576aa39638648f4a0fc18054c2284c37efdbf231fd27adcd75aa9d9a2e9cf9e7131452e3b9a0d12
7
+ data.tar.gz: 6ae328b0864be28dc176b5b318c60a85c54528d1a8a123beb44332d390915455fda8b432bc6b6072397abf044a15f70592b4fb41c8c2f600f4f287d87cdf8d2f
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.2.2', :require => 'stripe_mock'
15
+ gem 'stripe-ruby-mock', '~> 2.2.3', :require => 'stripe_mock'
16
16
 
17
17
  ## Features
18
18
 
@@ -85,8 +85,8 @@ module StripeMock
85
85
  avs_failure: false
86
86
  },
87
87
  keys: {
88
- secret: nil,
89
- publishable: nil
88
+ secret: "sk_test_AmJhMTLPtY9JL4c6EG0",
89
+ publishable: "pk_test_2rSaMTLPtY9JL449dsf"
90
90
  }
91
91
  }.merge(params)
92
92
  end
@@ -4,6 +4,8 @@ module StripeMock
4
4
  include StripeMock::RequestHandlers::Helpers
5
5
  include StripeMock::RequestHandlers::ParamValidators
6
6
 
7
+ DUMMY_API_KEY = (0...32).map { (65 + rand(26)).chr }.join.downcase
8
+
7
9
  # Handlers are ordered by priority
8
10
  @@handlers = []
9
11
 
@@ -71,7 +73,7 @@ module StripeMock
71
73
  def mock_request(method, url, api_key, params={}, headers={}, api_base_url=nil)
72
74
  return {} if method == :xtest
73
75
 
74
- api_key ||= Stripe.api_key
76
+ api_key ||= (Stripe.api_key || DUMMY_API_KEY)
75
77
 
76
78
  # Ensure params hash has symbols as keys
77
79
  params = Stripe::Util.symbolize_names(params)
@@ -78,6 +78,10 @@ module StripeMock
78
78
  add_refund_to_charge(refund, charge)
79
79
  end
80
80
 
81
+ if params[:application_fee]
82
+ charge[:application_fee] = params[:application_fee]
83
+ end
84
+
81
85
  charge[:captured] = true
82
86
  charge
83
87
  end
@@ -1,4 +1,4 @@
1
1
  module StripeMock
2
2
  # stripe-ruby-mock version
3
- VERSION = "2.2.2"
3
+ VERSION = "2.2.3"
4
4
  end
@@ -1,36 +1,50 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  shared_examples 'Account API' do
4
- it 'retrieves a stripe account', live: true do
5
- account = Stripe::Account.retrieve
4
+ describe 'retrive accounts' do
5
+ it 'retrieves a stripe account', live: true do
6
+ account = Stripe::Account.retrieve
6
7
 
7
- expect(account).to be_a Stripe::Account
8
- expect(account.id).to match /acct\_/
9
- end
10
- it 'retrieves a specific stripe account' do
11
- account = Stripe::Account.retrieve('acct_103ED82ePvKYlo2C')
8
+ expect(account).to be_a Stripe::Account
9
+ expect(account.id).to match /acct\_/
10
+ end
11
+ it 'retrieves a specific stripe account' do
12
+ account = Stripe::Account.retrieve('acct_103ED82ePvKYlo2C')
12
13
 
13
- expect(account).to be_a Stripe::Account
14
- expect(account.id).to match /acct\_/
15
- end
16
- it 'retrieves all' do
17
- accounts = Stripe::Account.all
14
+ expect(account).to be_a Stripe::Account
15
+ expect(account.id).to match /acct\_/
16
+ end
17
+ it 'retrieves all' do
18
+ accounts = Stripe::Account.all
18
19
 
19
- expect(accounts).to be_a Stripe::ListObject
20
- expect(accounts.data.count).to satisfy { |n| n >= 1 }
20
+ expect(accounts).to be_a Stripe::ListObject
21
+ expect(accounts.data.count).to satisfy { |n| n >= 1 }
22
+ end
21
23
  end
22
- it 'creates one more account' do
23
- account = Stripe::Account.create(email: 'lol@what.com')
24
+ describe 'create account' do
25
+ it 'creates one more account' do
26
+ account = Stripe::Account.create(email: 'lol@what.com')
27
+
28
+ expect(account).to be_a Stripe::Account
29
+ end
30
+ it 'create managed account' do
31
+ account = Stripe::Account.create(managed: true, country: 'CA')
24
32
 
25
- expect(account).to be_a Stripe::Account
33
+ # expect(account).to include(:keys)
34
+ expect(account.keys).not_to be_nil
35
+ expect(account.keys.secret).to match /sk_(live|test)_[\d\w]+/
36
+ expect(account.keys.publishable).to match /pk_(live|test)_[\d\w]+/
37
+ end
26
38
  end
27
- it 'updates account' do
28
- account = Stripe::Account.retrieve
29
- account.support_phone = '1234567'
30
- account.save
39
+ describe 'updates account' do
40
+ it 'updates account' do
41
+ account = Stripe::Account.retrieve
42
+ account.support_phone = '1234567'
43
+ account.save
31
44
 
32
- account = Stripe::Account.retrieve
45
+ account = Stripe::Account.retrieve
33
46
 
34
- expect(account.support_phone).to eq '1234567'
47
+ expect(account.support_phone).to eq '1234567'
48
+ end
35
49
  end
36
50
  end
@@ -199,7 +199,12 @@ shared_examples 'Charge API' do
199
199
  charge.amount = 777
200
200
  charge.source = {any: "source"}
201
201
 
202
- expect { charge.save }.to raise_error(Stripe::InvalidRequestError, /Received unknown parameters: currency, amount, source/i)
202
+ expect { charge.save }.to raise_error(Stripe::InvalidRequestError) do |error|
203
+ expect(error.message).to match(/Received unknown parameters/)
204
+ expect(error.message).to match(/currency/)
205
+ expect(error.message).to match(/amount/)
206
+ expect(error.message).to match(/source/)
207
+ end
203
208
  end
204
209
 
205
210
 
@@ -335,9 +340,10 @@ shared_examples 'Charge API' do
335
340
  capture: false
336
341
  })
337
342
 
338
- returned_charge = charge.capture({ amount: 677 })
343
+ returned_charge = charge.capture({ amount: 677, application_fee: 123 })
339
344
  expect(charge.captured).to eq(true)
340
345
  expect(returned_charge.amount_refunded).to eq(100)
346
+ expect(returned_charge.application_fee).to eq(123)
341
347
  expect(returned_charge.id).to eq(charge.id)
342
348
  expect(returned_charge.captured).to eq(true)
343
349
  end
@@ -17,7 +17,7 @@ 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', '1.31.0'
20
+ gem.add_dependency 'stripe', '>= 1.31.0'
21
21
  gem.add_dependency 'jimson-temp'
22
22
  gem.add_dependency 'dante', '>= 0.2.0'
23
23
 
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-ruby-mock
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilbert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-05-05 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
19
  version: 1.31.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.31.0
27
27
  - !ruby/object:Gem::Dependency