mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add unit tests for exception extensions
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2646 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
6273753a42
commit
8103d373e6
1 changed files with 24 additions and 0 deletions
24
activesupport/test/core_ext/exception_test.rb
Normal file
24
activesupport/test/core_ext/exception_test.rb
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
require 'test/unit'
|
||||||
|
require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/exception'
|
||||||
|
|
||||||
|
class ExceptionExtTests < Test::Unit::TestCase
|
||||||
|
|
||||||
|
def get_exception(cls = RuntimeError, msg = nil, trace = nil)
|
||||||
|
begin raise cls, msg, (trace || caller)
|
||||||
|
rescue Object => e
|
||||||
|
return e
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup
|
||||||
|
Exception::TraceSubstitutions.clear
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_clean_backtrace
|
||||||
|
Exception::TraceSubstitutions << [/\s*hidden.*/, '']
|
||||||
|
e = get_exception RuntimeError, 'RAWR', ['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
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue