Permalink
Browse files

Find a free port, don't guess one.

  • Loading branch information...
1 parent 9e58935 commit 97f2fa372e02706e48feddba4421d24f9ec58321 @tomlea tomlea committed Mar 15, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 test/geminabox_test_case.rb
@@ -115,8 +115,15 @@ def fixture(*args)
self.class.fixture(*args)
end
+ def find_free_port
+ server = TCPServer.new('127.0.0.1', 0)
+ port = server.addr[1]
+ server.close
+ port
+ end
+
def start_app!
- @test_server_port = 7000 + rand(1000)
+ @test_server_port = find_free_port
FileUtils.rm_rf("/tmp/geminabox-test-data")
FileUtils.mkdir("/tmp/geminabox-test-data")

0 comments on commit 97f2fa3

Please sign in to comment.