class VCR::Cassette

Constants

VALID_RECORD_MODES

Attributes

erb[R]
match_requests_on[R]
name[R]
re_record_interval[R]
record_mode[R]
tag[R]

Public Class Methods

new(name, options = {}) click to toggle source
# File lib/vcr/cassette.rb, line 13
def initialize(name, options = {})
  options = VCR::Config.default_cassette_options.merge(options)
  invalid_options = options.keys - [
    :record,
    :erb,
    :allow_real_http,
    :match_requests_on,
    :re_record_interval,
    :tag,
    :update_content_length_header
  ]

  if invalid_options.size > 0
    raise ArgumentError.new("You passed the following invalid options to VCR::Cassette.new: #{invalid_options.inspect}.")
  end

  @name               = name
  @record_mode        = options[:record]
  @erb                = options[:erb]
  @match_requests_on  = options[:match_requests_on]
  @re_record_interval = options[:re_record_interval]
  @tag                = options[:tag]
  @record_mode        = :all if should_re_record?
  @update_content_length_header = options[:update_content_length_header]

  deprecate_old_cassette_options(options)
  raise_error_unless_valid_record_mode

  set_http_connections_allowed
  load_recorded_interactions
end

Public Instance Methods

allow_real_http_requests_to?(uri) click to toggle source
# File lib/vcr/deprecations/cassette.rb, line 3
def allow_real_http_requests_to?(uri)
  warn "WARNING: VCR::Cassette#allow_real_http_requests_to? is deprecated and should no longer be used."
  VCR::Config.uri_should_be_ignored?(uri.to_s)
end
eject() click to toggle source
# File lib/vcr/cassette.rb, line 45
def eject
  write_recorded_interactions_to_disk
  VCR.http_stubbing_adapter.restore_stubs_checkpoint(self)
  restore_http_connections_allowed
  restore_ignore_localhost_for_deprecation
end
file() click to toggle source
# File lib/vcr/cassette.rb, line 64
def file
  File.join(VCR::Config.cassette_library_dir, "#{sanitized_name}.yml") if VCR::Config.cassette_library_dir
end
new_recorded_interactions() click to toggle source
# File lib/vcr/cassette.rb, line 60
def new_recorded_interactions
  @new_recorded_interactions ||= []
end
record_http_interaction(interaction) click to toggle source
# File lib/vcr/cassette.rb, line 56
def record_http_interaction(interaction)
  new_recorded_interactions << interaction
end
recorded_interactions() click to toggle source
# File lib/vcr/cassette.rb, line 52
def recorded_interactions
  @recorded_interactions ||= []
end
update_content_length_header?() click to toggle source
# File lib/vcr/cassette.rb, line 68
def update_content_length_header?
  @update_content_length_header
end