diff --git a/lib/capybara/node/base.rb b/lib/capybara/node/base.rb index 3396a6d6..f037206d 100644 --- a/lib/capybara/node/base.rb +++ b/lib/capybara/node/base.rb @@ -40,17 +40,17 @@ module Capybara protected def wait_until(seconds=Capybara.default_wait_time) - start_time = Time.now + retries = (seconds.to_f / 0.05).round begin yield rescue => e raise e unless driver.wait? raise e unless (driver.respond_to?(:invalid_element_errors) and driver.invalid_element_errors.include?(e.class)) or e.is_a?(Capybara::ElementNotFound) - raise e if (Time.now - start_time) >= seconds + raise e if retries.zero? 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 Time.now == start_time reload if Capybara.automatic_reload + retries -= 1 retry end end diff --git a/lib/capybara/spec/session/javascript.rb b/lib/capybara/spec/session/javascript.rb index 1f1b4c3b..e5759a86 100644 --- a/lib/capybara/spec/session/javascript.rb +++ b/lib/capybara/spec/session/javascript.rb @@ -131,15 +131,6 @@ shared_examples_for "session with javascript support" do @session.click_link('Click me') @session.find(:css, "a#has-been-clicked").text.should include('Has been clicked') end - - context "with frozen time" do - it "raises an error suggesting that Capybara is stuck in time" do - @session.visit('/with_js') - now = Time.now - Time.stub(:now).and_return(now) - expect { @session.find('//isnotthere') }.to raise_error(Capybara::FrozenInTime) - end - end end describe '#wait_until' do