Class: Peck::Notifiers::Documentation

Inherits:
Default show all
Defined in:
lib/peck/notifiers/documentation.rb

Constant Summary

Constants included from Base::BacktraceCleaning

Base::BacktraceCleaning::ANONYMOUS_BLOCK_RE, Base::BacktraceCleaning::PECK_PATH

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Default

#backtrace, #finished, #install_at_exit, #runtime_in_seconds, #started, #write, #write_event, #write_events, #write_exception, #write_stats

Methods inherited from Base

use

Methods included from Base::BacktraceCleaning

#clean_backtrace

Constructor Details

#initializeDocumentation

Returns a new instance of Documentation.



27
28
29
30
31
# File 'lib/peck/notifiers/documentation.rb', line 27

def initialize
  self.details = {}
  self.running = []
  self.semaphore = Mutex.new
end

Class Attribute Details

.runtime_report_cutoffObject

The cutoff point beyond which a test is reported as being slow. Expressed in milliseconds. Default is 500ms.



12
13
14
# File 'lib/peck/notifiers/documentation.rb', line 12

def runtime_report_cutoff
  @runtime_report_cutoff
end

Instance Attribute Details

#detailsObject

Keeps all the labels, start, and end times for the specs



17
18
19
# File 'lib/peck/notifiers/documentation.rb', line 17

def details
  @details
end

#runningObject

A FIFO queue of all the started specs being first on the queue means the spec has been reported as started. Being on the queue means the spec still needs to be reported as being finished.



22
23
24
# File 'lib/peck/notifiers/documentation.rb', line 22

def running
  @running
end

#semaphoreObject

Mutex to synchronize the access of the global data structures



25
26
27
# File 'lib/peck/notifiers/documentation.rb', line 25

def semaphore
  @semaphore
end

Instance Method Details

#finished_specification(spec) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/peck/notifiers/documentation.rb', line 44

def finished_specification(spec)
  self.semaphore.synchronize do
    spec_id = spec.object_id
    self.details[spec_id][:finished_at] = Time.now
    self.details[spec_id][:passed] = spec.passed?
    write_documentation
  end
end

#started_specification(spec) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/peck/notifiers/documentation.rb', line 33

def started_specification(spec)
  self.semaphore.synchronize do
    spec_id = spec.object_id
    self.running.push(spec_id)
    self.details[spec_id] ||= {}
    self.details[spec_id][:started_at] = Time.now
    self.details[spec_id][:label] = spec.label
    write_documentation
  end
end