Module: VCR::LibraryHooks::WebMock::Helpers
- Included in:
- VCR::LibraryHooks::WebMock, RequestHandler
- Defined in:
- lib/vcr/library_hooks/webmock.rb
Instance Method Summary collapse
- #request_headers_for(webmock_request) ⇒ Object
- #typed_request_for(webmock_request, remove = false) ⇒ Object
- #vcr_request_for(webmock_request) ⇒ Object
- #vcr_response_for(webmock_response) ⇒ Object
Instance Method Details
#request_headers_for(webmock_request) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# 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) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# 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\n | and VCR is attempting to work around it. Some VCR features\n | may not work properly.\n EOS\n\n Request::Typed.new(vcr_request_for(webmock_request), :unknown)\nend\n".gsub(/^\s+\|/, '') |
#vcr_request_for(webmock_request) ⇒ Object
28 29 30 31 32 33 34 |
# 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) ⇒ Object
37 38 39 40 41 42 43 |
# 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 |