test/test_epubmaker.rb in review-1.1.0 vs test/test_epubmaker.rb in review-1.2.0

- old
+ new

@@ -6,11 +6,11 @@ class EPUBMakerTest < Test::Unit::TestCase include EPUBMaker def setup @producer = Producer.new - @producer.mergeparams({ + @producer.merge_params({ "bookname" => "sample", "title" => "Sample Book", "version" => 2, "urnid" => "http://example.jp/", "date" => "2011-01-01", @@ -22,16 +22,16 @@ def test_initialize assert Producer.new end def test_resource_en - @producer.mergeparams({"language" => "en"}) + @producer.merge_params({"language" => "en"}) assert_equal "Table of Contents", @producer.res.v("toctitle") end def test_resource_ja - @producer.mergeparams({"language" => "ja"}) + @producer.merge_params({"language" => "ja"}) assert_equal "目次", @producer.res.v("toctitle") end def test_mimetype @producer.mimetype(@output) @@ -401,25 +401,51 @@ <meta name="generator" content="EPUBMaker::Producer"/> <title>Table of Contents</title> </head> <body> <h1 class="toc-title">Table of Contents</h1> - <ul class="toc-h1"> -<li><a href="ch01.html">CH01</a></li> + +<ul class="toc-h1"><li><a href="ch01.html">CH01</a></li> <li><a href="ch02.html">CH02</a> -<ul class="toc-h2"> -<li><a href="ch02.html#S1">CH02.1</a></li> +<ul class="toc-h2"><li><a href="ch02.html#S1">CH02.1</a></li> <li><a href="ch02.html#S2">CH02.2</a></li> -</ul> -</li> +</ul></li> <li><a href="ch03.html">CH03</a> -<ul class="toc-h2"> +<ul class="toc-h2"><li><a href="ch03.html#S1">CH03.1</a></li> +</ul></li> +<li><a href="ch04.html">CH04</a></li> +</ul></body> +</html> +EOT + assert_equal expect, @output.string + end + + def test_stage3_flat + @producer.merge_params({"flattoc" => true, "flattocindent" => false}) + stage3 + @producer.mytoc(@output) + expect = <<EOT +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> + <meta http-equiv="Content-Style-Type" content="text/css"/> + <meta name="generator" content="EPUBMaker::Producer"/> + <title>Table of Contents</title> +</head> +<body> + <h1 class="toc-title">Table of Contents</h1> +<ul class="toc-h1"> +<li><a href="ch01.html">CH01</a></li> +<li><a href="ch02.html">CH02</a></li> +<li><a href="ch02.html#S1">CH02.1</a></li> +<li><a href="ch02.html#S2">CH02.2</a></li> +<li><a href="ch03.html">CH03</a></li> <li><a href="ch03.html#S1">CH03.1</a></li> -</ul> -</li> <li><a href="ch04.html">CH04</a></li> - </ul> +</ul> </body> </html> EOT assert_equal expect, @output.string end @@ -468,12 +494,12 @@ EOT assert_equal expect, @output.string end def test_colophon_default - @producer.params["aut"] = "Mr.Smith" - @producer.params["prt"] = "BLUEPRINT" + @producer.params["aut"] = ["Mr.Smith"] + @producer.params["prt"] = ["BLUEPRINT"] @producer.colophon(@output) expect = <<EOT <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en"> @@ -484,12 +510,48 @@ <title>Colophon</title> </head> <body> <div class="colophon"> <p class="title">Sample Book</p> + <div class="pubhistory"> + <p>2011年1月1日 発行</p> + </div> <table class="colophon"> <tr><th>Author</th><td>Mr.Smith</td></tr> <tr><th>Publisher</th><td>BLUEPRINT</td></tr> + </table> + </div> +</body> +</html> +EOT + assert_equal expect, @output.string + end + + def test_colophon_pht + @producer.params["aut"] = ["Mr.Smith"] + @producer.params["prt"] = ["BLUEPRINT"] + @producer.params["pht"] = ["Mrs.Smith"] + @producer.colophon(@output) + expect = <<EOT +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> + <meta http-equiv="Content-Style-Type" content="text/css"/> + <meta name="generator" content="EPUBMaker::Producer"/> + <title>Colophon</title> +</head> +<body> + <div class="colophon"> + <p class="title">Sample Book</p> + <div class="pubhistory"> + <p>2011年1月1日 発行</p> + </div> + <table class="colophon"> + <tr><th>Author</th><td>Mr.Smith</td></tr> + <tr><th>Publisher</th><td>BLUEPRINT</td></tr> + <tr><th>Director of Photography</th><td>Mrs.Smith</td></tr> </table> </div> </body> </html> EOT