stripe-ruby-mock 1.8.7.6 → 1.8.7.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  In your gemfile:
10
10
 
11
- gem 'stripe-ruby-mock', '>= 1.8.7.6'
11
+ gem 'stripe-ruby-mock', '~> 1.8.7.7'
12
12
 
13
13
  ## Features
14
14
 
@@ -41,8 +41,9 @@ module StripeMock
41
41
  customer = customers[$1]
42
42
  assert_existance :customer, $1, customer
43
43
 
44
- plan = plans[ params[:plan] ]
45
- assert_existance :plan, params[:plan], plan
44
+ plan_id = params.delete(:plan)
45
+ plan = plans[plan_id]
46
+ assert_existance :plan, plan_id, plan
46
47
 
47
48
  if params[:card]
48
49
  new_card = get_card_by_token(params.delete(:card))
@@ -55,6 +56,9 @@ module StripeMock
55
56
  raise Stripe::InvalidRequestError.new('You must supply a valid card', nil, 400)
56
57
  end
57
58
 
59
+ # Update plan data
60
+ plan.merge!(params)
61
+
58
62
  sub = Data.mock_subscription id: new_id('su'), plan: plan, customer: $1
59
63
  customer[:subscription] = sub
60
64
  end
@@ -1,4 +1,4 @@
1
1
  module StripeMock
2
2
  # stripe-ruby-mock version
3
- VERSION = "1.8.7.6"
3
+ VERSION = "1.8.7.7"
4
4
  end
@@ -5,11 +5,10 @@ shared_examples 'Customer Subscriptions' do
5
5
  it "updates a stripe customer's subscription" do
6
6
  plan = Stripe::Plan.create(id: 'silver')
7
7
  customer = Stripe::Customer.create(id: 'test_customer_sub', card: 'tk')
8
- sub = customer.update_subscription({ :plan => 'silver', :quantity => 3 })
8
+ sub = customer.update_subscription({ :plan => 'silver' })
9
9
 
10
10
  expect(sub.object).to eq('subscription')
11
11
  expect(sub.plan.id).to eq('silver')
12
- expect(sub.plan.quantity).to eq(3)
13
12
  expect(sub.plan.to_hash).to eq(plan.to_hash)
14
13
 
15
14
  customer = Stripe::Customer.retrieve('test_customer_sub')
@@ -19,6 +18,16 @@ shared_examples 'Customer Subscriptions' do
19
18
  expect(customer.subscription.customer).to eq(customer.id)
20
19
  end
21
20
 
21
+ it "updates plan details" do
22
+ plan = Stripe::Plan.create(id: 'copper')
23
+ customer = Stripe::Customer.create(id: 'test_customer_sub2', card: 'tk')
24
+ sub = customer.update_subscription({ :plan => 'copper', :quantity => 3 })
25
+
26
+ expect(sub.object).to eq('subscription')
27
+ expect(sub.plan.id).to eq('copper')
28
+ expect(sub.plan.quantity).to eq(3)
29
+ end
30
+
22
31
  it "throws an error when subscribing a customer with no card" do
23
32
  plan = Stripe::Plan.create(id: 'enterprise', amount: 499)
24
33
  customer = Stripe::Customer.create(id: 'cardless')
@@ -10,6 +10,7 @@ def require_stripe_examples
10
10
  require 'shared_stripe_examples/invoice_item_examples'
11
11
  require 'shared_stripe_examples/plan_examples'
12
12
  require 'shared_stripe_examples/recipient_examples'
13
+ require 'shared_stripe_examples/subscription_examples'
13
14
  require 'shared_stripe_examples/webhook_event_examples'
14
15
  end
15
16
 
@@ -19,6 +20,7 @@ def it_behaves_like_stripe(&block)
19
20
  it_behaves_like 'Card API', &block
20
21
  it_behaves_like 'Charge API', &block
21
22
  it_behaves_like 'Customer API', &block
23
+ it_behaves_like 'Customer Subscriptions', &block
22
24
  it_behaves_like 'Invoice API', &block
23
25
  it_behaves_like 'Invoice Item API', &block
24
26
  it_behaves_like 'Plan API', &block
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-ruby-mock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.7.6
4
+ version: 1.8.7.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-23 00:00:00.000000000 Z
12
+ date: 2014-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: stripe