This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix for Ruby 1.9.

Signed-off-by: Dan Croak <dcroak@thoughtbot.com>
  • Loading branch information...
1 parent 9111eb9 commit cb8e610ca2ac2c62da61c0c6178b6d5f16a90036 @djanowski djanowski committed with croaky Jun 16, 2009
Showing with 20 additions and 11 deletions.
  1. +10 −4 lib/quietbacktrace.rb
  2. +10 −7 test/quietbacktrace_test.rb
View
@@ -11,12 +11,18 @@ def self.included(klass)
def filter_backtrace_with_cleaning(backtrace)
backtrace = filter_backtrace_without_cleaning(backtrace)
backtrace = backtrace.first.split("\n") if backtrace.size == 1
- cleaner = QuietBacktrace::BacktraceCleaner.new
+ cleaner = QuietBacktrace::BacktraceCleaner.new
cleaner.clean(backtrace)
end
end
end
-Test::Unit::Util::BacktraceFilter.module_eval do
- include QuietBacktrace::CleanerForTestUnit
-end
+Test::Unit::Util::BacktraceFilter.module_eval do
+ include QuietBacktrace::CleanerForTestUnit
+end if defined?(Test::Unit::Util)
+
+module MiniTest
+ def self.filter_backtrace(backtrace)
+ QuietBacktrace::BacktraceCleaner.new.clean(backtrace)
+ end
+end if defined?(MiniTest)
@@ -11,19 +11,22 @@ class RailsCleanerTest < Test::Unit::TestCase
"rubygems/custom_require", "benchmark.rb",
":in `_run_erb_."].each do |each|
test "silence #{each} noise" do
- self.filter_backtrace(@backtrace.dup).each do |line|
+ cleaner.filter_backtrace(@backtrace.dup).each do |line|
assert !line.include?(each),
"#{each} noise is not being silenced: #{line}"
end
end
end
-
+
test "do not clean a legitimate line" do
rails_app_line = "/Users/james/Documents/railsApps/generating_station/app/controllers/photos_controller.rb:315"
- default_quiet_backtrace = self.filter_backtrace(@backtrace.dup)
-
- assert default_quiet_backtrace.join.include?(rails_app_line),
+ default_quiet_backtrace = cleaner.filter_backtrace(@backtrace.dup)
+
+ assert default_quiet_backtrace.join.include?(rails_app_line),
"Rails app line is being quieted: #{default_quiet_backtrace}"
end
-
-end
+
+ def cleaner
+ defined?(MiniTest) ? MiniTest : self
+ end
+end

0 comments on commit cb8e610

Please sign in to comment.