aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorManfred Stienstra <manfred@fngtps.com>2008-11-24 11:25:28 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-11-24 11:35:55 +0100
commit1f48c09094610cbf26ec1e93d9bf978b2ae86fa8 (patch)
tree1f0094706f887a9beda6acb33009858afd372fe3 /railties
parentf3f67ce6212e2ae35470ab2960bb4967ae967ee2 (diff)
downloadrails-1f48c09094610cbf26ec1e93d9bf978b2ae86fa8.tar.gz
rails-1f48c09094610cbf26ec1e93d9bf978b2ae86fa8.tar.bz2
rails-1f48c09094610cbf26ec1e93d9bf978b2ae86fa8.zip
Accept a prefix argument to filter_backtrace_with_cleaning [#1456 state:committed]
Add a prefix argument to filter_backtrace_with_cleaning so it has the same arity as test/unit's filter_backtrace. Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/backtrace_cleaner.rb10
-rw-r--r--railties/test/abstract_unit.rb3
-rw-r--r--railties/test/backtrace_cleaner_test.rb28
3 files changed, 34 insertions, 7 deletions
diff --git a/railties/lib/rails/backtrace_cleaner.rb b/railties/lib/rails/backtrace_cleaner.rb
index ffc5ef42aa..88df0ebbda 100644
--- a/railties/lib/rails/backtrace_cleaner.rb
+++ b/railties/lib/rails/backtrace_cleaner.rb
@@ -1,14 +1,13 @@
module Rails
class BacktraceCleaner < ActiveSupport::BacktraceCleaner
ERB_METHOD_SIG = /:in `_run_erb_.*/
-
+
VENDOR_DIRS = %w( vendor/plugins vendor/gems vendor/rails )
MONGREL_DIRS = %w( lib/mongrel bin/mongrel )
RAILS_NOISE = %w( script/server )
RUBY_NOISE = %w( rubygems/custom_require benchmark.rb )
ALL_NOISE = VENDOR_DIRS + MONGREL_DIRS + RAILS_NOISE + RUBY_NOISE
-
def initialize
super
@@ -18,15 +17,14 @@ module Rails
end
end
-
# For installing the BacktraceCleaner in the test/unit
module BacktraceFilterForTestUnit #:nodoc:
def self.included(klass)
klass.send :alias_method_chain, :filter_backtrace, :cleaning
end
-
- def filter_backtrace_with_cleaning(backtrace)
- backtrace = filter_backtrace_without_cleaning(backtrace)
+
+ def filter_backtrace_with_cleaning(backtrace, prefix=nil)
+ backtrace = filter_backtrace_without_cleaning(backtrace, prefix)
backtrace = backtrace.first.split("\n") if backtrace.size == 1
Rails.backtrace_cleaner.clean(backtrace)
end
diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb
index 516ab8523e..b6edc03391 100644
--- a/railties/test/abstract_unit.rb
+++ b/railties/test/abstract_unit.rb
@@ -9,6 +9,7 @@ gem 'mocha', '>= 0.9.3'
require 'mocha'
require 'stringio'
require 'active_support'
+require 'active_support/test_case'
def uses_mocha(test_name)
yield
@@ -18,4 +19,4 @@ if defined?(RAILS_ROOT)
RAILS_ROOT.replace File.dirname(__FILE__)
else
RAILS_ROOT = File.dirname(__FILE__)
-end
+end \ No newline at end of file
diff --git a/railties/test/backtrace_cleaner_test.rb b/railties/test/backtrace_cleaner_test.rb
new file mode 100644
index 0000000000..5955fd2856
--- /dev/null
+++ b/railties/test/backtrace_cleaner_test.rb
@@ -0,0 +1,28 @@
+require 'abstract_unit'
+
+require 'initializer'
+require 'rails/backtrace_cleaner'
+
+class TestWithBacktrace
+ include Test::Unit::Util::BacktraceFilter
+ include Rails::BacktraceFilterForTestUnit
+end
+
+class BacktraceCleanerFilterTest < ActiveSupport::TestCase
+ def setup
+ @test = TestWithBacktrace.new
+ @backtrace = [ './test/rails/benchmark_test.rb', './test/rails/dependencies.rb', '/opt/local/lib/ruby/kernel.rb' ]
+ end
+
+ test "test with backtrace should use the rails backtrace cleaner to clean" do
+ Rails.stubs(:backtrace_cleaner).returns(stub(:clean))
+ Rails.backtrace_cleaner.expects(:clean).with(@backtrace, nil)
+ @test.filter_backtrace(@backtrace)
+ end
+
+ test "filter backtrace should have the same arity as Test::Unit::Util::BacktraceFilter" do
+ assert_nothing_raised do
+ @test.filter_backtrace(@backtrace, '/opt/local/lib')
+ end
+ end
+end \ No newline at end of file