From e714b25723b674bb6d66af40ea9047166907616b Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Tue, 4 Apr 2006 19:37:29 +0000 Subject: Update the diagnostics template skip the useless '' text. Fix symbol extensions test case. Clean paths inside of exception messages and traces. Add Pathname.clean_within for cleaning all the paths inside of a string. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4158 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/exception_test.rb | 23 +++++++++++++++++++++-- activesupport/test/core_ext/symbol.rb | 8 -------- activesupport/test/core_ext/symbol_test.rb | 8 ++++++++ activesupport/test/core_ext/symbol_tests.rb | 8 ++++++++ 4 files changed, 37 insertions(+), 10 deletions(-) delete mode 100644 activesupport/test/core_ext/symbol.rb create mode 100644 activesupport/test/core_ext/symbol_test.rb create mode 100644 activesupport/test/core_ext/symbol_tests.rb (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/exception_test.rb b/activesupport/test/core_ext/exception_test.rb index 58f1ba5540..9b7afb1913 100644 --- a/activesupport/test/core_ext/exception_test.rb +++ b/activesupport/test/core_ext/exception_test.rb @@ -41,6 +41,25 @@ class ExceptionExtTests < Test::Unit::TestCase assert_kind_of Exception, e assert_equal ['vendor/file.rb some stuff', ' vendor/file.rb some stuff'], e.framework_backtrace end - -end \ No newline at end of file + def test_backtrace_should_clean_paths + Exception::TraceSubstitutions << [/\s*hidden.*/, ''] + e = get_exception RuntimeError, 'RAWR', ['a/b/c/../d/../../../bhal.rb', 'rawh hid den stuff is not here', 'almost all'] + assert_kind_of Exception, e + assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace + end + + def test_clean_message_should_clean_paths + Exception::TraceSubstitutions << [/\s*hidden.*/, ''] + e = get_exception RuntimeError, "I dislike a/z/x/../../b/y/../c", ['a/b/c/../d/../../../bhal.rb', 'rawh hid den stuff is not here', 'almost all'] + assert_kind_of Exception, e + assert_equal "I dislike a/b/c", e.clean_message + end + + def test_app_trace_should_be_empty_when_no_app_frames + Exception::TraceSubstitutions << [/\s*hidden.*/, ''] + e = get_exception RuntimeError, 'RAWR', ['vendor/file.rb some stuff', 'generated/bhal.rb', ' vendor/file.rb some stuff', 'generated/almost all'] + assert_kind_of Exception, e + assert_equal [], e.application_backtrace + end +end diff --git a/activesupport/test/core_ext/symbol.rb b/activesupport/test/core_ext/symbol.rb deleted file mode 100644 index ae2c585fc2..0000000000 --- a/activesupport/test/core_ext/symbol.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test/unit' -require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/symbol' - -class TestSymbol < Test::Case::TestUnit - def test_to_proc - assert_equal %w(one two three), [:one, :two, :three].map &:to_s - end -end diff --git a/activesupport/test/core_ext/symbol_test.rb b/activesupport/test/core_ext/symbol_test.rb new file mode 100644 index 0000000000..fec504d9d1 --- /dev/null +++ b/activesupport/test/core_ext/symbol_test.rb @@ -0,0 +1,8 @@ +require 'test/unit' +require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/symbol' + +class SymbolTests < Test::Unit::TestCase + def test_to_proc + assert_equal %w(one two three), [:one, :two, :three].map(&:to_s) + end +end diff --git a/activesupport/test/core_ext/symbol_tests.rb b/activesupport/test/core_ext/symbol_tests.rb new file mode 100644 index 0000000000..ae2c585fc2 --- /dev/null +++ b/activesupport/test/core_ext/symbol_tests.rb @@ -0,0 +1,8 @@ +require 'test/unit' +require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/symbol' + +class TestSymbol < Test::Case::TestUnit + def test_to_proc + assert_equal %w(one two three), [:one, :two, :three].map &:to_s + end +end -- cgit v1.2.3