Sha256: 9d700550f22f3c8db6d70ff4507870cda2bf299c650744f6705f218493b5dbde

Contents?: true

Size: 1.18 KB

Versions: 38

Compression:

Stored size: 1.18 KB

Contents

module RSpec
  module Core
    class BacktraceCleaner

      DEFAULT_EXCLUSION_PATTERNS = [
        /\/lib\d*\/ruby\//,
        /org\/jruby\//,
        /bin\//,
        %r|/gems/|,
        /spec\/spec_helper\.rb/,
        /lib\/rspec\/(core|expectations|matchers|mocks)/
      ]

      attr_accessor :inclusion_patterns
      attr_accessor :exclusion_patterns

      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

      def exclude?(line)
        @inclusion_patterns.none? {|p| line =~ p} and matches_an_exclusion_pattern?(line)
      end

      def full_backtrace=(true_or_false)
        @exclusion_patterns = true_or_false ? [] : DEFAULT_EXCLUSION_PATTERNS.dup
      end

      def full_backtrace?
        @exclusion_patterns.empty?
      end

      private

      def matches_an_exclusion_pattern?(line)
        @exclusion_patterns.any? {|p| line =~ p}
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/lib/rspec/core/backtrace_cleaner.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/lib/rspec/core/backtrace_cleaner.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/lib/rspec/core/backtrace_cleaner.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/lib/rspec/core/backtrace_cleaner.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/lib/rspec/core/backtrace_cleaner.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/lib/rspec/core/backtrace_cleaner.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/lib/rspec/core/backtrace_cleaner.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/lib/rspec/core/backtrace_cleaner.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-core-2.14.8/lib/rspec/core/backtrace_cleaner.rb
rspec-core-2.99.2 lib/rspec/core/backtrace_cleaner.rb
dxruby_rp5-0.0.4 spec/vendor/rspec-core-2.14.7/lib/rspec/core/backtrace_cleaner.rb
rspec-core-2.99.1 lib/rspec/core/backtrace_cleaner.rb
rspec-core-2.99.0 lib/rspec/core/backtrace_cleaner.rb
rspec-core-2.99.0.rc1 lib/rspec/core/backtrace_cleaner.rb
rspec-core-2.14.8 lib/rspec/core/backtrace_cleaner.rb
rspec-core-2.99.0.beta2 lib/rspec/core/backtrace_cleaner.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/backtrace_cleaner.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/backtrace_cleaner.rb
dxruby_rp5-0.0.3 spec/vendor/rspec-core-2.14.7/lib/rspec/core/backtrace_cleaner.rb
tuktuk-rails-0.0.10 vendor/bundle/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/backtrace_cleaner.rb