Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Stubbing a POST request with body in hash format does NOT work with Typhoeus #348

changmason opened this Issue Dec 19, 2013 · 3 comments


None yet
3 participants

I created a spec, it seems like stubbing a POST request with body in hash format does not work properly with Typhoeus but work fine with HttpClient. The resulting error is,


  1) Webmock stubbing post request with body in hash format should work with typhoeus
     Failure/Error: response = Typhoeus.post('http://example.com/path', :body => {:data => 'blah~'})
       undefined method `split' for {:data=>"blah~"}:Hash
     # ./mock_post_body_spec.rb:13:in `block (2 levels) in <top (required)>'

Here is the spec file, (filename is: mock_post_body_spec.rb)

require 'typhoeus'
require 'httpclient'
require 'webmock/rspec'

describe "Webmock stubbing post request with body in hash format" do
  before do
    stub_request(:post, 'http://example.com/path').
      with(:body => {:data => 'blah~'}).
      to_return({:status => 200, :body => 'Success!'})

  it "should work with typhoeus" do
    response = Typhoeus.post('http://example.com/path', :body => {:data => 'blah~'})
    expect(response.body).to eq('Success!')

  it "should work with httpclient" do
    response = HTTPClient.post('http://example.com/path', {:data => 'blah~'})
    expect(response.body).to eq('Success!')

bblimke commented Feb 2, 2014

Fixed in version 1.17.2

@bblimke bblimke closed this Feb 2, 2014

erwanlr commented Feb 2, 2014

Awesome, thx :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment