Sha256: ea659ba5c1fd70d44713c9e7dab5d48651c725ab91dbf1495bb8ccf46463e4ce
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
require 'open-uri' require 'file-tail' require 'retries' require_relative 'process_pool' module RSpecBackgroundProcess class ProcessPool class ProcessDefinition def ready_when_log_includes(log_line) ready_test do |instance| log_line = instance.render(log_line) # NOTE: log file my not be crated just after process is started (spawned) so we need to retry with_retries( max_tries: 10000, base_sleep_seconds: 0.01, max_sleep_seconds: 0.2, rescue: Errno::ENOENT ) do File::Tail::Logfile.tail(instance.log_file, forward: 0, interval: 0.01, max_interval: 1, suspicious_interval: 4) do |line| line.include?(log_line) and break true end end end end def ready_when_url_response_status(uri, status = 'OK') ready_test do |instance| _uri = instance.render(uri) # NOTE: new variable (_uri) is needed or strange things happen... begin with_retries( max_tries: 10000, base_sleep_seconds: 0.06, max_sleep_seconds: 0.2, rescue: Errno::ECONNREFUSED ) do open(_uri).status.last.strip == status and break true end end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems