Chapter 12Testing External Services

We’ve decided the one thing our project-management tool really needs is a bit of graphical spark. Specifically, we’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 to hard to set up.) Since this is Rails 4 Test Prescriptions and not Rails 4 Connecting to Twitter Prescriptions, we’d like to be able to test our interaction with the Twitter API.

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

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.