summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-02-28 01:52:14 +0000
committerseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-02-28 01:52:14 +0000
commitc85e310795a30e2c5981d4eb9a9afd597dd9819c (patch)
treed02f78ce6aefc30b32e2977a141d70fbecf7a24a /test
parentbf08067ded3a38c12924cbb02289162e11792547 (diff)
* MANIFEST: add test_erb.rb
* lib/erb.rb, test/erb/test_erb.rb: don't forget filename, if both filename and safe_level given. [ruby-dev:23050] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/erb/test_erb.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/erb/test_erb.rb b/test/erb/test_erb.rb
new file mode 100644
index 0000000000..8641197414
--- /dev/null
+++ b/test/erb/test_erb.rb
@@ -0,0 +1,40 @@
+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", 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", 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", 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", e.backtrace[0])
+ end
+end