Class: RSpec::Signal::Configuration

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

Overview

Everything tunable, with defaults chosen to need no tuning.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



38
39
40
41
42
43
44
45
46
# File 'lib/rspec/signal/configuration.rb', line 38

def initialize
  default_budgets
  default_artifacts
  default_classification

  @output_dir       = ENV.fetch("RSPEC_SIGNAL_OUTPUT_DIR", "tmp/rspec-signal")
  @enabled          = !truthy?(ENV.fetch("RSPEC_SIGNAL_DISABLE", nil))
  @terminal_summary = true
end

Instance Attribute Details

#capture_capybaraObject

Behaviour.



33
34
35
# File 'lib/rspec/signal/configuration.rb', line 33

def capture_capybara
  @capture_capybara
end

#capture_page_htmlObject

Behaviour.



33
34
35
# File 'lib/rspec/signal/configuration.rb', line 33

def capture_page_html
  @capture_page_html
end

#enabledObject

Behaviour.



33
34
35
# File 'lib/rspec/signal/configuration.rb', line 33

def enabled
  @enabled
end

#extra_first_partyObject

Classification.



36
37
38
# File 'lib/rspec/signal/configuration.rb', line 36

def extra_first_party
  @extra_first_party
end

#fallback_framesObject

Backtrace reduction budgets.



11
12
13
# File 'lib/rspec/signal/configuration.rb', line 11

def fallback_frames
  @fallback_frames
end

#framework_patternsObject

Classification.



36
37
38
# File 'lib/rspec/signal/configuration.rb', line 36

def framework_patterns
  @framework_patterns
end

#ignore_patternsObject

Classification.



36
37
38
# File 'lib/rspec/signal/configuration.rb', line 36

def ignore_patterns
  @ignore_patterns
end

#max_affected_examplesObject

Report budgets. max_affected_examples caps the per-group list of other failing examples; max_groups caps how many signatures are rendered in full (nil means all).



20
21
22
# File 'lib/rspec/signal/configuration.rb', line 20

def max_affected_examples
  @max_affected_examples
end

#max_cluster_specsObject

Related-failure clustering. relate_failures turns the whole layer off; the budgets cap how much of it reaches the Markdown report.



24
25
26
# File 'lib/rspec/signal/configuration.rb', line 24

def max_cluster_specs
  @max_cluster_specs
end

#max_clustersObject

Related-failure clustering. relate_failures turns the whole layer off; the budgets cap how much of it reaches the Markdown report.



24
25
26
# File 'lib/rspec/signal/configuration.rb', line 24

def max_clusters
  @max_clusters
end

#max_diff_linesObject

Message budgets. max_html_chars is the smallest HTML blob replaced by a summary; reduce_html turns that off entirely.



15
16
17
# File 'lib/rspec/signal/configuration.rb', line 15

def max_diff_lines
  @max_diff_lines
end

#max_external_contextObject

Backtrace reduction budgets.



11
12
13
# File 'lib/rspec/signal/configuration.rb', line 11

def max_external_context
  @max_external_context
end

#max_framesObject

Backtrace reduction budgets.



11
12
13
# File 'lib/rspec/signal/configuration.rb', line 11

def max_frames
  @max_frames
end

#max_groupsObject

Report budgets. max_affected_examples caps the per-group list of other failing examples; max_groups caps how many signatures are rendered in full (nil means all).



20
21
22
# File 'lib/rspec/signal/configuration.rb', line 20

def max_groups
  @max_groups
end

#max_html_charsObject

Message budgets. max_html_chars is the smallest HTML blob replaced by a summary; reduce_html turns that off entirely.



15
16
17
# File 'lib/rspec/signal/configuration.rb', line 15

def max_html_chars
  @max_html_chars
end

#max_message_linesObject

Message budgets. max_html_chars is the smallest HTML blob replaced by a summary; reduce_html turns that off entirely.



15
16
17
# File 'lib/rspec/signal/configuration.rb', line 15

def max_message_lines
  @max_message_lines
end

#max_project_framesObject

Backtrace reduction budgets.



11
12
13
# File 'lib/rspec/signal/configuration.rb', line 11

def max_project_frames
  @max_project_frames
