stripe-ruby-mock 2.5.0 → 2.5.1
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 +4 -4
- data/README.md +1 -1
- data/lib/stripe_mock.rb +3 -0
- data/lib/stripe_mock/api/account_balance.rb +14 -0
- data/lib/stripe_mock/api/webhooks.rb +2 -0
- data/lib/stripe_mock/client.rb +4 -0
- data/lib/stripe_mock/data.rb +78 -3
- data/lib/stripe_mock/instance.rb +21 -4
- data/lib/stripe_mock/request_handlers/accounts.rb +18 -2
- data/lib/stripe_mock/request_handlers/balance.rb +17 -0
- data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +27 -6
- data/lib/stripe_mock/request_handlers/invoices.rb +20 -4
- data/lib/stripe_mock/request_handlers/payouts.rb +32 -0
- data/lib/stripe_mock/request_handlers/subscriptions.rb +65 -9
- data/lib/stripe_mock/request_handlers/tokens.rb +6 -0
- data/lib/stripe_mock/request_handlers/validators/param_validators.rb +7 -1
- data/lib/stripe_mock/server.rb +4 -0
- data/lib/stripe_mock/util.rb +8 -2
- data/lib/stripe_mock/version.rb +1 -1
- data/lib/stripe_mock/webhook_fixtures/account.updated.json +1 -1
- data/lib/stripe_mock/webhook_fixtures/charge.updated.json +58 -0
- data/lib/stripe_mock/webhook_fixtures/customer.subscription.created.json +40 -10
- data/lib/stripe_mock/webhook_fixtures/customer.subscription.deleted.json +39 -10
- data/lib/stripe_mock/webhook_fixtures/customer.subscription.trial_will_end.json +39 -10
- data/lib/stripe_mock/webhook_fixtures/customer.subscription.updated.json +39 -10
- data/lib/stripe_mock/webhook_fixtures/invoice.payment_succeeded.json +92 -85
- data/spec/shared_stripe_examples/account_examples.rb +8 -0
- data/spec/shared_stripe_examples/balance_examples.rb +11 -0
- data/spec/shared_stripe_examples/bank_examples.rb +27 -0
- data/spec/shared_stripe_examples/dispute_examples.rb +10 -0
- data/spec/shared_stripe_examples/invoice_examples.rb +68 -6
- data/spec/shared_stripe_examples/payout_examples.rb +68 -0
- data/spec/shared_stripe_examples/plan_examples.rb +7 -1
- data/spec/shared_stripe_examples/subscription_examples.rb +132 -2
- data/spec/shared_stripe_examples/webhook_event_examples.rb +69 -0
- data/spec/support/stripe_examples.rb +2 -0
- data/spec/util_spec.rb +35 -1
- metadata +10 -2
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples 'Payout API' do
|
4
|
+
|
5
|
+
it "creates a stripe payout" do
|
6
|
+
payout = Stripe::Payout.create(amount: "100", currency: "usd")
|
7
|
+
|
8
|
+
expect(payout.id).to match(/^test_po/)
|
9
|
+
expect(payout.amount).to eq('100')
|
10
|
+
expect(payout.currency).to eq('usd')
|
11
|
+
expect(payout.metadata.to_hash).to eq({})
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "listing payouts" do
|
15
|
+
before do
|
16
|
+
3.times do
|
17
|
+
Stripe::Payout.create(amount: "100", currency: "usd")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "without params retrieves all tripe payouts" do
|
22
|
+
expect(Stripe::Payout.all.count).to eq(3)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "accepts a limit param" do
|
26
|
+
expect(Stripe::Payout.all(limit: 2).count).to eq(2)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "retrieves a stripe payout" do
|
31
|
+
original = Stripe::Payout.create(amount: "100", currency: "usd")
|
32
|
+
payout = Stripe::Payout.retrieve(original.id)
|
33
|
+
|
34
|
+
expect(payout.id).to eq(original.id)
|
35
|
+
expect(payout.amount).to eq(original.amount)
|
36
|
+
expect(payout.currency).to eq(original.currency)
|
37
|
+
expect(payout.metadata.to_hash).to eq(original.metadata.to_hash)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "cannot retrieve a payout that doesn't exist" do
|
41
|
+
expect { Stripe::Payout.retrieve('nope') }.to raise_error {|e|
|
42
|
+
expect(e).to be_a Stripe::InvalidRequestError
|
43
|
+
expect(e.param).to eq('payout')
|
44
|
+
expect(e.http_status).to eq(404)
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'when amount is not integer', live: true do
|
49
|
+
expect { Stripe::Payout.create(amount: '400.2',
|
50
|
+
currency: 'usd',
|
51
|
+
description: 'Payout for test@example.com') }.to raise_error { |e|
|
52
|
+
expect(e).to be_a Stripe::InvalidRequestError
|
53
|
+
expect(e.param).to eq('amount')
|
54
|
+
expect(e.http_status).to eq(400)
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'when amount is negative', live: true do
|
59
|
+
expect { Stripe::Payout.create(amount: '-400',
|
60
|
+
currency: 'usd',
|
61
|
+
description: 'Payout for test@example.com') }.to raise_error { |e|
|
62
|
+
expect(e).to be_a Stripe::InvalidRequestError
|
63
|
+
expect(e.param).to eq('amount')
|
64
|
+
expect(e.message).to match(/^Invalid.*integer/)
|
65
|
+
expect(e.http_status).to eq(400)
|
66
|
+
}
|
67
|
+
end
|
68
|
+
end
|
@@ -137,7 +137,13 @@ shared_examples 'Plan API' do
|
|
137
137
|
describe "Required Parameters" do
|
138
138
|
after do
|
139
139
|
params.delete(@name)
|
140
|
-
|
140
|
+
message =
|
141
|
+
if @name == :amount
|
142
|
+
"Plans require an `#{@name}` parameter to be set."
|
143
|
+
else
|
144
|
+
"Missing required param: #{@name}."
|
145
|
+
end
|
146
|
+
expect { subject }.to raise_error(Stripe::InvalidRequestError, message)
|
141
147
|
end
|
142
148
|
|
143
149
|
it("requires a name") { @name = :name }
|
@@ -7,6 +7,35 @@ shared_examples 'Customer Subscriptions' do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
context "creating a new subscription" do
|
10
|
+
it "adds a new subscription to customer with none using items", :live => true do
|
11
|
+
plan = stripe_helper.create_plan(id: 'silver', name: 'Silver Plan', amount: 4999, currency: 'usd')
|
12
|
+
customer = Stripe::Customer.create(source: gen_card_tk)
|
13
|
+
|
14
|
+
expect(customer.subscriptions.data).to be_empty
|
15
|
+
expect(customer.subscriptions.count).to eq(0)
|
16
|
+
|
17
|
+
sub = Stripe::Subscription.create({ items: [{ plan: 'silver' }],
|
18
|
+
customer: customer.id, metadata: { foo: "bar", example: "yes" } })
|
19
|
+
|
20
|
+
expect(sub.object).to eq('subscription')
|
21
|
+
expect(sub.plan.to_hash).to eq(plan.to_hash)
|
22
|
+
expect(sub.metadata.foo).to eq( "bar" )
|
23
|
+
expect(sub.metadata.example).to eq( "yes" )
|
24
|
+
|
25
|
+
customer = Stripe::Customer.retrieve(customer.id)
|
26
|
+
expect(customer.subscriptions.data).to_not be_empty
|
27
|
+
expect(customer.subscriptions.count).to eq(1)
|
28
|
+
expect(customer.subscriptions.data.length).to eq(1)
|
29
|
+
expect(customer.charges.data.length).to eq(1)
|
30
|
+
expect(customer.currency).to eq( "usd" )
|
31
|
+
|
32
|
+
expect(customer.subscriptions.data.first.id).to eq(sub.id)
|
33
|
+
expect(customer.subscriptions.data.first.plan.to_hash).to eq(plan.to_hash)
|
34
|
+
expect(customer.subscriptions.data.first.customer).to eq(customer.id)
|
35
|
+
expect(customer.subscriptions.data.first.metadata.foo).to eq( "bar" )
|
36
|
+
expect(customer.subscriptions.data.first.metadata.example).to eq( "yes" )
|
37
|
+
end
|
38
|
+
|
10
39
|
it "adds a new subscription to customer with none", :live => true do
|
11
40
|
plan = stripe_helper.create_plan(id: 'silver', name: 'Silver Plan', amount: 4999, currency: 'usd')
|
12
41
|
customer = Stripe::Customer.create(source: gen_card_tk)
|
@@ -31,6 +60,7 @@ shared_examples 'Customer Subscriptions' do
|
|
31
60
|
expect(customer.subscriptions.data.first.id).to eq(sub.id)
|
32
61
|
expect(customer.subscriptions.data.first.plan.to_hash).to eq(plan.to_hash)
|
33
62
|
expect(customer.subscriptions.data.first.customer).to eq(customer.id)
|
63
|
+
expect(customer.subscriptions.data.first.billing).to eq('charge_automatically')
|
34
64
|
expect(customer.subscriptions.data.first.metadata.foo).to eq( "bar" )
|
35
65
|
expect(customer.subscriptions.data.first.metadata.example).to eq( "yes" )
|
36
66
|
end
|
@@ -46,6 +76,7 @@ shared_examples 'Customer Subscriptions' do
|
|
46
76
|
|
47
77
|
expect(sub.object).to eq('subscription')
|
48
78
|
expect(sub.plan.to_hash).to eq(plan.to_hash)
|
79
|
+
expect(sub.billing).to eq('charge_automatically')
|
49
80
|
expect(sub.metadata.foo).to eq( "bar" )
|
50
81
|
expect(sub.metadata.example).to eq( "yes" )
|
51
82
|
|
@@ -60,7 +91,7 @@ shared_examples 'Customer Subscriptions' do
|
|
60
91
|
expect(customer.subscriptions.data.first.plan.to_hash).to eq(plan.to_hash)
|
61
92
|
|
62
93
|
expect(customer.subscriptions.data.first.customer).to eq(customer.id)
|
63
|
-
|
94
|
+
expect(customer.subscriptions.data.first.billing).to eq('charge_automatically')
|
64
95
|
expect(customer.subscriptions.data.first.metadata.foo).to eq( "bar" )
|
65
96
|
expect(customer.subscriptions.data.first.metadata.example).to eq( "yes" )
|
66
97
|
end
|
@@ -136,6 +167,22 @@ shared_examples 'Customer Subscriptions' do
|
|
136
167
|
expect(subscription.tax_percent).to eq(20)
|
137
168
|
end
|
138
169
|
|
170
|
+
it "correctly sets created when it's not provided as a parameter", live: true do
|
171
|
+
customer = Stripe::Customer.create(source: gen_card_tk)
|
172
|
+
plan = stripe_helper.create_plan(id: 'silver', name: 'Silver Plan', amount: 4999, currency: 'usd')
|
173
|
+
subscription = Stripe::Subscription.create({ plan: 'silver', customer: customer.id })
|
174
|
+
|
175
|
+
expect(subscription.created).to eq(subscription.current_period_start)
|
176
|
+
end
|
177
|
+
|
178
|
+
it "correctly sets created when it's provided as a parameter" do
|
179
|
+
customer = Stripe::Customer.create(source: gen_card_tk)
|
180
|
+
plan = stripe_helper.create_plan(id: 'silver', name: 'Silver Plan', amount: 4999, currency: 'usd')
|
181
|
+
subscription = Stripe::Subscription.create({ plan: 'silver', customer: customer.id, created: 1473576318 })
|
182
|
+
|
183
|
+
expect(subscription.created).to eq(1473576318)
|
184
|
+
end
|
185
|
+
|
139
186
|
it "adds additional subscription to customer with existing subscription" do
|
140
187
|
silver = stripe_helper.create_plan(id: 'silver')
|
141
188
|
gold = stripe_helper.create_plan(id: 'gold')
|
@@ -248,6 +295,29 @@ shared_examples 'Customer Subscriptions' do
|
|
248
295
|
expect(customer.charges.count).to eq(0)
|
249
296
|
end
|
250
297
|
|
298
|
+
it "subscribes a customer with no card to a plan with a free trial with plan as item" do
|
299
|
+
plan = stripe_helper.create_plan(id: 'trial', amount: 999, trial_period_days: 14)
|
300
|
+
customer = Stripe::Customer.create(id: 'cardless')
|
301
|
+
|
302
|
+
sub = Stripe::Subscription.create({ items: [ { plan: 'trial' } ], customer: customer.id })
|
303
|
+
|
304
|
+
expect(sub.object).to eq('subscription')
|
305
|
+
expect(sub.items.data[0].plan.to_hash).to eq(plan.to_hash)
|
306
|
+
# no idea how to fix this one
|
307
|
+
# expect(sub.trial_end - sub.trial_start).to eq(14 * 86400)
|
308
|
+
|
309
|
+
customer = Stripe::Customer.retrieve('cardless')
|
310
|
+
expect(customer.subscriptions.data).to_not be_empty
|
311
|
+
expect(customer.subscriptions.count).to eq(1)
|
312
|
+
expect(customer.subscriptions.data.length).to eq(1)
|
313
|
+
|
314
|
+
expect(customer.subscriptions.data.first.id).to eq(sub.id)
|
315
|
+
expect(customer.subscriptions.data.first.items.data.first.plan.to_hash).to eq(plan.to_hash)
|
316
|
+
expect(customer.subscriptions.data.first.customer).to eq(customer.id)
|
317
|
+
# No idea on this one
|
318
|
+
# expect(customer.charges.count).to eq(0)
|
319
|
+
end
|
320
|
+
|
251
321
|
it "subscribes a customer with no card to a free plan" do
|
252
322
|
plan = stripe_helper.create_plan(id: 'free_tier', amount: 0)
|
253
323
|
customer = Stripe::Customer.create(id: 'cardless')
|
@@ -328,6 +398,54 @@ shared_examples 'Customer Subscriptions' do
|
|
328
398
|
}
|
329
399
|
end
|
330
400
|
|
401
|
+
it 'when plan defined inside items', live: true do
|
402
|
+
plan = stripe_helper.create_plan(id: 'BASE_PRICE_PLAN1')
|
403
|
+
|
404
|
+
plan2 = stripe_helper.create_plan(id: 'PER_USER_PLAN1')
|
405
|
+
customer = Stripe::Customer.create(
|
406
|
+
source: {
|
407
|
+
object: 'card',
|
408
|
+
exp_month: 11,
|
409
|
+
exp_year: 2019,
|
410
|
+
number: '4242424242424242',
|
411
|
+
cvc: '123'
|
412
|
+
}
|
413
|
+
)
|
414
|
+
subscription = Stripe::Subscription.create(
|
415
|
+
customer: customer.id,
|
416
|
+
items: [
|
417
|
+
{ plan: plan.id, quantity: 1 },
|
418
|
+
{ plan: plan2.id, quantity: 2 }
|
419
|
+
]
|
420
|
+
)
|
421
|
+
|
422
|
+
expect(subscription.id).to match /(test_su_|sub_).+/
|
423
|
+
expect(subscription.plan).to eq nil
|
424
|
+
expect(subscription.items.data[0].plan.id).to eq plan.id
|
425
|
+
expect(subscription.items.data[1].plan.id).to eq plan2.id
|
426
|
+
end
|
427
|
+
|
428
|
+
it 'when plan defined inside items for trials with no card', live: true do
|
429
|
+
plan = stripe_helper.create_plan(id: 'BASE_PRICE_PLAN1')
|
430
|
+
|
431
|
+
plan2 = stripe_helper.create_plan(id: 'PER_USER_PLAN1')
|
432
|
+
customer = Stripe::Customer.create
|
433
|
+
trial_end = Time.now.utc.to_i + 3600
|
434
|
+
|
435
|
+
subscription = Stripe::Subscription.create(
|
436
|
+
customer: customer.id,
|
437
|
+
items: [
|
438
|
+
{ plan: plan.id, quantity: 1 },
|
439
|
+
{ plan: plan2.id, quantity: 2 }
|
440
|
+
],
|
441
|
+
trial_end: trial_end
|
442
|
+
)
|
443
|
+
|
444
|
+
expect(subscription.id).to match /(test_su_|sub_).+/
|
445
|
+
expect(subscription.plan).to eq nil
|
446
|
+
expect(subscription.items.data[0].plan.id).to eq plan.id
|
447
|
+
expect(subscription.items.data[1].plan.id).to eq plan2.id
|
448
|
+
end
|
331
449
|
end
|
332
450
|
|
333
451
|
context "updating a subscription" do
|
@@ -345,7 +463,19 @@ shared_examples 'Customer Subscriptions' do
|
|
345
463
|
}
|
346
464
|
end
|
347
465
|
|
348
|
-
it "updates a stripe customer's existing subscription" do
|
466
|
+
it "updates a stripe customer's existing subscription with one plan inside items" do
|
467
|
+
silver = stripe_helper.create_plan(id: 'silver')
|
468
|
+
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk)
|
469
|
+
|
470
|
+
sub = Stripe::Subscription.create({ items: [ { plan: 'silver' } ], customer: customer.id })
|
471
|
+
sub.delete(at_period_end: true)
|
472
|
+
|
473
|
+
expect(sub.cancel_at_period_end).to be_truthy
|
474
|
+
expect(sub.save).to be_truthy
|
475
|
+
expect(sub.cancel_at_period_end).to be_falsey
|
476
|
+
end
|
477
|
+
|
478
|
+
it "updates a stripe customer's existing subscription when plan inside of items" do
|
349
479
|
silver = stripe_helper.create_plan(id: 'silver')
|
350
480
|
gold = stripe_helper.create_plan(id: 'gold')
|
351
481
|
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk, plan: 'silver')
|
@@ -129,6 +129,22 @@ shared_examples 'Webhook Events API' do
|
|
129
129
|
}.to raise_error StripeMock::UnsupportedRequestError
|
130
130
|
end
|
131
131
|
|
132
|
+
it 'has actual created attribute' do
|
133
|
+
time = Time.now.to_i
|
134
|
+
|
135
|
+
evnt = StripeMock.mock_webhook_event('customer.subscription.updated')
|
136
|
+
|
137
|
+
expect(evnt.created).to eq time
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'when created param can be overrided' do
|
141
|
+
time = Time.now.to_i - 1000
|
142
|
+
|
143
|
+
evnt = StripeMock.mock_webhook_event('customer.subscription.updated', created: time)
|
144
|
+
|
145
|
+
expect(evnt.created).to eq time
|
146
|
+
end
|
147
|
+
|
132
148
|
describe "listing events" do
|
133
149
|
|
134
150
|
it "retrieves all events" do
|
@@ -188,5 +204,58 @@ shared_examples 'Webhook Events API' do
|
|
188
204
|
end
|
189
205
|
|
190
206
|
end
|
207
|
+
|
208
|
+
describe 'Subscription events' do
|
209
|
+
it "Checks for billing items in customer.subscription.created" do
|
210
|
+
subscription_created_event = StripeMock.mock_webhook_event('customer.subscription.created')
|
211
|
+
expect(subscription_created_event).to be_a(Stripe::Event)
|
212
|
+
expect(subscription_created_event.id).to_not be_nil
|
213
|
+
expect(subscription_created_event.data.object.items.data.class).to be Array
|
214
|
+
expect(subscription_created_event.data.object.items.data.length).to be 2
|
215
|
+
expect(subscription_created_event.data.object.items.data.first).to respond_to(:plan)
|
216
|
+
expect(subscription_created_event.data.object.items.data.first.id).to eq('si_00000000000000')
|
217
|
+
end
|
218
|
+
|
219
|
+
it "Checks for billing items in customer.subscription.deleted" do
|
220
|
+
subscription_deleted_event = StripeMock.mock_webhook_event('customer.subscription.deleted')
|
221
|
+
expect(subscription_deleted_event).to be_a(Stripe::Event)
|
222
|
+
expect(subscription_deleted_event.id).to_not be_nil
|
223
|
+
expect(subscription_deleted_event.data.object.items.data.class).to be Array
|
224
|
+
expect(subscription_deleted_event.data.object.items.data.length).to be 2
|
225
|
+
expect(subscription_deleted_event.data.object.items.data.first).to respond_to(:plan)
|
226
|
+
expect(subscription_deleted_event.data.object.items.data.first.id).to eq('si_00000000000000')
|
227
|
+
end
|
228
|
+
|
229
|
+
it "Checks for billing items in customer.subscription.updated" do
|
230
|
+
subscription_updated_event = StripeMock.mock_webhook_event('customer.subscription.updated')
|
231
|
+
expect(subscription_updated_event).to be_a(Stripe::Event)
|
232
|
+
expect(subscription_updated_event.id).to_not be_nil
|
233
|
+
expect(subscription_updated_event.data.object.items.data.class).to be Array
|
234
|
+
expect(subscription_updated_event.data.object.items.data.length).to be 2
|
235
|
+
expect(subscription_updated_event.data.object.items.data.first).to respond_to(:plan)
|
236
|
+
expect(subscription_updated_event.data.object.items.data.first.id).to eq('si_00000000000000')
|
237
|
+
end
|
238
|
+
|
239
|
+
it "Checks for billing items in customer.subscription.trial_will_end" do
|
240
|
+
subscription_trial_will_end_event = StripeMock.mock_webhook_event('customer.subscription.trial_will_end')
|
241
|
+
expect(subscription_trial_will_end_event).to be_a(Stripe::Event)
|
242
|
+
expect(subscription_trial_will_end_event.id).to_not be_nil
|
243
|
+
expect(subscription_trial_will_end_event.data.object.items.data.class).to be Array
|
244
|
+
expect(subscription_trial_will_end_event.data.object.items.data.length).to be 2
|
245
|
+
expect(subscription_trial_will_end_event.data.object.items.data.first).to respond_to(:plan)
|
246
|
+
expect(subscription_trial_will_end_event.data.object.items.data.first.id).to eq('si_00000000000000')
|
247
|
+
end
|
248
|
+
end
|
191
249
|
|
250
|
+
describe 'Invoices events' do
|
251
|
+
it "Checks for billing items in invoice.payment_succeeded" do
|
252
|
+
invoice_payment_succeeded = StripeMock.mock_webhook_event('invoice.payment_succeeded')
|
253
|
+
expect(invoice_payment_succeeded).to be_a(Stripe::Event)
|
254
|
+
expect(invoice_payment_succeeded.id).to_not be_nil
|
255
|
+
expect(invoice_payment_succeeded.data.object.lines.data.class).to be Array
|
256
|
+
expect(invoice_payment_succeeded.data.object.lines.data.length).to be 2
|
257
|
+
expect(invoice_payment_succeeded.data.object.lines.data.first).to respond_to(:plan)
|
258
|
+
expect(invoice_payment_succeeded.data.object.lines.data.first.id).to eq('sub_00000000000000')
|
259
|
+
end
|
260
|
+
end
|
192
261
|
end
|
@@ -6,6 +6,7 @@ end
|
|
6
6
|
|
7
7
|
def it_behaves_like_stripe(&block)
|
8
8
|
it_behaves_like 'Account API', &block
|
9
|
+
it_behaves_like 'Balance API', &block
|
9
10
|
it_behaves_like 'Balance Transaction API', &block
|
10
11
|
it_behaves_like 'Bank Account Token Mocking', &block
|
11
12
|
it_behaves_like 'Card Token Mocking', &block
|
@@ -22,6 +23,7 @@ def it_behaves_like_stripe(&block)
|
|
22
23
|
it_behaves_like 'Recipient API', &block
|
23
24
|
it_behaves_like 'Refund API', &block
|
24
25
|
it_behaves_like 'Transfer API', &block
|
26
|
+
it_behaves_like 'Payout API', &block
|
25
27
|
it_behaves_like 'Stripe Error Mocking', &block
|
26
28
|
it_behaves_like 'Customer Subscriptions', &block
|
27
29
|
it_behaves_like 'Webhook Events API', &block
|
data/spec/util_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe StripeMock::Util do
|
|
19
19
|
expect(result).to eq({ x: { y: 999, z: { m: 44, n: 55 } } })
|
20
20
|
end
|
21
21
|
|
22
|
-
it "merges array elements" do
|
22
|
+
it "merges array elements (that are hashes)" do
|
23
23
|
dest = { x: [ {a: 1}, {b: 2}, {c: 3} ] }
|
24
24
|
source = { x: [ {a: 0}, {a: 0} ] }
|
25
25
|
result = StripeMock::Util.rmerge(dest, source)
|
@@ -27,6 +27,40 @@ describe StripeMock::Util do
|
|
27
27
|
expect(result).to eq({ x: [ {a: 0}, {a: 0, b: 2}, {c: 3} ] })
|
28
28
|
end
|
29
29
|
|
30
|
+
context "array elements (that are simple values)" do
|
31
|
+
it "merges arrays" do
|
32
|
+
dest = { x: [ 1, 2 ] }
|
33
|
+
source = { x: [ 3, 4 ] }
|
34
|
+
result = StripeMock::Util.rmerge(dest, source)
|
35
|
+
|
36
|
+
expect(result).to eq({ x: [ 1, 3, 2, 4 ] })
|
37
|
+
end
|
38
|
+
|
39
|
+
it "ignores empty arrays" do
|
40
|
+
dest = { x: [] }
|
41
|
+
source = { x: [ 3, 4 ] }
|
42
|
+
result = StripeMock::Util.rmerge(dest, source)
|
43
|
+
|
44
|
+
expect(result).to eq({ x: [ 3, 4 ] })
|
45
|
+
end
|
46
|
+
|
47
|
+
it "removes nil values" do
|
48
|
+
dest = { x: [ 1, 2, nil ] }
|
49
|
+
source = { x: [ nil, 3, 4 ] }
|
50
|
+
result = StripeMock::Util.rmerge(dest, source)
|
51
|
+
|
52
|
+
expect(result).to eq({ x: [ 1, 2, 3, 4 ] })
|
53
|
+
end
|
54
|
+
|
55
|
+
it "respects duplicate values" do
|
56
|
+
dest = { x: [ 1, 2, 3 ] }
|
57
|
+
source = { x: [ 3, 4 ] }
|
58
|
+
result = StripeMock::Util.rmerge(dest, source)
|
59
|
+
|
60
|
+
expect(result).to eq({ x: [ 1, 3, 2, 4, 3 ] })
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
30
64
|
it "does not truncate the array when merging" do
|
31
65
|
dest = { x: [ {a: 1}, {b: 2} ] }
|
32
66
|
source = { x: [ nil, nil, {c: 3} ] }
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gilbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stripe
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- Rakefile
|
113
113
|
- bin/stripe-mock-server
|
114
114
|
- lib/stripe_mock.rb
|
115
|
+
- lib/stripe_mock/api/account_balance.rb
|
115
116
|
- lib/stripe_mock/api/bank_tokens.rb
|
116
117
|
- lib/stripe_mock/api/card_tokens.rb
|
117
118
|
- lib/stripe_mock/api/client.rb
|
@@ -136,6 +137,7 @@ files:
|
|
136
137
|
- lib/stripe_mock/errors/unsupported_request_error.rb
|
137
138
|
- lib/stripe_mock/instance.rb
|
138
139
|
- lib/stripe_mock/request_handlers/accounts.rb
|
140
|
+
- lib/stripe_mock/request_handlers/balance.rb
|
139
141
|
- lib/stripe_mock/request_handlers/balance_transactions.rb
|
140
142
|
- lib/stripe_mock/request_handlers/cards.rb
|
141
143
|
- lib/stripe_mock/request_handlers/charges.rb
|
@@ -153,6 +155,7 @@ files:
|
|
153
155
|
- lib/stripe_mock/request_handlers/invoice_items.rb
|
154
156
|
- lib/stripe_mock/request_handlers/invoices.rb
|
155
157
|
- lib/stripe_mock/request_handlers/orders.rb
|
158
|
+
- lib/stripe_mock/request_handlers/payouts.rb
|
156
159
|
- lib/stripe_mock/request_handlers/plans.rb
|
157
160
|
- lib/stripe_mock/request_handlers/recipients.rb
|
158
161
|
- lib/stripe_mock/request_handlers/refunds.rb
|
@@ -179,6 +182,7 @@ files:
|
|
179
182
|
- lib/stripe_mock/webhook_fixtures/charge.failed.json
|
180
183
|
- lib/stripe_mock/webhook_fixtures/charge.refunded.json
|
181
184
|
- lib/stripe_mock/webhook_fixtures/charge.succeeded.json
|
185
|
+
- lib/stripe_mock/webhook_fixtures/charge.updated.json
|
182
186
|
- lib/stripe_mock/webhook_fixtures/coupon.created.json
|
183
187
|
- lib/stripe_mock/webhook_fixtures/coupon.deleted.json
|
184
188
|
- lib/stripe_mock/webhook_fixtures/customer.created.json
|
@@ -222,6 +226,7 @@ files:
|
|
222
226
|
- spec/readme_spec.rb
|
223
227
|
- spec/server_spec.rb
|
224
228
|
- spec/shared_stripe_examples/account_examples.rb
|
229
|
+
- spec/shared_stripe_examples/balance_examples.rb
|
225
230
|
- spec/shared_stripe_examples/balance_transaction_examples.rb
|
226
231
|
- spec/shared_stripe_examples/bank_examples.rb
|
227
232
|
- spec/shared_stripe_examples/bank_token_examples.rb
|
@@ -236,6 +241,7 @@ files:
|
|
236
241
|
- spec/shared_stripe_examples/extra_features_examples.rb
|
237
242
|
- spec/shared_stripe_examples/invoice_examples.rb
|
238
243
|
- spec/shared_stripe_examples/invoice_item_examples.rb
|
244
|
+
- spec/shared_stripe_examples/payout_examples.rb
|
239
245
|
- spec/shared_stripe_examples/plan_examples.rb
|
240
246
|
- spec/shared_stripe_examples/recipient_examples.rb
|
241
247
|
- spec/shared_stripe_examples/refund_examples.rb
|
@@ -286,6 +292,7 @@ test_files:
|
|
286
292
|
- spec/readme_spec.rb
|
287
293
|
- spec/server_spec.rb
|
288
294
|
- spec/shared_stripe_examples/account_examples.rb
|
295
|
+
- spec/shared_stripe_examples/balance_examples.rb
|
289
296
|
- spec/shared_stripe_examples/balance_transaction_examples.rb
|
290
297
|
- spec/shared_stripe_examples/bank_examples.rb
|
291
298
|
- spec/shared_stripe_examples/bank_token_examples.rb
|
@@ -300,6 +307,7 @@ test_files:
|
|
300
307
|
- spec/shared_stripe_examples/extra_features_examples.rb
|
301
308
|
- spec/shared_stripe_examples/invoice_examples.rb
|
302
309
|
- spec/shared_stripe_examples/invoice_item_examples.rb
|
310
|
+
- spec/shared_stripe_examples/payout_examples.rb
|
303
311
|
- spec/shared_stripe_examples/plan_examples.rb
|
304
312
|
- spec/shared_stripe_examples/recipient_examples.rb
|
305
313
|
- spec/shared_stripe_examples/refund_examples.rb
|