Use WebMock to test your use of pipelined HTTP requests.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

WebMock + Net::HTTP::Pipeline

Use WebMock to test your use of pipelined HTTP requests.

WebMock is a great tool for stubbing HTTP requests in tests. net-http-pipeline is an HTTP/1.1 pipelining implementation build on top of Net::HTTP, used for making batches of HTTP calls more efficient. The only problem is that the two don't play well together: net-http-pipeline bypasses the hooks that WebMock sets in place to provide its behaviour.

This library mimics the -pipeline behaviour within WebMock's version of Net::HTTP#request to allow you to test your pipelined HTTP calls.


Add this line to your application"s Gemfile:

gem "webmock-net-http-pipeline"

And then execute:

$ bundle

Or install it yourself as:

$ gem install webmock-net-http-pipeline


Simply continue to mock your HTTP requests as you already do with Webmock, but now you can test your mocked pipeline calls too.

require "webmock"
require "webmock/net/http/pipeline"

include WebMock::API

host = ""
stub_request(:any, host)

http      = Net::HTTP.start(host, 80).tap { |http| http.pipelining = true }
requests  = (1..3).map {"/") }
responses = http.pipeline(requests)

p responses   #=> [#<Net::HTTPOK 200  readbody=true>, ...]

Ruby Version Compatilbility

As of v2.0.0, this library is compatible with Ruby versions >= 2.0.0. For a version compatible with earlier Rubies, please v1.0.0.


  1. Fork it:
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am "Add some feature"
  4. Push to the branch: git push origin my-new-feature
  5. Create new Pull Request

Licensing and Attribution

webmock-net-http-pipeline is released under the MIT license as detailed in the LICENSE file that should be distributed with ; the source code is freely available.

webmock-net-http-pipeline was developed by Tim Blair and Mat Sadler during work on White Label Dating, while employed by Global Personals Ltd. Global Personals Ltd. have kindly agreed to the extraction and release of this software under the license terms above.