module VCR::HttpStubbingAdapters::Common

Constants

RECORDING_INSTRUCTIONS

Attributes

exclusively_enabled_adapter[RW]

Public Class Methods

adapters() click to toggle source
# File lib/vcr/http_stubbing_adapters/common.rb, line 24
def adapters
  @adapters ||= []
end
add_vcr_info_to_exception_message(exception_klass) click to toggle source
# File lib/vcr/http_stubbing_adapters/common.rb, line 16
def add_vcr_info_to_exception_message(exception_klass)
  exception_klass.class_eval do
    def initialize(message)
      super(message + '.  ' + VCR::HttpStubbingAdapters::Common::RECORDING_INSTRUCTIONS)
    end
  end
end
included(adapter) click to toggle source
# File lib/vcr/http_stubbing_adapters/common.rb, line 28
def included(adapter)
  adapters << adapter
end
initialize(message) click to toggle source
# File lib/vcr/http_stubbing_adapters/common.rb, line 18
def initialize(message)
  super(message + '.  ' + VCR::HttpStubbingAdapters::Common::RECORDING_INSTRUCTIONS)
end

Public Instance Methods

check_version!() click to toggle source
# File lib/vcr/http_stubbing_adapters/common.rb, line 50
def check_version!
  case compare_version
    when :too_low
      raise "You are using #{library_name} #{version}.  VCR requires version #{version_requirement}."
    when :too_high
      warn "You are using #{library_name} #{version}.  VCR is known to work with #{library_name} #{version_requirement}.  It may not work with this version."
  end
end
enabled?() click to toggle source
# File lib/vcr/http_stubbing_adapters/common.rb, line 36
def enabled?
  [nil, self].include? VCR::HttpStubbingAdapters::Common.exclusively_enabled_adapter
end
exclusively_enabled() { || ... } click to toggle source
# File lib/vcr/http_stubbing_adapters/common.rb, line 40
def exclusively_enabled
  VCR::HttpStubbingAdapters::Common.exclusively_enabled_adapter = self

  begin
    yield
  ensure
    VCR::HttpStubbingAdapters::Common.exclusively_enabled_adapter = nil
  end
end
ignore_localhost?() click to toggle source
# File lib/vcr/deprecations/http_stubbing_adapters/common.rb, line 4
def ignore_localhost?
  VCR::Config.ignore_localhost?
end
library_name() click to toggle source
# File lib/vcr/http_stubbing_adapters/common.rb, line 59
def library_name
  @library_name ||= self.to_s.split('::').last
end
restore_stubs_checkpoint(cassette) click to toggle source
# File lib/vcr/http_stubbing_adapters/common.rb, line 67
def restore_stubs_checkpoint(cassette)
  raise ArgumentError.new("No checkpoint for #{cassette.inspect} could be found")
end
set_http_connections_allowed_to_default() click to toggle source
# File lib/vcr/http_stubbing_adapters/common.rb, line 63
def set_http_connections_allowed_to_default
  self.http_connections_allowed = VCR::Config.allow_http_connections_when_no_cassette?
end