Chapter 7Using Test Doubles as Mocks and Stubs
You have a problem. You want to add credit-card processing to your project application so that you can make money. Testing the credit-card functionality presents immediate difficulties. For one thing, you don’t want to accidentally make a credit-card purchase during testing—that would be bad. But even if the purchase gateway provides a test sandbox, you still don’t want to depend on it for your unit tests to run. That network call is slow and you don’t want your passing tests to depend on the status of a remote server.
Or, you might have a different problem. You’d like to build your code using a modular design. In doing so, you’d like your tests to be as isolated as possible from dependencies on ...
Get Rails 5 Test Prescriptions now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.