Sha256: 565468d06524c7a4f37f59778e20c7818db762b7c4459513e20791fc27622008

Contents?: true

Size: 767 Bytes

Versions: 86

Compression:

Stored size: 767 Bytes

Contents

module WaitForHelper
  # Wait for a condition to be met
  #
  # @example
  #   # Perform threaded operation
  #   wait_for("enough probe calls") { probe.calls >= 2 }
  #   # Assert on result
  #
  # @param name [String] The name of the condition to check. Used in the
  #   error when it fails.
  # @yield Assertion to check.
  # @yieldreturn [Boolean] True/False value that indicates if the condition
  #   is met.
  # @raise [StandardError] Raises error if the condition is not met after 5
  #   seconds, 5_000 tries.
  def wait_for(name)
    max_wait = 5_000
    i = 0
    while i < max_wait
      break if yield
      i += 1
      sleep 0.001
    end

    return unless i >= max_wait
    raise "Waited 5 seconds for #{name} condition, but was not met."
  end
end

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
appsignal-2.11.10-java spec/support/helpers/wait_for_helper.rb
appsignal-2.11.10 spec/support/helpers/wait_for_helper.rb
appsignal-3.0.7-java spec/support/helpers/wait_for_helper.rb
appsignal-3.0.7 spec/support/helpers/wait_for_helper.rb
appsignal-3.0.6-java spec/support/helpers/wait_for_helper.rb
appsignal-3.0.6 spec/support/helpers/wait_for_helper.rb
appsignal-3.0.5-java spec/support/helpers/wait_for_helper.rb
appsignal-3.0.5 spec/support/helpers/wait_for_helper.rb
appsignal-3.0.4-java spec/support/helpers/wait_for_helper.rb
appsignal-3.0.4 spec/support/helpers/wait_for_helper.rb
appsignal-3.0.4.alpha.1-java spec/support/helpers/wait_for_helper.rb
appsignal-3.0.4.alpha.1 spec/support/helpers/wait_for_helper.rb
appsignal-3.0.3-java spec/support/helpers/wait_for_helper.rb
appsignal-3.0.3 spec/support/helpers/wait_for_helper.rb
appsignal-3.0.2-java spec/support/helpers/wait_for_helper.rb
appsignal-3.0.2 spec/support/helpers/wait_for_helper.rb
appsignal-3.0.1-java spec/support/helpers/wait_for_helper.rb
appsignal-3.0.1 spec/support/helpers/wait_for_helper.rb
appsignal-3.0.0-java spec/support/helpers/wait_for_helper.rb
appsignal-3.0.0 spec/support/helpers/wait_for_helper.rb