Permalink
Browse files

Support post bodies specified on the request object

  • Loading branch information...
1 parent d80e642 commit c493eb5c359fd018b4135c1de8876953a44b193c @paulj paulj committed with wycats Mar 28, 2010
Showing with 14 additions and 1 deletion.
  1. +1 −1 lib/artifice.rb
  2. +13 −0 spec/artifice_spec.rb
View
@@ -89,7 +89,7 @@ def request(req, body = nil, &block)
prefix = "#{scheme}://#{addr_port}"
response = rack_request.request("#{prefix}#{req.path}",
- {:method => req.method, :input => body})
+ {:method => req.method, :input => body || req.body})
make_net_http_response(response, &block)
end
View
@@ -138,5 +138,18 @@
it_should_behave_like "a working GET request"
it_should_behave_like "a working HTTP request"
end
+
+ describe "and make a POST request with Net::HTTP::Post.new" do
+ before do
+ Net::HTTP.start('google.com') do |http|
+ req = Net::HTTP::Post.new('/index')
+ req.body = 'foo=bar'
+ @response = http.request(req)
+ end
+ end
+
+ it_should_behave_like "a working POST request"
+ it_should_behave_like "a working HTTP request"
+ end
end
end

0 comments on commit c493eb5

Please sign in to comment.