Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

26 lines (20 sloc) 0.879 kb
require 'net/http'
module Net
class HTTP
def request_with_vcr(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))
if VCR.http_stubbing_adapter.should_unwind_response?(response)
response.extend VCR::Net::HTTPResponse # "unwind" the response
end
end
yield response if block_given?
response
end
alias request_without_vcr request
alias request request_with_vcr
end
end
Jump to Line
Something went wrong with that request. Please try again.