mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
raise an error if Capybara is stuck in time
This commit is contained in:
parent
b056efbfa5
commit
aaf2f44d2d
3 changed files with 11 additions and 0 deletions
|
@ -4,6 +4,7 @@ require 'xpath'
|
|||
module Capybara
|
||||
class CapybaraError < StandardError; end
|
||||
class DriverNotFoundError < CapybaraError; end
|
||||
class FrozenInTime < CapybaraError; end
|
||||
class ElementNotFound < CapybaraError; end
|
||||
class ExpectationNotMet < ElementNotFound; end
|
||||
class FileNotFound < CapybaraError; end
|
||||
|
|
|
@ -49,6 +49,7 @@ module Capybara
|
|||
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
|
||||
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
|
||||
retry
|
||||
end
|
||||
|
|
|
@ -123,6 +123,15 @@ 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
|
||||
|
|
Loading…
Reference in a new issue