2010-09-24 21:42:01 -04:00
|
|
|
require "abstract_unit"
|
|
|
|
|
|
|
|
class TemplateErrorTest < ActiveSupport::TestCase
|
|
|
|
def test_provides_original_message
|
2015-11-03 09:54:34 -05:00
|
|
|
error = begin
|
|
|
|
raise Exception.new("original")
|
|
|
|
rescue Exception
|
|
|
|
raise ActionView::Template::Error.new("test") rescue $!
|
|
|
|
end
|
|
|
|
|
2010-09-24 21:42:01 -04:00
|
|
|
assert_equal "original", error.message
|
|
|
|
end
|
|
|
|
|
2013-10-30 11:48:09 -04:00
|
|
|
def test_provides_original_backtrace
|
2015-11-03 09:54:34 -05:00
|
|
|
error = begin
|
|
|
|
original_exception = Exception.new
|
|
|
|
original_exception.set_backtrace(%W[ foo bar baz ])
|
|
|
|
raise original_exception
|
|
|
|
rescue Exception
|
|
|
|
raise ActionView::Template::Error.new("test") rescue $!
|
|
|
|
end
|
|
|
|
|
2013-10-30 11:48:09 -04:00
|
|
|
assert_equal %W[ foo bar baz ], error.backtrace
|
|
|
|
end
|
|
|
|
|
2010-09-24 21:42:01 -04:00
|
|
|
def test_provides_useful_inspect
|
2015-11-03 09:54:34 -05:00
|
|
|
error = begin
|
|
|
|
raise Exception.new("original")
|
|
|
|
rescue Exception
|
|
|
|
raise ActionView::Template::Error.new("test") rescue $!
|
|
|
|
end
|
|
|
|
|
2010-09-24 21:42:01 -04:00
|
|
|
assert_equal "#<ActionView::Template::Error: original>", error.inspect
|
|
|
|
end
|
|
|
|
end
|