Permalink
Browse files

use random OS port in test

  • Loading branch information...
1 parent 34a7f28 commit d744d4cee6d4ea465c73c35f007aa73b59c30521 @avalanche123 committed Apr 15, 2012
Showing with 9 additions and 8 deletions.
  1. +5 −5 spec/uv/stream_spec.rb
  2. +4 −3 spec/uv/tcp_spec.rb
View
@@ -12,12 +12,12 @@
server.close
end
end
- end
- start_client do |client|
- client.start_read do |data, err|
- @received << data
- client.close
+ start_client(server) do |client|
+ client.start_read do |data, err|
+ @received << data
+ client.close
+ end
end
end
View
@@ -3,13 +3,14 @@
describe UV::TCP do
def start_server
server = UV::Loop.default.tcp
- server.bind("0.0.0.0", 10000)
+ server.bind("0.0.0.0", 0)
yield server if block_given?
end
- def start_client
+ def start_client(server)
+ _, port = server.sockname
client = UV::Loop.default.tcp
- client.connect("127.0.0.1", 10000) do |err|
+ client.connect("127.0.0.1", port) do |err|
yield client if block_given?
end
end

0 comments on commit d744d4c

Please sign in to comment.