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

- old
+ new

@@ -7,17 +7,17 @@ include EPUBMaker def setup @producer = Producer.new @producer.merge_params({ - "bookname" => "sample", - "title" => "Sample Book", - "epubversion" => 2, - "urnid" => "http://example.jp/", - "date" => "2011-01-01", - "language" => "en", - }) + "bookname" => "sample", + "title" => "Sample Book", + "epubversion" => 2, + "urnid" => "http://example.jp/", + "date" => "2011-01-01", + "language" => "en", + }) @output = StringIO.new end def test_initialize assert Producer.new @@ -104,11 +104,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"?> <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1"> <head> <meta name="dtb:depth" content="1"/> <meta name="dtb:totalPageCount" content="0"/> @@ -135,11 +135,11 @@ end def test_stage1_ncx_escape @producer.params["title"] = "Sample<>Book" @producer.ncx(@output) - expect = <<EOT + expect = <<EOT <?xml version="1.0" encoding="UTF-8"?> <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1"> <head> <meta name="dtb:depth" content="1"/> <meta name="dtb:totalPageCount" content="0"/> @@ -210,11 +210,11 @@ end def test_stage2_ncx stage2 @producer.ncx(@output) - expect = <<EOT + expect = <<EOT <?xml version="1.0" encoding="UTF-8"?> <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1"> <head> <meta name="dtb:depth" content="1"/> <meta name="dtb:totalPageCount" content="0"/> @@ -270,30 +270,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), - 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), + 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 @@ -338,11 +338,11 @@ end def test_stage3_ncx stage3 @producer.ncx(@output) - expect = <<EOT + expect = <<EOT <?xml version="1.0" encoding="UTF-8"?> <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1"> <head> <meta name="dtb:depth" content="1"/> <meta name="dtb:totalPageCount" content="0"/> @@ -660,10 +660,61 @@ </html> EOT assert_equal expect, @output.string end + def test_colophon_history + @producer.params["aut"] = ["Mr.Smith"] + @producer.params["pbl"] = ["BLUEPRINT"] + @producer.params["pht"] = ["Mrs.Smith"] + @producer.merge_params({"language" => "ja"}) + @producer.params["history"] = [[ + "2011-08-03", + "2012-02-15", + ],[ + "2012-10-01", + ],[ + "2013-03-01", + ]] + epub = @producer.instance_eval{@epub} + result = epub.colophon_history + expect = <<-EOT + <div class=\"pubhistory\"> + <p>2011年8月3日 初版第1刷 発行</p> + <p>2012年2月15日 初版第2刷 発行</p> + <p>2012年10月1日 第2版第1刷 発行</p> + <p>2013年3月1日 第3版第1刷 発行</p> + </div> + EOT + assert_equal expect, result + end + + def test_colophon_history_freeformat + @producer.params["aut"] = ["Mr.Smith"] + @producer.params["pbl"] = ["BLUEPRINT"] + @producer.params["pht"] = ["Mrs.Smith"] + @producer.merge_params({"language" => "ja"}) + @producer.params["history"] = [[ + "2011年8月3日 ver 1.1.0発行", + ],[ + "2011年10月12日 ver 1.2.0発行", + ],[ + "2012年1月31日 ver 1.2.1発行", + ]] + + epub = @producer.instance_eval{@epub} + result = epub.colophon_history + expect = <<-EOT + <div class=\"pubhistory\"> + <p>2011年8月3日 ver 1.1.0発行</p> + <p>2011年10月12日 ver 1.2.0発行</p> + <p>2012年1月31日 ver 1.2.1発行</p> + </div> + EOT + assert_equal expect, result + end + def test_colophon_pht @producer.params["aut"] = ["Mr.Smith"] @producer.params["pbl"] = ["BLUEPRINT"] @producer.params["pht"] = ["Mrs.Smith"] @producer.colophon(@output) @@ -706,16 +757,9 @@ def test_isbn_nil @producer.params["isbn"] = nil assert_equal nil, @producer.isbn_hyphen 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_title @producer.params["aut"] = ["Mr.Smith"] @producer.params["pbl"] = ["BLUEPRINT"] @producer.titlepage(@output)