Sha256: a6f02fbe00400c99c57851f6eb88935209a8ed5200e9d54023561ba3b8b22f31

Contents?: true

Size: 1.45 KB

Versions: 6

Compression:

Stored size: 1.45 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

require 'tmpdir'
require 'fileutils'

describe "EeePub::OCF" do
  before do
    @tmpdir = File.join(Dir.tmpdir, 'eeepub_test')
    FileUtils.mkdir_p(@tmpdir)
    @container = EeePub::OCF::Container.new('foo.opf')
    @ocf = EeePub::OCF.new(:dir => @tmpdir, :container => @container)
  end

  after do
    FileUtils.rm_rf(@tmpdir)
  end

  it 'should return rootfiles' do
    @container.rootfiles.should == [{:full_path => 'foo.opf', :media_type => 'application/oebps-package+xml'}]
  end

  it 'should specify container as String' do
    ocf = EeePub::OCF.new(:dir => @tmpdir, :container => 'foo.opf')
    ocf.container.rootfiles == [{:full_path => 'foo.opf', :media_type => 'application/oebps-package+xml'}]
  end

  it 'should make xml' do
    doc  = Nokogiri::XML(@container.to_xml)
    rootfiles = doc.at('rootfiles')
    rootfiles.should_not be_nil
    rootfiles.search('rootfile').each_with_index do |rootfile, index|
      expect = @container.rootfiles[index]
      rootfile.attribute('full-path').value.should == expect[:full_path]
      rootfile.attribute('media-type').value.should == expect[:media_type]
    end
  end

  it 'should make epub' do
    output_path = File.join('eeepub_test.epub')
    @ocf.save(output_path)
    File.exists?(output_path)
  end

  it 'should stream epub' do
    pending
    output = @ocf.render
    output.size.should == 134
    output.is_binary_data?.should be_true
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
eeepub3-0.0.1 spec/eeepub/ocf_spec.rb
eeepub-with-cover-support-0.8.8 spec/eeepub/ocf_spec.rb
eeepub-0.8.1 spec/eeepub/ocf_spec.rb
eeepub-with-cover-support-0.8.7 spec/eeepub/ocf_spec.rb
eeepub-with-cover-support-0.8.6 spec/eeepub/ocf_spec.rb
eeepub-0.8.0 spec/eeepub/ocf_spec.rb