Class: WaitUntil::Wait
- Inherits:
-
Object
- Object
- WaitUntil::Wait
- Defined in:
- lib/wait_until/wait.rb
Class Attribute Summary collapse
-
.default_timeout_in_seconds ⇒ Object
Returns the value of attribute default_timeout_in_seconds.
Class Method Summary collapse
- .until!(description, &block) ⇒ Object
- .until_false!(description, &block) ⇒ Object
- .until_true!(description, &block) ⇒ Object
Class Attribute Details
.default_timeout_in_seconds ⇒ Object
Returns the value of attribute default_timeout_in_seconds.
6 7 8 |
# File 'lib/wait_until/wait.rb', line 6 def default_timeout_in_seconds @default_timeout_in_seconds end |
Class Method Details
.until!(description, &block) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/wait_until/wait.rb', line 30 def until!(description, &block) until_true!(description) do block.call true end end |
.until_false!(description, &block) ⇒ Object
26 27 28 |
# File 'lib/wait_until/wait.rb', line 26 def until_false!(description, &block) until_true!(description) { !block.call } end |
.until_true!(description, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/wait_until/wait.rb', line 8 def until_true!(description, &block) start_time = Time.now last_exc = nil while true begin return if block.call rescue => exc last_exc = exc end elapsed_time = Time.now - start_time if elapsed_time >= self.default_timeout_in_seconds = "Timed-out waiting until '#{description}'" << ". Last observed exception: #{last_exc}" if last_exc raise end end end |