-
-
Save kmeister2000/311d1287a0caf6e21b5a to your computer and use it in GitHub Desktop.
Stripe Payment Gateway Test (Minitest)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
describe PayingCustomer do | |
describe "without valid stripe_customer_id" do | |
it "saves the user and creates the Stripe Customer" do | |
user = MiniTest::Mock.new | |
customer = PayingCustomer.new(user) | |
user.expect(:save, true) | |
def customer.gateway | |
@gateway ||= MiniTest::Mock.new | |
end | |
customer.gateway.expect(:create, nil) | |
customer.save | |
assert user.verify | |
assert customer.gateway.verify | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Next piece of the refactor should probably be:
Where we inject the gateway, but default to StripeGateway (or whatever) so we don't have to do the ugly "stubbing" thing in the middle.
This makes me think that stubbing is useful, but could point toward a problem with your design?