diff --git a/lib/fake_stripe.rb b/lib/fake_stripe.rb index c841486..ef6ddac 100644 --- a/lib/fake_stripe.rb +++ b/lib/fake_stripe.rb @@ -24,8 +24,17 @@ def self.refund_count=(refund_count) @@refund_count = refund_count end + def self.customer_count + @@customer_count + end + + def self.customer_count=(customer_count) + @@customer_count = customer_count + end + def self.reset @@charge_count = 0 + @@customer_count = 0 @@refund_count = 0 end diff --git a/lib/fake_stripe/stub_app.rb b/lib/fake_stripe/stub_app.rb index 229c2a3..bf72839 100644 --- a/lib/fake_stripe/stub_app.rb +++ b/lib/fake_stripe/stub_app.rb @@ -32,6 +32,7 @@ class StubApp < Sinatra::Base # Customers post '/v1/customers' do + FakeStripe.customer_count += 1 json_response 200, fixture('create_customer') end diff --git a/spec/fake_stripe/stub_app_spec.rb b/spec/fake_stripe/stub_app_spec.rb index 32fe375..773595e 100644 --- a/spec/fake_stripe/stub_app_spec.rb +++ b/spec/fake_stripe/stub_app_spec.rb @@ -28,4 +28,12 @@ end.to change(FakeStripe, :refund_count).by(1) end end + + describe "POST /v1/customers" do + it "increments the customer counter" do + expect do + Stripe::Customer.create + end.to change(FakeStripe, :customer_count).by(1) + end + end end