Introducing VCR

VCR is one of my favorite testing tools. The concept is simple. When VCR is enabled, it intercepts any third-party HTTP request. By default, the first time the request is made, VCR allows the request to proceed normally. However, VCR saves the response and associated metadata to a YAML file, which VCR calls a cassette. When the test is run again, VCR intercepts the request. Rather than actually making the request as a network call, VCR converts the cassette back into a response object and returns that response object. By default, if you then make an HTTP request that the VCR cassette doesn’t know about, the test will fail.

VCR has many great features. Because the data that VCR stores is based on a real request, it’s real data, ...

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.