Skip to content

Instantly share code, notes, and snippets.

@timblair
Created January 20, 2014 17:15
Show Gist options
  • Save timblair/8524379 to your computer and use it in GitHub Desktop.
Save timblair/8524379 to your computer and use it in GitHub Desktop.
WebMock overrides the Net::HTTP#request method to do it's thing, but Net::HTTP::Pipeline circumvents that method to do *it's* thing. We only care about the responses during testing, so getting WebMock behaviour for pipelined requests is most easily done by just not pipelining them.
WebMock::HttpLibAdapters::NetHttpAdapter.instance_variable_get(:@webMockNetHTTP).class_eval do
def pipeline(requests)
responses = []
requests.reject! do |req|
response = request(req)
yield response if block_given?
responses << response
end
responses
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment