stripe-ruby-mock 2.2.2 → 2.2.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/data.rb +2 -2
- data/lib/stripe_mock/instance.rb +3 -1
- data/lib/stripe_mock/request_handlers/charges.rb +4 -0
- data/lib/stripe_mock/version.rb +1 -1
- data/spec/shared_stripe_examples/account_examples.rb +37 -23
- data/spec/shared_stripe_examples/charge_examples.rb +8 -2
- data/stripe-ruby-mock.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bba43dc6fa6783116ffe44184f71d0dfde22dfd7
|
4
|
+
data.tar.gz: 3edc82d06fc617bc52edc782c78f5f88add7c032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98260ded2e2586fae954ccb8c5a27c42e408a6d9493b40175576aa39638648f4a0fc18054c2284c37efdbf231fd27adcd75aa9d9a2e9cf9e7131452e3b9a0d12
|
7
|
+
data.tar.gz: 6ae328b0864be28dc176b5b318c60a85c54528d1a8a123beb44332d390915455fda8b432bc6b6072397abf044a15f70592b4fb41c8c2f600f4f287d87cdf8d2f
|
data/README.md
CHANGED
data/lib/stripe_mock/data.rb
CHANGED
data/lib/stripe_mock/instance.rb
CHANGED
@@ -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)
|
data/lib/stripe_mock/version.rb
CHANGED
@@ -1,36 +1,50 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
shared_examples 'Account API' do
|
4
|
-
|
5
|
-
account
|
4
|
+
describe 'retrive accounts' do
|
5
|
+
it 'retrieves a stripe account', live: true do
|
6
|
+
account = Stripe::Account.retrieve
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
20
|
-
|
20
|
+
expect(accounts).to be_a Stripe::ListObject
|
21
|
+
expect(accounts.data.count).to satisfy { |n| n >= 1 }
|
22
|
+
end
|
21
23
|
end
|
22
|
-
|
23
|
-
|
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
|
-
|
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
|
-
|
28
|
-
account
|
29
|
-
|
30
|
-
|
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
|
-
|
45
|
+
account = Stripe::Account.retrieve
|
33
46
|
|
34
|
-
|
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
|
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
|
data/stripe-ruby-mock.gemspec
CHANGED
@@ -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.
|
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-
|
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
|