diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-10-20 09:32:26 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-10-20 09:32:26 -0500 |
commit | fa1926ddaa7ad481c55b76d1f2c1952721b7b586 (patch) | |
tree | dc1de35e1218013b8815d40440b094c58500c144 /railties | |
parent | 80a3983b7b987ef11c8875c5c23707b4903cdf72 (diff) | |
download | rails-fa1926ddaa7ad481c55b76d1f2c1952721b7b586.tar.gz rails-fa1926ddaa7ad481c55b76d1f2c1952721b7b586.tar.bz2 rails-fa1926ddaa7ad481c55b76d1f2c1952721b7b586.zip |
Exclude gem backtrace filter if rubygems is not loaded
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/backtrace_cleaner.rb | 4 | ||||
-rw-r--r-- | railties/test/backtrace_cleaner_test.rb | 33 |
2 files changed, 19 insertions, 18 deletions
diff --git a/railties/lib/rails/backtrace_cleaner.rb b/railties/lib/rails/backtrace_cleaner.rb index 2f5632c3e4..cd7dd0f80a 100644 --- a/railties/lib/rails/backtrace_cleaner.rb +++ b/railties/lib/rails/backtrace_cleaner.rb @@ -27,10 +27,10 @@ module Rails add_silencer { |line| RAILS_GEMS.any? { |gem| line =~ /^#{gem} / } } add_silencer { |line| line =~ %r(vendor/plugins/[^\/]+/lib) } end - - + private def add_gem_filters + return unless defined? Gem (Gem.path + [Gem.default_dir]).uniq.each do |path| # http://gist.github.com/30430 add_filter { |line| line.sub(/(#{path})\/gems\/([a-z]+)-([0-9.]+)\/(.*)/, '\2 (\3) \4')} diff --git a/railties/test/backtrace_cleaner_test.rb b/railties/test/backtrace_cleaner_test.rb index 64a47712b7..4e273852e0 100644 --- a/railties/test/backtrace_cleaner_test.rb +++ b/railties/test/backtrace_cleaner_test.rb @@ -29,25 +29,26 @@ else $stderr.puts 'No BacktraceFilter for minitest' end -class BacktraceCleanerVendorGemTest < ActiveSupport::TestCase - def setup - @cleaner = Rails::BacktraceCleaner.new - end - - test "should format installed gems correctly" do - @backtrace = [ "#{Gem.path[0]}/gems/nosuchgem-1.2.3/lib/foo.rb" ] - @result = @cleaner.clean(@backtrace) - assert_equal "nosuchgem (1.2.3) lib/foo.rb", @result[0] - end +if defined? Gem + class BacktraceCleanerVendorGemTest < ActiveSupport::TestCase + def setup + @cleaner = Rails::BacktraceCleaner.new + end - test "should format installed gems not in Gem.default_dir correctly" do - @target_dir = Gem.path.detect { |p| p != Gem.default_dir } - # skip this test if default_dir is the only directory on Gem.path - if @target_dir - @backtrace = [ "#{@target_dir}/gems/nosuchgem-1.2.3/lib/foo.rb" ] + test "should format installed gems correctly" do + @backtrace = [ "#{Gem.path[0]}/gems/nosuchgem-1.2.3/lib/foo.rb" ] @result = @cleaner.clean(@backtrace) assert_equal "nosuchgem (1.2.3) lib/foo.rb", @result[0] end - end + test "should format installed gems not in Gem.default_dir correctly" do + @target_dir = Gem.path.detect { |p| p != Gem.default_dir } + # skip this test if default_dir is the only directory on Gem.path + if @target_dir + @backtrace = [ "#{@target_dir}/gems/nosuchgem-1.2.3/lib/foo.rb" ] + @result = @cleaner.clean(@backtrace) + assert_equal "nosuchgem (1.2.3) lib/foo.rb", @result[0] + end + end + end end |