Module: RSpec::Signal::Symptoms

Defined in:
lib/rspec/signal/symptoms.rb,
lib/rspec/signal/symptoms/route.rb,
lib/rspec/signal/symptoms/record.rb,
lib/rspec/signal/symptoms/selector.rb,
lib/rspec/signal/symptoms/ruby_error.rb,
lib/rspec/signal/symptoms/http_status.rb,
lib/rspec/signal/symptoms/exception_class.rb

Overview

The symptom extractors, in the order they are tried.

A failure takes the first symptom that matches and no more, so it belongs to at most one related cluster. The order is significance, not convenience: a 404 in a request spec is a better organising fact than the exception class that carried it, and the exception class is a worse one than everything above it, which is why it is last.

Defined Under Namespace

Modules: ExceptionClass, HttpStatus, Record, Route, RubyError, Selector

Constant Summary collapse

EXTRACTORS =
[HttpStatus, Route, Selector, Record, RubyError, ExceptionClass].freeze

Class Method Summary collapse

Class Method Details

.for(failure) ⇒ Symptom?

Parameters:

Returns:



26
27
28
29
30
31
32
33
34
35
# File 'lib/rspec/signal/symptoms.rb', line 26

def for(failure)
  text = one_line(failure.message.text)
  EXTRACTORS.each do |extractor|
    symptom = extractor.call(failure, text)
    return symptom if symptom
  end
  nil
rescue StandardError
  nil
end

.one_line(text) ⇒ Object

Extractor patterns are written against a single line: RSpec wraps the same sentence differently depending on matcher and terminal width.



39
# File 'lib/rspec/signal/symptoms.rb', line 39

def one_line(text) = text.to_s.gsub(/\s+/, " ").strip