Module: RSpec::Signal
- Defined in:
- lib/rspec/signal.rb,
lib/rspec/signal/group.rb,
lib/rspec/signal/report.rb,
lib/rspec/signal/writer.rb,
lib/rspec/signal/cluster.rb,
lib/rspec/signal/failure.rb,
lib/rspec/signal/grouper.rb,
lib/rspec/signal/message.rb,
lib/rspec/signal/project.rb,
lib/rspec/signal/symptom.rb,
lib/rspec/signal/version.rb,
lib/rspec/signal/redactor.rb,
lib/rspec/signal/symptoms.rb,
lib/rspec/signal/clusterer.rb,
lib/rspec/signal/formatter.rb,
lib/rspec/signal/fingerprint.rb,
lib/rspec/signal/html_summary.rb,
lib/rspec/signal/parallel_run.rb,
lib/rspec/signal/configuration.rb,
lib/rspec/signal/symptoms/route.rb,
lib/rspec/signal/backtrace/frame.rb,
lib/rspec/signal/failure_builder.rb,
lib/rspec/signal/parallel_merger.rb,
lib/rspec/signal/symptoms/record.rb,
lib/rspec/signal/backtrace/parser.rb,
lib/rspec/signal/backtrace/reducer.rb,
lib/rspec/signal/symptoms/selector.rb,
lib/rspec/signal/reporters/markdown.rb,
lib/rspec/signal/symptoms/ruby_error.rb,
lib/rspec/signal/backtrace/classifier.rb,
lib/rspec/signal/symptoms/http_status.rb,
lib/rspec/signal/integrations/capybara.rb,
lib/rspec/signal/reporters/full_output.rb,
lib/rspec/signal/reporters/json_report.rb,
lib/rspec/signal/symptoms/exception_class.rb,
lib/rspec/signal/reporters/related_failures.rb
Overview
Turns noisy RSpec failures into compact, high-signal diagnostic artifacts designed to be handed to an AI coding agent.
Defined Under Namespace
Modules: Backtrace, Clusterer, Grouper, Integrations, ParallelRun, Reporters, Symptoms Classes: Cluster, Configuration, Failure, FailureBuilder, Fingerprint, Formatter, Group, HtmlSummary, Message, ParallelMerger, Project, Redactor, Report, Symptom, Writer
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
-
.auto_installed? ⇒ Boolean
True when we added the formatter ourselves rather than the user asking for it with
--format. - .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
-
.environment ⇒ Object
Versions worth recording in the report header.
-
.install!(rspec_config = ::RSpec.configuration) ⇒ Boolean
Registers the formatter and optional integrations.
- .installed? ⇒ Boolean
-
.quiet_mode? ⇒ Boolean
Explicit formatter selection happens after --require files are loaded, so install! may initially look automatic.
- .reset! ⇒ Object
-
.restore_default_formatter!(rspec_config = ::RSpec.configuration) ⇒ Object
Adding any formatter suppresses RSpec's default one.
Class Method Details
.auto_installed? ⇒ Boolean
True when we added the formatter ourselves rather than the user asking
for it with --format. Only then do we put RSpec's default formatter
back, because only then did we displace it.
83 84 85 |
# File 'lib/rspec/signal.rb', line 83 def auto_installed? !!@auto_installed end |
.configuration ⇒ Object
40 41 42 |
# File 'lib/rspec/signal.rb', line 40 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
44 45 46 47 48 |
# File 'lib/rspec/signal.rb', line 44 def configure yield configuration if block_given? configuration.reset_memoized! configuration end |
.environment ⇒ Object
Versions worth recording in the report header.
115 116 117 118 119 120 121 122 |
# File 'lib/rspec/signal.rb', line 115 def environment versions = { "ruby" => RUBY_VERSION, "rspec" => ::RSpec::Core::Version::STRING } versions["rails"] = ::Rails::VERSION::STRING if defined?(::Rails::VERSION::STRING) versions["capybara"] = ::Capybara::VERSION if defined?(::Capybara::VERSION) versions rescue StandardError { "ruby" => RUBY_VERSION } end |
.install!(rspec_config = ::RSpec.configuration) ⇒ Boolean
Registers the formatter and optional integrations.
Called automatically when you require "rspec/signal" inside an
RSpec.configure block or from spec_helper.rb. Safe to call twice.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rspec/signal.rb', line 56 def install!(rspec_config = ::RSpec.configuration) return false if @installed @installed = true return false unless configuration.enabled? quiet_mode? # Capture CLI intent before RSpec finishes parsing ARGV. loader = rspec_config.formatter_loader unless loader.formatters.any?(Formatter) rspec_config.add_formatter(Formatter) @auto_installed = true end install_integrations!(rspec_config) true rescue StandardError => e warn "rspec-signal: could not install (#{e.class}: #{e.})" false end |
.installed? ⇒ Boolean
76 77 78 |
# File 'lib/rspec/signal.rb', line 76 def installed? !!@installed end |
.quiet_mode? ⇒ Boolean
Explicit formatter selection happens after --require files are loaded, so install! may initially look automatic. Detect the user's intent from the original CLI arguments (or the wrapper's explicit marker) at start time, after RSpec has finished configuring its formatter loader.
91 92 93 94 95 96 |
# File 'lib/rspec/signal.rb', line 91 def quiet_mode? return true if ENV["RSPEC_SIGNAL_QUIET"] == "1" return @quiet_mode_requested if defined?(@quiet_mode_requested) @quiet_mode_requested = !(formatter_arguments & ["RSpec::Signal::Formatter", "signal"]).empty? end |
.reset! ⇒ Object
125 126 127 128 129 130 |
# File 'lib/rspec/signal.rb', line 125 def reset! @installed = false @auto_installed = false remove_instance_variable(:@quiet_mode_requested) if defined?(@quiet_mode_requested) @configuration = nil end |
.restore_default_formatter!(rspec_config = ::RSpec.configuration) ⇒ Object
Adding any formatter suppresses RSpec's default one. When rspec-signal installed itself the user did not ask for that, so restore normal terminal feedback.
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/rspec/signal.rb', line 101 def restore_default_formatter!(rspec_config = ::RSpec.configuration) loader = rspec_config.formatter_loader return if loader.formatters.any? { |formatter| primary_output_formatter?(formatter) } before = loader.formatters.dup loader.add(loader.default_formatter, rspec_config.output_stream) (loader.formatters - before).each do |formatter| formatter.start(::RSpec::Core::Notifications::StartNotification.new(0, 0)) if formatter.respond_to?(:start) end rescue StandardError nil end |