Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for stripe-ruby v10 #893

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/stripe_mock/api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def self.stop_client(opts={})

private

def self.redirect_to_mock_server(method, url, api_key: nil, api_base: nil, params: {}, headers: {})
def self.redirect_to_mock_server(method, url, api_key: nil, api_base: nil, usage: [], params: {}, headers: {})
handler = Instance.handler_for_method_url("#{method} #{url}")

if mock_error = client.error_queue.error_for_handler_name(handler[:name])
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe_mock/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def initialize
@base_strategy = TestStrategies::Base.new
end

def mock_request(method, url, api_key: nil, api_base: nil, params: {}, headers: {})
def mock_request(method, url, api_key: nil, api_base: nil, usage: [], params: {}, headers: {})
return {} if method == :xtest

api_key ||= (Stripe.api_key || DUMMY_API_KEY)
Expand Down
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 spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'set'

gem 'rspec', '~> 3.1'
gem 'rspec', '~> 3.12'
require 'rspec'
require 'stripe'
require 'stripe_mock'
Expand Down
4 changes: 2 additions & 2 deletions stripe-ruby-mock.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ 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'

gem.add_development_dependency 'rspec', '~> 3.7.0'
gem.add_development_dependency 'rspec', '~> 3.12'
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
gem.add_development_dependency 'thin', '~> 1.8.1'
end