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
endend
RSpec.configure do |rspec|
rspec.include WaitHelpersend
RSpec.describe "A docker container" do
before do
@container = Docker::Container.create
@container.start
wait_until_port_available(@container)
endend
HTH,
Myron
On Fri, Apr 6, 2018 at 5:44 AM, Samuel Mutel <[email protected]> wrote:
> Hello,
>
> I am currently using rspec and docker api to test docker container
> (@container = Docker::Container.create & @container.start).
> I would like to know if it is possible to wait a condition (port available
> for example) to continue the test suite?
> I saw this module rspec-wait ...
>
> Thanks.
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/rspec/1ff39192-ef6a-4dd1-830c-c120d61faafd%40googlegroups.com
> <https://groups.google.com/d/msgid/rspec/1ff39192-ef6a-4dd1-830c-c120d61faafd%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/CADUxQmufRPiOaG3shc00BePoC29q5iJ45pkDvP6ypbgKj%3DcFbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.