VCR: A Recorder For All Your Tests’ HTTP Interactions
VCR is a library by Myron Marston that records your test suite's HTTP interactions so that they can be quickly replayed during future test runs. The big win is that you get predictable, quick and accurate tests. If you need to update the data, just delete the fixtures VCR generates and you're good to go.
On the surface, VCR sounds like it copies the work of libraries like FakeWeb and Webmock, but VCR uses those libraries to provide a cleaner, more abstracted experience. VCR supports the mocking features of FakeWeb, Webmock, Typhoeus and Faraday out of the box, and further, supports multiple HTTP client libraries including Net::HTTP, Typhoeus, HTTPClient, Curb, Patron, em-http-request and Net::HTTP-based clients like HTTParty, RESTClient and Mechanize.
You can learn more at the VCR GitHub page (it has a good, basic README) or give it a try right now with the following:
sudo gem install webmock vcr
And then run the following code:
require 'rubygems' require 'test/unit' require 'vcr' VCR.config do |c| c.cassette_library_dir = 'fixtures/vcr_cassettes' c.stub_with :webmock # or :fakeweb end class VCRTest < Test::Unit::TestCase def test_example_dot_com VCR.use_cassette('synopsis', :record => :n