Class: SitePrism::Waiter

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

Class Method Summary collapse

Class Method Details

.wait_until_true(wait_time = Capybara.default_max_wait_time) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/site_prism/waiter.rb', line 6

def wait_until_true(wait_time = Capybara.default_max_wait_time)
  start_time = Time.now

  loop do
    return true if yield
    break if Time.now - start_time > wait_time

    sleep(0.05)

    check_for_time_stopped!(start_time)
  end

  raise SitePrism::TimeoutError, "Timed out after #{wait_time}s."
end