From 22a5c3af93a883db9739ca5ca10d4f0b153f09b3 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 15 Oct 2021 16:34:22 +0200 Subject: [PATCH] Fix :connect_timeout spec * Using a similar approach to the CRuby test TestSocket_TCPSocket#test_initialize_connect_timeout --- library/socket/tcpsocket/initialize_spec.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/library/socket/tcpsocket/initialize_spec.rb b/library/socket/tcpsocket/initialize_spec.rb index e1c17c9362..7d546ad69c 100644 --- a/library/socket/tcpsocket/initialize_spec.rb +++ b/library/socket/tcpsocket/initialize_spec.rb @@ -7,6 +7,12 @@ it 'raises Errno::ECONNREFUSED' do -> { TCPSocket.new(ip_address, 666) }.should raise_error(Errno::ECONNREFUSED) end + + it 'raises Errno::ETIMEDOUT with :connect_timeout' do + -> { + TCPSocket.new("192.0.2.1", 80, connect_timeout: 0) + }.should raise_error(Errno::ETIMEDOUT) + end end describe 'when a server is listening on the given address' do @@ -56,14 +62,6 @@ @client.local_address.ip_port.should_not == @port end end - - describe 'when server connection is timeout' do - ruby_version_is "3.0" do - it 'raises Errno::ETIMEDOUT' do - -> { TCPSocket.new(ip_address, @port, connect_timeout: 0) }.should raise_error(Errno::ETIMEDOUT) - end - end - end end end end