diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/converter_spec.rb | 36 | ||||
| -rw-r--r-- | spec/fixtures/author/book-multiple-authors.adoc | 5 | ||||
| -rw-r--r-- | spec/fixtures/author/book-no-author.adoc | 4 | ||||
| -rw-r--r-- | spec/fixtures/author/book-one-author.adoc | 6 | ||||
| -rw-r--r-- | spec/fixtures/author/chapter.adoc | 1 |
5 files changed, 52 insertions, 0 deletions
diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb index a818791..7f1f4e4 100644 --- a/spec/converter_spec.rb +++ b/spec/converter_spec.rb @@ -96,5 +96,41 @@ describe Asciidoctor::Epub3::Converter do expect(chapter).not_to be_nil expect(chapter.content).to include '<p>Hello</p>' end + + it 'adds no book authors if there are none' do + book, = to_epub 'author/book-no-author.adoc' + expect(book.creator).to be_nil + expect(book.creator_list.size).to eq(0) + end + + it 'adds a single book author' do + book, = to_epub 'author/book-one-author.adoc' + expect(book.creator).not_to be_nil + expect(book.creator.content).to eq('Author One') + expect(book.creator.role.content).to eq('aut') + expect(book.creator_list.size).to eq(1) + end + + it 'adds multiple book authors' do + book, = to_epub 'author/book-multiple-authors.adoc' + expect(book.metadata.creator).not_to be_nil + expect(book.metadata.creator.content).to eq('Author One') + expect(book.metadata.creator.role.content).to eq('aut') + expect(book.creator_list.size).to eq(2) + expect(book.metadata.creator_list[0].content).to eq('Author One') + expect(book.metadata.creator_list[1].content).to eq('Author Two') + end + + it 'adds the publisher if both publisher and producer are defined' do + book, = to_epub 'author/book-one-author.adoc' + expect(book.publisher).not_to be_nil + expect(book.publisher.content).to eq('MyPublisher') + end + + it 'adds the producer as publisher if no publisher is defined' do + book, = to_epub 'author/book-no-author.adoc' + expect(book.publisher).not_to be_nil + expect(book.publisher.content).to eq('MyProducer') + end end end diff --git a/spec/fixtures/author/book-multiple-authors.adoc b/spec/fixtures/author/book-multiple-authors.adoc new file mode 100644 index 0000000..e65f597 --- /dev/null +++ b/spec/fixtures/author/book-multiple-authors.adoc @@ -0,0 +1,5 @@ += Minimal book +Author One; Author Two +:doctype: book + +include::chapter.adoc[leveloffset=+1] diff --git a/spec/fixtures/author/book-no-author.adoc b/spec/fixtures/author/book-no-author.adoc new file mode 100644 index 0000000..12ea080 --- /dev/null +++ b/spec/fixtures/author/book-no-author.adoc @@ -0,0 +1,4 @@ += Minimal book +:doctype: book +:producer: MyProducer +include::chapter.adoc[leveloffset=+1] diff --git a/spec/fixtures/author/book-one-author.adoc b/spec/fixtures/author/book-one-author.adoc new file mode 100644 index 0000000..be076a0 --- /dev/null +++ b/spec/fixtures/author/book-one-author.adoc @@ -0,0 +1,6 @@ += Minimal book +Author One +:doctype: book +:publisher: MyPublisher +:producer: MyProducer +include::chapter.adoc[leveloffset=+1] diff --git a/spec/fixtures/author/chapter.adoc b/spec/fixtures/author/chapter.adoc new file mode 100644 index 0000000..31b7fa2 --- /dev/null +++ b/spec/fixtures/author/chapter.adoc @@ -0,0 +1 @@ += Chapter |
