Class: Wait
- Inherits:
-
Object
- Object
- Wait
- Defined in:
- lib/frameworks/wait.rb
Class Method Summary collapse
-
.until(options = {:timeout => 5}) ⇒ Object
Execute a block until it returns true.
Class Method Details
.until(options = {:timeout => 5}) ⇒ Object
Execute a block until it returns true. Optionally pass a timeout (by default 5 seconds).
wait = Wait.new wait.until
(Random.rand(2) % 2)
wait.until(:timeout => 4)
(Random.rand(2) % 2)
17 18 19 20 21 22 23 24 |
# File 'lib/frameworks/wait.rb', line 17 def Wait.until(={:timeout => 5}) timeout = Time.new + [:timeout].to_f while (Time.new < timeout) return if (yield) end raise 'Timeout exceeded for wait until.' end |