From 4ac332fa9a16ae86b948251e372999b9f4618dec Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 28 Jan 2007 07:10:35 +0000 Subject: Fix Test::Unit::TestCase#clean_backtrace git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6056 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/test_test.rb | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 2b0086c5f4..ab44fbf3ca 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -1,5 +1,5 @@ -require File.dirname(__FILE__) + '/../abstract_unit' -require File.dirname(__FILE__) + '/fake_controllers' +require "#{File.dirname(__FILE__)}/../abstract_unit" +require "#{File.dirname(__FILE__)}/fake_controllers" class TestTest < Test::Unit::TestCase class TestController < ActionController::Base @@ -493,3 +493,31 @@ HTML end end end + + +class CleanBacktraceTest < Test::Unit::TestCase + def test_should_reraise_the_same_object + exception = Test::Unit::AssertionFailedError.new('message') + clean_backtrace { raise exception } + rescue => caught + assert_equal exception.object_id, caught.object_id + assert_equal exception.message, caught.message + end + + def test_should_clean_assertion_lines_from_backtrace + path = File.expand_path("#{File.dirname(__FILE__)}/../../lib/action_controller") + exception = Test::Unit::AssertionFailedError.new('message') + exception.set_backtrace ["#{path}/abc", "#{path}/assertions/def"] + clean_backtrace { raise exception } + rescue => caught + assert_equal ["#{path}/abc"], caught.backtrace + end + + def test_should_only_clean_assertion_failure_errors + clean_backtrace do + raise "can't touch this", [File.expand_path("#{File.dirname(__FILE__)}/../../lib/action_controller/assertions/abc")] + end + rescue => caught + assert !caught.backtrace.empty? + end +end -- cgit v1.2.3