end

#output_dirObject

Where artifacts are written, relative to the project root unless absolute.



8
9
10
# File 'lib/rspec/signal/configuration.rb', line 8

def output_dir
  @output_dir
end

#project_rootObject

Classification.



36
37
38
# File 'lib/rspec/signal/configuration.rb', line 36

def project_root
  @project_root
end

#redactObject

Secret scrubbing.



27
28
29
# File 'lib/rspec/signal/configuration.rb', line 27

def redact
  @redact
end

#redaction_filterObject

Secret scrubbing.



27
28
29
# File 'lib/rspec/signal/configuration.rb', line 27

def redaction_filter
  @redaction_filter
end

#redaction_patternsObject

Secret scrubbing.



27
28
29
# File 'lib/rspec/signal/configuration.rb', line 27

def redaction_patterns
  @redaction_patterns
end

#reduce_htmlObject

Message budgets. max_html_chars is the smallest HTML blob replaced by a summary; reduce_html turns that off entirely.



15
16
17
# File 'lib/rspec/signal/configuration.rb', line 15

def reduce_html
  @reduce_html
end

#relate_failuresObject

Related-failure clustering. relate_failures turns the whole layer off; the budgets cap how much of it reaches the Markdown report.



24
25
26
# File 'lib/rspec/signal/configuration.rb', line 24

def relate_failures
  @relate_failures
end

#terminal_summaryObject

Behaviour.



33
34
35
# File 'lib/rspec/signal/configuration.rb', line 33

def terminal_summary
  @terminal_summary
end

#write_fullObject

Artifacts.



30
31
32
# File 'lib/rspec/signal/configuration.rb', line 30

def write_full
  @write_full
end

#write_gitignoreObject

Artifacts.



30
31
32
# File 'lib/rspec/signal/configuration.rb', line 30

def write_gitignore
  @write_gitignore
end

#write_jsonObject

Artifacts.



30
31
32
# File 'lib/rspec/signal/configuration.rb', line 30

def write_json
  @write_json
end

Instance Method Details

#classifierObject



81
82
83
84
85
86
87
# File 'lib/rspec/signal/configuration.rb', line 81

def classifier
  @classifier ||= Backtrace::Classifier.new(
    project: project,
    framework_patterns: framework_patterns,
    ignore_patterns: ignore_patterns
  )
end

#enabled?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/rspec/signal/configuration.rb', line 48

def enabled?
  !!@enabled
end

#html_thresholdObject

Nil means "leave HTML alone", which is what Message expects.



57
58
59
# File 'lib/rspec/signal/configuration.rb', line 57

def html_threshold
  reduce_html ? max_html_chars : nil
end

#output_pathObject



65
66
67
# File 'lib/rspec/signal/configuration.rb', line 65

def output_path
  @output_path ||= File.expand_path(@output_dir, root)
end

#projectObject



69
70
71
# File 'lib/rspec/signal/configuration.rb', line 69

def project
  @project ||= Project.new(root: root, extra_first_party: extra_first_party)
end

#redact?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/rspec/signal/configuration.rb', line 52

def redact?
  !!@redact
end

#redactorObject



73
74
75
76
77
78
79
# File 'lib/rspec/signal/configuration.rb', line 73

def redactor
  @redactor ||= Redactor.new(
    enabled: redact?,
    extra_patterns: redaction_patterns,
    filter: redaction_filter
  )
end

#reducerObject



89
90
91
92
93
94
95
96
# File 'lib/rspec/signal/configuration.rb', line 89

def reducer
  @reducer ||= Backtrace::Reducer.new(
    max_frames: max_frames,
    max_external_context: max_external_context,
    max_project_frames: max_project_frames,
    fallback_frames: fallback_frames
  )
end

#reset_memoized!Object

Memoized collaborators must be rebuilt if the user reconfigures.



99
100
101
102
# File 'lib/rspec/signal/configuration.rb', line 99

def reset_memoized!
  @root = @output_path = @project = @redactor = @classifier = @reducer = nil
  self
end

#rootObject



61
62
63
# File 'lib/rspec/signal/configuration.rb', line 61

def root
  @root ||= File.expand_path(@project_root || default_root)
end