O'Reilly logo

RSpec Essentials by Mani Tadayon

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

Using VCR for mock requests

VCR is a popular tool for recording and replaying HTTP requests. VCR was created by Myron Marston, who also happens to be the lead developer of RSpec. Although it is much more sophisticated than our primitive HTTP request mocking setup, at its heart, VCR works the same way: it records real HTTP requests to files and replays them during specs. The nice thing about VCR is that it does everything in a configurable and automated way. We can tap into recorded HTTP requests with a small configuration file and an RSpec tag, so we don't actually have much code in our specs related to mocking HTTP requests. We can also record new HTTP requests very easily to a new cassette (the term used by VCR for the file that records 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