test/test_topbuilder.rb in review-5.1.1 vs test/test_topbuilder.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) @@ -537,14 +539,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) @@ -877,12 +879,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| @@ -894,12 +896,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| @@ -910,12 +912,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) @@ -996,22 +998,28 @@ assert_match(/WARN --: :1: word not bound: N/, io.string) end 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}')