Skip to content

Commit

Permalink
Merge pull request #135 from libc/master
Browse files Browse the repository at this point in the history
The curb adapter doesn't call on_failure on 4xx response codes
  • Loading branch information
bblimke committed Sep 24, 2011
2 parents 76eefec + 563acd8 commit 0366ce1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/webmock/http_lib_adapters/curb_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def invoke_curb_callbacks
case response_code
when 200..299
@on_success.call(self) if @on_success
when 500..599
when 400..599
@on_failure.call(self, self.response_code) if @on_failure
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/acceptance/curb/curb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@
test.should == body
end

it "should call on_failure with 4xx response" do
response_code = 403
stub_request(:any, "example.com").
to_return(:status => [response_code, "None shall pass"])

test = nil
@curl.on_failure do |c, code|
test = code
end
@curl.http_get
test.should == response_code
end

it "should call on_failure with 5xx response" do
response_code = 599
stub_request(:any, "example.com").
Expand Down

0 comments on commit 0366ce1

Please sign in to comment.