Sha256: dd1a8c3bac635bf70754035011d00a31252662f391bb6061801cc03a2fd122e0

Contents?: true

Size: 356 Bytes

Versions: 3

Compression:

Stored size: 356 Bytes

Contents

# frozen_string_literal: true

module Wait
  def self.for(condition_name, max_wait_time: 5, polling_interval: 0.001)
    wait_until = Time.now + max_wait_time.seconds
    loop do
      return if yield
      if Time.now > wait_until
        raise "Condition not met: #{condition_name}"
      else
        sleep(polling_interval)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
delayed_job_heartbeat_plugin-0.6.0 spec/support/wait.rb
delayed_job_heartbeat_plugin-0.5.0 spec/support/wait.rb
delayed_job_heartbeat_plugin-0.4.0 spec/support/wait.rb