class ToleranceForSeleniumSyncIssues::Patiently
Constants
- WAIT_PERIOD
Public Instance Methods
patiently(seconds, &block)
click to toggle source
# File lib/spreewald_support/tolerance_for_selenium_sync_issues.rb, line 40 def patiently(seconds, &block) started = monotonic_time tries = 0 begin tries += 1 block.call rescue Exception => e raise e unless retryable_error?(e) raise e if (monotonic_time - started > seconds && tries >= 2) sleep(WAIT_PERIOD) raise Capybara::FrozenInTime, "time appears to be frozen, Capybara does not work with libraries which freeze time, consider using time travelling instead" if monotonic_time == started retry end end
Private Instance Methods
monotonic_time()
click to toggle source
# File lib/spreewald_support/tolerance_for_selenium_sync_issues.rb, line 57 def monotonic_time # We use the system clock (i.e. seconds since boot) to calculate the time, # because Time.now may be frozen Process.clock_gettime(Process::CLOCK_MONOTONIC) end
retryable_error?(e)
click to toggle source
# File lib/spreewald_support/tolerance_for_selenium_sync_issues.rb, line 63 def retryable_error?(e) RETRY_ERRORS.include?(e.class.name) end