def wait_for(timeout_message,
                 timeout: Calabash::Wait.default_options[:timeout],
                 retry_frequency: Calabash::Wait.default_options[:retry_frequency],
                 exception_class: Calabash::Wait.default_options[:exception_class],
                 &block)
      with_timeout(timeout, timeout_message,
                   exception_class: exception_class) do
        loop do
          value = block.call

          return value if value

          sleep(retry_frequency)
        end
      end
    end
def wait_for(timeout_message,
                 timeout: Calabash::Wait.default_options[:timeout],
                 retry_frequency: Calabash::Wait.default_options[:retry_frequency],
                 exception_class: Calabash::Wait.default_options[:exception_class],
                 &block)
      with_timeout(timeout, timeout_message,
                   exception_class: exception_class) do
        loop do
          value = block.call

          return value if value

          sleep(retry_frequency)
        end
      end
    end
Evaluates the given block until the block evaluates to truthy. If the
 block raises an error, it is **not** rescued.

 If the block does not evaluate to truthy within the given timeout
 an TimeoutError will be raised.

 The default timeout will be {Calabash::Wait.default_options
 Wait.default_options[:timeout]}.

 @example
  # Pan up **at least once** and continue pan up until the
  # 'PictureRow' exists.
  cal.wait_for('Could not find picture row') do
    cal.pan_screen_up
    cal.view_exists?("PictureRow")
  end

 @see Calabash::Wait#with_timeout

 @param [String, Proc] timeout_message The error message if timed out.
 @param [Number] timeout (default: {Calabash::Wait.default_options
  Calabash::Wait.default_options[:timeout]}) The time to wait before
  failing.
 @param [Number] retry_frequency (default: {Calabash::Wait.default_options
  Calabash::Wait.default_options[:retry_frequency]}) How often to check
  for the block to be truthy
 @param [Class] exception_class
  (default: {Calabash::Wait.default_options
  Calabash::Wait.default_options[:exception_class]}) The exception type
  raised if timed out
 @return The returned value of `block` if it is truthy