module VCR::LibraryHooks::WebMock::Helpers

@private

Public Instance Methods

request_headers_for(webmock_request) click to toggle source

@private

# File lib/vcr/library_hooks/webmock.rb, line 47
def request_headers_for(webmock_request)
  return nil unless webmock_request.headers

  # WebMock hooks deeply into a Excon at a place where it manually adds a "Host"
  # header, but this isn't a header we actually care to store...
  webmock_request.headers.dup.tap do |headers|
    headers.delete("Host")
  end
end
typed_request_for(webmock_request, remove = false) click to toggle source
# File lib/vcr/library_hooks/webmock.rb, line 63
        def typed_request_for(webmock_request, remove = false)
          if webmock_request.instance_variables.find { |v| v.to_sym == :@__typed_vcr_request }
            meth = remove ? :remove_instance_variable : :instance_variable_get
            return webmock_request.send(meth, :@__typed_vcr_request)
          end

          warn "            |WARNING: There appears to be a bug in WebMock's after_request hook
            |         and VCR is attempting to work around it. Some VCR features
            |         may not work properly.
".gsub(/^\s+\|/, '')

          Request::Typed.new(vcr_request_for(webmock_request), :unknown)
        end
vcr_request_for(webmock_request) click to toggle source
# File lib/vcr/library_hooks/webmock.rb, line 28
def vcr_request_for(webmock_request)
  VCR::Request.new              webmock_request.method,
    webmock_request.uri.to_s,
    webmock_request.body,
    request_headers_for(webmock_request)
end
vcr_response_for(webmock_response) click to toggle source

@private

# File lib/vcr/library_hooks/webmock.rb, line 37
def vcr_response_for(webmock_response)
  VCR::Response.new              VCR::ResponseStatus.new(*webmock_response.status),
    webmock_response.headers,
    webmock_response.body,
    nil
end