O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 parts of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required