Class: SitePrism::Waiter

Inherits:
Object
  • Object
show all
Defined in:
lib/site_prism/waiter.rb

Class Method Summary collapse

Class Method Details

.default_wait_timeObject


13
14
15
# File 'lib/site_prism/waiter.rb', line 13

def self.default_wait_time
  Capybara.default_wait_time
end

.wait_until_true(wait_time_seconds = default_wait_time) ⇒ Object


3
4
5
6
7
8
9
10
11
# File 'lib/site_prism/waiter.rb', line 3

def self.wait_until_true(wait_time_seconds = default_wait_time)
  start_time = Time.now
  loop do
    return true if yield
    break unless Time.now - start_time <= wait_time_seconds
    sleep(0.05)
  end
  fail SitePrism::TimeoutException, 'Timed out while waiting for block to return true'
end