bin/support/ruby/lib/commands/exercise/instructions.rb
# Wait until the given block evaluates to true
# @example
#   In ERB template:
#   <%
#     wait_until do
#       # code
#     end
#   %>
# @param timeout_after [Fixnum] the number of seconds to wait before timing out.
# @param retry_every [Float] the number of seconds to wait before re-evaluating the given block again
# @raise [TimeoutError] if given block does not return true within the allowed time.
Wait until the given block evaluates to true
Wait until the given block evaluates to true
def wait_until(timeout_after: 5, retry_every: 0.1)
      start_time = Time.now
      until Time.now > start_time + timeout_after
        return true if yield == true
        sleep retry_every
      end
      raise TimeoutError, 'Action took to long'
    end
def wait_until ( timeout_after : 5 , retry_every : 0.1 ) start_time = Time . now until Time . now > start_time + timeout_after return true if yield == true sleep retry_every end raise TimeoutError , 'Action took to long' end
Wait until the given block evaluates to true
Wait until the given block evaluates to true
[TimeoutError] if given block does not return true within the allowed time.
[ TimeoutError ] if given block does not return true within the allowed time .
timeout_after
the number of seconds to wait before timing out.
the number of seconds to wait before timing out .
retry_every
the number of seconds to wait before re-evaluating the given block again
the number of seconds to wait before re - evaluating the given block again
example
In ERB template: <% wait_until do # code end %>
In ERB template : <% wait_until do # code end % >