class Capybara::Node::Base
Public Instance Methods
synchronize(seconds = nil, options = {}) { || ... }
click to toggle source
START PUNCHING DUCKS
orig code:
def synchronize(seconds=Capybara.default_max_wait_time, options = {})
new code:
# File lib/dmc_kanye/imma_let_you_finish.rb, line 54 def synchronize(seconds = nil, options = {}) kanye_in_the_house = session.driver.respond_to?(:kanye_invited?) && session.driver.kanye_invited? if seconds seconds_to_wait = seconds elsif kanye_in_the_house seconds_to_wait = DmcKanye::Config.default_wait_time || Capybara.default_max_wait_time else seconds_to_wait = Capybara.default_max_wait_time end ##### STOP PUNCHING DUCKS, BACK TO ORIGINAL CODE start_time = Capybara::Helpers.monotonic_time if session.synchronized yield else session.synchronized = true begin ##### START PUNCHING DUCKS # orig code: # yield # new code: session.driver.send(:imma_let_you_finish) if kanye_in_the_house result = yield session.driver.send(:imma_let_you_finish) if kanye_in_the_house result ##### STOP PUNCHING DUCKS, BACK TO ORIGINAL CODE rescue => e session.raise_server_error! raise e unless driver.wait? raise e unless catch_error?(e, options[:errors]) ##### START PUNCHING DUCKS # orig code: # raise e if (Capybara::Helpers.monotonic_time - start_time) >= seconds # new code: raise e if (Capybara::Helpers.monotonic_time - start_time) >= seconds_to_wait ##### STOP PUNCHING DUCKS, BACK TO ORIGINAL CODE sleep(0.05) raise Capybara::FrozenInTime, "time appears to be frozen, Capybara does not work with libraries which freeze time, consider using time travelling instead" if Capybara::Helpers.monotonic_time == start_time reload if Capybara.automatic_reload retry ensure session.synchronized = false end end end