Module: Bulldogger::FailureOutput

Defined in:
lib/bulldogger/failure_output.rb

Overview

Formats the file guidance that the recorded evidence state supports. Integrations own framework output; this module only formats two stable lines.

Class Method Summary collapse

Class Method Details

.lines(path, replay_enabled: true) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bulldogger/failure_output.rb', line 12

def lines(path, replay_enabled: true)
  evidence = JSON.parse(File.read(path))
  replay_path = evidence["replay"]

  if evidence["capture_mode"] == "missed"
    ["bulldogger evidence: #{path} (snapshot holds no frames)"]
  elsif replay_path
    ["bulldogger evidence: #{path}", replay_guidance(replay_path, evidence["replay_reproduced"])]
  elsif ApplicationFrames.available?(evidence.dig("test", "file"), evidence.fetch("frames", []))
    ["bulldogger evidence: #{path} (raising method is in these frames)"]
  else
    [missing_origin_line(path, replay_enabled)]
  end
rescue JSON::ParserError, SystemCallError
  ["bulldogger evidence: #{path}"]
end

.missing_origin_line(path, replay_enabled) ⇒ Object



38
39
40
41
42
# File 'lib/bulldogger/failure_output.rb', line 38

def missing_origin_line(path, replay_enabled)
  reason = "frames do not show where the value came from"
  reason += "; set BULLDOGGER_REPLAY=1" unless replay_enabled
  "bulldogger evidence: #{path} (#{reason})"
end

.replay_guidance(path, reproduced) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/bulldogger/failure_output.rb', line 29

def replay_guidance(path, reproduced)
  reason = if reproduced == false
             "test passed alone; this trace shows the passing run"
           else
             "value was produced before the assertion raised"
           end
  "bulldogger replay: #{path} (#{reason})"
end