Class: Mocha::BacktraceFilter

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

Constant Summary collapse

LIB_DIRECTORY =
File.expand_path(File.join(File.dirname(__FILE__), "..")) + File::SEPARATOR

Instance Method Summary collapse

Constructor Details

#initialize(lib_directory = LIB_DIRECTORY) ⇒ BacktraceFilter

Returns a new instance of BacktraceFilter


7
8
9
# File 'lib/mocha/backtrace_filter.rb', line 7

def initialize(lib_directory = LIB_DIRECTORY)
  @path_pattern = Regexp.new(lib_directory)
end

Instance Method Details

#filtered(backtrace) ⇒ Object


11
12
13
# File 'lib/mocha/backtrace_filter.rb', line 11

def filtered(backtrace)
  backtrace.reject { |location| @path_pattern.match(File.expand_path(location)) }
end