mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_erb.rb: add test cases for uncovered methods
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
08bb7d3d19
commit
054e4bc4fd
1 changed files with 22 additions and 0 deletions
|
@ -86,6 +86,10 @@ class TestERBCore < Test::Unit::TestCase
|
|||
@erb = ERB
|
||||
end
|
||||
|
||||
def test_version
|
||||
assert_equal(String, @erb.version.class)
|
||||
end
|
||||
|
||||
def test_core
|
||||
_test_core(nil)
|
||||
_test_core(0)
|
||||
|
@ -221,6 +225,18 @@ EOS
|
|||
assert_equal("line\r\n" * 3, erb.result)
|
||||
end
|
||||
|
||||
def test_run
|
||||
out = StringIO.new
|
||||
orig, $stdout = $stdout, out
|
||||
|
||||
num = 3
|
||||
@erb.new('<%= num * 3 %>').run(binding)
|
||||
|
||||
$stdout = orig
|
||||
out.rewind
|
||||
assert_equal('9', out.read)
|
||||
end
|
||||
|
||||
class Foo; end
|
||||
|
||||
def test_def_class
|
||||
|
@ -320,6 +336,12 @@ EOS
|
|||
assert_match(/\Atest fname:1\b/, e.backtrace[0])
|
||||
end
|
||||
|
||||
def test_def_module
|
||||
klass = Class.new
|
||||
klass.include ERB.new('<%= val %>').def_module('render(val)')
|
||||
assert_equal('1', klass.new.render(1))
|
||||
end
|
||||
|
||||
def test_escape
|
||||
src = <<EOS
|
||||
1.<%% : <%="<%%"%>
|
||||
|
|
Loading…
Add table
Reference in a new issue