2008-10-25 03:05:28 +04:00
|
|
|
require 'rubygems'
|
2010-04-01 11:45:16 +04:00
|
|
|
require 'minitest/autorun'
|
2008-01-19 03:06:19 +03:00
|
|
|
require 'rdoc/markup'
|
|
|
|
require 'rdoc/markup/to_test'
|
2003-12-01 10:12:49 +03:00
|
|
|
|
2008-10-25 03:05:28 +04:00
|
|
|
class TestRDocMarkup < MiniTest::Unit::TestCase
|
2003-12-01 10:12:49 +03:00
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def test_convert
|
|
|
|
str = <<-STR
|
|
|
|
now is
|
|
|
|
the time
|
2003-12-01 10:12:49 +03:00
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
hello
|
|
|
|
dave
|
2003-12-01 10:12:49 +03:00
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
1. l1
|
|
|
|
2. l2
|
|
|
|
STR
|
2003-12-01 10:12:49 +03:00
|
|
|
|
2008-02-10 06:59:08 +03:00
|
|
|
m = RDoc::Markup.new
|
2011-06-16 08:59:24 +04:00
|
|
|
|
|
|
|
tt = RDoc::Markup::ToTest.new m
|
|
|
|
|
|
|
|
out = m.convert str, tt
|
2010-04-01 11:45:16 +04:00
|
|
|
|
|
|
|
expected = [
|
|
|
|
"now is the time",
|
|
|
|
"\n",
|
|
|
|
" hello\n dave\n",
|
|
|
|
"1: ",
|
|
|
|
"l1",
|
|
|
|
"1: ",
|
|
|
|
"l2",
|
2008-02-10 06:59:08 +03:00
|
|
|
]
|
2003-12-01 10:12:49 +03:00
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
assert_equal expected, out
|
2003-12-01 10:12:49 +03:00
|
|
|
end
|
|
|
|
|
2011-06-16 08:59:24 +04:00
|
|
|
def test_convert_custom_markup
|
|
|
|
str = <<-STR
|
|
|
|
{stricken}
|
|
|
|
STR
|
|
|
|
|
|
|
|
m = RDoc::Markup.new
|
|
|
|
m.add_word_pair '{', '}', :STRIKE
|
|
|
|
|
|
|
|
tt = RDoc::Markup::ToTest.new m
|
|
|
|
tt.add_tag :STRIKE, 'STRIKE ', ' STRIKE'
|
|
|
|
|
|
|
|
out = m.convert str, tt
|
|
|
|
|
|
|
|
expected = [
|
|
|
|
"STRIKE stricken STRIKE",
|
|
|
|
]
|
|
|
|
|
|
|
|
assert_equal expected, out
|
|
|
|
end
|
|
|
|
|
2003-12-01 10:12:49 +03:00
|
|
|
end
|
2007-12-28 09:13:06 +03:00
|
|
|
|