Chapter 14Testing External Services

The one thing your project-management tool really needs is a bit of graphical spark. Specifically, you’ve been asked to have users’ Twitter avatars show up on the site attached to tasks they have completed. (Handily, Twitter has a Ruby gem that’s not too hard to set up.) Since this is Rails 5 Test Prescriptions and not Rails 5 Connecting to Twitter Prescriptions, you’d like to be able to test your interaction with the Twitter API.

Unfortunately, interacting with a third-party web service introduces a lot of complexity to your testing. Connecting to a web service is slow—even slower than the database connections you’ve already tried to avoid. Plus, connecting to a web service requires an Internet connection, ...

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.