Sha256: 40effca39412a499be70c98ca4ec155660c8b2dcc4622cf1f0b6c43b7d2d1012

Contents?: true

Size: 1.7 KB

Versions: 14

Compression:

Stored size: 1.7 KB

Contents

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

describe "EeePub::Easy" do
  before do
    @easy = EeePub::Easy.new do
      title 'sample'
      creator 'jugyo'
      identifier 'http://example.com/book/foo', :scheme => 'URL'
      uid 'http://example.com/book/foo'
    end

    @easy.sections << ['1. foo', <<HTML]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
  <head>
    <title>foo</title>
  </head>
  <body>
    <p>
    foo foo foo foo foo foo
    </p>
  </body>
</html>
HTML

    @easy.sections << ['2. bar', <<HTML]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
  <head>
    <title>bar</title>
  </head>
  <body>
    <p>
    bar bar bar bar bar bar
    </p>
  </body>
</html>
HTML

    @easy.assets << 'image.png'
  end

  it 'spec for prepare' do
    Dir.mktmpdir do |dir|
      mock(FileUtils).cp('image.png', dir)

      @easy.send(:prepare, dir)

      file1 = File.join(dir, 'section_0.html')
      file2 = File.join(dir, 'section_1.html')
      File.exists?(file1).should be_true
      File.exists?(file2).should be_true
      File.read(file1).should == @easy.sections[0][1]
      File.read(file2).should == @easy.sections[1][1]

      @easy.instance_variable_get(:@nav).should == [
        {:label => '1. foo', :content => 'section_0.html'},
        {:label => '2. bar', :content => 'section_1.html'}
      ]

      @easy.instance_variable_get(:@files).should == [file1, file2, 'image.png']
    end
  end
end

Version data entries

14 entries across 14 versions & 6 rubygems

Version Path
eeepub3-0.0.1 spec/eeepub/easy_spec.rb
eeepub-with-cover-support-0.8.8 spec/eeepub/easy_spec.rb
eeepub-0.8.1 spec/eeepub/easy_spec.rb
eeepub-with-cover-support-0.8.7 spec/eeepub/easy_spec.rb
eeepub-with-cover-support-0.8.6 spec/eeepub/easy_spec.rb
eeepub-0.8.0 spec/eeepub/easy_spec.rb
eeepub-0.7.1 spec/eeepub/easy_spec.rb
eeepub-0.7.0 spec/eeepub/easy_spec.rb
walterdavis-eeepub-0.6.3 spec/eeepub/easy_spec.rb
sudothinker-eeepub-0.6.1 spec/eeepub/easy_spec.rb
lyrics-ebook-0.1 lib/eeepub/spec/eeepub/easy_spec.rb
eeepub-0.6.1 spec/eeepub/easy_spec.rb
eeepub-0.6.0 spec/eeepub/easy_spec.rb
eeepub-0.5.1 spec/eeepub/easy_spec.rb