Chapter 7Using Test Doubles as Mocks and Stubs
We have a problem. We want to add credit-card processing to our project application so that we can make money. Testing the credit-card functionality presents immediate difficulties. For one thing, we 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, we still donât want to depend on it for our unit tests to run. That network call is slow and we donât want our passing tests to depend on the status of a remote server.
We have a different problem. Weâd like to build our code in a very modular kind of way. In doing so, weâd like our tests to be as isolated as possible from dependencies on other ...
Get Rails 4 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.