Skip to content
Browse files

working version matching Rails implementation

  • Loading branch information...
1 parent 6f3eb93 commit 86f031c444228f55b6c5562225ceb0ebdb5ca824 @croaky croaky committed Jan 1, 2009
Showing with 9 additions and 41 deletions.
  1. +7 −17 README.markdown
  2. +2 −24 lib/quietbacktrace.rb
View
24 README.markdown
@@ -14,26 +14,16 @@ Usage
Silencers remove lines from the backtrace. Create your own:
- class Test::Unit::TestCase
-
- end
+ # Will reject all lines that include the word "mongrel",
+ # like "/gems/mongrel/server.rb" or "/app/my_mongrel_server/rb"
+ backtrace_cleaner = QuietBacktrace.BacktraceCleaner.new
+ backtrace_cleaner.add_silencer { |line| line =~ /mongrel/ }
Filters modify the output of backtrace lines. Create your own:
- class Test::Unit::TestCase
-
- end
-
-Turn Quiet Backtrace off anywhere in your test suite by setting the flag to false:
-
- Test::Unit::TestCase.quiet_backtrace = false
-
-Rails-specific usage
---------------------
-
-Because Quiet Backtrace works by adding attributes onto Test::Unit::TestCase,
-you can add and remove silencers and filters at any level in your test suite,
-down to the individual test.
+ # Will turn "/my/rails/root/app/models/person.rb" into "/app/models/person.rb"
+ backtrace_cleaner = QuietBacktrace.BacktraceCleaner.new
+ backtrace_cleaner.add_filter { |line| line.gsub(Rails.root, '') }
Requirements
------------
View
26 lib/quietbacktrace.rb
@@ -1,17 +1,7 @@
require 'test/unit'
-require 'cattr_accessor'
require File.join(File.dirname(__FILE__), 'backtrace_cleaner')
module QuietBacktrace
- module TestCase
- def self.included(klass)
- klass.class_eval do
- cattr_accessor :quiet_backtrace
- self.quiet_backtrace = true
- end
- end
- end
-
module CleanerForTestUnit
def self.included(klass)
klass.send :alias_method, :filter_backtrace_without_cleaning, :filter_backtrace
@@ -27,18 +17,6 @@ def filter_backtrace_with_cleaning(backtrace)
end
end
-Test::Unit::TestCase.class_eval { include QuietBacktrace::TestCase }
-
-if Test::Unit::TestCase.quiet_backtrace
- Test::Unit::Util::BacktraceFilter.module_eval do
- include QuietBacktrace::CleanerForTestUnit
- end
+Test::Unit::Util::BacktraceFilter.module_eval do
+ include QuietBacktrace::CleanerForTestUnit
end
-
-# module Rails
-# def backtrace_cleaner
-# @@backtrace_cleaner ||= begin
-# QuietBacktrace::BacktraceCleaner.new
-# end
-# end
-# end

0 comments on commit 86f031c

Please sign in to comment.
Something went wrong with that request. Please try again.