Class: TestBench::Telemetry::Sink::Capture::Record::Generate

Inherits:
Object
  • Object
show all
Includes:
Event::Events
Defined in:
lib/test_bench/telemetry/sink/capture/record/generate.rb

Constant Summary

Constants included from Event::Events

Event::Events::Asserted, Event::Events::Commented, Event::Events::ContextEntered, Event::Events::ContextExited, Event::Events::ContextSkipped, Event::Events::DetailDecreased, Event::Events::DetailIncreased, Event::Events::ErrorRaised, Event::Events::FileEntered, Event::Events::FileExited, Event::Events::FixtureFinished, Event::Events::FixtureStarted, Event::Events::RunAborted, Event::Events::RunFinished, Event::Events::RunStarted, Event::Events::TestFinished, Event::Events::TestSkipped, Event::Events::TestStarted

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#detail_levelObject



14
15
16
# File 'lib/test_bench/telemetry/sink/capture/record/generate.rb', line 14

def detail_level
  @detail_level ||= 0
end

#pathObject



9
10
11
# File 'lib/test_bench/telemetry/sink/capture/record/generate.rb', line 9

def path
  @path ||= Path.new
end

Instance Method Details

#call(event) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/test_bench/telemetry/sink/capture/record/generate.rb', line 19

def call(event)
  case event
  when TestStarted, ContextEntered
    path.push(event.title)
  when TestFinished, ContextExited
    path.pop(event.title)
  when DetailIncreased
    self.detail_level += 1
  when DetailDecreased
    self.detail_level -= 1
  end

  record = Record.build(event, path, detail_level)

  case event
  when TestFinished, ContextExited
    title = event.title
    record.path.push(title)
  when Commented
    comment = event.comment
    record.path.push(comment)
  end

  record
end