Skip to content

Commit

Permalink
Fix :connect_timeout spec
Browse files Browse the repository at this point in the history
* Using a similar approach to the CRuby test
  TestSocket_TCPSocket#test_initialize_connect_timeout
  • Loading branch information
eregon committed Oct 15, 2021
1 parent 079ad49 commit 22a5c3a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions library/socket/tcpsocket/initialize_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 22a5c3a

Please sign in to comment.