# frozen_string_literal: true require 'socket' RSpec.configure do |config| config.add_setting :http config.http = Net::Hippie::Client.new config.add_setting :bind_addr config.bind_addr = ENV.fetch("BIND_ADDR", "127.0.0.1:7878") config.add_setting :pid config.before :suite do bind_addr = RSpec.configuration.bind_addr RSpec.configuration.pid = Process.spawn({ "BIND_ADDR" => bind_addr, }, "mise exec -- cargo run") ip, port = bind_addr.split(":") 300.times do |n| begin Socket.tcp(ip, port.to_i) { true } break rescue Errno::ECONNREFUSED => error sleep 1 end end end config.after :suite do Process.kill('SIGTERM', RSpec.configuration.pid) system("killall sts") end end at_exit do system("killall sts") end