stripe-ruby-mock 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +7 -2
- data/README.md +22 -4
- data/lib/stripe_mock.rb +2 -0
- data/lib/stripe_mock/api/errors.rb +23 -11
- data/lib/stripe_mock/api/webhooks.rb +4 -4
- data/lib/stripe_mock/data.rb +19 -4
- data/lib/stripe_mock/data/list.rb +2 -5
- data/lib/stripe_mock/instance.rb +7 -3
- data/lib/stripe_mock/request_handlers/accounts.rb +35 -0
- data/lib/stripe_mock/request_handlers/charges.rb +28 -0
- data/lib/stripe_mock/request_handlers/coupons.rb +3 -2
- data/lib/stripe_mock/request_handlers/customers.rb +25 -2
- data/lib/stripe_mock/request_handlers/helpers/card_helpers.rb +3 -3
- data/lib/stripe_mock/request_handlers/helpers/coupon_helpers.rb +13 -0
- data/lib/stripe_mock/request_handlers/invoices.rb +1 -0
- data/lib/stripe_mock/request_handlers/subscriptions.rb +30 -2
- data/lib/stripe_mock/request_handlers/transfers.rb +5 -0
- data/lib/stripe_mock/request_handlers/validators/param_validators.rb +1 -1
- data/lib/stripe_mock/test_strategies/base.rb +35 -0
- data/lib/stripe_mock/test_strategies/live.rb +13 -0
- data/lib/stripe_mock/version.rb +1 -1
- data/lib/stripe_mock/webhook_fixtures/{customer.card.created.json → customer.source.created.json} +2 -2
- data/lib/stripe_mock/webhook_fixtures/{customer.card.deleted.json → customer.source.deleted.json} +2 -2
- data/lib/stripe_mock/webhook_fixtures/{customer.card.updated.json → customer.source.updated.json} +2 -2
- data/lib/stripe_mock/webhook_fixtures/transfer.created.json +1 -0
- data/lib/stripe_mock/webhook_fixtures/transfer.failed.json +1 -0
- data/lib/stripe_mock/webhook_fixtures/transfer.paid.json +1 -0
- data/lib/stripe_mock/webhook_fixtures/transfer.updated.json +1 -0
- data/spec/integration_examples/charge_token_examples.rb +16 -14
- data/spec/integration_examples/prepare_error_examples.rb +20 -0
- data/spec/shared_stripe_examples/account_examples.rb +17 -0
- data/spec/shared_stripe_examples/card_examples.rb +2 -1
- data/spec/shared_stripe_examples/charge_examples.rb +64 -0
- data/spec/shared_stripe_examples/coupon_examples.rb +68 -84
- data/spec/shared_stripe_examples/customer_examples.rb +57 -2
- data/spec/shared_stripe_examples/plan_examples.rb +1 -1
- data/spec/shared_stripe_examples/subscription_examples.rb +65 -0
- data/spec/shared_stripe_examples/transfer_examples.rb +14 -0
- data/spec/spec_helper.rb +18 -3
- data/spec/support/stripe_examples.rb +2 -0
- data/stripe-ruby-mock.gemspec +1 -1
- metadata +31 -41
@@ -1,95 +1,79 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
shared_examples 'Coupon API' do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
expect(coupon.metadata.to_hash).to eq( { :created_by => 'admin_acct_1' } )
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
it "stores a created stripe coupon in memory" do
|
35
|
-
coupon = Stripe::Coupon.create(
|
36
|
-
:id => '10BUCKS',
|
37
|
-
:amount_off => 1000,
|
38
|
-
:currency => 'USD',
|
39
|
-
:redeem_by => nil,
|
40
|
-
:max_redemptions => 100,
|
41
|
-
:metadata => {
|
42
|
-
:created_by => 'admin_acct_1',
|
43
|
-
},
|
44
|
-
)
|
45
|
-
coupon2 = Stripe::Coupon.create(percent_off_attributes)
|
46
|
-
|
47
|
-
data = test_data_source(:coupons)
|
48
|
-
expect(data[coupon.id]).to_not be_nil
|
49
|
-
expect(data[coupon.id][:amount_off]).to eq(1000)
|
50
|
-
|
51
|
-
expect(data[coupon2.id]).to_not be_nil
|
52
|
-
expect(data[coupon2.id][:percent_off]).to eq(25)
|
4
|
+
context 'create coupon' do
|
5
|
+
let(:coupon) { stripe_helper.create_coupon }
|
6
|
+
|
7
|
+
it 'creates a stripe coupon', live: true do
|
8
|
+
expect(coupon.id).to eq('10BUCKS')
|
9
|
+
expect(coupon.amount_off).to eq(1000)
|
10
|
+
|
11
|
+
expect(coupon.currency).to eq('usd')
|
12
|
+
expect(coupon.max_redemptions).to eq(100)
|
13
|
+
expect(coupon.metadata.to_hash).to eq( { :created_by => 'admin_acct_1' } )
|
14
|
+
expect(coupon.duration).to eq('once')
|
15
|
+
end
|
16
|
+
it 'stores a created stripe coupon in memory' do
|
17
|
+
coupon
|
18
|
+
|
19
|
+
data = test_data_source(:coupons)
|
20
|
+
|
21
|
+
expect(data[coupon.id]).to_not be_nil
|
22
|
+
expect(data[coupon.id][:amount_off]).to eq(1000)
|
23
|
+
end
|
24
|
+
it 'fails when a coupon is created without a duration' do
|
25
|
+
expect { Stripe::Coupon.create(id: '10PERCENT') }.to raise_error {|e|
|
26
|
+
expect(e).to be_a(Stripe::InvalidRequestError)
|
27
|
+
expect(e.message).to match /duration/
|
28
|
+
}
|
29
|
+
end
|
53
30
|
end
|
54
31
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
32
|
+
context 'retrieve coupon', live: true do
|
33
|
+
let(:coupon1) { stripe_helper.create_coupon }
|
34
|
+
let(:coupon2) { stripe_helper.create_coupon(id: '11BUCKS', amount_off: 3000) }
|
35
|
+
|
36
|
+
it 'retrieves a stripe coupon' do
|
37
|
+
coupon1
|
38
|
+
|
39
|
+
coupon = Stripe::Coupon.retrieve(coupon1.id)
|
40
|
+
|
41
|
+
expect(coupon.id).to eq(coupon1.id)
|
42
|
+
expect(coupon.amount_off).to eq(coupon1.amount_off)
|
43
|
+
end
|
44
|
+
it 'retrieves all coupons' do
|
45
|
+
stripe_helper.delete_all_coupons
|
46
|
+
|
47
|
+
coupon1
|
48
|
+
coupon2
|
49
|
+
|
50
|
+
all = Stripe::Coupon.all
|
51
|
+
|
52
|
+
expect(all.count).to eq(2)
|
53
|
+
expect(all.map &:id).to include('10BUCKS', '11BUCKS')
|
54
|
+
expect(all.map &:amount_off).to include(1000, 3000)
|
55
|
+
end
|
56
|
+
it "cannot retrieve a stripe coupon that doesn't exist" do
|
57
|
+
expect { Stripe::Coupon.retrieve('nope') }.to raise_error {|e|
|
58
|
+
expect(e).to be_a Stripe::InvalidRequestError
|
59
|
+
expect(e.param).to eq('id')
|
60
|
+
expect(e.http_status).to eq(404)
|
61
|
+
}
|
62
|
+
end
|
62
63
|
end
|
63
64
|
|
65
|
+
context 'Delete coupon', live: true do
|
66
|
+
it 'deletes a stripe coupon' do
|
67
|
+
original = stripe_helper.create_coupon
|
68
|
+
coupon = Stripe::Coupon.retrieve(original.id)
|
64
69
|
|
65
|
-
|
66
|
-
expect { Stripe::Coupon.retrieve('nope') }.to raise_error {|e|
|
67
|
-
expect(e).to be_a Stripe::InvalidRequestError
|
68
|
-
expect(e.param).to eq('coupon')
|
69
|
-
expect(e.http_status).to eq(404)
|
70
|
-
}
|
71
|
-
end
|
72
|
-
|
73
|
-
it "deletes a stripe coupon" do
|
74
|
-
original = Stripe::Coupon.create(percent_off_attributes)
|
75
|
-
coupon = Stripe::Coupon.retrieve(original.id)
|
76
|
-
|
77
|
-
coupon.delete
|
78
|
-
|
79
|
-
expect { Stripe::Coupon.retrieve(original.id) }.to raise_error {|e|
|
80
|
-
expect(e).to be_a Stripe::InvalidRequestError
|
81
|
-
expect(e.param).to eq('coupon')
|
82
|
-
expect(e.http_status).to eq(404)
|
83
|
-
}
|
84
|
-
end
|
85
|
-
|
86
|
-
it "retrieves all coupons" do
|
87
|
-
Stripe::Coupon.create({ id: 'Coupon One', amount_off: 1500 })
|
88
|
-
Stripe::Coupon.create({ id: 'Coupon Two', amount_off: 3000 })
|
70
|
+
coupon.delete
|
89
71
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
72
|
+
expect { Stripe::Coupon.retrieve(coupon.id) }.to raise_error {|e|
|
73
|
+
expect(e).to be_a Stripe::InvalidRequestError
|
74
|
+
expect(e.param).to eq('id')
|
75
|
+
expect(e.http_status).to eq(404)
|
76
|
+
}
|
77
|
+
end
|
94
78
|
end
|
95
79
|
end
|
@@ -38,6 +38,24 @@ shared_examples 'Customer API' do
|
|
38
38
|
expect(customer.default_source).to be_nil
|
39
39
|
end
|
40
40
|
|
41
|
+
it 'creates a stripe customer with a dictionary of card values', live: true do
|
42
|
+
customer = Stripe::Customer.create(source: {
|
43
|
+
object: 'card',
|
44
|
+
number: '4242424242424242',
|
45
|
+
exp_month: 12,
|
46
|
+
exp_year: 2024
|
47
|
+
},
|
48
|
+
email: 'blah@blah.com')
|
49
|
+
|
50
|
+
expect(customer).to be_a Stripe::Customer
|
51
|
+
expect(customer.id).to match(/cus_/)
|
52
|
+
expect(customer.email).to eq 'blah@blah.com'
|
53
|
+
expect(customer.sources.data.first.object).to eq 'card'
|
54
|
+
expect(customer.sources.data.first.last4).to eq '4242'
|
55
|
+
expect(customer.sources.data.first.exp_month).to eq 12
|
56
|
+
expect(customer.sources.data.first.exp_year).to eq 2024
|
57
|
+
end
|
58
|
+
|
41
59
|
it 'creates a customer with a plan' do
|
42
60
|
plan = stripe_helper.create_plan(id: 'silver')
|
43
61
|
customer = Stripe::Customer.create(id: 'test_cus_plan', source: gen_card_tk, :plan => 'silver')
|
@@ -98,6 +116,19 @@ shared_examples 'Customer API' do
|
|
98
116
|
expect(customer.subscriptions.first.trial_end).to eq(trial_end)
|
99
117
|
end
|
100
118
|
|
119
|
+
it 'creates a customer when trial_end is set and no source', live: true do
|
120
|
+
plan = stripe_helper.create_plan(id: 'silver', amount: 999)
|
121
|
+
trial_end = Time.now.utc.to_i + 3600
|
122
|
+
customer = Stripe::Customer.create(plan: 'silver', trial_end: trial_end)
|
123
|
+
expect(customer.subscriptions.count).to eq(1)
|
124
|
+
expect(customer.subscriptions.data.length).to eq(1)
|
125
|
+
|
126
|
+
expect(customer.subscriptions).to_not be_nil
|
127
|
+
expect(customer.subscriptions.first.plan.id).to eq('silver')
|
128
|
+
expect(customer.subscriptions.first.current_period_end).to eq(trial_end)
|
129
|
+
expect(customer.subscriptions.first.trial_end).to eq(trial_end)
|
130
|
+
end
|
131
|
+
|
101
132
|
it "returns no trial when trial_end is set to 'now'" do
|
102
133
|
plan = stripe_helper.create_plan(id: 'silver', amount: 999, trial_period_days: 14)
|
103
134
|
customer = Stripe::Customer.create(id: 'test_cus_trial_end', source: gen_card_tk, plan: 'silver', trial_end: "now")
|
@@ -153,6 +184,26 @@ shared_examples 'Customer API' do
|
|
153
184
|
}
|
154
185
|
end
|
155
186
|
|
187
|
+
it 'creates a customer with a coupon discount' do
|
188
|
+
coupon = Stripe::Coupon.create(id: "10PERCENT", duration: 'once')
|
189
|
+
|
190
|
+
customer =
|
191
|
+
Stripe::Customer.create(id: 'test_cus_coupon', coupon: '10PERCENT')
|
192
|
+
|
193
|
+
customer = Stripe::Customer.retrieve('test_cus_coupon')
|
194
|
+
expect(customer.discount).to_not be_nil
|
195
|
+
expect(customer.discount.coupon).to_not be_nil
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'cannot create a customer with a coupon that does not exist' do
|
199
|
+
expect{
|
200
|
+
customer = Stripe::Customer.create(id: 'test_cus_no_coupon', coupon: '5OFF')
|
201
|
+
}.to raise_error {|e|
|
202
|
+
expect(e).to be_a(Stripe::InvalidRequestError)
|
203
|
+
expect(e.message).to eq('No such coupon: 5OFF')
|
204
|
+
}
|
205
|
+
end
|
206
|
+
|
156
207
|
it "stores a created stripe customer in memory" do
|
157
208
|
customer = Stripe::Customer.create({
|
158
209
|
email: 'johnny@appleseed.com',
|
@@ -205,28 +256,32 @@ shared_examples 'Customer API' do
|
|
205
256
|
original = Stripe::Customer.create(id: 'test_customer_update')
|
206
257
|
email = original.email
|
207
258
|
|
259
|
+
coupon = Stripe::Coupon.create(id: "10PERCENT", duration: 'once')
|
208
260
|
original.description = 'new desc'
|
261
|
+
original.coupon = coupon.id
|
209
262
|
original.save
|
210
263
|
|
211
264
|
expect(original.email).to eq(email)
|
212
265
|
expect(original.description).to eq('new desc')
|
266
|
+
expect(original.discount.coupon).to be_a Stripe::Coupon
|
213
267
|
|
214
268
|
customer = Stripe::Customer.retrieve("test_customer_update")
|
215
269
|
expect(customer.email).to eq(original.email)
|
216
270
|
expect(customer.description).to eq('new desc')
|
271
|
+
expect(customer.discount.coupon).to be_a Stripe::Coupon
|
217
272
|
end
|
218
273
|
|
219
274
|
it "updates a stripe customer's card" do
|
220
275
|
original = Stripe::Customer.create(id: 'test_customer_update', source: gen_card_tk)
|
221
276
|
card = original.sources.data.first
|
222
277
|
expect(original.default_source).to eq(card.id)
|
223
|
-
expect(original.sources.count).to eq(1)
|
278
|
+
expect(original.sources.data.count).to eq(1)
|
224
279
|
|
225
280
|
original.source = gen_card_tk
|
226
281
|
original.save
|
227
282
|
|
228
283
|
new_card = original.sources.data.last
|
229
|
-
expect(original.sources.count).to eq(1)
|
284
|
+
expect(original.sources.data.count).to eq(1)
|
230
285
|
expect(original.default_source).to_not eq(card.id)
|
231
286
|
|
232
287
|
expect(new_card.id).to_not eq(card.id)
|
@@ -109,7 +109,7 @@ shared_examples 'Plan API' do
|
|
109
109
|
describe "Required Parameters" do
|
110
110
|
after do
|
111
111
|
params.delete(@name)
|
112
|
-
expect { subject }.to raise_error(Stripe::InvalidRequestError, "Missing required param: #{@name}")
|
112
|
+
expect { subject }.to raise_error(Stripe::InvalidRequestError, "Missing required param: #{@name}.")
|
113
113
|
end
|
114
114
|
|
115
115
|
it("requires a name") { @name = :name }
|
@@ -34,6 +34,31 @@ shared_examples 'Customer Subscriptions' do
|
|
34
34
|
|
35
35
|
end
|
36
36
|
|
37
|
+
it 'contains coupon object', live: true do
|
38
|
+
plan = stripe_helper.create_plan(id: 'plan_with_coupon', name: 'One More Test Plan', amount: 777)
|
39
|
+
coupon = stripe_helper.create_coupon(id: 'free_coupon', duration: 'repeating', duration_in_months: 3)
|
40
|
+
customer = Stripe::Customer.create(source: gen_card_tk)
|
41
|
+
customer.subscriptions.create(plan: plan.id, coupon: coupon.id)
|
42
|
+
customer = Stripe::Customer.retrieve(customer.id)
|
43
|
+
|
44
|
+
expect(customer.subscriptions.data).to be_a(Array)
|
45
|
+
expect(customer.subscriptions.data.count).to eq(1)
|
46
|
+
expect(customer.subscriptions.data.first.discount).not_to be_nil
|
47
|
+
expect(customer.subscriptions.data.first.discount).to be_a(Stripe::StripeObject)
|
48
|
+
expect(customer.subscriptions.data.first.discount.coupon.id).to eq(coupon.id)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'when coupon is not exist', live: true do
|
52
|
+
plan = stripe_helper.create_plan(id: 'plan_with_coupon', name: 'One More Test Plan', amount: 777)
|
53
|
+
customer = Stripe::Customer.create(source: gen_card_tk)
|
54
|
+
|
55
|
+
expect { customer.subscriptions.create(plan: plan.id, coupon: 'none') }.to raise_error {|e|
|
56
|
+
expect(e).to be_a Stripe::InvalidRequestError
|
57
|
+
expect(e.http_status).to eq(400)
|
58
|
+
expect(e.message).to eq('No such coupon: none')
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
37
62
|
it "correctly sets quantity, application_fee_percent and tax_percent" do
|
38
63
|
Stripe::Plan.create(
|
39
64
|
:amount => 2500,
|
@@ -250,6 +275,35 @@ shared_examples 'Customer Subscriptions' do
|
|
250
275
|
expect(customer.subscriptions.data.first.customer).to eq(customer.id)
|
251
276
|
end
|
252
277
|
|
278
|
+
it 'when adds coupon', live: true do
|
279
|
+
plan = stripe_helper.create_plan(id: 'plan_with_coupon2', name: 'One More Test Plan', amount: 777)
|
280
|
+
coupon = stripe_helper.create_coupon
|
281
|
+
customer = Stripe::Customer.create(source: gen_card_tk, plan: plan.id)
|
282
|
+
subscription = customer.subscriptions.retrieve(customer.subscriptions.data.first.id)
|
283
|
+
|
284
|
+
subscription.coupon = coupon.id
|
285
|
+
subscription.save
|
286
|
+
|
287
|
+
expect(subscription.discount).not_to be_nil
|
288
|
+
expect(subscription.discount).to be_an_instance_of(Stripe::StripeObject)
|
289
|
+
expect(subscription.discount.coupon.id).to eq(coupon.id)
|
290
|
+
end
|
291
|
+
|
292
|
+
it 'when add not exist coupon' do
|
293
|
+
plan = stripe_helper.create_plan(id: 'plan_with_coupon3', name: 'One More Test Plan', amount: 777)
|
294
|
+
customer = Stripe::Customer.create(source: gen_card_tk, plan: plan.id)
|
295
|
+
subscription = customer.subscriptions.retrieve(customer.subscriptions.data.first.id)
|
296
|
+
|
297
|
+
subscription.coupon = 'none'
|
298
|
+
|
299
|
+
expect { subscription.save }.to raise_error {|e|
|
300
|
+
expect(e).to be_a Stripe::InvalidRequestError
|
301
|
+
expect(e.http_status).to eq(400)
|
302
|
+
expect(e.message).to eq('No such coupon: none')
|
303
|
+
}
|
304
|
+
|
305
|
+
end
|
306
|
+
|
253
307
|
it "throws an error when plan does not exist" do
|
254
308
|
free = stripe_helper.create_plan(id: 'free', amount: 0)
|
255
309
|
customer = Stripe::Customer.create(id: 'cardless', plan: 'free')
|
@@ -305,6 +359,17 @@ shared_examples 'Customer Subscriptions' do
|
|
305
359
|
expect(customer.subscriptions.data.first.plan.to_hash).to eq(free.to_hash)
|
306
360
|
end
|
307
361
|
|
362
|
+
it 'updates a subscription if the customer has a free trial', live: true do
|
363
|
+
stripe_helper.create_plan(id: 'enterprise', amount: 499)
|
364
|
+
trial_end = Time.now.utc.to_i + 3600
|
365
|
+
customer = Stripe::Customer.create(plan: 'enterprise',
|
366
|
+
trial_end: trial_end)
|
367
|
+
subscription = customer.subscriptions.first
|
368
|
+
subscription.quantity = 2
|
369
|
+
subscription.save
|
370
|
+
expect(subscription.quantity).to eq(2)
|
371
|
+
end
|
372
|
+
|
308
373
|
it "updates a customer with no card to a plan with a free trial" do
|
309
374
|
free = stripe_helper.create_plan(id: 'free', amount: 0)
|
310
375
|
trial = stripe_helper.create_plan(id: 'trial', amount: 999, trial_period_days: 14)
|
@@ -64,4 +64,18 @@ shared_examples 'Transfer API' do
|
|
64
64
|
}
|
65
65
|
end
|
66
66
|
|
67
|
+
it 'when amount is not integer', live: true do
|
68
|
+
rec = Stripe::Recipient.create({
|
69
|
+
type: 'individual',
|
70
|
+
name: 'Alex Smith',
|
71
|
+
})
|
72
|
+
expect { Stripe::Transfer.create(amount: '400.2',
|
73
|
+
currency: 'usd',
|
74
|
+
recipient: rec.id,
|
75
|
+
description: 'Transfer for test@example.com') }.to raise_error { |e|
|
76
|
+
expect(e).to be_a Stripe::InvalidRequestError
|
77
|
+
expect(e.param).to eq('amount')
|
78
|
+
expect(e.http_status).to eq(400)
|
79
|
+
}
|
80
|
+
end
|
67
81
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -27,9 +27,18 @@ RSpec.configure do |c|
|
|
27
27
|
c.filter_run_excluding :mock_server => true, :oauth => true
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
if ENV['IS_TRAVIS']
|
31
|
+
puts "Travis ruby version: #{RUBY_VERSION}"
|
32
|
+
api_key = case RUBY_VERSION
|
33
|
+
when '1.9.3' then ENV['STRIPE_TEST_SECRET_KEY_A']
|
34
|
+
when '2.0.0' then ENV['STRIPE_TEST_SECRET_KEY_B']
|
35
|
+
when '2.1.6' then ENV['STRIPE_TEST_SECRET_KEY_C']
|
36
|
+
end
|
37
|
+
else
|
38
|
+
api_key = ENV['STRIPE_TEST_SECRET_KEY']
|
39
|
+
if api_key.nil? || api_key == ''
|
40
|
+
raise "Please set your STRIPE_TEST_SECRET_KEY environment variable."
|
41
|
+
end
|
33
42
|
end
|
34
43
|
|
35
44
|
c.before(:each) do
|
@@ -38,5 +47,11 @@ RSpec.configure do |c|
|
|
38
47
|
Stripe.api_key = api_key
|
39
48
|
end
|
40
49
|
c.after(:each) { sleep 1 }
|
50
|
+
else
|
51
|
+
c.filter_run_excluding :oauth => true
|
52
|
+
Stripe.api_key ||= ''
|
41
53
|
end
|
54
|
+
|
55
|
+
c.filter_run focus: true
|
56
|
+
c.run_all_when_everything_filtered = true
|
42
57
|
end
|
@@ -5,6 +5,7 @@ def require_stripe_examples
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def it_behaves_like_stripe(&block)
|
8
|
+
it_behaves_like 'Account API', &block
|
8
9
|
it_behaves_like 'Bank Account Token Mocking', &block
|
9
10
|
it_behaves_like 'Card Token Mocking', &block
|
10
11
|
it_behaves_like 'Card API', &block
|
@@ -25,4 +26,5 @@ def it_behaves_like_stripe(&block)
|
|
25
26
|
# Integration tests
|
26
27
|
it_behaves_like 'Multiple Customer Cards'
|
27
28
|
it_behaves_like 'Charging with Tokens'
|
29
|
+
it_behaves_like 'Card Error Prep'
|
28
30
|
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', '
|
20
|
+
gem.add_dependency 'stripe', '>= 1.27.0'
|
21
21
|
gem.add_dependency 'jimson-temp'
|
22
22
|
gem.add_dependency 'dante', '>= 0.2.0'
|
23
23
|
|
metadata
CHANGED
@@ -1,110 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe-ruby-mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
5
|
-
prerelease:
|
4
|
+
version: 2.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Gilbert
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2015-
|
11
|
+
date: 2015-09-23 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: stripe
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
19
|
+
version: 1.27.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
26
|
+
version: 1.27.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: jimson-temp
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: dante
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 0.2.0
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 0.2.0
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: 3.1.0
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: 3.1.0
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rubygems-tasks
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- - ~>
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0.2'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- - ~>
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0.2'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: thin
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
description: A drop-in library to test stripe without hitting their servers
|
@@ -114,9 +101,9 @@ executables:
|
|
114
101
|
extensions: []
|
115
102
|
extra_rdoc_files: []
|
116
103
|
files:
|
117
|
-
- .gitignore
|
118
|
-
- .rspec
|
119
|
-
- .travis.yml
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
120
107
|
- ChangeLog.rdoc
|
121
108
|
- Gemfile
|
122
109
|
- LICENSE.txt
|
@@ -146,6 +133,7 @@ files:
|
|
146
133
|
- lib/stripe_mock/errors/unstarted_state_error.rb
|
147
134
|
- lib/stripe_mock/errors/unsupported_request_error.rb
|
148
135
|
- lib/stripe_mock/instance.rb
|
136
|
+
- lib/stripe_mock/request_handlers/accounts.rb
|
149
137
|
- lib/stripe_mock/request_handlers/cards.rb
|
150
138
|
- lib/stripe_mock/request_handlers/charges.rb
|
151
139
|
- lib/stripe_mock/request_handlers/coupons.rb
|
@@ -153,6 +141,7 @@ files:
|
|
153
141
|
- lib/stripe_mock/request_handlers/events.rb
|
154
142
|
- lib/stripe_mock/request_handlers/helpers/card_helpers.rb
|
155
143
|
- lib/stripe_mock/request_handlers/helpers/charge_helpers.rb
|
144
|
+
- lib/stripe_mock/request_handlers/helpers/coupon_helpers.rb
|
156
145
|
- lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb
|
157
146
|
- lib/stripe_mock/request_handlers/helpers/token_helpers.rb
|
158
147
|
- lib/stripe_mock/request_handlers/invoice_items.rb
|
@@ -181,14 +170,14 @@ files:
|
|
181
170
|
- lib/stripe_mock/webhook_fixtures/charge.succeeded.json
|
182
171
|
- lib/stripe_mock/webhook_fixtures/coupon.created.json
|
183
172
|
- lib/stripe_mock/webhook_fixtures/coupon.deleted.json
|
184
|
-
- lib/stripe_mock/webhook_fixtures/customer.card.created.json
|
185
|
-
- lib/stripe_mock/webhook_fixtures/customer.card.deleted.json
|
186
|
-
- lib/stripe_mock/webhook_fixtures/customer.card.updated.json
|
187
173
|
- lib/stripe_mock/webhook_fixtures/customer.created.json
|
188
174
|
- lib/stripe_mock/webhook_fixtures/customer.deleted.json
|
189
175
|
- lib/stripe_mock/webhook_fixtures/customer.discount.created.json
|
190
176
|
- lib/stripe_mock/webhook_fixtures/customer.discount.deleted.json
|
191
177
|
- lib/stripe_mock/webhook_fixtures/customer.discount.updated.json
|
178
|
+
- lib/stripe_mock/webhook_fixtures/customer.source.created.json
|
179
|
+
- lib/stripe_mock/webhook_fixtures/customer.source.deleted.json
|
180
|
+
- lib/stripe_mock/webhook_fixtures/customer.source.updated.json
|
192
181
|
- lib/stripe_mock/webhook_fixtures/customer.subscription.created.json
|
193
182
|
- lib/stripe_mock/webhook_fixtures/customer.subscription.deleted.json
|
194
183
|
- lib/stripe_mock/webhook_fixtures/customer.subscription.trial_will_end.json
|
@@ -220,6 +209,7 @@ files:
|
|
220
209
|
- spec/list_spec.rb
|
221
210
|
- spec/readme_spec.rb
|
222
211
|
- spec/server_spec.rb
|
212
|
+
- spec/shared_stripe_examples/account_examples.rb
|
223
213
|
- spec/shared_stripe_examples/bank_token_examples.rb
|
224
214
|
- spec/shared_stripe_examples/card_examples.rb
|
225
215
|
- spec/shared_stripe_examples/card_token_examples.rb
|
@@ -245,27 +235,26 @@ files:
|
|
245
235
|
homepage: https://github.com/rebelidealist/stripe-ruby-mock
|
246
236
|
licenses:
|
247
237
|
- MIT
|
238
|
+
metadata: {}
|
248
239
|
post_install_message:
|
249
240
|
rdoc_options: []
|
250
241
|
require_paths:
|
251
242
|
- lib
|
252
243
|
required_ruby_version: !ruby/object:Gem::Requirement
|
253
|
-
none: false
|
254
244
|
requirements:
|
255
|
-
- -
|
245
|
+
- - ">="
|
256
246
|
- !ruby/object:Gem::Version
|
257
247
|
version: '0'
|
258
248
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
259
|
-
none: false
|
260
249
|
requirements:
|
261
|
-
- -
|
250
|
+
- - ">="
|
262
251
|
- !ruby/object:Gem::Version
|
263
252
|
version: '0'
|
264
253
|
requirements: []
|
265
254
|
rubyforge_project:
|
266
|
-
rubygems_version:
|
255
|
+
rubygems_version: 2.2.3
|
267
256
|
signing_key:
|
268
|
-
specification_version:
|
257
|
+
specification_version: 4
|
269
258
|
summary: TDD with stripe
|
270
259
|
test_files:
|
271
260
|
- spec/_dummy/webhooks/dummy.event.json
|
@@ -279,6 +268,7 @@ test_files:
|
|
279
268
|
- spec/list_spec.rb
|
280
269
|
- spec/readme_spec.rb
|
281
270
|
- spec/server_spec.rb
|
271
|
+
- spec/shared_stripe_examples/account_examples.rb
|
282
272
|
- spec/shared_stripe_examples/bank_token_examples.rb
|
283
273
|
- spec/shared_stripe_examples/card_examples.rb
|
284
274
|
- spec/shared_stripe_examples/card_token_examples.rb
|