Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updating docs

  • Loading branch information...
commit 294359c371749cbacaefaade3d99359f86936e0b 1 parent 0b179e7
@croaky croaky authored
View
7 README.markdown
@@ -12,13 +12,6 @@ sudo gem install thoughtbot-quietbacktrace --source=http://gems.github.com
Usage
-----
-Quiet Backtrace works by adding new attributes to Test::Unit::TestCase.
-By default, their values are:
-
- self.quiet_backtrace = true
- self.backtrace_silencers = [:test_unit, :gem_root, :e1]
- self.backtrace_filters = [:method_name]
-
Silencers remove lines from the backtrace that return true for given conditions.
Filters modify the output of backtrace lines.
View
20 lib/quietbacktrace.rb
@@ -1,15 +1,23 @@
require 'test/unit'
-if defined?(Rails)
+def mix_cleaner_into_test_unit
+ require File.join(File.dirname(__FILE__), 'quietbacktrace', 'cleaner')
+
+ Test::Unit::Util::BacktraceFilter.module_eval do
+ include QuietBacktrace::CleanerForTestUnit
+ end
+end
+
+def mix_rails_cleaner_into_test_unit
require File.join(File.dirname(__FILE__), 'quietbacktrace', 'rails', 'cleaner')
Test::Unit::Util::BacktraceFilter.module_eval do
include QuietBacktrace::Rails::CleanerForTestUnit
end
+end
+
+if defined?(Rails)
+ mix_rails_cleaner_into_test_unit
else
- require File.join(File.dirname(__FILE__), 'quietbacktrace', 'cleaner')
-
- Test::Unit::Util::BacktraceFilter.module_eval do
- include QuietBacktrace::CleanerForTestUnit
- end
+ mix_cleaner_into_test_unit
end
View
13 lib/quietbacktrace/cleaner.rb
@@ -26,7 +26,8 @@ def clean(backtrace)
#
# Example:
#
- # # Will turn "/my/rails/root/app/models/person.rb" into "/app/models/person.rb"
+ # Will turn "/my/rails/root/app/models/person.rb" into "/app/models/person.rb"
+ # backtrace_cleaner = QuietBacktrace.Cleaner.new
# backtrace_cleaner.add_filter { |line| line.gsub(Rails.root, '') }
def add_filter(&block)
@filters << block
@@ -37,13 +38,17 @@ def add_filter(&block)
#
# Example:
#
- # # Will reject all lines that include the word "mongrel", like "/gems/mongrel/server.rb" or "/app/my_mongrel_server/rb"
+ # Will reject all lines that include the word "mongrel",
+ # like "/gems/mongrel/server.rb" or "/app/my_mongrel_server/rb"
+ #
+ # backtrace_cleaner = QuietBacktrace.Cleaner.new
# backtrace_cleaner.add_silencer { |line| line =~ /mongrel/ }
def add_silencer(&block)
@silencers << block
end
- # Will remove all silencers, but leave in the filters. This is useful if your context of debugging suddenly expands as
+ # Will remove all silencers, but leave in the filters.
+ # This is useful if your context of debugging suddenly expands as
# you suspect a bug in the libraries you use.
def remove_silencers!
@silencers = []
@@ -69,7 +74,7 @@ def silence(backtrace)
end
# For installing the Cleaner in test/unit
- module CleanerForTestUnit #:nodoc:
+ module CleanerForTestUnit
def self.included(klass)
klass.send :alias_method, :filter_backtrace_without_cleaning, :filter_backtrace
klass.send :alias_method, :filter_backtrace, :filter_backtrace_with_cleaning
View
1  lib/quietbacktrace/rails/cleaner.rb
@@ -17,6 +17,7 @@ class Cleaner < QuietBacktrace::Cleaner
def initialize
super
+
if defined?(RAILS_ROOT)
add_filter { |line| line.sub("#{RAILS_ROOT}/", '') }
end
Please sign in to comment.
Something went wrong with that request. Please try again.