test/test_parser_publication.rb in epub-parser-0.0.9.4 vs test/test_parser_publication.rb in epub-parser-0.1.0

- old
+ new

@@ -3,13 +3,14 @@ require 'epub/parser/publication' class TestParserPublication < Test::Unit::TestCase def setup file = 'test/fixtures/book.epub' - root_file = 'OPS/ルートファイル.opf' + rootfile = 'OPS/ルートファイル.opf' @zip = Zip::Archive.open(file) - @parser = EPUB::Parser::Publication.new(@zip, root_file) + opf = @zip.fopen(rootfile).read + @parser = EPUB::Parser::Publication.new(opf, rootfile) @package = @parser.parse_package end def teardown @zip.close @@ -42,12 +43,12 @@ def setup super @manifest = @parser.parse_manifest end - def test_manifest_has_8_items - assert_equal 8, @manifest.items.length + def test_manifest_has_10_items + assert_equal 10, @manifest.items.length end def test_item_has_relative_path_as_iri_attribute assert_equal 'OPS/nav.xhtml', @manifest['nav'].iri.to_s end @@ -133,8 +134,37 @@ def test_reference_refers_item @parser.parse_manifest assert_instance_of EPUB::Publication::Package::Manifest::Item, @guide.cover.item + end + end + + class TestParseBindings < TestParserPublication + def setup + super + @package.manifest = @parser.parse_manifest + @bindings = @parser.parse_bindings + @bindings.package = @package + end + + def test_has_one_bindings + assert @bindings + end + + def test_bindings_has_one_media_type + assert_equal 1, @bindings.media_types.length + end + + def test_media_type_has_media_type_attribute + assert_equal 'application/x-demo-slideshow', @bindings.media_types.first.media_type + end + + def test_media_type_has_handler_attribute + assert_not_nil @bindings.media_types.first.handler + end + + def test_media_type_refers_item_as_handler + assert_kind_of EPUB::Publication::Package::Manifest::Item, @bindings.media_types.first.handler end end end