module VCR::HttpStubbingAdapters::FakeWeb

Constants

MAXIMUM_VERSION
MINIMUM_VERSION
UNSUPPORTED_REQUEST_MATCH_ATTRIBUTES

Public Class Methods

const_missing(const) click to toggle source
# File lib/vcr/deprecations/http_stubbing_adapters/fakeweb.rb, line 4
def self.const_missing(const)
  return super unless const == :LOCALHOST_REGEX
  warn "WARNING: `VCR::HttpStubbingAdapters::FakeWeb::LOCALHOST_REGEX` is deprecated."
  VCR::Regexes.url_regex_for_hosts(VCR::LOCALHOST_ALIASES)
end

Public Instance Methods

create_stubs_checkpoint(cassette) click to toggle source
# File lib/vcr/http_stubbing_adapters/fakeweb.rb, line 42
def create_stubs_checkpoint(cassette)
  checkpoints[cassette] = ::FakeWeb::Registry.instance.uri_map.dup
end
http_connections_allowed=(value) click to toggle source
# File lib/vcr/http_stubbing_adapters/fakeweb.rb, line 16
def http_connections_allowed=(value)
  @http_connections_allowed = value
  update_fakeweb_allow_net_connect
end
http_connections_allowed?() click to toggle source
# File lib/vcr/http_stubbing_adapters/fakeweb.rb, line 21
def http_connections_allowed?
  !!::FakeWeb.allow_net_connect?("http://some.url/besides/localhost")
end
ignored_hosts=(hosts) click to toggle source
# File lib/vcr/http_stubbing_adapters/fakeweb.rb, line 25
def ignored_hosts=(hosts)
  @ignored_hosts = hosts
  update_fakeweb_allow_net_connect
end
request_stubbed?(request, match_attributes) click to toggle source
# File lib/vcr/http_stubbing_adapters/fakeweb.rb, line 50
def request_stubbed?(request, match_attributes)
  validate_match_attributes(match_attributes)
  !!::FakeWeb.registered_uri?(request.method, request.uri)
end
request_uri(net_http, request) click to toggle source
# File lib/vcr/http_stubbing_adapters/fakeweb.rb, line 55
def request_uri(net_http, request)
  ::FakeWeb::Utility.request_uri_as_string(net_http, request)
end
restore_stubs_checkpoint(cassette) click to toggle source
# File lib/vcr/http_stubbing_adapters/fakeweb.rb, line 46
def restore_stubs_checkpoint(cassette)
  ::FakeWeb::Registry.instance.uri_map = checkpoints.delete(cassette) || super
end
stub_requests(http_interactions, match_attributes) click to toggle source
# File lib/vcr/http_stubbing_adapters/fakeweb.rb, line 30
def stub_requests(http_interactions, match_attributes)
  validate_match_attributes(match_attributes)

  grouped_responses(http_interactions, match_attributes).each do |request_matcher, responses|
    ::FakeWeb.register_uri(
      request_matcher.method || :any,
      request_matcher.uri,
      responses.map{ |r| response_hash(r) }
    )
  end
end