Class: WTT::RSpec::Formatter

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/wtt/rspec/formatter.rb

Overview

Rspec formatter that gathers coverage information for each scenario.

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Formatter

Returns a new instance of Formatter.



15
16
17
18
19
20
21
22
# File 'lib/wtt/rspec/formatter.rb', line 15

def initialize(output)
  super
  @tests = []
  @repo = Rugged::Repository.discover(Dir.pwd)
  @storage = WTT::Core::Storage.new @repo
  @mapping = WTT::Core::Mapper.new(@storage)
  @tracer = WTT::Core::Tracer.new
end

Instance Method Details

#close(_example) ⇒ Object



43
44
45
46
# File 'lib/wtt/rspec/formatter.rb', line 43

def close(_example)
  @tracer.stop_trace
  @mapping.write!
end

#example_failed(notification) ⇒ Object



33
34
35
# File 'lib/wtt/rspec/formatter.rb', line 33

def example_failed(notification)
  record_example notification.example
end

#example_passed(notification) ⇒ Object



29
30
31
# File 'lib/wtt/rspec/formatter.rb', line 29

def example_passed(notification)
  record_example notification.example
end

#record_example(example) ⇒ Object



37
38
39
40
41
# File 'lib/wtt/rspec/formatter.rb', line 37

def record_example(example)
  @tracer.stop_trace
  @mapping.append_from_coverage("RSPEC:#{example.id}", @tracer.coverage)
  @tracer.start_trace
end

#start(_notification) ⇒ Object



25
26
27
# File 'lib/wtt/rspec/formatter.rb', line 25

def start(_notification)
  @tracer.start_trace
end