Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

This is no longer the canonical repo -- it has moved to https://github.com/vcr/vcr

This branch is 0 commits ahead and 0 commits behind master

Merge pull request #5 from JonahMoses/patch-1

Update readme to include irc server/channel with link
latest commit d35bd4903f
Myron Marston authored
Octocat-spinner-32 benchmarks Add quality spec that enforces whitespace policy. February 25, 2012
Octocat-spinner-32 features Skip cukes that have been intermittently failing on 1.8.7 on travis. October 29, 2012
Octocat-spinner-32 gemfiles
Octocat-spinner-32 lib Fix YAML serialization on ruby 2.0. November 23, 2012
Octocat-spinner-32 script Add -x flag so it gives me more info. October 29, 2012
Octocat-spinner-32 spec Add regression spec for typhoeus/VCR bug found by @jeg2. November 22, 2012
Octocat-spinner-32 vendor Update vendored rspec 1 to my fork that ignored rubinius .rbc files. October 11, 2010
Octocat-spinner-32 .gemtest Add support for gem-testers.org. February 27, 2011
Octocat-spinner-32 .gitignore Put Gemfile.lock under source control. November 20, 2012
Octocat-spinner-32 .gitmodules
Octocat-spinner-32 .limited_red Setup limited red. February 21, 2012
Octocat-spinner-32 .rspec Use fuubar rspec formatter. November 25, 2010
Octocat-spinner-32 .travis.yml Build all branches. October 11, 2012
Octocat-spinner-32 .yardopts Add additional files to yard listing. February 12, 2012
Octocat-spinner-32 Appraisals Update to released versions of things. November 20, 2012
Octocat-spinner-32 CHANGELOG.md 2.3.0 release. October 29, 2012
Octocat-spinner-32 CONTRIBUTING.md Fix links in contributing.md to use markdown format rather than githu… November 21, 2011
Octocat-spinner-32 Gemfile Update to released versions of things. November 20, 2012
Octocat-spinner-32 Gemfile.lock Add regression spec for typhoeus/VCR bug found by @jeg2. November 22, 2012
Octocat-spinner-32 LICENSE Update copyright years. January 28, 2012
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile Add back support for Typhoeus 0.4. October 29, 2012
Octocat-spinner-32 Upgrade.md Clarify a few things in the Upgrade doc. March 03, 2012
Octocat-spinner-32 cucumber.yml Add cukes documenting new http request hooks. November 27, 2011
Octocat-spinner-32 vcr.gemspec Add regression spec for typhoeus/VCR bug found by @jeg2. November 22, 2012
README.md

VCR

Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.

Build Status

Synopsis

require 'rubygems'
require 'test/unit'
require 'vcr'

VCR.configure do |c|
  c.cassette_library_dir = 'fixtures/vcr_cassettes'
  c.hook_into :webmock # or :fakeweb
end

class VCRTest < Test::Unit::TestCase
  def test_example_dot_com
    VCR.use_cassette('synopsis') do
      response = Net::HTTP.get_response(URI('http://www.iana.org/domains/example/'))
      assert_match /Example Domains/, response.body
    end
  end
end

Run this test once, and VCR will record the http request to fixtures/vcr_cassettes/synopsis.yml. Run it again, and VCR will replay the response from iana.org when the http request is made. This test is now fast (no real HTTP requests are made anymore), deterministic (the test will continue to pass, even if you are offline, or iana.org goes down for maintenance) and accurate (the response will contain the same headers and body you get from a real request).

Features

  • Automatically records and replays your HTTP interactions with minimal setup/configuration code.
  • Supports and works with the HTTP stubbing facilities of multiple libraries. Currently, the following are supported:
  • Supports multiple HTTP libraries:
  • Request matching is configurable based on HTTP method, URI, host, path, body and headers, or you can easily implement a custom request matcher to handle any need.
  • The same request can receive different responses in different tests--just use different cassettes.
  • The recorded requests and responses are stored on disk in a serialization format of your choice (currently YAML and JSON are built in, and you can easily implement your own custom serializer) and can easily be inspected and edited.
  • Dynamic responses are supported using ERB.
  • Automatically re-records cassettes on a configurable regular interval to keep them fresh and current.
  • Disables all HTTP requests that you don't explicitly allow.
  • Simple cucumber integration is provided using tags.
  • Includes convenient RSpec macro and integration with RSpec 2 metadata.
  • Known to work well with many popular ruby libraries including RSpec 1 & 2, Cucumber, Test::Unit, Capybara, Mechanize, Rest-Client and HTTParty.
  • Includes Rack and Faraday middleware.

Usage

The docs come in two flavors:

  • The relish docs contain example-based documentation (VCR's cucumber suite, in fact). It's a good place to look when you are first getting started with VCR, or if you want to see an example of how to use a feature.
  • The rubydoc.info docs contain API documentation. The API docs contain detailed info about all of VCR's public API.

See the Upgrade doc for info about what's new and changed in VCR 2.0.

Release Policy

VCR follows the principles of semantic versioning. The API documentation define VCR's public API. Patch level releases contain only bug fixes. Minor releases contain backward-compatible new features. Major new releases contain backwards-incompatible changes to the public API.

Ruby Interpreter Compatibility

VCR has been tested on the following ruby interpreters:

  • MRI 1.8.7
  • MRI 1.9.2
  • MRI 1.9.3
  • REE 1.8.7
  • JRuby
  • Rubinius

Note that as of VCR 2, 1.8.6 and 1.9.1 are not supported.

Development

  • Source hosted on GitHub.
  • Direct questions and discussions to the IRC channel (irc.freenode.net #vcr) or the mailing list.
  • Report issues on GitHub Issues.
  • Pull requests are very welcome! Please include spec and/or feature coverage for every patch, and create a topic branch for every separate change you make.
  • See the Contributing guide for instructions on running the specs and features.
  • Code quality metrics are checked by Code Climate.
  • Documentation is generated with YARD (cheat sheet). To generate while developing:
yard server --reload

Thanks

Thanks also to the following people who have contributed patches or helpful suggestions:

Ports in other languages

Similar Libraries in Ruby

Copyright

Copyright (c) 2010-2012 Myron Marston. Released under the terms of the MIT license. See LICENSE for details.

Something went wrong with that request. Please try again.