module VCR::HttpStubbingAdapters::WebMock

Constants

MAXIMUM_VERSION
MINIMUM_VERSION

Public Instance Methods

create_stubs_checkpoint(cassette) click to toggle source
# File lib/vcr/http_stubbing_adapters/webmock.rb, line 37
def create_stubs_checkpoint(cassette)
  checkpoints[cassette] = ::WebMock::StubRegistry.instance.request_stubs.dup
end
http_connections_allowed=(value) click to toggle source
# File lib/vcr/http_stubbing_adapters/webmock.rb, line 12
def http_connections_allowed=(value)
  @http_connections_allowed = value
  update_webmock_allow_net_connect
end
http_connections_allowed?() click to toggle source
# File lib/vcr/http_stubbing_adapters/webmock.rb, line 17
def http_connections_allowed?
  !!::WebMock::Config.instance.allow_net_connect
end
ignored_hosts=(hosts) click to toggle source
# File lib/vcr/http_stubbing_adapters/webmock.rb, line 21
def ignored_hosts=(hosts)
  @ignored_hosts = hosts
  update_webmock_allow_net_connect
end
restore_stubs_checkpoint(cassette) click to toggle source
# File lib/vcr/http_stubbing_adapters/webmock.rb, line 41
def restore_stubs_checkpoint(cassette)
  ::WebMock::StubRegistry.instance.request_stubs = checkpoints.delete(cassette) || super
end
stub_requests(http_interactions, match_attributes) click to toggle source
# File lib/vcr/http_stubbing_adapters/webmock.rb, line 26
def stub_requests(http_interactions, match_attributes)
  grouped_responses(http_interactions, match_attributes).each do |request_matcher, responses|
    stub = ::WebMock.stub_request(request_matcher.method || :any, request_matcher.uri)

    with_hash = request_signature_hash(request_matcher)
    stub = stub.with(with_hash) if with_hash.size > 0

    stub.to_return(responses.map{ |r| response_hash(r) })
  end
end