test/test_plaintextbuilder.rb in review-5.1.1 vs test/test_plaintextbuilder.rb in review-5.2.0
- old
+ new
@@ -12,10 +12,12 @@
@config = ReVIEW::Configure.values
@config['secnolevel'] = 2
@config['language'] = 'ja'
@book = Book::Base.new
@book.config = @config
+ @log_io = StringIO.new
+ ReVIEW.logger = ReVIEW::Logger.new(@log_io)
@compiler = ReVIEW::Compiler.new(@builder)
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
location = Location.new(nil, nil)
@builder.bind(@compiler, @chapter, location)
@@ -467,14 +469,14 @@
assert_equal expected, actual
end
def test_empty_table
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
- assert_equal ':2: error: no rows in the table', e.message
+ assert_equal 'no rows in the table', e.message
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
- assert_equal ':3: error: no rows in the table', e.message
+ assert_equal 'no rows in the table', e.message
end
def test_inline_table
def @chapter.table(_id)
Book::Index::Item.new('sampletable', 1)
@@ -689,12 +691,12 @@
//#{type}{
//}
//}
EOS
- e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
- assert_match(/minicolumn cannot be nested:/, e.message)
+ assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
+ assert_match(/minicolumn cannot be nested:/, @log_io.string)
end
end
def test_minicolumn_blocks_nest_error2
%w[note memo tip info warning important caution notice].each do |type|
@@ -706,12 +708,12 @@
//}
//}
EOS
- e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
- assert_match(/minicolumn cannot be nested:/, e.message)
+ assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
+ assert_match(/minicolumn cannot be nested:/, @log_io.string)
end
end
def test_minicolumn_blocks_nest_error3
%w[memo tip info warning important caution notice].each do |type|
@@ -722,12 +724,12 @@
//note{
//}
//}
EOS
- e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
- assert_match(/minicolumn cannot be nested:/, e.message)
+ assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
+ assert_match(/minicolumn cannot be nested:/, @log_io.string)
end
end
def test_image
def @chapter.image(_id)
@@ -759,23 +761,29 @@
actual = compile_block("//texequation{\n\\sin\n1^{2}\n//}\n")
assert_equal %Q(\\sin\n1^{2}\n\n), actual
end
def test_inline_unknown
- e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
- assert_equal ':1: error: unknown image: n', e.message
- e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
- assert_equal ':1: error: unknown footnote: n', e.message
- e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
- assert_equal ':1: error: unknown headline: n', e.message
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
+ assert_match(/unknown image: n/, @log_io.string)
+
+ @log_io.string = ''
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
+ assert_match(/unknown footnote: n/, @log_io.string)
+
+ @log_io.string = ''
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
+ assert_match(/unknown headline: n/, @log_io.string)
%w[list table column].each do |name|
- e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
- assert_equal ":1: error: unknown #{name}: n", e.message
+ @log_io.string = ''
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
+ assert_match(/unknown #{name}: n/, @log_io.string)
end
%w[chap chapref title].each do |name|
- e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
- assert_equal ':1: error: key not found: "n"', e.message
+ @log_io.string = ''
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
+ assert_match(/key not found: "n"/, @log_io.string)
end
end
def test_inline_raw0
assert_equal 'normal', compile_inline('@<raw>{normal}')
@@ -889,19 +897,19 @@
def test_nest_error_open
src = <<-EOS
//endchild
EOS
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
- assert_equal ":1: error: //endchild is shown, but any opened //beginchild doesn't exist", e.message
+ assert_equal "//endchild is shown, but any opened //beginchild doesn't exist", e.message
end
def test_nest_error_close1
src = <<-EOS
//beginchild
EOS
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
- assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
+ assert_equal "//beginchild is shown, but previous element isn't ul, ol, or dl", e.message
end
def test_nest_error_close2
src = <<-EOS
* foo
@@ -915,11 +923,11 @@
: foo
//beginchild
EOS
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
- assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message
+ assert_equal '//beginchild of dl,ol,ul misses //endchild', e.message
end
def test_nest_error_close3
src = <<-EOS
* foo
@@ -935,10 +943,10 @@
//beginchild
//endchild
EOS
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
- assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message
+ assert_equal '//beginchild of ol,ul misses //endchild', e.message
end
def test_nest_ul
src = <<-EOS
* UL1