Module: RSpec::Core::BacktraceFormatter

Extended by:
BacktraceFormatter
Included in:
BacktraceFormatter, Formatters::Helpers
Defined in:
lib/rspec/core/formatters/helpers.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) format_backtrace(backtrace, options = {})



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rspec/core/formatters/helpers.rb', line 6

def format_backtrace(backtrace, options = {})
  return "" unless backtrace
  return backtrace if options[:full_backtrace] == true

  if at_exit_index = backtrace.index(RSpec::Core::Runner::AT_EXIT_HOOK_BACKTRACE_LINE)
    backtrace = backtrace[0, at_exit_index]
  end

  cleansed = backtrace.map { |line| backtrace_line(line) }.compact
  cleansed.empty? ? backtrace : cleansed
end