Sha256: 44dfaa3d490f3bf4476069e7ced9a6df143c34f4537722d91582f8f17956d958

Contents?: true

Size: 325 Bytes

Versions: 2

Compression:

Stored size: 325 Bytes

Contents

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

2 entries across 2 versions & 1 rubygems

Version Path
delayed_job_heartbeat_plugin-0.2.0 spec/support/wait.rb
delayed_job_heartbeat_plugin-0.1.0 spec/support/wait.rb