Sha256: bf013597466fa2ed66ccf90cd4be4b8fdf6fc0126207ba1d15f8a7156f09d361

Contents?: true

Size: 1.55 KB

Versions: 27

Compression:

Stored size: 1.55 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)
        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/*"].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\./,
          /mock_frameworks\/rspec/,
          /spec_server/
        ]
      end
      
      def tweak_backtrace(error)
        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

27 entries across 27 versions & 5 rubygems

Version Path
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
picolena-0.1.1 rails_plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
picolena-0.1.0 rails_plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
picolena-0.1.4 rails_plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
picolena-0.1.3 rails_plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
picolena-0.1.2 rails_plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
picolena-0.1.5 rails_plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
radiant-0.6.5.1 vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
radiant-0.6.5 vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
radiant-0.6.6 vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
radiant-0.6.7 vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
radiant-0.6.8 vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
radiant-0.6.9 vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
rspec-1.1.1 lib/spec/runner/backtrace_tweaker.rb
rspec-1.1.0 lib/spec/runner/backtrace_tweaker.rb
rspec-1.1.3 lib/spec/runner/backtrace_tweaker.rb
rspec-1.1.2 lib/spec/runner/backtrace_tweaker.rb
spree-0.2.0 vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
typo-5.0.1 vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
typo-5.0.2 vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb