Class: RSpec::Core::BacktraceCleaner
- Inherits:
-
Object
- Object
- RSpec::Core::BacktraceCleaner
- Defined in:
- lib/rspec/core/backtrace_cleaner.rb
Constant Summary collapse
- DEFAULT_EXCLUSION_PATTERNS =
[ /\/lib\d*\/ruby\//, /org\/jruby\//, /bin\//, %r|/gems/|, /spec\/spec_helper\.rb/, /lib\/rspec\/(core|expectations|matchers|mocks)/ ]
Instance Attribute Summary collapse
-
#exclusion_patterns ⇒ Object
Returns the value of attribute exclusion_patterns.
-
#inclusion_patterns ⇒ Object
Returns the value of attribute inclusion_patterns.
Instance Method Summary collapse
- #exclude?(line) ⇒ Boolean
- #full_backtrace=(true_or_false) ⇒ Object
- #full_backtrace? ⇒ Boolean
-
#initialize(inclusion_patterns = nil, exclusion_patterns = DEFAULT_EXCLUSION_PATTERNS.dup) ⇒ BacktraceCleaner
constructor
A new instance of BacktraceCleaner.
Constructor Details
#initialize(inclusion_patterns = nil, exclusion_patterns = DEFAULT_EXCLUSION_PATTERNS.dup) ⇒ BacktraceCleaner
Returns a new instance of BacktraceCleaner.
17 18 19 20 21 22 23 24 25 |
# File 'lib/rspec/core/backtrace_cleaner.rb', line 17 def initialize(inclusion_patterns=nil, exclusion_patterns=DEFAULT_EXCLUSION_PATTERNS.dup) @exclusion_patterns = exclusion_patterns if inclusion_patterns.nil? @inclusion_patterns = (matches_an_exclusion_pattern? Dir.getwd) ? [Regexp.new(Dir.getwd)] : [] else @inclusion_patterns = inclusion_patterns end end |
Instance Attribute Details
#exclusion_patterns ⇒ Object
Returns the value of attribute exclusion_patterns.
15 16 17 |
# File 'lib/rspec/core/backtrace_cleaner.rb', line 15 def exclusion_patterns @exclusion_patterns end |
#inclusion_patterns ⇒ Object
Returns the value of attribute inclusion_patterns.
14 15 16 |
# File 'lib/rspec/core/backtrace_cleaner.rb', line 14 def inclusion_patterns @inclusion_patterns end |
Instance Method Details
#exclude?(line) ⇒ Boolean
27 28 29 |
# File 'lib/rspec/core/backtrace_cleaner.rb', line 27 def exclude?(line) @inclusion_patterns.none? {|p| line =~ p} and matches_an_exclusion_pattern?(line) end |
#full_backtrace=(true_or_false) ⇒ Object
31 32 33 |
# File 'lib/rspec/core/backtrace_cleaner.rb', line 31 def full_backtrace=(true_or_false) @exclusion_patterns = true_or_false ? [] : DEFAULT_EXCLUSION_PATTERNS.dup end |
#full_backtrace? ⇒ Boolean
35 36 37 |
# File 'lib/rspec/core/backtrace_cleaner.rb', line 35 def full_backtrace? @exclusion_patterns.empty? end |