stripe-ruby-mock 2.2.4 → 2.3.0
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/api/bank_tokens.rb +5 -5
- data/lib/stripe_mock/api/card_tokens.rb +4 -4
- data/lib/stripe_mock/api/client.rb +6 -3
- data/lib/stripe_mock/api/errors.rb +4 -4
- data/lib/stripe_mock/api/server.rb +0 -1
- data/lib/stripe_mock/client.rb +12 -7
- data/lib/stripe_mock/data.rb +48 -2
- data/lib/stripe_mock/error_queue.rb +5 -1
- data/lib/stripe_mock/instance.rb +5 -3
- data/lib/stripe_mock/request_handlers/balance_transactions.rb +21 -0
- data/lib/stripe_mock/request_handlers/charges.rb +17 -10
- data/lib/stripe_mock/request_handlers/customers.rb +1 -0
- data/lib/stripe_mock/request_handlers/helpers/card_helpers.rb +35 -0
- data/lib/stripe_mock/request_handlers/helpers/token_helpers.rb +2 -2
- data/lib/stripe_mock/request_handlers/sources.rb +1 -1
- data/lib/stripe_mock/request_handlers/subscriptions.rb +79 -17
- data/lib/stripe_mock/request_handlers/tokens.rb +14 -4
- data/lib/stripe_mock/server.rb +21 -15
- data/lib/stripe_mock/test_strategies/base.rb +15 -0
- data/lib/stripe_mock/version.rb +1 -1
- data/lib/stripe_mock.rb +2 -1
- data/spec/server_spec.rb +1 -1
- data/spec/shared_stripe_examples/balance_transaction_examples.rb +35 -0
- data/spec/shared_stripe_examples/bank_examples.rb +202 -0
- data/spec/shared_stripe_examples/bank_token_examples.rb +8 -0
- data/spec/shared_stripe_examples/card_token_examples.rb +10 -0
- data/spec/shared_stripe_examples/charge_examples.rb +27 -1
- data/spec/shared_stripe_examples/customer_examples.rb +2 -1
- data/spec/shared_stripe_examples/invoice_examples.rb +12 -12
- data/spec/shared_stripe_examples/refund_examples.rb +13 -0
- data/spec/shared_stripe_examples/subscription_examples.rb +47 -56
- data/spec/support/stripe_examples.rb +5 -3
- data/stripe-ruby-mock.gemspec +2 -2
- metadata +14 -9
@@ -14,7 +14,7 @@ shared_examples 'Customer Subscriptions' do
|
|
14
14
|
expect(customer.subscriptions.data).to be_empty
|
15
15
|
expect(customer.subscriptions.count).to eq(0)
|
16
16
|
|
17
|
-
sub =
|
17
|
+
sub = Stripe::Subscription.create({ plan: 'silver', customer: customer.id, metadata: { foo: "bar", example: "yes" } })
|
18
18
|
|
19
19
|
expect(sub.object).to eq('subscription')
|
20
20
|
expect(sub.plan.to_hash).to eq(plan.to_hash)
|
@@ -40,13 +40,13 @@ shared_examples 'Customer Subscriptions' do
|
|
40
40
|
expect(customer.subscriptions.count).to eq(0)
|
41
41
|
|
42
42
|
plan = stripe_helper.create_plan(id: :silver, name: 'Silver Plan', amount: 4999, currency: 'usd')
|
43
|
-
sub =
|
43
|
+
sub = Stripe::Subscription.create({ plan: 'silver', customer: customer.id })
|
44
44
|
customer = Stripe::Customer.retrieve(customer.id)
|
45
45
|
expect(sub.plan.to_hash).to eq(plan.to_hash)
|
46
46
|
expect(customer.subscriptions.count).to eq(1)
|
47
47
|
|
48
48
|
plan = stripe_helper.create_plan(id: 'gold', name: 'Gold Plan', amount: 14999, currency: 'usd')
|
49
|
-
sub =
|
49
|
+
sub = Stripe::Subscription.create({ plan: 'gold', customer: customer.id })
|
50
50
|
customer = Stripe::Customer.retrieve(customer.id)
|
51
51
|
expect(sub.plan.to_hash).to eq(plan.to_hash)
|
52
52
|
expect(customer.subscriptions.count).to eq(2)
|
@@ -56,7 +56,7 @@ shared_examples 'Customer Subscriptions' do
|
|
56
56
|
stripe_helper.create_plan(id: 'silver', name: 'Silver Plan', amount: 4999)
|
57
57
|
|
58
58
|
customer = Stripe::Customer.create(source: gen_card_tk)
|
59
|
-
|
59
|
+
Stripe::Subscription.create({ plan: 'silver', customer: customer.id, metadata: { foo: "bar", example: "yes" } })
|
60
60
|
customer = Stripe::Customer.retrieve(customer.id)
|
61
61
|
|
62
62
|
expect(customer.charges.data.length).to eq(1)
|
@@ -67,7 +67,7 @@ shared_examples 'Customer Subscriptions' do
|
|
67
67
|
plan = stripe_helper.create_plan(id: 'plan_with_coupon', name: 'One More Test Plan', amount: 777)
|
68
68
|
coupon = stripe_helper.create_coupon(id: 'free_coupon', duration: 'repeating', duration_in_months: 3)
|
69
69
|
customer = Stripe::Customer.create(source: gen_card_tk)
|
70
|
-
|
70
|
+
Stripe::Subscription.create(plan: plan.id, customer: customer.id, coupon: coupon.id)
|
71
71
|
customer = Stripe::Customer.retrieve(customer.id)
|
72
72
|
|
73
73
|
expect(customer.subscriptions.data).to be_a(Array)
|
@@ -81,7 +81,7 @@ shared_examples 'Customer Subscriptions' do
|
|
81
81
|
plan = stripe_helper.create_plan(id: 'plan_with_coupon', name: 'One More Test Plan', amount: 777)
|
82
82
|
customer = Stripe::Customer.create(source: gen_card_tk)
|
83
83
|
|
84
|
-
expect {
|
84
|
+
expect { Stripe::Subscription.create(plan: plan.id, customer: customer.id, coupon: 'none') }.to raise_error {|e|
|
85
85
|
expect(e).to be_a Stripe::InvalidRequestError
|
86
86
|
expect(e.http_status).to eq(400)
|
87
87
|
expect(e.message).to eq('No such coupon: none')
|
@@ -99,8 +99,8 @@ shared_examples 'Customer Subscriptions' do
|
|
99
99
|
)
|
100
100
|
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk)
|
101
101
|
|
102
|
-
subscription =
|
103
|
-
:
|
102
|
+
subscription = Stripe::Subscription.create({
|
103
|
+
plan: "silver", customer: customer.id, quantity: 2, application_fee_percent: 10, tax_percent: 20})
|
104
104
|
expect(subscription.quantity).to eq(2)
|
105
105
|
expect(subscription.application_fee_percent).to eq(10)
|
106
106
|
expect(subscription.tax_percent).to eq(20)
|
@@ -111,7 +111,7 @@ shared_examples 'Customer Subscriptions' do
|
|
111
111
|
gold = stripe_helper.create_plan(id: 'gold')
|
112
112
|
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk, plan: 'gold')
|
113
113
|
|
114
|
-
sub =
|
114
|
+
sub = Stripe::Subscription.create({ plan: 'silver', customer: customer.id })
|
115
115
|
|
116
116
|
expect(sub.object).to eq('subscription')
|
117
117
|
expect(sub.plan.to_hash).to eq(silver.to_hash)
|
@@ -133,7 +133,7 @@ shared_examples 'Customer Subscriptions' do
|
|
133
133
|
plan = stripe_helper.create_plan(id: 'enterprise', amount: 499)
|
134
134
|
customer = Stripe::Customer.create(id: 'cardless')
|
135
135
|
|
136
|
-
sub =
|
136
|
+
sub = Stripe::Subscription.create(plan: 'enterprise', customer: customer.id, source: gen_card_tk)
|
137
137
|
customer = Stripe::Customer.retrieve('cardless')
|
138
138
|
|
139
139
|
expect(customer.subscriptions.data.first.id).to eq(sub.id)
|
@@ -148,7 +148,7 @@ shared_examples 'Customer Subscriptions' do
|
|
148
148
|
it "throws an error when plan does not exist" do
|
149
149
|
customer = Stripe::Customer.create(id: 'cardless')
|
150
150
|
|
151
|
-
expect {
|
151
|
+
expect { Stripe::Subscription.create({ plan: 'gazebo', customer: customer.id }) }.to raise_error {|e|
|
152
152
|
expect(e).to be_a Stripe::InvalidRequestError
|
153
153
|
expect(e.http_status).to eq(404)
|
154
154
|
expect(e.message).to_not be_nil
|
@@ -162,7 +162,7 @@ shared_examples 'Customer Subscriptions' do
|
|
162
162
|
plan = stripe_helper.create_plan(id: 'enterprise', amount: 499)
|
163
163
|
customer = Stripe::Customer.create(id: 'cardless')
|
164
164
|
|
165
|
-
expect {
|
165
|
+
expect { Stripe::Subscription.create({ plan: 'enterprise', customer: customer.id }) }.to raise_error {|e|
|
166
166
|
expect(e).to be_a Stripe::InvalidRequestError
|
167
167
|
expect(e.http_status).to eq(400)
|
168
168
|
expect(e.message).to_not be_nil
|
@@ -175,10 +175,10 @@ shared_examples 'Customer Subscriptions' do
|
|
175
175
|
it "throws an error when subscribing the customer to a second plan in a different currency" do
|
176
176
|
usd_plan = stripe_helper.create_plan(id: 'enterprise_usd', amount: 499, currency: 'usd')
|
177
177
|
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk)
|
178
|
-
usd_subscription =
|
178
|
+
usd_subscription = Stripe::Subscription.create({ plan: 'enterprise_usd', customer: customer.id })
|
179
179
|
|
180
180
|
eur_plan = stripe_helper.create_plan(id: 'enterprise_eur', amount: 499, currency: 'eur')
|
181
|
-
expect {
|
181
|
+
expect { Stripe::Subscription.create({ plan: 'enterprise_eur', customer: customer.id }) }.to raise_error {|e|
|
182
182
|
expect(e).to be_a Stripe::InvalidRequestError
|
183
183
|
expect(e.http_status).to eq(400)
|
184
184
|
expect(e.message).to_not be_nil
|
@@ -189,7 +189,7 @@ shared_examples 'Customer Subscriptions' do
|
|
189
189
|
plan = stripe_helper.create_plan(id: 'trial', amount: 999, trial_period_days: 14)
|
190
190
|
customer = Stripe::Customer.create(id: 'cardless')
|
191
191
|
|
192
|
-
sub =
|
192
|
+
sub = Stripe::Subscription.create({ plan: 'trial', customer: customer.id })
|
193
193
|
|
194
194
|
expect(sub.object).to eq('subscription')
|
195
195
|
expect(sub.plan.to_hash).to eq(plan.to_hash)
|
@@ -209,7 +209,7 @@ shared_examples 'Customer Subscriptions' do
|
|
209
209
|
plan = stripe_helper.create_plan(id: 'free_tier', amount: 0)
|
210
210
|
customer = Stripe::Customer.create(id: 'cardless')
|
211
211
|
|
212
|
-
sub =
|
212
|
+
sub = Stripe::Subscription.create({ plan: 'free_tier', customer: customer.id })
|
213
213
|
|
214
214
|
expect(sub.object).to eq('subscription')
|
215
215
|
expect(sub.plan.to_hash).to eq(plan.to_hash)
|
@@ -229,7 +229,7 @@ shared_examples 'Customer Subscriptions' do
|
|
229
229
|
customer = Stripe::Customer.create(id: 'short_trial')
|
230
230
|
trial_end = Time.now.utc.to_i + 3600
|
231
231
|
|
232
|
-
sub =
|
232
|
+
sub = Stripe::Subscription.create({ plan: 'trial', customer: customer.id, trial_end: trial_end })
|
233
233
|
|
234
234
|
expect(sub.object).to eq('subscription')
|
235
235
|
expect(sub.plan.to_hash).to eq(plan.to_hash)
|
@@ -241,7 +241,7 @@ shared_examples 'Customer Subscriptions' do
|
|
241
241
|
plan = stripe_helper.create_plan(id: 'trial', amount: 999, trial_period_days: 14)
|
242
242
|
customer = Stripe::Customer.create(id: 'no_trial', source: gen_card_tk)
|
243
243
|
|
244
|
-
sub =
|
244
|
+
sub = Stripe::Subscription.create({ plan: 'trial', customer: customer.id, trial_end: "now" })
|
245
245
|
|
246
246
|
expect(sub.object).to eq('subscription')
|
247
247
|
expect(sub.plan.to_hash).to eq(plan.to_hash)
|
@@ -254,7 +254,7 @@ shared_examples 'Customer Subscriptions' do
|
|
254
254
|
plan = stripe_helper.create_plan(id: 'trial', amount: 999, trial_period_days: 14)
|
255
255
|
customer = Stripe::Customer.create(id: 'cus_trial')
|
256
256
|
|
257
|
-
expect {
|
257
|
+
expect { Stripe::Subscription.create({ plan: 'trial', customer: customer.id, trial_end: "gazebo" }) }.to raise_error {|e|
|
258
258
|
expect(e).to be_a Stripe::InvalidRequestError
|
259
259
|
expect(e.http_status).to eq(400)
|
260
260
|
expect(e.message).to eq("Invalid timestamp: must be an integer")
|
@@ -266,7 +266,7 @@ shared_examples 'Customer Subscriptions' do
|
|
266
266
|
customer = Stripe::Customer.create(id: 'past_trial')
|
267
267
|
trial_end = Time.now.utc.to_i - 3600
|
268
268
|
|
269
|
-
expect {
|
269
|
+
expect { Stripe::Subscription.create({ plan: 'trial', customer: customer.id, trial_end: trial_end }) }.to raise_error {|e|
|
270
270
|
expect(e).to be_a Stripe::InvalidRequestError
|
271
271
|
expect(e.http_status).to eq(400)
|
272
272
|
expect(e.message).to eq("Invalid timestamp: must be an integer Unix timestamp in the future")
|
@@ -278,7 +278,7 @@ shared_examples 'Customer Subscriptions' do
|
|
278
278
|
customer = Stripe::Customer.create(id: 'long_trial')
|
279
279
|
trial_end = Time.now.utc.to_i + 31557600*5 + 3600 # 5 years + 1 hour
|
280
280
|
|
281
|
-
expect {
|
281
|
+
expect { Stripe::Subscription.create({ plan: 'trial', customer: customer.id, trial_end: trial_end }) }.to raise_error {|e|
|
282
282
|
expect(e).to be_a Stripe::InvalidRequestError
|
283
283
|
expect(e.http_status).to eq(400)
|
284
284
|
expect(e.message).to eq("Invalid timestamp: can be no more than five years in the future")
|
@@ -294,7 +294,7 @@ shared_examples 'Customer Subscriptions' do
|
|
294
294
|
gold = stripe_helper.create_plan(id: 'gold')
|
295
295
|
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk, plan: 'silver')
|
296
296
|
|
297
|
-
sub =
|
297
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
298
298
|
sub.plan = 'gold'
|
299
299
|
sub.quantity = 5
|
300
300
|
sub.metadata.foo = "bar"
|
@@ -322,7 +322,7 @@ shared_examples 'Customer Subscriptions' do
|
|
322
322
|
plan = stripe_helper.create_plan(id: 'plan_with_coupon2', name: 'One More Test Plan', amount: 777)
|
323
323
|
coupon = stripe_helper.create_coupon
|
324
324
|
customer = Stripe::Customer.create(source: gen_card_tk, plan: plan.id)
|
325
|
-
subscription =
|
325
|
+
subscription = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
326
326
|
|
327
327
|
subscription.coupon = coupon.id
|
328
328
|
subscription.save
|
@@ -335,7 +335,7 @@ shared_examples 'Customer Subscriptions' do
|
|
335
335
|
it 'when add not exist coupon' do
|
336
336
|
plan = stripe_helper.create_plan(id: 'plan_with_coupon3', name: 'One More Test Plan', amount: 777)
|
337
337
|
customer = Stripe::Customer.create(source: gen_card_tk, plan: plan.id)
|
338
|
-
subscription =
|
338
|
+
subscription = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
339
339
|
|
340
340
|
subscription.coupon = 'none'
|
341
341
|
|
@@ -351,7 +351,7 @@ shared_examples 'Customer Subscriptions' do
|
|
351
351
|
free = stripe_helper.create_plan(id: 'free', amount: 0)
|
352
352
|
customer = Stripe::Customer.create(id: 'cardless', plan: 'free')
|
353
353
|
|
354
|
-
sub =
|
354
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
355
355
|
sub.plan = 'gazebo'
|
356
356
|
|
357
357
|
expect { sub.save }.to raise_error {|e|
|
@@ -370,7 +370,7 @@ shared_examples 'Customer Subscriptions' do
|
|
370
370
|
free = stripe_helper.create_plan(id: 'free', amount: 0)
|
371
371
|
customer = Stripe::Customer.create(id: 'cardless', plan: 'free')
|
372
372
|
|
373
|
-
expect {
|
373
|
+
expect { Stripe::Subscription.retrieve("gazebo") }.to raise_error {|e|
|
374
374
|
expect(e).to be_a Stripe::InvalidRequestError
|
375
375
|
expect(e.http_status).to eq(404)
|
376
376
|
expect(e.message).to_not be_nil
|
@@ -387,7 +387,7 @@ shared_examples 'Customer Subscriptions' do
|
|
387
387
|
paid = stripe_helper.create_plan(id: 'enterprise', amount: 499)
|
388
388
|
customer = Stripe::Customer.create(id: 'cardless', plan: 'free')
|
389
389
|
|
390
|
-
sub =
|
390
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
391
391
|
sub.plan = 'enterprise'
|
392
392
|
|
393
393
|
expect { sub.save }.to raise_error {|e|
|
@@ -418,7 +418,7 @@ shared_examples 'Customer Subscriptions' do
|
|
418
418
|
trial = stripe_helper.create_plan(id: 'trial', amount: 999, trial_period_days: 14)
|
419
419
|
customer = Stripe::Customer.create(id: 'cardless', plan: 'free')
|
420
420
|
|
421
|
-
sub =
|
421
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
422
422
|
sub.plan = 'trial'
|
423
423
|
sub.save
|
424
424
|
|
@@ -440,7 +440,7 @@ shared_examples 'Customer Subscriptions' do
|
|
440
440
|
gratis = stripe_helper.create_plan(id: 'gratis', amount: 0)
|
441
441
|
customer = Stripe::Customer.create(id: 'cardless', plan: 'free')
|
442
442
|
|
443
|
-
sub =
|
443
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
444
444
|
sub.plan = 'gratis'
|
445
445
|
sub.save
|
446
446
|
|
@@ -462,7 +462,7 @@ shared_examples 'Customer Subscriptions' do
|
|
462
462
|
paid = stripe_helper.create_plan(id: 'paid', amount: 499)
|
463
463
|
customer = Stripe::Customer.create(id: 'test_customer_sub', plan: 'free')
|
464
464
|
|
465
|
-
sub =
|
465
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
466
466
|
sub.plan = 'paid'
|
467
467
|
sub.source = gen_card_tk
|
468
468
|
sub.save
|
@@ -479,7 +479,7 @@ shared_examples 'Customer Subscriptions' do
|
|
479
479
|
plan = stripe_helper.create_plan(id: 'trial', amount: 999, trial_period_days: 14)
|
480
480
|
customer = Stripe::Customer.create(id: 'test_trial_end', plan: 'trial')
|
481
481
|
|
482
|
-
sub =
|
482
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
483
483
|
|
484
484
|
trial_end = Time.now.utc.to_i + 3600
|
485
485
|
sub.trial_end = trial_end
|
@@ -494,7 +494,7 @@ shared_examples 'Customer Subscriptions' do
|
|
494
494
|
plan = stripe_helper.create_plan(id: 'trial', amount: 999, trial_period_days: 14)
|
495
495
|
customer = Stripe::Customer.create(id: 'test_trial_end', plan: 'trial')
|
496
496
|
|
497
|
-
sub =
|
497
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
498
498
|
|
499
499
|
sub.trial_end = "now"
|
500
500
|
sub.save
|
@@ -510,7 +510,7 @@ shared_examples 'Customer Subscriptions' do
|
|
510
510
|
plan = stripe_helper.create_plan(id: 'no_trial', amount: 999)
|
511
511
|
customer = Stripe::Customer.create(id: 'test_trial_end', plan: 'no_trial', source: gen_card_tk)
|
512
512
|
|
513
|
-
sub =
|
513
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
514
514
|
|
515
515
|
trial_end = Time.now.utc.to_i + 3600
|
516
516
|
sub.trial_end = trial_end
|
@@ -528,7 +528,7 @@ shared_examples 'Customer Subscriptions' do
|
|
528
528
|
plan = stripe_helper.create_plan(id: 'no_trial', amount: 999)
|
529
529
|
customer = Stripe::Customer.create(id: 'test_trial_end', plan: 'no_trial', source: gen_card_tk)
|
530
530
|
|
531
|
-
sub =
|
531
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
532
532
|
sub.trial_end = "gazebo"
|
533
533
|
|
534
534
|
expect { sub.save }.to raise_error {|e|
|
@@ -545,7 +545,7 @@ shared_examples 'Customer Subscriptions' do
|
|
545
545
|
truth = stripe_helper.create_plan(id: 'the truth')
|
546
546
|
customer = Stripe::Customer.create(source: gen_card_tk, plan: "the truth")
|
547
547
|
|
548
|
-
sub =
|
548
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
549
549
|
result = sub.delete
|
550
550
|
|
551
551
|
expect(result.status).to eq('canceled')
|
@@ -563,7 +563,7 @@ shared_examples 'Customer Subscriptions' do
|
|
563
563
|
truth = stripe_helper.create_plan(id: 'the_truth')
|
564
564
|
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk, plan: "the_truth")
|
565
565
|
|
566
|
-
sub =
|
566
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
567
567
|
result = sub.delete(at_period_end: true)
|
568
568
|
|
569
569
|
expect(result.status).to eq('active')
|
@@ -585,7 +585,7 @@ shared_examples 'Customer Subscriptions' do
|
|
585
585
|
truth = stripe_helper.create_plan(id: 'the_truth')
|
586
586
|
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk, plan: "the_truth")
|
587
587
|
|
588
|
-
sub =
|
588
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
589
589
|
result = sub.delete(at_period_end: true)
|
590
590
|
|
591
591
|
sub.plan = 'the_truth'
|
@@ -607,7 +607,7 @@ shared_examples 'Customer Subscriptions' do
|
|
607
607
|
trial = stripe_helper.create_plan(id: 'trial', trial_period_days: 14)
|
608
608
|
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk, plan: "trial")
|
609
609
|
|
610
|
-
sub =
|
610
|
+
sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
|
611
611
|
result = sub.delete(at_period_end: true)
|
612
612
|
|
613
613
|
expect(result.status).to eq('trialing')
|
@@ -626,10 +626,9 @@ shared_examples 'Customer Subscriptions' do
|
|
626
626
|
:id => 'gold'
|
627
627
|
)
|
628
628
|
|
629
|
-
options = {plan: plan.id, trial_end: (Date.today + 30).to_time.to_i}
|
630
|
-
|
631
629
|
stripe_customer = Stripe::Customer.create
|
632
|
-
stripe_customer.
|
630
|
+
options = {plan: plan.id, customer: stripe_customer.id, trial_end: (Date.today + 30).to_time.to_i}
|
631
|
+
Stripe::Subscription.create options
|
633
632
|
end
|
634
633
|
|
635
634
|
context "retrieve multiple subscriptions" do
|
@@ -638,28 +637,20 @@ shared_examples 'Customer Subscriptions' do
|
|
638
637
|
free = stripe_helper.create_plan(id: 'free', amount: 0)
|
639
638
|
paid = stripe_helper.create_plan(id: 'paid', amount: 499)
|
640
639
|
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk, plan: "free")
|
641
|
-
|
642
|
-
|
643
|
-
customer = Stripe::Customer.retrieve('test_customer_sub')
|
644
|
-
|
645
|
-
list = customer.subscriptions.all
|
646
|
-
|
647
|
-
expect(list.object).to eq("list")
|
648
|
-
expect(list.count).to eq(2)
|
649
|
-
expect(list.data.length).to eq(2)
|
640
|
+
Stripe::Subscription.create({ plan: 'paid', customer: customer.id })
|
650
641
|
|
651
|
-
|
652
|
-
expect(list.data.last.plan.to_hash).to eq(free.to_hash)
|
642
|
+
subs = Stripe::Subscription.all({ customer: customer.id })
|
653
643
|
|
654
|
-
expect(
|
655
|
-
expect(
|
644
|
+
expect(subs.object).to eq("list")
|
645
|
+
expect(subs.count).to eq(2)
|
646
|
+
expect(subs.data.length).to eq(2)
|
656
647
|
end
|
657
648
|
|
658
649
|
it "retrieves an empty list if there's no subscriptions" do
|
659
650
|
Stripe::Customer.create(id: 'no_subs')
|
660
651
|
customer = Stripe::Customer.retrieve('no_subs')
|
661
652
|
|
662
|
-
list = customer.
|
653
|
+
list = Stripe::Subscription.all({ customer: customer.id })
|
663
654
|
|
664
655
|
expect(list.object).to eq("list")
|
665
656
|
expect(list.count).to eq(0)
|
@@ -684,7 +675,7 @@ shared_examples 'Customer Subscriptions' do
|
|
684
675
|
source: gen_card_tk
|
685
676
|
})
|
686
677
|
|
687
|
-
subscription =
|
678
|
+
subscription = Stripe::Subscription.create({ plan: "Sample5", customer: customer.id })
|
688
679
|
subscription.metadata['foo'] = 'bar'
|
689
680
|
|
690
681
|
expect(subscription.save).to be_a Stripe::Subscription
|
@@ -4,15 +4,17 @@ def require_stripe_examples
|
|
4
4
|
Dir["./spec/integration_examples/**/*.rb"].each {|f| require f}
|
5
5
|
end
|
6
6
|
|
7
|
-
def it_behaves_like_stripe(&block)
|
7
|
+
def it_behaves_like_stripe(&block)
|
8
8
|
it_behaves_like 'Account API', &block
|
9
|
+
it_behaves_like 'Balance Transaction API', &block
|
9
10
|
it_behaves_like 'Bank Account Token Mocking', &block
|
10
11
|
it_behaves_like 'Card Token Mocking', &block
|
11
12
|
it_behaves_like 'Card API', &block
|
12
13
|
it_behaves_like 'Charge API', &block
|
14
|
+
it_behaves_like 'Bank API', &block
|
13
15
|
it_behaves_like 'Coupon API', &block
|
14
|
-
it_behaves_like 'Customer API', &block
|
15
|
-
it_behaves_like 'Dispute API', &block
|
16
|
+
it_behaves_like 'Customer API', &block
|
17
|
+
it_behaves_like 'Dispute API', &block
|
16
18
|
it_behaves_like 'Extra Features', &block
|
17
19
|
it_behaves_like 'Invoice API', &block
|
18
20
|
it_behaves_like 'Invoice Item API', &block
|
data/stripe-ruby-mock.gemspec
CHANGED
@@ -17,8 +17,8 @@ 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', '
|
21
|
-
gem.add_dependency '
|
20
|
+
gem.add_dependency 'stripe', ['>= 1.31.0', '<= 1.43']
|
21
|
+
gem.add_dependency 'multi_json', '>= 1.0.0'
|
22
22
|
gem.add_dependency 'dante', '>= 0.2.0'
|
23
23
|
|
24
24
|
gem.add_development_dependency 'rspec', '~> 3.1.0'
|
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.
|
4
|
+
version: 2.3.0
|
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-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stripe
|
@@ -17,9 +17,9 @@ dependencies:
|
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.31.0
|
20
|
-
- -
|
20
|
+
- - <=
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '1.
|
22
|
+
version: '1.43'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,23 +27,23 @@ dependencies:
|
|
27
27
|
- - '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 1.31.0
|
30
|
-
- -
|
30
|
+
- - <=
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '1.
|
32
|
+
version: '1.43'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: multi_json
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - '>='
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: 1.0.0
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 1.0.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: dante
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- lib/stripe_mock/errors/unsupported_request_error.rb
|
141
141
|
- lib/stripe_mock/instance.rb
|
142
142
|
- lib/stripe_mock/request_handlers/accounts.rb
|
143
|
+
- lib/stripe_mock/request_handlers/balance_transactions.rb
|
143
144
|
- lib/stripe_mock/request_handlers/cards.rb
|
144
145
|
- lib/stripe_mock/request_handlers/charges.rb
|
145
146
|
- lib/stripe_mock/request_handlers/coupons.rb
|
@@ -219,6 +220,8 @@ files:
|
|
219
220
|
- spec/readme_spec.rb
|
220
221
|
- spec/server_spec.rb
|
221
222
|
- spec/shared_stripe_examples/account_examples.rb
|
223
|
+
- spec/shared_stripe_examples/balance_transaction_examples.rb
|
224
|
+
- spec/shared_stripe_examples/bank_examples.rb
|
222
225
|
- spec/shared_stripe_examples/bank_token_examples.rb
|
223
226
|
- spec/shared_stripe_examples/card_examples.rb
|
224
227
|
- spec/shared_stripe_examples/card_token_examples.rb
|
@@ -279,6 +282,8 @@ test_files:
|
|
279
282
|
- spec/readme_spec.rb
|
280
283
|
- spec/server_spec.rb
|
281
284
|
- spec/shared_stripe_examples/account_examples.rb
|
285
|
+
- spec/shared_stripe_examples/balance_transaction_examples.rb
|
286
|
+
- spec/shared_stripe_examples/bank_examples.rb
|
282
287
|
- spec/shared_stripe_examples/bank_token_examples.rb
|
283
288
|
- spec/shared_stripe_examples/card_examples.rb
|
284
289
|
- spec/shared_stripe_examples/card_token_examples.rb
|