Module: Bulldogger::RSpec
- Defined in:
- lib/bulldogger/integrations/rspec.rb
Overview
Connects RSpec failures to evidence and replay paths. It does not control test execution, formatter behavior, or test results.
Class Attribute Summary collapse
-
.instance ⇒ Object
Dogfood can assign an isolated observer.
Class Method Summary collapse
-
.annotate!(exception, path) ⇒ Object
Mirrors the minitest integration's annotate!: tag the exception's own #message first, so the evidence line sits inside the same text RSpec's own formatter already prints for this failure.
-
.test_for(example) ⇒ Object
RSpec has already scored the example's description and its file/line into metadata by the time after(:each) runs; test_for reads those off the Example instead of re-deriving them.
Class Attribute Details
.instance ⇒ Object
Dogfood can assign an isolated observer. The default preserves the normal integration API for applications that need one lifecycle.
16 17 18 |
# File 'lib/bulldogger/integrations/rspec.rb', line 16 def instance @instance || Bulldogger.default end |
Class Method Details
.annotate!(exception, path) ⇒ Object
Mirrors the minitest integration's annotate!: tag the exception's own #message first, so the evidence line sits inside the same text RSpec's own formatter already prints for this failure. A frozen exception can't take a singleton method; fall back to printing the line directly so a frozen exception never means a silently missing evidence line.
39 40 41 42 43 44 45 46 |
# File 'lib/bulldogger/integrations/rspec.rb', line 39 def self.annotate!(exception, path) original = exception. lines = FailureOutput.lines(path, replay_enabled: instance.config.replay_on_failure) suffix = "\n#{lines.join("\n")}" exception.define_singleton_method(:message) { "#{original}#{suffix}" } rescue FrozenError $stdout.puts lines end |
.test_for(example) ⇒ Object
RSpec has already scored the example's description and its file/line into metadata by the time after(:each) runs; test_for reads those off the Example instead of re-deriving them.
24 25 26 27 28 29 30 31 |
# File 'lib/bulldogger/integrations/rspec.rb', line 24 def self.test_for(example) { framework: "rspec", id: example.full_description, file: example.[:file_path], line: example.[:line_number] } end |