test/test_epub3maker.rb in review-2.1.0 vs test/test_epub3maker.rb in review-2.2.0

- old
+ new

@@ -8,18 +8,18 @@ include EPUBMaker def setup @producer = Producer.new @producer.merge_params({ - "bookname" => "sample", - "title" => "Sample Book", - "epubversion" => 3, - "urnid" => "http://example.jp/", - "date" => "2011-01-01", - "language" => "en", - "modified" => "2014-12-13T14:15:16Z" - }) + "bookname" => "sample", + "title" => "Sample Book", + "epubversion" => 3, + "urnid" => "http://example.jp/", + "date" => "2011-01-01", + "language" => "en", + "modified" => "2014-12-13T14:15:16Z" + }) @output = StringIO.new end def test_initialize assert Producer.new @@ -155,11 +155,11 @@ assert_equal expect, @output.string end def test_stage1_ncx @producer.ncx(@output) - expect = <<EOT + expect = <<EOT <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en"> <head> <meta charset="UTF-8" /> @@ -224,11 +224,11 @@ end def test_stage2_ncx stage2 @producer.ncx(@output) - expect = <<EOT + expect = <<EOT <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en"> <head> <meta charset="UTF-8" /> @@ -271,30 +271,30 @@ end def test_stage3_add_various_items stage3 expect = [ - Content.new("ch01.html", "ch01-html", "application/xhtml+xml", "CH01<>&\"", 1), - Content.new("ch02.html", "ch02-html", "application/xhtml+xml", "CH02", 1), - Content.new("ch02.html#S1", "ch02-html#S1","html#s1","CH02.1", 2), - Content.new("ch02.html#S1.1", "ch02-html#S1-1", "1", "CH02.1.1", 3), - Content.new("ch02.html#S1.1.1", "ch02-html#S1-1-1","1", "CH02.1.1.1", 4), - Content.new("ch02.html#S1.1.1.1", "ch02-html#S1-1-1-1", "1","CH02.1.1.1.1", 5), - Content.new("ch02.html#S1.1.2", "ch02-html#S1-1-2", "2", "CH02.1.1.2", 4), - Content.new("ch02.html#S2", "ch02-html#S2", "html#s2", "CH02.2", 2), - Content.new("ch02.html#S2.1", "ch02-html#S2-1", "1", "CH02.2.1", 3), - Content.new("ch03.html", "ch03-html", "application/xhtml+xml", "CH03", 1, nil, ["mathml"]), - Content.new("ch03.html#S1", "ch03-html#S1", "html#s1", "CH03.1", 2), - Content.new("ch03.html#S1.1", "ch03-html#S1-1", "1", "CH03.1.1", 3), - Content.new("ch04.html", "ch04-html", "application/xhtml+xml", "CH04", 1), - Content.new("sample.png", "sample-png", "image/png"), - Content.new("sample.jpg", "sample-jpg", "image/jpeg"), - Content.new("sample.JPEG", "sample-JPEG", "image/jpeg"), - Content.new("sample.SvG", "sample-SvG", "image/svg+xml"), - Content.new("sample.GIF", "sample-GIF", "image/gif"), - Content.new("sample.css", "sample-css", "text/css") - ] + Content.new("ch01.html", "ch01-html", "application/xhtml+xml", "CH01<>&\"", 1), + Content.new("ch02.html", "ch02-html", "application/xhtml+xml", "CH02", 1), + Content.new("ch02.html#S1", "ch02-html#S1","html#s1","CH02.1", 2), + Content.new("ch02.html#S1.1", "ch02-html#S1-1", "1", "CH02.1.1", 3), + Content.new("ch02.html#S1.1.1", "ch02-html#S1-1-1","1", "CH02.1.1.1", 4), + Content.new("ch02.html#S1.1.1.1", "ch02-html#S1-1-1-1", "1","CH02.1.1.1.1", 5), + Content.new("ch02.html#S1.1.2", "ch02-html#S1-1-2", "2", "CH02.1.1.2", 4), + Content.new("ch02.html#S2", "ch02-html#S2", "html#s2", "CH02.2", 2), + Content.new("ch02.html#S2.1", "ch02-html#S2-1", "1", "CH02.2.1", 3), + Content.new("ch03.html", "ch03-html", "application/xhtml+xml", "CH03", 1, nil, ["mathml"]), + Content.new("ch03.html#S1", "ch03-html#S1", "html#s1", "CH03.1", 2), + Content.new("ch03.html#S1.1", "ch03-html#S1-1", "1", "CH03.1.1", 3), + Content.new("ch04.html", "ch04-html", "application/xhtml+xml", "CH04", 1), + Content.new("sample.png", "sample-png", "image/png"), + Content.new("sample.jpg", "sample-jpg", "image/jpeg"), + Content.new("sample.JPEG", "sample-JPEG", "image/jpeg"), + Content.new("sample.SvG", "sample-SvG", "image/svg+xml"), + Content.new("sample.GIF", "sample-GIF", "image/gif"), + Content.new("sample.css", "sample-css", "text/css") + ] assert_equal expect, @producer.contents end def test_stage3_opf @@ -341,11 +341,11 @@ end def test_stage3_ncx stage3 @producer.ncx(@output) - expect = <<EOT + expect = <<EOT <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en"> <head> <meta charset="UTF-8" /> @@ -555,13 +555,13 @@ @producer.params["aut"] = ["Mr.Smith"] @producer.params["pbl"] = ["BLUEPRINT"] @producer.params["pht"] = ["Mrs.Smith"] @producer.merge_params({"language" => "ja", "history" => [[ - "2011-08-03 v1.0.0版発行", - "2012-02-15 v1.1.0版発行", - ]] }) + "2011-08-03 v1.0.0版発行", + "2012-02-15 v1.1.0版発行", + ]] }) history = @producer.instance_eval{ @epub.colophon_history } expect = <<EOT <div class="pubhistory"> <p>2011年8月3日 v1.0.0版発行</p> <p>2012年2月15日 v1.1.0版発行</p> @@ -574,13 +574,13 @@ @producer.params["aut"] = ["Mr.Smith"] @producer.params["pbl"] = ["BLUEPRINT"] @producer.params["pht"] = ["Mrs.Smith"] @producer.merge_params({"language" => "ja", "history" => [[ - "2011-08-03", - "2012-02-15", - ]] }) + "2011-08-03", + "2012-02-15", + ]] }) history = @producer.instance_eval{ @epub.colophon_history } expect = <<EOT <div class="pubhistory"> <p>2011年8月3日 初版第1刷 発行</p> <p>2012年2月15日 初版第2刷 発行</p> @@ -593,17 +593,17 @@ @producer.params["aut"] = ["Mr.Smith"] @producer.params["pbl"] = ["BLUEPRINT"] @producer.params["pht"] = ["Mrs.Smith"] @producer.merge_params({"language" => "ja", "history" => [[ - "2011-08-03", - "2012-02-15", - ],[ - "2012-10-01", - ],[ - "2013-03-01", - ]] }) + "2011-08-03", + "2012-02-15", + ],[ + "2012-10-01", + ],[ + "2013-03-01", + ]] }) history = @producer.instance_eval{ @epub.colophon_history } expect = <<EOT <div class="pubhistory"> <p>2011年8月3日 初版第1刷 発行</p> <p>2012年2月15日 初版第2刷 発行</p> @@ -612,16 +612,9 @@ </div> EOT assert_equal expect, history end - -# def test_duplicate_id -# stage3 -# assert_raise(Error) do -# @producer.contents << Content.new({"file" => "ch02.html#S1", "title" => "CH02.1", "level" => 2}) -# end -# end def test_detect_mathml Dir.mktmpdir do |dir| epubmaker = ReVIEW::EPUBMaker.new path = File.join(dir,"test.html")