Created
January 20, 2014 17:15
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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