Sha256: 373fca5a48ab4da6d08b6359fa698cfbe6d889415cb559a9e7a5a29a9b0ff4c5

Contents?: true

Size: 418 Bytes

Versions: 25

Compression:

Stored size: 418 Bytes

Contents

require 'socket'

module RestAssured
  module Utils
    class PortExplorer
      def self.free_port
        server = TCPServer.new('127.0.0.1', 0)
        free_port = server.addr[1]
        server.close
        free_port
      end

      def self.port_free?(port)
        Net::HTTP.get('127.0.0.1', '/', port)
      rescue => e
        e.is_a?(Errno::ECONNREFUSED)
      else
        false
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
rest-assured-4.0.0 lib/rest-assured/utils/port_explorer.rb
rest-assured-3.0.1 lib/rest-assured/utils/port_explorer.rb
rest-assured-3.0.0 lib/rest-assured/utils/port_explorer.rb
rest-assured-2.2.0 lib/rest-assured/utils/port_explorer.rb
rest-assured-2.1.0 lib/rest-assured/utils/port_explorer.rb
rest-assured-2.0.2 lib/rest-assured/utils/port_explorer.rb
rest-assured-2.0.1 lib/rest-assured/utils/port_explorer.rb
rest-assured-2.0.0 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.2.2 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.2.1 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.2.0 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.1.10 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.1.9 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.1.8 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.1.7 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.1.6 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.1.5 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.1.4 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.1.3 lib/rest-assured/utils/port_explorer.rb
rest-assured-1.1.2 lib/rest-assured/utils/port_explorer.rb