Module: FTest::BacktraceFilter

Extended by:
BacktraceFilter
Included in:
BacktraceFilter
Defined in:
lib/ftest/backtrace_filter.rb

Instance Method Summary collapse

Instance Method Details

#call(trace) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ftest/backtrace_filter.rb', line 5

def call trace
  return trace unless Config.trim_backtraces

  entry_point = trace.last
  ftest_root = File.expand_path "../..", __FILE__

  first_pass = trace.drop_while do |location|
    full_path = File.expand_path location.to_s
    full_path.start_with? ftest_root
  end

  second_pass = first_pass.take_while do |location|
    full_path = File.expand_path location.to_s
    not full_path.start_with? ftest_root
  end

  second_pass << entry_point unless second_pass.last == entry_point
  second_pass
end