ruby-mocha

Mocking an external API

亡梦爱人 提交于 2021-01-24 07:08:37
问题 I'm new to testing strategies and mocking, and I'm having a tough time figuring out how to mock a call to an external service. I'm sure it's something easy I'm missing, I just don't know what exactly. I'm using the Braintree gem to charge for subscription services through the Braintree gateway, and I wanted to mock the Customer create method and Subscription create method in my UserController's create method. A Customer.create method looks something like this: result = Braintree::Customer

Mocking an external API

喜欢而已 提交于 2021-01-24 07:05:16
问题 I'm new to testing strategies and mocking, and I'm having a tough time figuring out how to mock a call to an external service. I'm sure it's something easy I'm missing, I just don't know what exactly. I'm using the Braintree gem to charge for subscription services through the Braintree gateway, and I wanted to mock the Customer create method and Subscription create method in my UserController's create method. A Customer.create method looks something like this: result = Braintree::Customer