diff options
-rw-r--r-- | spec/rubyspec/library/socket/fixtures/classes.rb | 5 | ||||
-rw-r--r-- | spec/rubyspec/library/socket/tcpsocket/shared/new.rb | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/spec/rubyspec/library/socket/fixtures/classes.rb b/spec/rubyspec/library/socket/fixtures/classes.rb index f154330b9d..f6436c7d23 100644 --- a/spec/rubyspec/library/socket/fixtures/classes.rb +++ b/spec/rubyspec/library/socket/fixtures/classes.rb @@ -46,6 +46,11 @@ module SocketSpecs find_available_port end + def self.reserved_unused_port + # https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers + 0 + end + def self.sockaddr_in(port, host) Socket::SockAddr_In.new(Socket.sockaddr_in(port, host)) end diff --git a/spec/rubyspec/library/socket/tcpsocket/shared/new.rb b/spec/rubyspec/library/socket/tcpsocket/shared/new.rb index b6f557fc18..fed399d80a 100644 --- a/spec/rubyspec/library/socket/tcpsocket/shared/new.rb +++ b/spec/rubyspec/library/socket/tcpsocket/shared/new.rb @@ -8,7 +8,7 @@ describe :tcpsocket_new, shared: true do it "refuses the connection when there is no server to connect to" do lambda do - TCPSocket.send(@method, SocketSpecs.hostname, SocketSpecs.local_port) + TCPSocket.send(@method, SocketSpecs.hostname, SocketSpecs.reserved_unused_port) end.should raise_error(Errno::ECONNREFUSED) end |