Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Curb::Easy#http_post & Curb::Easy#http_put w/o arguments #71

Merged
1 commit merged into from

2 participants

@eugenebolshakov

It's not quite clear from the curb docs, but it's possible to use Curb::Easy#http_post & Curb::Easy#http_put methods without arguments (by setting post_body or put_data beforehand). In the current webmock implementation the data argument is mandatory and this patch makes it optional as it is in curb.

@socialpaths

Thanks Eugene! Your changes are now released in version 1.6.2.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 4 deletions.
  1. +4 −4 lib/webmock/http_lib_adapters/curb.rb
  2. +18 −0 spec/curb_spec.rb
View
8 lib/webmock/http_lib_adapters/curb.rb
@@ -117,9 +117,9 @@ def http_with_webmock(method)
alias_method "http_#{verb}", "http_#{verb}_with_webmock"
end
- def http_put_with_webmock data
+ def http_put_with_webmock data = nil
@webmock_method = :put
- @put_data = data
+ @put_data = data if data
curb_or_webmock do
http_put_without_webmock(data)
end
@@ -127,9 +127,9 @@ def http_put_with_webmock data
alias_method :http_put_without_webmock, :http_put
alias_method :http_put, :http_put_with_webmock
- def http_post_with_webmock data
+ def http_post_with_webmock data = nil
@webmock_method = :post
- @post_body = data
+ @post_body = data if data
curb_or_webmock do
http_post_without_webmock(data)
end
View
18 spec/curb_spec.rb
@@ -153,6 +153,24 @@
describe "using #http_* methods for requests" do
it_should_behave_like "Curb"
include CurbSpecHelper::NamedHttp
+
+ it "should work with blank arguments for post" do
+ stub_http_request(:post, "www.example.com").with(:body => "01234")
+ c = Curl::Easy.new
+ c.url = "http://www.example.com"
+ c.post_body = "01234"
+ c.http_post
+ c.response_code.should == 200
+ end
+
+ it "should work with blank arguments for put" do
+ stub_http_request(:put, "www.example.com").with(:body => "01234")
+ c = Curl::Easy.new
+ c.url = "http://www.example.com"
+ c.put_data = "01234"
+ c.http_put
+ c.response_code.should == 200
+ end
end
describe "using #perform for requests" do
Something went wrong with that request. Please try again.