spec/support/non_listening_port_helper.rb
def non_listening_port
      @non_listening_port ||= begin
        server = TCPServer.new('127.0.0.1', 0)
        server.addr[1]
      ensure
        server&.close
      end
    end
# Returns a free TCP port that never listened
#
# @return [Integer]
Returns a free TCP port that never listened
Returns a free TCP port that never listened
def non_listening_port
      @non_listening_port ||= begin
        server = TCPServer.new('127.0.0.1', 0)
        server.addr[1]
      ensure
        server&.close
      end
    end
def non_listening_port @non_listening_port ||= begin server = TCPServer . new ( '127.0.0.1' , 0 ) server . addr [ 1 ] ensure server &. close end end
Returns a free TCP port that never listened
Returns a free TCP port that never listened
None
Integer