From 0de302c977496c4ccdc77c5ceeb21979791d409f Mon Sep 17 00:00:00 2001 From: Donal McBreen Date: Mon, 20 Jul 2026 16:20:15 +0100 Subject: [PATCH] Fix unfurl rebinding tests for newer Ruby Net::HTTP now passes an open_timeout: option to TCPSocket.open, so the mock that matched exact positional arguments no longer matches. Match on the host instead. --- test/models/opengraph/fetch_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/models/opengraph/fetch_test.rb b/test/models/opengraph/fetch_test.rb index 3bcf19d..e0bf2b0 100644 --- a/test/models/opengraph/fetch_test.rb +++ b/test/models/opengraph/fetch_test.rb @@ -49,8 +49,8 @@ class Opengraph::FetchTest < ActiveSupport::TestCase # to a resolved IP, not a hostname to re-resolve. WebMock.disable_net_connect! allow: [ @url.host ] Resolv.stubs(:getaddress).with(@url.host).returns("1.2.3.4", "127.0.0.1") - TCPSocket.expects(:open).with(@url.host, 443, nil, nil).never - TCPSocket.expects(:open).with("1.2.3.4", 443, nil, nil).throws(:dns_not_rebound) + TCPSocket.expects(:open).with { |*args, **| args.first == @url.host }.never + TCPSocket.expects(:open).with { |*args, **| args.first == "1.2.3.4" }.throws(:dns_not_rebound) assert_throws :dns_not_rebound do @fetch.fetch_document(@url) @@ -66,8 +66,8 @@ class Opengraph::FetchTest < ActiveSupport::TestCase # to a resolved IP, not a hostname to re-resolve. WebMock.disable_net_connect! allow: [ @url.host ] Resolv.stubs(:getaddress).with(@url.host).returns("1.2.3.4", "127.0.0.1") - TCPSocket.expects(:open).with(@url.host, 443, nil, nil).never - TCPSocket.expects(:open).with("1.2.3.4", 443, nil, nil).throws(:dns_not_rebound) + TCPSocket.expects(:open).with { |*args, **| args.first == @url.host }.never + TCPSocket.expects(:open).with { |*args, **| args.first == "1.2.3.4" }.throws(:dns_not_rebound) assert_throws :dns_not_rebound do @fetch.fetch_document(URI.parse("https://www.other.com/"), ip: "1.2.3.4")