def setup
@tmpdir = Dir.mktmpdir
@epubdir = "#{@tmpdir}/epubdir"
FileUtils.mkdir_p("#{@epubdir}/META-INF")
FileUtils.mkdir_p("#{@epubdir}/OEBPS")
File.write("#{@epubdir}/mimetype", "application/epub+zip")
container_xml = <<-EOB
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
<rootfiles>
<rootfile full-path="OEBPS/book.opf" media-type="application/oebps-package+xml" />
</rootfiles>
</container>
EOB
book_opf = <<-EOB
<?xml version="1.0"?>
<package xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookID" version="2.0">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
<dc:title>sample epub</dc:title>
<dc:creator opf:role="aut">AUTHOR</dc:creator>
<dc:language>ja</dc:language>
<dc:identifier id="BookID" opf:scheme="URL">http://example.com/epub/sample/sample1.epub</dc:identifier>
</metadata>
<manifest>
<item id="ch1.xhtml" href="OEBPS/ch1.xhtml" media-type="application/xhtml+xml"/>
</manifest>
<spine toc="ncx">
<itemref idref="ch1.xhtml"/>
</spine>
<guide>
<reference type="cover" title="Cover Page" href="OEPBS/ch1.xhtml"/>
</guide>
</package>
EOB
ch1_xhtml = <<-EOB
<html>
<head>
<title>test</title>
</head>
<body>
<p>hello, world!</p>
</body>
</html>
EOB
File.write("#{@epubdir}/META-INF/container.xml", container_xml)
File.write("#{@epubdir}/OEBPS/book.opf", book_opf)
File.write("#{@epubdir}/OEBPS/ch1.xhtml", ch1_xhtml)
end