Skip to content

Instantly share code, notes, and snippets.

@mangantj
Last active December 25, 2015 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mangantj/7002272 to your computer and use it in GitHub Desktop.
Save mangantj/7002272 to your computer and use it in GitHub Desktop.
context "creating stripe subscribe customer" do
before(:each) do
Stripe::Plan.stub(:create) {"1"}
@plan = Fabricate(:plan, skip_callbacks: true)
@organization = Fabricate(:organization)
end
it "should fail to create subscription and catch exception" do
@subscription = Fabricate.build(:subscription, plan: @plan, organization: @organization)
customer = double("customer")
customer.stub(:id).and_return("2434")
customer.stub(:subscription).at_least(1).and_return(@subscription)
@subscription.stub(:current_period_start).at_least(1).and_return((Time.now.end_of_day + 1.month).to_time)
@subscription.stub(:current_period_end).at_least(1).and_return(Time.now.end_of_day.to_time)
Stripe::Customer.stub(:create).and_raise("Credit Card number is invalid.")
#@subscription.save_with_payment!
expect {@subscription.save_with_payment!}.to raise_error
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment