Class: Cucumber::Formatter::BacktraceFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/formatter/backtrace_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ BacktraceFilter

Returns a new instance of BacktraceFilter.



8
9
10
11
# File 'lib/cucumber/formatter/backtrace_filter.rb', line 8

def initialize(exception)
  @exception = exception
  @backtrace_filters = standard_ruby_paths + dynamic_ruby_paths
end

Instance Method Details

#exceptionObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cucumber/formatter/backtrace_filter.rb', line 13

def exception
  return @exception if ::Cucumber.use_full_backtrace

  backtrace = @exception.backtrace.map { |line| line.gsub(pwd_pattern, './') }
  filtered = backtrace.reject { |line| line.match?(backtrace_filter_patterns) }

  if ::ENV['CUCUMBER_TRUNCATE_OUTPUT']
    filtered = filtered.map do |line|
      # Strip off file locations
      match = regexp_filter.match(line)
      match ? match[1] : line
    end
  end

  @exception.tap { |error_object| error_object.set_backtrace(filtered) }
end