test/test_searcher.rb in epub-parser-0.3.1 vs test/test_searcher.rb in epub-parser-0.3.2

- old
+ new

@@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- require_relative 'helper' require 'epub/searcher' -require 'epub/parser/cfi' +require 'epub/cfi' class TestSearcher < Test::Unit::TestCase class TestPublication < self def setup super @@ -38,11 +38,11 @@ "epubcfi(/6/2!/4/2/2[idid]/4/4/4/2/2)", "epubcfi(/6/2!/4/2/2[idid]/4/4/4/4/2)", "epubcfi(/6/2!/4/2/2[idid]/4/4/4/6/2)", "epubcfi(/6/2!/4/2/2[idid]/4/4/4/8/2)" ], - EPUB::Searcher::Publication.search_element(@package, xpath: './/xhtml:a').collect {|result| result[:location]}.map(&:to_fragment) + EPUB::Searcher::Publication.search_element(@package, xpath: './/xhtml:a').collect {|result| result[:location]}.map(&:to_s) ) end def test_search_element_xpath_with_namespaces assert_equal( @@ -51,11 +51,11 @@ "epubcfi(/6/2!/4/2/2[idid]/4/4/4/2/2)", "epubcfi(/6/2!/4/2/2[idid]/4/4/4/4/2)", "epubcfi(/6/2!/4/2/2[idid]/4/4/4/6/2)", "epubcfi(/6/2!/4/2/2[idid]/4/4/4/8/2)" ], - EPUB::Searcher::Publication.search_element(@package, xpath: './/customnamespace:a', namespaces: {'customnamespace' => 'http://www.w3.org/1999/xhtml'}).collect {|result| result[:location]}.map(&:to_fragment) + EPUB::Searcher::Publication.search_element(@package, xpath: './/customnamespace:a', namespaces: {'customnamespace' => 'http://www.w3.org/1999/xhtml'}).collect {|result| result[:location]}.map(&:to_s) ) end def test_search_element_css_selector assert_equal( @@ -65,17 +65,17 @@ "epubcfi(/6/2!/4/2/2[idid]/4/4/4/2)", "epubcfi(/6/2!/4/2/2[idid]/4/4/4/4)", "epubcfi(/6/2!/4/2/2[idid]/4/4/4/6)", "epubcfi(/6/2!/4/2/2[idid]/4/4/4/8)" ], - EPUB::Searcher::Publication.search_element(@package, css: 'ol > li').collect {|result| result[:location]}.map(&:to_fragment) + EPUB::Searcher::Publication.search_element(@package, css: 'ol > li').collect {|result| result[:location]}.map(&:to_s) ) end class TesetResult < self def test_to_cfi - assert_equal 'epubcfi(/6/2!/4/2/2[idid]/2/4/1,:9,:16)', EPUB::Searcher::Publication.search_text(@package, 'Content').last.to_cfi.to_fragment + assert_equal 'epubcfi(/6/2!/4/2/2[idid]/2/4/1,:9,:16)', EPUB::Searcher::Publication.search_text(@package, 'Content').last.to_cfi.to_s end end end class TestXHTML < self @@ -149,14 +149,14 @@ super @result = EPUB::Searcher::XHTML::Restricted.search_text(@doc, '第二節').first end def test_to_cfi - assert_equal 'epubcfi(/4/2/2[idid]/4/4/4/4/2/1,:0,:3)', @result.to_cfi.to_fragment + assert_equal 'epubcfi(/4/2/2[idid]/4/4/4/4/2/1,:0,:3)', @result.to_cfi.to_s end def test_to_cfi_img - assert_equal 'epubcfi(/4/2/2[idid]/4/4/4/6/2/2)', EPUB::Searcher::XHTML::Restricted.search_text(@doc, '第三節').first.to_cfi.to_fragment + assert_equal 'epubcfi(/4/2/2[idid]/4/4/4/6/2/2)', EPUB::Searcher::XHTML::Restricted.search_text(@doc, '第三節').first.to_cfi.to_s end end end private