mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
23 lines
420 B
Ruby
23 lines
420 B
Ruby
module Capybara
|
|
#Provides timeout similar to standard library Timeout, but avoids threads
|
|
class WaitUntil
|
|
|
|
class << self
|
|
|
|
def timeout(seconds = 1, &block)
|
|
start_time = Time.now
|
|
|
|
result = nil
|
|
|
|
until result
|
|
return result if result = yield
|
|
|
|
if (Time.now - start_time) > seconds
|
|
raise TimeoutError
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|