Skip to content

Commit

Permalink
Find a free port, don't guess one.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlea committed Mar 15, 2012
1 parent 9e58935 commit 97f2fa3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/geminabox_test_case.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -115,8 +115,15 @@ def fixture(*args)
self.class.fixture(*args) self.class.fixture(*args)
end end


def find_free_port
server = TCPServer.new('127.0.0.1', 0)
port = server.addr[1]
server.close
port
end

def start_app! def start_app!
@test_server_port = 7000 + rand(1000) @test_server_port = find_free_port


FileUtils.rm_rf("/tmp/geminabox-test-data") FileUtils.rm_rf("/tmp/geminabox-test-data")
FileUtils.mkdir("/tmp/geminabox-test-data") FileUtils.mkdir("/tmp/geminabox-test-data")
Expand Down

0 comments on commit 97f2fa3

Please sign in to comment.