Skip to content

Commit

Permalink
Fix broken Net::HTTP#ipaddr
Browse files Browse the repository at this point in the history
  • Loading branch information
rzane committed Aug 5, 2022
1 parent cadef36 commit 0eb3a7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/webmock/http_lib_adapters/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def io
class StubIO
def setsockopt(*args); end
def peer_cert; end
def peeraddr; ["AF_INET", 443, "127.0.0.1", "127.0.0.1"] end
end
end

Expand Down
6 changes: 6 additions & 0 deletions spec/acceptance/net_http/net_http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ class TestMarshalingInWebMockNetHTTP
end
end

it "uses the StubSocket to provide IP address" do
Net::HTTP.start("http://example.com") do |http|
expect(http.ipaddr).to eq("127.0.0.1")
end
end

describe "connecting on Net::HTTP.start" do
before(:each) do
@http = Net::HTTP.new('www.google.com', 443)
Expand Down

0 comments on commit 0eb3a7b

Please sign in to comment.