Sha256: f8dba6e7bf5594e7ce0c9b3b9cee1140598b425294850081d61888e799242073

Contents?: true

Size: 1.52 KB

Versions: 24

Compression:

Stored size: 1.52 KB

Contents

# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/spec_helper.rb'
require 'rubygems'
require 'nokogiri'

describe GEPUB::Manifest do
  context 'parse existing opf' do
    before do
      @manifest = GEPUB::Package.parse_opf(File.open(File.dirname(__FILE__) + '/fixtures/testdata/test.opf'), '/package.opf').instance_eval{ @manifest }
    end

    it 'should be parsed' do
      @manifest.item_list.size.should == 9
      @manifest.item_list['ncx'].href.should == 'toc.ncx'
      @manifest.item_list['ncx'].media_type.should == 'application/x-dtbncx+xml'
      @manifest.item_list['cover'].href.should == 'cover/cover.xhtml'
      @manifest.item_list['cover'].media_type.should == 'application/xhtml+xml'
      @manifest.item_list['cover-image'].href.should == 'img/cover.jpg'
      @manifest.item_list['cover-image'].media_type.should == 'image/jpeg'
      @manifest.item_list['cover-image'].properties[0].should == 'cover-image'
    end
  end
  context 'generate new opf' do
    it 'should generate xml' do
      manifest = GEPUB::Manifest.new
      manifest.add_item('ncx', 'toc.ncx', 'application/x-dtbncx+xml')
      builder = Nokogiri::XML::Builder.new { |xml|
        xml.package('xmlns' => "http://www.idpf.org/2007/opf",'version' => "3.0",'unique-identifier' => "pub-id",'xml:lang' => "ja") {
          manifest.to_xml(xml)
        }
      }
      xml = Nokogiri::XML::Document.parse(builder.to_xml)
      xml.xpath("//xmlns:item[@id='ncx' and @href='toc.ncx' and @media-type='application/x-dtbncx+xml']").size.should == 1
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
gepub-0.6.9.1 spec/manifest_spec.rb
gepub-0.6.9.0 spec/manifest_spec.rb
gepub-0.6.8.9 spec/manifest_spec.rb
gepub-0.6.8.8 spec/manifest_spec.rb
gepub-0.6.8.7 spec/manifest_spec.rb
gepub-0.6.8.6 spec/manifest_spec.rb
gepub-0.6.8.5 spec/manifest_spec.rb
gepub-0.6.8.3 spec/manifest_spec.rb
gepub-0.6.8 spec/manifest_spec.rb
gepub-0.6.6 spec/manifest_spec.rb
gepub-0.6.5.2 spec/manifest_spec.rb
gepub-0.6.5.1 spec/manifest_spec.rb
gepub-0.6.4.6 spec/manifest_spec.rb
gepub-0.6.4.5 spec/manifest_spec.rb
gepub-0.6.4.4 spec/manifest_spec.rb
gepub-0.6.4.3 spec/manifest_spec.rb
gepub-0.6.4.2 spec/manifest_spec.rb
gepub-0.6.4.1 spec/manifest_spec.rb
gepub-0.6.4 spec/manifest_spec.rb
gepub-0.6.3.1 spec/manifest_spec.rb