Class: Capybara::Helpers::Timer Private

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/helpers.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(expire_in) ⇒ Timer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Timer.


99
100
101
102
# File 'lib/capybara/helpers.rb', line 99

def initialize(expire_in)
  @start = current
  @expire_in = expire_in
end

Instance Method Details

#expired?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

104
105
106
107
108
109
110
# File 'lib/capybara/helpers.rb', line 104

def expired?
  if stalled?
    raise Capybara::FrozenInTime, 'Time appears to be frozen. Capybara does not work with libraries which freeze time, consider using time travelling instead'
  end

  current - @start >= @expire_in
end

#stalled?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

112
113
114
# File 'lib/capybara/helpers.rb', line 112

def stalled?
  @start == current
end