Commit 5835a4d6 authored by Daniel Podaru's avatar Daniel Podaru
Browse files

Add currency specs

parent 1c37be54
......@@ -8,7 +8,7 @@ shared_examples 'Customer Subscriptions' do
context "creating a new subscription" do
it "adds a new subscription to customer with none", :live => true do
plan = stripe_helper.create_plan(id: 'silver', name: 'Silver Plan', amount: 4999)
plan = stripe_helper.create_plan(id: 'silver', name: 'Silver Plan', amount: 4999, currency: 'usd')
customer = Stripe::Customer.create(source: gen_card_tk)
expect( be_empty
......@@ -26,15 +26,15 @@ shared_examples 'Customer Subscriptions' do
expect(customer.subscriptions.count).to eq(1)
expect( eq(1)
expect( eq(1)
expect(customer.currency).to eq( "usd" )
expect( eq(
expect( eq(plan.to_hash)
expect( eq(
expect( eq( "bar" )
expect( eq( "yes" )
it 'creates a charge for the customer', live: true do
stripe_helper.create_plan(id: 'silver', name: 'Silver Plan', amount: 4999)
......@@ -155,6 +155,19 @@ shared_examples 'Customer Subscriptions' do
expect(customer.subscriptions.count).to eq(0)
it "throws an error when subscribing the customer to a second plan in a different currency" do
usd_plan = stripe_helper.create_plan(id: 'enterprise_usd', amount: 499, currency: 'usd')
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk)
usd_subscription = customer.subscriptions.create({ :plan => 'enterprise_usd' })
eur_plan = stripe_helper.create_plan(id: 'enterprise_eur', amount: 499, currency: 'eur')
expect { customer.subscriptions.create({ :plan => 'enterprise_eur' }) }.to raise_error {|e|
expect(e).to be_a Stripe::InvalidRequestError
expect(e.http_status).to eq(400)
expect(e.message).to_not be_nil
it "subscribes a customer with no card to a plan with a free trial" do
plan = stripe_helper.create_plan(id: 'trial', amount: 999, trial_period_days: 14)
customer = Stripe::Customer.create(id: 'cardless')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment