Skip to content

Commit

Permalink
add spec. Close jugyo#4
Browse files Browse the repository at this point in the history
  • Loading branch information
jugyo committed Oct 23, 2010
1 parent f929f84 commit ffbd8ef
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions spec/eeepub/maker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,53 @@

@maker.save('test.epub')
end

describe "files as hash" do
before do
@maker = EeePub::Maker.new do
title 'sample'
creator 'jugyo'
publisher 'jugyo.org'
date "2010-05-06"
language 'en'
subject 'epub sample'
description 'this is epub sample'
rights 'xxx'
relation 'xxx'
identifier 'http://example.com/book/foo', :scheme => 'URL'
uid 'http://example.com/book/foo'
ncx_file 'toc.ncx'
opf_file 'content.opf'
files [{:dir => 'foo', :path => 'foo.html'}, {:dir => 'bar', :path => 'bar.html'}]
nav [
{:label => '1. foo', :content => 'foo.html'},
{:label => '1. bar', :content => 'bar.html'}
]
end
end

it 'should save' do
stub(FileUtils).cp.with_any_args
stub(FileUtils).mkdir_p.with_any_args
mock(Dir).mktmpdir {|i| i.call('/tmp')}
mock(EeePub::NCX).new.with_any_args { stub!.save }
mock(EeePub::OPF).new(
:title => ["sample"],
:creator => ["jugyo"],
:date => ["2010-05-06"],
:language => ['en'],
:subject => ['epub sample'],
:description => ['this is epub sample'],
:rights => ['xxx'],
:relation => ['xxx'],
:ncx => "toc.ncx",
:publisher => ["jugyo.org"],
:identifier => [{:value => "http://example.com/book/foo", :scheme => "URL"}],
:manifest => ["foo/foo.html", "bar/bar.html"]
) { stub!.save }
mock(EeePub::OCF).new.with_any_args { stub!.save }

@maker.save('test.epub')
end
end
end

0 comments on commit ffbd8ef

Please sign in to comment.