test/test_content_document.rb in epub-parser-0.1.4 vs test/test_content_document.rb in epub-parser-0.1.5

- old
+ new

@@ -1,5 +1,6 @@ +# -*- coding: utf-8 -*- require_relative 'helper' class TestContentDocument < Test::Unit::TestCase include EPUB::ContentDocument @@ -26,7 +27,27 @@ assert_true doc.top_level? doc = XHTML.new doc.item = item2 assert_false doc.top_level? + end + + def test_read_returns_content_document_as_string + item = stub + stub(item).read {'content'} + content_doc = XHTML.new + content_doc.item = item + assert_equal 'content', content_doc.read + end + + def test_title_returns_value_of_title_element + content_doc = XHTML.new + stub(content_doc).read {File.read(File.join(File.dirname(__FILE__), 'fixtures', 'book', 'OPS', '日本語.xhtml'))} + assert_equal '日本語', content_doc.title + end + + def test_title_returns_empty_string_when_title_element_not_exist + content_doc = XHTML.new + stub(content_doc).read {'content'} + assert_equal '', content_doc.title end end