Module VCR
In: lib/vcr.rb
lib/vcr/deprecations.rb
lib/vcr/test_frameworks/rspec.rb
lib/vcr/test_frameworks/cucumber.rb
lib/vcr/request_handler.rb
lib/vcr/request_matcher_registry.rb
lib/vcr/errors.rb
lib/vcr/structs.rb
lib/vcr/library_hooks/excon.rb
lib/vcr/library_hooks/faraday.rb
lib/vcr/library_hooks/typhoeus_0.4.rb
lib/vcr/library_hooks/fakeweb.rb
lib/vcr/library_hooks/typhoeus.rb
lib/vcr/library_hooks/webmock.rb
lib/vcr/cassette/http_interaction_list.rb
lib/vcr/cassette/erb_renderer.rb
lib/vcr/cassette/persisters.rb
lib/vcr/cassette/serializers/compressed.rb
lib/vcr/cassette/serializers/json.rb
lib/vcr/cassette/serializers/psych.rb
lib/vcr/cassette/serializers/syck.rb
lib/vcr/cassette/serializers/yaml.rb
lib/vcr/cassette/persisters/file_system.rb
lib/vcr/cassette/migrator.rb
lib/vcr/cassette/serializers.rb
lib/vcr/cassette.rb
lib/vcr/version.rb
lib/vcr/extensions/net_http_response.rb
lib/vcr/util/logger.rb
lib/vcr/util/internet_connection.rb
lib/vcr/util/variable_args_block_caller.rb
lib/vcr/util/version_checker.rb
lib/vcr/util/hooks.rb
lib/vcr/request_ignorer.rb
lib/vcr/linked_cassette.rb
lib/vcr/middleware/excon.rb
lib/vcr/middleware/faraday.rb
lib/vcr/middleware/excon/legacy_methods.rb
lib/vcr/middleware/rack.rb
lib/vcr/configuration.rb
lib/vcr/library_hooks.rb

The main entry point for VCR. @note This module is extended onto itself; thus, the methods listed

 here as instance methods are available directly off of VCR.

Methods

Included Modules

VariableArgsBlockCaller Errors

Classes and Modules

Module VCR::Cassette
Module VCR::ClassMethods
Module VCR::Deprecations
Module VCR::Errors
Module VCR::Hooks
Module VCR::InternetConnection
Module VCR::Middleware
Module VCR::Net
Module VCR::Normalizers
Module VCR::OrderedHashSerializer
Module VCR::Ping
Module VCR::RSpec
Module VCR::VariableArgsBlockCaller
Class VCR::Cassette
Class VCR::Configuration
Class VCR::CucumberTags
Class VCR::HTTPInteraction
Class VCR::LibraryHooks
Class VCR::LinkedCassette
Class VCR::Logger
Class VCR::Request
Class VCR::RequestHandler
Class VCR::RequestIgnorer
Class VCR::RequestMatcherRegistry
Class VCR::Response
Class VCR::ResponseStatus
Class VCR::VersionChecker

Constants

CassetteMutex = Mutex.new   Mutex to synchronize access to cassettes in a threaded environment
MainThread = Thread.current   The main thread in which VCR was loaded
Ping = ::Ping

Public Class methods

Public Instance methods

@return [Enumerable] list of all cassettes currently being used

@deprecated Use configure instead. @see configure

Used to configure VCR.

@example

   VCR.configure do |c|
     c.some_config_option = true
   end

@yield the configuration block @yieldparam config [VCR::Configuration] the configuration object @return [void]

Sets up `Before` and `After` cucumber hooks in order to use VCR with particular cucumber tags.

@example

  VCR.cucumber_tags do |t|
    t.tags "tag1", "tag2"
    t.tag "@some_other_tag", :record => :new_episodes
  end

@yield the cucumber tags configuration block @yieldparam t [VCR::CucumberTags] Cucumber tags config object @return [void] @see VCR::CucumberTags#tags

The currently active cassette.

@return [nil, VCR::Cassette] The current cassette or nil if there is

 no current cassette.

Ejects the current cassette. The cassette will no longer be used. In addition, any newly recorded HTTP interactions will be written to disk.

@param options [Hash] Eject options. @option options :skip_no_unused_interactions_assertion [Boolean]

 If `true` is given, this will skip the "no unused HTTP interactions"
 assertion enabled by the `:allow_unused_http_interactions => false`
 cassette option. This is intended for use when your test has had
 an error, but your test framework has already handled it.

@return [VCR::Cassette, nil] the ejected cassette if there was one

Inserts the named cassette using the given cassette options. New HTTP interactions, if allowed by the cassette‘s `:record` option, will be recorded to the cassette. The cassette‘s existing HTTP interactions will be used to stub requests, unless prevented by the cassete‘s `:record` option.

@example

  VCR.insert_cassette('twitter', :record => :new_episodes)

  # ...later, after making an HTTP request:

  VCR.eject_cassette

