O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

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

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, ...

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