Class: RSpec::Signal::Backtrace::Classifier
- Inherits:
-
Object
- Object
- RSpec::Signal::Backtrace::Classifier
- Defined in:
- lib/rspec/signal/backtrace/classifier.rb
Overview
Decides whether a frame is project code, meaningful library code, or pure test-runner / CLI plumbing.
The framework list is deliberately narrow: it contains only code that runs tests, loads files, or dispatches a CLI. Application libraries (ActiveRecord, Capybara, Rack, Net::HTTP, ...) are never framework, even though most of their frames still get collapsed by the reducer — they can legitimately explain what operation failed.
Constant Summary collapse
- DEFAULT_FRAMEWORK_PATTERNS =
[ # RSpec itself, however it is vendored %r{/lib/rspec/(?:core|support|expectations|mocks|matchers|rails|its|retry)[./]}, %r{/rspec-(?:core|support|expectations|mocks|rails|its|retry)-[^/]+/}, %r{/lib/rspec/signal[./]}, %r{/lib/rspec_junit_formatter[./]}, # Bundler / RubyGems / CLI plumbing %r{/lib/bundler/}, %r{/bundler-[^/]+/}, %r{/lib/rubygems/}, %r{/rubygems/core_ext/kernel_require\.rb}, %r{/bundled_gems\.rb}, %r{/thor-[^/]+/}, %r{/lib/thor/}, %r{/rake-[^/]+/}, %r{/lib/rake/}, # Ruby internals /\A<internal:/, %r{/lib/ruby/[^/]+/bundled_gems\.rb}, # Other test-runner plumbing %r{/minitest[-/]}, %r{/lib/minitest/}, %r{/spring-[^/]+/}, %r{/simplecov[-/]}, %r{/simplecov-html[-/]}, %r{/parallel_tests-[^/]+/}, %r{/knapsack[-_]}, %r{/railties-[^/]+/lib/rails/(?:commands|test_unit|app_loader)}, %r{/lib/rails/(?:commands|test_unit|app_loader)} ].freeze
- DEFAULT_IGNORE_PATTERNS =
Checked before first-party detection. Binstubs live inside the project but are still pure plumbing, and anything a user adds here is taken as authoritative about their own repository.
[ %r{(?:\A|/)(?:bin|exe|\.bundle/bin)/(?:rspec|bundle|rake|spring)(?:\.\w+)?\z}, # Ruby pseudo-frames: the `-e` script, eval, irb, VM internals. /\A-e\z/, /\A\((?:eval|irb)[^)]*\)\z/, /\A<internal:/ ].freeze
Instance Method Summary collapse
-
#call(frame) ⇒ Object
Mutates the frame in place with :kind, :display and :gem_name.
-
#initialize(project:, framework_patterns: DEFAULT_FRAMEWORK_PATTERNS, ignore_patterns: DEFAULT_IGNORE_PATTERNS) ⇒ Classifier
constructor
A new instance of Classifier.
Constructor Details
#initialize(project:, framework_patterns: DEFAULT_FRAMEWORK_PATTERNS, ignore_patterns: DEFAULT_IGNORE_PATTERNS) ⇒ Classifier
Returns a new instance of Classifier.
51 52 53 54 55 56 |
# File 'lib/rspec/signal/backtrace/classifier.rb', line 51 def initialize(project:, framework_patterns: DEFAULT_FRAMEWORK_PATTERNS, ignore_patterns: DEFAULT_IGNORE_PATTERNS) @project = project @framework_patterns = framework_patterns @ignore_patterns = ignore_patterns end |
Instance Method Details
#call(frame) ⇒ Object
Mutates the frame in place with :kind, :display and :gem_name.
59 60 61 62 63 64 65 |
# File 'lib/rspec/signal/backtrace/classifier.rb', line 59 def call(frame) absolute = @project.absolutize(frame.path) frame.display_path = @project.display_path(frame.path) frame.gem_name = @project.gem_name(frame.path) frame.kind = classify(frame, absolute) frame end |