@param name [to_s] The name of the cassette. VCR will sanitize

                    this to ensure it is a valid file name.

@param options [Hash] The cassette options. The given options will

 be merged with the configured default_cassette_options.

@option options :record [:all, :none, :new_episodes, :once] The record mode. @option options :erb [Boolean, Hash] Whether or not to evaluate the

 cassette as an ERB template. Defaults to false. A hash can be used
 to provide the ERB template with local variables.

@option options :match_requests_on [Array<Symbol, call>] List of request matchers

 to use to determine what recorded HTTP interaction to replay. Defaults to
 [:method, :uri]. The built-in matchers are :method, :uri, :host, :path, :headers
 and :body. You can also pass the name of a registered custom request matcher or
 any object that responds to #call.

@option options :re_record_interval [Integer] When given, the

 cassette will be re-recorded at the given interval, in seconds.

@option options :tag [Symbol] Used to apply tagged `before_record`

 and `before_playback` hooks to the cassette.

@option options :tags [Array<Symbol>] Used to apply multiple tags to

 a cassette so that tagged `before_record` and `before_playback` hooks
 will apply to the cassette.

@option options :update_content_length_header [Boolean] Whether or

 not to overwrite the Content-Length header of the responses to
 match the length of the response body. Defaults to false.

@option options :decode_compressed_response [Boolean] Whether or

 not to decode compressed responses before recording the cassette.
 This makes the cassette more human readable. Defaults to false.

@option options :allow_playback_repeats [Boolean] Whether or not to

 allow a single HTTP interaction to be played back multiple times.
 Defaults to false.

@option options :allow_unused_http_interactions [Boolean] If set to

 false, an error will be raised if a cassette is ejected before all
 previously recorded HTTP interactions have been used.
 Defaults to true. Note that when an error has already occurred
 (as indicated by the `$!` variable) unused interactions will be
 allowed so that we don't silence the original error (which is almost
 certainly more interesting/important).

@option options :exclusive [Boolean] Whether or not to use only this

 cassette and to completely ignore any cassettes in the cassettes stack.
 Defaults to false.

@option options :serialize_with [Symbol] Which serializer to use.

 Valid values are :yaml, :syck, :psych, :json or any registered
 custom serializer. Defaults to :yaml.

@option options :persist_with [Symbol] Which cassette persister to

 use. Defaults to :file_system. You can also register and use a
 custom persister.

@option options :preserve_exact_body_bytes [Boolean] Whether or not

 to base64 encode the bytes of the requests and responses for this cassette
 when serializing it. See also `VCR::Configuration#preserve_exact_body_bytes`.

@return [VCR::Cassette] the inserted cassette

@raise [ArgumentError] when the given cassette is already being used. @raise [VCR::Errors::TurnedOffError] when VCR has been turned off

 without using the :ignore_cassettes option.

@raise [VCR::Errors::MissingERBVariableError] when the `:erb` option

 is used and the ERB template requires variables that you did not provide.

@note If you use this method you must call `eject_cassette` when you

 are done. It is generally recommended that you use {#use_cassette}
 unless your code-under-test cannot be run as a block.

@return [RequestMatcherRegistry] the request matcher registry

Turns VCR off, so that it no longer handles every HTTP request.

@param options [Hash] hash of options @option options :ignore_cassettes [Boolean] controls what happens when a cassette is

 inserted while VCR is turned off. If `true` is passed, the cassette insertion
 will be ignored; otherwise a {VCR::Errors::TurnedOffError} will be raised.

@return [void] @raise [VCR::Errors::CassetteInUseError] if there is currently a cassette in use @raise [ArgumentError] if you pass an invalid option

Turns on VCR, if it has previously been turned off. @return [void] @see turn_off! @see turned_off @see turned_on?

Turns VCR off for the duration of a block.

@param (see turn_off!) @return [void] @raise (see turn_off!) @see turn_off! @see turn_on! @see turned_on?

@return whether or not VCR is turned on @note Normally VCR is always turned on; it will only be off if you have

 explicitly turned it off.

@see turn_on! @see turn_off! @see turned_off

Inserts a cassette using the given name and options, runs the given block, and ejects the cassette.

@example

  VCR.use_cassette('twitter', :record => :new_episodes) do
    # make an HTTP request
  end

@param (see insert_cassette) @option (see insert_cassette) @yield Block to run while this cassette is in use. @yieldparam cassette [(optional) VCR::Cassette] the cassette that has

 been inserted.

@raise (see insert_cassette) @return [void] @see insert_cassette @see eject_cassette

@return [String] the current VCR version. @note This string also has singleton methods:

  * `major` [Integer] The major version.
  * `minor` [Integer] The minor version.
  * `patch` [Integer] The patch version.
  * `parts` [Array<Integer>] List of the version parts.

[Validate]