Skip to content
Browse files

Fixed handling of request body passed as a hash to `Typhoeus.post`

  • Loading branch information...
1 parent 02a795c commit 9a3988c9b25625f5a50bbcb2d22923334f9b9cb2 @bblimke committed
View
4 lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb
@@ -59,6 +59,10 @@ def self.build_request_signature(req)
body = req.options[:body]
+ if body.is_a?(Hash)
+ body = WebMock::Util::QueryMapper.values_to_query(body)
+ end
+
request_signature = WebMock::RequestSignature.new(
req.options[:method] || :get,
uri.to_s,
View
6 spec/acceptance/typhoeus/typhoeus_hydra_spec.rb
@@ -28,6 +28,12 @@
hydra.run
end
+ it "should take into account body for POST request" do
+ stub_request(:post, "www.example.com").with(:body => {:hello => 'world'})
+ response = Typhoeus.post("http://www.example.com", :method => :post, :body => {:hello => 'world'})
+ expect(response.code).to eq(200)
+ end
+
it "should take into account params for GET request" do
stub_request(:get, "http://www.example.com/?hello=world").to_return({})
request = Typhoeus::Request.new("http://www.example.com/?hello=world", :method => :get)

0 comments on commit 9a3988c

Please sign in to comment.
Something went wrong with that request. Please try again.