lib/fake_stripe.rb in fake_stripe-0.0.8 vs lib/fake_stripe.rb in fake_stripe-0.0.9
- old
+ new
@@ -5,38 +5,26 @@
module FakeStripe
extend Configuration
VALID_CARD_NUMBER = '4242424242424242'
+ STRIPE_OBJECTS = %w{card charge coupon customer invoice invoiceitem plan
+ recipient refund subscription token transfer}.freeze
- def self.charge_count
- @@charge_count
- end
+ STRIPE_OBJECTS.each do |object|
+ define_singleton_method "#{object}_count" do
+ instance_variable_get("@#{object}_count")
+ end
- def self.charge_count=(charge_count)
- @@charge_count = charge_count
+ define_singleton_method "#{object}_count=" do |count|
+ instance_variable_set("@#{object}_count", count)
+ end
end
- def self.refund_count
- @@refund_count
- end
-
- 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
+ STRIPE_OBJECTS.each do |object|
+ instance_variable_set("@#{object}_count", 0)
+ end
end
def self.stub_stripe
Stripe.api_key = 'FAKE_STRIPE_API_KEY'
FakeStripe.reset