What You’ve Done

In this chapter you looked at a pattern for testing external services while still allowing the test suite to run quickly and consistently and allowing you to set up and test for error conditions. You used an adapter in your code to convert between your application logic and the external service API. Tests internal to the codebase can use a test double to replace the adapter.

For external tests, you saw how to use the VCR gem to simulate interactions with the external server by recording and replaying the actual results of interactions. This allows you to both use real data and not be dependent on the vagaries of network connectivity for your tests to run.

Next up, you’ll look at the tools you can use to diagnose failing tests. ...

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.