1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Search for open ports on the address that will be listened on

This commit is contained in:
Aaron Stone 2016-03-18 14:34:58 -07:00 committed by Thomas Walpole
parent 2a51b817b3
commit 5695789460

View file

@ -65,7 +65,7 @@ module Capybara
@server_thread = nil # suppress warnings
@host, @port = host, port
@port ||= Capybara::Server.ports[Capybara.reuse_server ? @app.object_id : @middleware.object_id]
@port ||= find_available_port
@port ||= find_available_port(host)
end
def reset_error!
@ -112,8 +112,8 @@ module Capybara
private
def find_available_port
server = TCPServer.new('127.0.0.1', 0)
def find_available_port(host)
server = TCPServer.new(host, 0)
server.addr[1]
ensure
server.close if server