Sha256: 844548b02db3b23f7830149b90835393895aa37ecedca6fe9d3240cde9f4426c

Contents?: true

Size: 1.52 KB

Versions: 10

Compression:

Stored size: 1.52 KB

Contents

module Spec
  module Runner
    class BacktraceTweaker
      def clean_up_double_slashes(line)
        line.gsub!('//','/')
      end
    end

    class NoisyBacktraceTweaker < BacktraceTweaker
      def tweak_backtrace(error, spec_name)
        return if error.backtrace.nil?
        error.backtrace.each do |line|
          clean_up_double_slashes(line)
        end
      end
    end

    # Tweaks raised Exceptions to mask noisy (unneeded) parts of the backtrace
    class QuietBacktraceTweaker < BacktraceTweaker
      unless defined?(IGNORE_PATTERNS)
        root_dir = File.expand_path(File.join(__FILE__, '..', '..', '..', '..'))
        spec_files = Dir["#{root_dir}/lib/spec/*"].map do |path| 
          subpath = path[root_dir.length..-1]
          /#{subpath}/
        end
        IGNORE_PATTERNS = spec_files + [
          /\/lib\/ruby\//,
          /bin\/spec:/,
          /bin\/rcov:/,
          /lib\/rspec_on_rails/,
          /vendor\/rails/,
          # TextMate's Ruby and RSpec plugins
          /Ruby\.tmbundle\/Support\/tmruby.rb:/,
          /RSpec\.tmbundle\/Support\/lib/,
          /temp_textmate\./
        ]
      end
      
      def tweak_backtrace(error, spec_name)
        return if error.backtrace.nil?
        error.backtrace.collect! do |line|
          clean_up_double_slashes(line)
          IGNORE_PATTERNS.each do |ignore|
            if line =~ ignore
              line = nil
              break
            end
          end
          line
        end
        error.backtrace.compact!
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
puppet-0.23.0 test/lib/spec/runner/backtrace_tweaker.rb
puppet-0.22.4 test/lib/spec/runner/backtrace_tweaker.rb
puppet-0.23.1 test/lib/spec/runner/backtrace_tweaker.rb
puppet-0.23.2 test/lib/spec/runner/backtrace_tweaker.rb
riess-0.0.8 vendor/rspec-0.8.2/lib/spec/runner/backtrace_tweaker.rb
rspec-0.7.5.1 lib/spec/runner/backtrace_tweaker.rb
rspec-0.7.5 lib/spec/runner/backtrace_tweaker.rb
rspec-0.8.0 lib/spec/runner/backtrace_tweaker.rb
rspec-0.8.1 lib/spec/runner/backtrace_tweaker.rb
rspec-0.8.2 lib/spec/runner/backtrace_tweaker.rb