RSpec doesn’t have any built-in features for what you’re asking for, but it’s easy enough to write it yourself:
require 'timeout'
module WaitHelpers
def wait_until(timeout)
timeout_time = Time.now + timeout
loop do
sleep 0.1
return if yield
raise Timeout::Error if Time.now > timeout_time
end
end
def wait_until_port_available(container)
wait_until(10) do
container.port.available? # or whatever the logic to check port availability is
end
end
end
RSpec.configure do |rspec|
rspec.include WaitHelpers
end
RSpec.describe "A docker container" do
before do
@container = Docker::Container.create
@container.start
wait_until_port_available(@container)
end
end
--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+unsubscribe@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/1ff39192-ef6a-4dd1-830c-c120d61faafd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.