Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
Track customer creation count and expose it
Browse files Browse the repository at this point in the history
  • Loading branch information
r00k committed Sep 23, 2014
1 parent a91de07 commit ac244e1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/fake_stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions lib/fake_stripe/stub_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class StubApp < Sinatra::Base

# Customers
post '/v1/customers' do
FakeStripe.customer_count += 1
json_response 200, fixture('create_customer')
end

Expand Down
8 changes: 8 additions & 0 deletions spec/fake_stripe/stub_app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ac244e1

Please sign in to comment.