Skip to content

Commit

Permalink
Adds support for stripe-ruby v10
Browse files Browse the repository at this point in the history
- Fixed deprecated methods in specs
  • Loading branch information
fabianoarruda committed Nov 26, 2023
1 parent 32b1ded commit b05c1b2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
11 changes: 5 additions & 6 deletions spec/shared_stripe_examples/bank_token_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@
expect(bank_token).to match /^test_btok/
end

it "assigns the generated bank account to a new recipient" do
it "assigns the generated bank account to a new customer" do
bank_token = StripeMock.generate_bank_token(
:bank_name => "Bank Token Mocking",
:last4 => "7777"
)

recipient = Stripe::Recipient.create({
customer = Stripe::Customer.create({
name: "Fred Flinstone",
type: "individual",
email: 'blah@domain.co',
bank_account: bank_token
source: bank_token
})
expect(recipient.active_account.last4).to eq("7777")
expect(recipient.active_account.bank_name).to eq("Bank Token Mocking")
expect(customer.sources.first.last4).to eq("7777")
expect(customer.sources.first.bank_name).to eq("Bank Token Mocking")
end

it "retrieves a created token" do
Expand Down
3 changes: 2 additions & 1 deletion spec/shared_stripe_examples/invoice_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@
describe 'parameter validation' do
it 'fails without parameters' do
expect { Stripe::Invoice.upcoming() }.to raise_error {|e|
expect(e).to be_a(ArgumentError) }
expect(e).to be_a(Stripe::InvalidRequestError)
expect(e.message).to eq('Missing required param: customer if subscription is not provided')}
end

it 'fails without a valid customer' do
Expand Down
12 changes: 6 additions & 6 deletions spec/shared_stripe_examples/subscription_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk)

sub = Stripe::Subscription.create({ items: { '0' => { plan: 'silver' } }, customer: customer.id })
sub.delete(at_period_end: true)
sub.cancel(at_period_end: true)

expect(sub.cancel_at_period_end).to be_truthy
expect(sub.save).to be_truthy
Expand Down Expand Up @@ -752,7 +752,7 @@
customer = Stripe::Customer.create(source: gen_card_tk, plan: plan.id)

subscription = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
subscription.delete
subscription.cancel

expect { subscription.save }.to raise_error { |e|
expect(e).to be_a(Stripe::InvalidRequestError)
Expand All @@ -765,7 +765,7 @@
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk)

sub = Stripe::Subscription.create({ items: [ { plan: plan.id } ], customer: customer.id })
sub.delete(at_period_end: true)
sub.cancel(at_period_end: true)

expect(sub.cancel_at_period_end).to be_truthy
expect(sub.save).to be_truthy
Expand Down Expand Up @@ -1180,7 +1180,7 @@
customer = Stripe::Customer.create(source: gen_card_tk, plan: plan.id)

sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
result = sub.delete
result = sub.cancel

expect(result.status).to eq('canceled')
expect(result.cancel_at_period_end).to eq false
Expand Down Expand Up @@ -1247,7 +1247,7 @@
customer = Stripe::Customer.create(id: 'test_customer_sub', source: gen_card_tk, plan: "trial")

sub = Stripe::Subscription.retrieve(customer.subscriptions.data.first.id)
result = sub.delete(at_period_end: true)
result = sub.cancel(at_period_end: true)

expect(result.status).to eq('trialing')

Expand Down Expand Up @@ -1331,7 +1331,7 @@
it "does not include canceled subscriptions by default" do
customer = Stripe::Customer.create(source: gen_card_tk)
subscription = Stripe::Subscription.create({ plan: plan.id, customer: customer.id })
subscription.delete
subscription.cancel

list = Stripe::Subscription.list({customer: customer.id})

Expand Down
2 changes: 1 addition & 1 deletion stripe-ruby-mock.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ['lib']

gem.add_dependency 'stripe', '> 5', '< 6'
gem.add_dependency 'stripe', '> 5', '< 11'
gem.add_dependency 'multi_json', '~> 1.0'
gem.add_dependency 'dante', '>= 0.2.0'

Expand Down

0 comments on commit b05c1b2

Please sign in to comment.