Class: HyperSpec::Lolex

Inherits:
Object
  • Object
show all
Defined in:
lib/hyper-spec/lolex.rb

Class Method Summary collapse

Class Method Details

.init(page, client_time_zone, resolution) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/hyper-spec/lolex.rb', line 4

def init(page, client_time_zone, resolution)
  @capybara_page = page
  @resolution = resolution || 10
  @client_time_zone = client_time_zone
  run_pending_evaluations
  @initialized = true
end

.initialized?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/hyper-spec/lolex.rb', line 12

def initialized?
  @initialized
end

.popObject



29
30
31
# File 'lib/hyper-spec/lolex.rb', line 29

def pop
  evaluate_ruby { 'Lolex.pop' }
end

.push(mock_type, *args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hyper-spec/lolex.rb', line 16

def push(mock_type, *args)
  scale = if mock_type == :freeze
            0
          elsif mock_type == :scale
            args[0]
          else
            1
          end
  evaluate_ruby do
    "Lolex.push('#{time_string_in_zone}', #{scale}, #{@resolution})"
  end
end

.restoreObject



37
38
39
# File 'lib/hyper-spec/lolex.rb', line 37

def restore
  evaluate_ruby { 'Lolex.restore' }
end

.unmockObject



33
34
35
# File 'lib/hyper-spec/lolex.rb', line 33

def unmock
  evaluate_ruby { "Lolex.unmock('#{time_string_in_zone}', #{@resolution})" }
end