Class: Test::BacktraceFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/core_assertions.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#filter(bt) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/core_assertions.rb', line 13

def filter bt
  return ["No backtrace"] unless bt

  new_bt = []
  pattern = %r[/(?:lib\/test/|core_assertions\.rb:)]

  unless $DEBUG then
    bt.each do |line|
      break if pattern.match?(line)
      new_bt << line
    end

    new_bt = bt.reject { |line| pattern.match?(line) } if new_bt.empty?
    new_bt = bt.dup if new_bt.empty?
  else
    new_bt = bt.dup
  end

  new_bt
end