Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
1 commit merged into from
Jan 12, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/webmock/http_lib_adapters/curb.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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