Skip to content

Commit

Permalink
Curb::Easy#http_post & Curb::Easy#http_put can be used without arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenebolshakov committed Jan 11, 2011
1 parent ed9ff32 commit 6b6b3aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/webmock/http_lib_adapters/curb.rb
Expand Up @@ -117,19 +117,19 @@ 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
end
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
Expand Down
18 changes: 18 additions & 0 deletions spec/curb_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 6b6b3aa

Please sign in to comment.