Skip to content

Commit 801ad3b

Browse files
authored
Merge pull request #1122 from criess/cr/curb-easy-code-as-alias
[fix] CurbAdapter alias `code` from `response_code`
2 parents 596d8a8 + c6cf2f1 commit 801ad3b

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

lib/webmock/http_lib_adapters/curb_adapter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ def body_str
313313
def response_code
314314
@response_code ||= super
315315
end
316+
alias code response_code
316317

317318
def header_str
318319
@header_str ||= super

spec/acceptance/curb/curb_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,15 @@
373373
expect(c.body).to eq("abc")
374374
end
375375

376+
it "should alias code to response_code" do
377+
stub_request(:get, "www.example.com").to_return(status: 456)
378+
379+
c = Curl::Easy.new
380+
c.url = "http://www.example.com"
381+
c.http(:GET)
382+
expect(c.code).to eq(456)
383+
end
384+
376385
it "supports array headers passed to Curl::Easy" do
377386
stub_request(:get, "www.example.com").with(headers: {'X-One' => '1'}).to_return(body: "abc")
378387

0 commit comments

Comments
 (0)