Sha256: 96229908e1b3cb3de71826a1fbe3bc5f297867f3629badcb8ecfa0086ba0ff14
Contents?: true
Size: 1.28 KB
Versions: 10
Compression:
Stored size: 1.28 KB
Contents
# -*- coding: utf-8 -*- require File.dirname(__FILE__) + '/spec_helper.rb' require 'rubygems' require 'nokogiri' describe GEPUB::Bindings do context 'parse existing opf' do before do @bindings = GEPUB::Package.parse_opf(File.open(File.dirname(__FILE__) + '/fixtures/testdata/test_with_bindings.opf'), '/package.opf').instance_eval{ @bindings } end it 'should be parsed' do @bindings.media_types.size.should == 2 @bindings.media_types[0].handler.should == 'h' @bindings.media_types[0].media_type.should == 'application/x-foreign-type' @bindings.media_types[1].handler.should == 'v' @bindings.media_types[1].media_type.should == 'application/x-other-foreign-type' end end context 'generate new opf' do it 'should generate xml' do bindings = GEPUB::Bindings.new bindings.add('id1', 'application/x-some-type') 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") { bindings.to_xml(xml) } } xml = Nokogiri::XML::Document.parse(builder.to_xml) xml.xpath("//xmlns:mediaType[@handler='id1' and @media-type='application/x-some-type']").size.should == 1 end end end
Version data entries
10 entries across 10 versions & 1 rubygems