summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/server.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/support/server.rb b/spec/support/server.rb
index 51d4ed8..e5acdd1 100644
--- a/spec/support/server.rb
+++ b/spec/support/server.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+require 'socket'
RSpec.configure do |config|
config.add_setting :http
@@ -10,10 +11,21 @@ RSpec.configure do |config|
config.add_setting :pid
config.before :suite do
+ bind_addr = RSpec.configuration.bind_addr
RSpec.configuration.pid = Process.spawn({
- "BIND_ADDR" => RSpec.configuration.bind_addr,
+ "BIND_ADDR" => bind_addr,
}, "mise exec -- cargo run")
- sleep 1
+
+ ip, port = bind_addr.split(":")
+ 10.times do |n|
+ begin
+ Socket.tcp(ip, port.to_i) { true }
+ break
+ rescue Errno::ECONNREFUSED => error
+ puts error.inspect
+ sleep 1
+ end
+ end
end
config.after :suite do