Class: RSpec::Signal::Reporters::RelatedFailures

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/signal/reporters/related_failures.rb

Overview

The "Related failures" section of the Markdown report.

The second, looser grouping layer. A signature says "these failures are the same failure"; a cluster says only "these share one strong diagnostic symptom, so look at them together". The section says so in those words, because the difference is the whole point: a reader who takes a cluster for a root cause has been misled.

Kept to a few lines per cluster. This layer exists to save the reader from reading thirty-five signature sections, and it would be a poor trade if it cost thirty-five sections' worth of prose to do it.

Constant Summary collapse

MAX_SYMPTOMS =
4
MAX_SIGNATURES =
8
PREAMBLE =
"Failures sharing one diagnostic symptom across more than one signature. " \
"Weaker than a signature: a likely common cause, not a proven identical failure. " \
"The signatures below remain authoritative."

Instance Method Summary collapse

Constructor Details

#initialize(clusters, signature_positions, config) ⇒ RelatedFailures

Returns a new instance of RelatedFailures.

Parameters:

  • clusters (Array<Cluster>)
  • signature_positions (Hash{String => Integer})

    digest => index in the report



27
28
29
30
31
# File 'lib/rspec/signal/reporters/related_failures.rb', line 27

def initialize(clusters, signature_positions, config)
  @clusters = clusters
  @signature_positions = signature_positions
  @config = config
end

Instance Method Details

#renderString?

Returns nil when nothing relates, so the section vanishes.

Returns:

  • (String, nil)

    nil when nothing relates, so the section vanishes



34
35
36
37
38
39
40
# File 'lib/rspec/signal/reporters/related_failures.rb', line 34

def render
  return nil if shown.empty?

  blocks = shown.each_with_index.map { |cluster, position| block(cluster, position + 1) }
  blocks << truncation_note if hidden.positive?
  [["## Related failures", "", PREAMBLE].join("\n"), *blocks].join("\n\n")
end