Module: SpecTimer::Timer

Defined in:
lib/spec_timer/timer.rb

Class Method Summary collapse

Class Method Details

.finish(example) ⇒ Object



6
7
8
9
# File 'lib/spec_timer/timer.rb', line 6

def self.finish(example)
  @end_time = Time.now
  record(example)
end

.long_testsObject



16
17
18
# File 'lib/spec_timer/timer.rb', line 16

def self.long_tests
  recorded.select { |r| r[:time] > 1 }
end

.record(example) ⇒ Object



11
12
13
14
# File 'lib/spec_timer/timer.rb', line 11

def self.record(example)
  @recorded ||= []
  @recorded << { time: time_taken, file: example.location, name: example.full_description }
end

.recordedObject



20
21
22
# File 'lib/spec_timer/timer.rb', line 20

def self.recorded
  @recorded
end

.resetObject



28
29
30
# File 'lib/spec_timer/timer.rb', line 28

def self.reset
  @recorded = []
end

.startObject



2
3
4
# File 'lib/spec_timer/timer.rb', line 2

def self.start
  @start_time = Time.now
end

.time_takenObject



24
25
26
# File 'lib/spec_timer/timer.rb', line 24

def self.time_taken
  @end_time - @start_time
end