1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/erb/test_erb.rb
ko1 a3e1b1ce7e * Merge YARV
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-31 15:02:22 +00:00

40 lines
1,018 B
Ruby

require 'test/unit'
require 'erb'
class TestERB < Test::Unit::TestCase
class MyError < RuntimeError ; end
def test_without_filename
erb = ERB.new("<% raise ::TestERB::MyError %>")
e = assert_raise(MyError) {
erb.result
}
assert_equal("(erb):1:in `raise'", e.backtrace[0])
end
def test_with_filename
erb = ERB.new("<% raise ::TestERB::MyError %>")
erb.filename = "test filename"
e = assert_raise(MyError) {
erb.result
}
assert_equal("test filename:1:in `raise'", e.backtrace[0])
end
def test_without_filename_with_safe_level
erb = ERB.new("<% raise ::TestERB::MyError %>", 1)
e = assert_raise(MyError) {
erb.result
}
assert_equal("(erb):1:in `raise'", e.backtrace[0])
end
def test_with_filename_and_safe_level
erb = ERB.new("<% raise ::TestERB::MyError %>", 1)
erb.filename = "test filename"
e = assert_raise(MyError) {
erb.result
}
assert_equal("test filename:1:in `raise'", e.backtrace[0])
end
end