Sha256: 453d0524f91fd4a42cb89c1a72936e439d5e0c20b032ecd5f9c0626033ab15dd

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

require 'net/http'

module Net
  class HTTP
    alias_method :request_without_vcr, :request

    def request(request, body = nil, &block)
      vcr_request = VCR::Request.from_net_http_request(self, request)
      response = request_without_vcr(request, body)

      match_attributes = (cass = VCR.current_cassette) ? cass.match_requests_on : VCR::RequestMatcher::DEFAULT_MATCH_ATTRIBUTES
      if started? && !VCR.http_stubbing_adapter.request_stubbed?(vcr_request, match_attributes)
        VCR.record_http_interaction VCR::HTTPInteraction.new(vcr_request, VCR::Response.from_net_http_response(response))
        response.extend VCR::Net::HTTPResponse # "unwind" the response
      end

      yield response if block_given?
      response
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vcr-1.1.1 lib/vcr/extensions/net_http.rb