summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-01-07 17:43:27 +0300
committerGitHub <noreply@github.com>2024-01-07 17:43:27 +0300
commitf4159115829d804dd3276b5e5f730357c88a226a (patch)
treeeceef4aec17aa2c811a5c8ae06cecc7adb955996 /spec
parent47da1c369ca576e7ad30075929f8e4760ba926e7 (diff)
Update rubocop requirement from ~> 1.28.2 to ~> 1.50.2 (#454)
Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.28.2...v1.50.2) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/cli_spec.rb14
-rw-r--r--spec/converter_spec.rb101
-rw-r--r--spec/image_spec.rb4
-rw-r--r--spec/spec_helper.rb23
-rw-r--r--spec/table_spec.rb26
-rw-r--r--spec/xref_spec.rb22
6 files changed, 95 insertions, 95 deletions
diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb
index 86f57ba..fd790a3 100644
--- a/spec/cli_spec.rb
+++ b/spec/cli_spec.rb
@@ -12,15 +12,15 @@ describe 'asciidoctor-epub3' do
it 'exits with 1 when given nonexistent path' do
_, err, res = to_epub Pathname.new('/nonexistent')
expect(res.exitstatus).to eq(1)
- expect(err).to match(/input file \/nonexistent( is)? missing/)
+ expect(err).to match(%r{input file /nonexistent( is)? missing})
end
it 'exits with 1 when epub validation fails with --failure-level=ERROR' do
_, err, res = run_command asciidoctor_epub3_bin,
- '--failure-level=ERROR',
- '-a', 'ebook-validate',
- fixture_file('invalid.adoc').to_s,
- '-o', temp_file('invalid.epub').to_s
+ '--failure-level=ERROR',
+ '-a', 'ebook-validate',
+ fixture_file('invalid.adoc').to_s,
+ '-o', temp_file('invalid.epub').to_s
expect(res.exitstatus).to eq(1)
# Error from epubcheck
expect(err).to include 'ERROR(RSC-012)'
@@ -63,12 +63,12 @@ describe 'asciidoctor-epub3' do
expect(res.exitstatus).to eq(0)
end
- def to_mobi in_file, out_file
+ def to_mobi(in_file, out_file)
skip_unless_has_kindlegen
run_command asciidoctor_epub3_bin, '-a', 'ebook-format=mobi', in_file.to_s, '-o', out_file.to_s
end
- def to_epub in_file, out_file = nil
+ def to_epub(in_file, out_file = nil)
argv = asciidoctor_epub3_bin + ['-a', 'ebook-validate', in_file.to_s]
argv += ['-o', out_file.to_s] unless out_file.nil?
run_command argv
diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb
index 05bb0f1..5590042 100644
--- a/spec/converter_spec.rb
+++ b/spec/converter_spec.rb
@@ -13,13 +13,12 @@ describe Asciidoctor::Epub3::Converter do
end
it 'converts empty heredoc document to epub without exceptions' do
- to_epub <<~EOS
- EOS
+ to_epub ''
end
it 'converts minimal heredoc document to epub without exceptions' do
book = to_epub <<~EOS
- = Title
+ = Title
EOS
expect(book).to be_a(GEPUB::Book)
end
@@ -81,7 +80,7 @@ describe Asciidoctor::Epub3::Converter do
it 'supports quotes in section titles' do
book, = to_epub <<~EOS
-= "Title"
+ = "Title"
EOS
chapter = book.item_by_href '_title.xhtml'
expect(chapter).not_to be_nil
@@ -90,11 +89,11 @@ describe Asciidoctor::Epub3::Converter do
it 'supports section numbers' do
book, = to_epub <<~EOS
-= Title
-:sectnums:
-:doctype: book
+ = Title
+ :sectnums:
+ :doctype: book
-== Chapter
+ == Chapter
EOS
chapter = book.item_by_href '_chapter.xhtml'
expect(chapter).not_to be_nil
@@ -117,7 +116,7 @@ describe Asciidoctor::Epub3::Converter do
it 'populates ebook subject from keywords' do
book, = to_epub fixture_file('keywords/book.adoc')
keywords = book.subject_list.map(&:content)
- expect(keywords).to eq(%w(a b c))
+ expect(keywords).to eq(%w[a b c])
end
it 'adds front matter page with images' do
@@ -167,23 +166,23 @@ describe Asciidoctor::Epub3::Converter do
it 'supports custom epub-chapter-level' do
book = to_epub <<~EOS
-= Book
-:epub-chapter-level: 2
-:doctype: book
+ = Book
+ :epub-chapter-level: 2
+ :doctype: book
-text0
+ text0
-== Level 1
+ == Level 1
-text1
+ text1
-=== Level 2
+ === Level 2
-text2
+ text2
-==== Level 3
+ ==== Level 3
-text3
+ text3
EOS
spine = book.spine.itemref_list
@@ -235,10 +234,10 @@ text3
it 'adds book series metadata' do
book = to_epub <<~EOS
-= Article
-:series-name: My Series
-:series-volume: 42
-:series-id: bla
+ = Article
+ :series-name: My Series
+ :series-volume: 42
+ :series-id: bla
EOS
meta = book.metadata.meta_list[1]
expect(meta).not_to be_nil
@@ -250,10 +249,10 @@ text3
it 'adds toc to spine' do
book = to_epub <<~EOS
-= Title
-:toc:
+ = Title
+ :toc:
-Text
+ Text
EOS
spine = book.spine.itemref_list
expect(spine).to have_size(2)
@@ -264,19 +263,19 @@ Text
it "doesn't crash when sees inline toc" do
to_epub <<~EOS
-= Title
+ = Title
-toc::[]
+ toc::[]
EOS
end
it 'does not crash when sees inline pass macro `m` with an icon' do
to_epub <<~EOS
-= Test
-:icons: font
-:call-to-action: pass:m,q[icon:hand-o-right[] *Call to Action*]
+ = Test
+ :icons: font
+ :call-to-action: pass:m,q[icon:hand-o-right[] *Call to Action*]
-{call-to-action}
+ {call-to-action}
EOS
end
@@ -292,9 +291,9 @@ toc::[]
it 'supports remote video' do
book, = to_epub <<~EOS
-= Article
+ = Article
-video::http://nonexistent/small.webm[]
+ video::http://nonexistent/small.webm[]
EOS
article = book.item_by_href '_article.xhtml'
expect(article).not_to be_nil
@@ -317,9 +316,9 @@ video::http://nonexistent/small.webm[]
it 'supports remote audio' do
book, = to_epub <<~EOS
-= Article
+ = Article
-audio::http://nonexistent/small.mp3[]
+ audio::http://nonexistent/small.mp3[]
EOS
article = book.item_by_href '_article.xhtml'
expect(article).not_to be_nil
@@ -332,27 +331,27 @@ audio::http://nonexistent/small.mp3[]
it 'supports horizontal dlist' do
book = to_epub <<~EOS
-= Article
+ = Article
-[horizontal]
-CPU:: The brain of the computer.
-Hard drive:: Permanent storage for operating system and/or user files.
-RAM:: Temporarily stores information the CPU uses during operation.
+ [horizontal]
+ CPU:: The brain of the computer.
+ Hard drive:: Permanent storage for operating system and/or user files.
+ RAM:: Temporarily stores information the CPU uses during operation.
EOS
chapter = book.item_by_href '_article.xhtml'
expect(chapter).not_to be_nil
expect(chapter.content).to include <<~EOS
-<tr>
-<td class="hdlist1">
-<p>
-CPU
-</p>
-</td>
-<td class="hdlist2">
-<p>The brain of the computer.</p>
-</td>
-</tr>
+ <tr>
+ <td class="hdlist1">
+ <p>
+ CPU
+ </p>
+ </td>
+ <td class="hdlist2">
+ <p>The brain of the computer.</p>
+ </td>
+ </tr>
EOS
end
end
diff --git a/spec/image_spec.rb b/spec/image_spec.rb
index 437c950..f9bd2ea 100644
--- a/spec/image_spec.rb
+++ b/spec/image_spec.rb
@@ -32,12 +32,12 @@ describe 'Asciidoctor::Epub3::Converter - Image' do
it 'does not duplicate images in manifest' do
book, = to_epub fixture_file('inline-image/book.adoc')
- expect(book.items.keys.select {|k| k.include? 'wolpertinger' }.size).to eq(1)
+ expect(book.items.keys.select { |k| k.include? 'wolpertinger' }.size).to eq(1)
end
it 'does not add data-uri images to manifest' do
book, = to_epub fixture_file('inline-image/book.adoc'), attributes: { 'data-uri' => '' }
- expect(book.manifest.items.select {|_, v| v.href.start_with? 'data:' }).to be_empty
+ expect(book.manifest.items.select { |_, v| v.href.start_with? 'data:' }).to be_empty
end
it 'converts font-based icons to CSS' do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 6eac717..941c643 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -13,7 +13,7 @@ RSpec.configure do |config|
FileUtils.rm_r temp_dir, force: true, secure: true
end
- def bin_script name, opts = {}
+ def bin_script(name, opts = {})
path = Gem.bin_path (opts.fetch :gem, 'asciidoctor-epub3'), name
[Gem.ruby, path]
end
@@ -28,7 +28,7 @@ RSpec.configure do |config|
def run_command cmd, *args
Dir.chdir __dir__ do
- if Array === cmd
+ if cmd.is_a?(Array)
args.unshift(*cmd)
cmd = args.shift
end
@@ -67,13 +67,13 @@ RSpec.configure do |config|
skip 'kindlegen gem is unavailable'
end
- def convert input, opts = {}
+ def convert(input, opts = {})
opts[:backend] = 'epub3'
opts[:header_footer] = true
opts[:mkdirs] = true
opts[:safe] = Asciidoctor::SafeMode::UNSAFE unless opts.key? :safe
- if Pathname === input
+ if input.is_a?(Pathname)
opts[:to_dir] = temp_dir.to_s unless opts.key?(:to_dir) || opts.key?(:to_file)
Asciidoctor.convert_file input.to_s, opts
else
@@ -81,15 +81,16 @@ RSpec.configure do |config|
end
end
- def to_epub input, opts = {}
+ def to_epub(input, opts = {})
result = convert input, opts
- return result if GEPUB::Book === result
+ return result if result.is_a?(GEPUB::Book)
+
output = Pathname.new result.attr('outfile')
book = GEPUB::Book.parse output
[book, output]
end
- def to_mobi input, opts = {}
+ def to_mobi(input, opts = {})
skip_unless_has_kindlegen
(opts[:attributes] ||= {})['ebook-format'] = 'mobi'
doc = convert input, opts
@@ -100,11 +101,11 @@ RSpec.configure do |config|
end
RSpec::Matchers.define :have_size do |expected|
- match {|actual| actual.size == expected }
- failure_message {|actual| %(expected #{actual} to have size #{expected}, but was #{actual.size}) }
+ match { |actual| actual.size == expected }
+ failure_message { |actual| %(expected #{actual} to have size #{expected}, but was #{actual.size}) }
end
RSpec::Matchers.define :have_item_with_href do |expected|
- match {|actual| actual.item_by_href expected }
- failure_message {|actual| %(expected '#{actual.title}' to have item with href #{expected}) }
+ match { |actual| actual.item_by_href expected }
+ failure_message { |actual| %(expected '#{actual.title}' to have item with href #{expected}) }
end
diff --git a/spec/table_spec.rb b/spec/table_spec.rb
index ec85d2f..653d9ea 100644
--- a/spec/table_spec.rb
+++ b/spec/table_spec.rb
@@ -5,11 +5,11 @@ require_relative 'spec_helper'
describe 'Asciidoctor::Epub3::Converter - Table' do
it 'supports halign' do
book = to_epub <<~EOS
-= Article
+ = Article
-|===
->| Text
-|===
+ |===
+ >| Text
+ |===
EOS
article = book.item_by_href '_article.xhtml'
expect(article).not_to be_nil
@@ -18,11 +18,11 @@ describe 'Asciidoctor::Epub3::Converter - Table' do
it 'supports valign' do
book = to_epub <<~EOS
-= Article
+ = Article
-|===
-.>| Text
-|===
+ |===
+ .>| Text
+ |===
EOS
article = book.item_by_href '_article.xhtml'
expect(article).not_to be_nil
@@ -31,12 +31,12 @@ describe 'Asciidoctor::Epub3::Converter - Table' do
it 'supports colwidth' do
book = to_epub <<~EOS
-= Article
+ = Article
-[cols="3,1"]
-|===
-| A | B
-|===
+ [cols="3,1"]
+ |===
+ | A | B
+ |===
EOS
article = book.item_by_href '_article.xhtml'
expect(article).not_to be_nil
diff --git a/spec/xref_spec.rb b/spec/xref_spec.rb
index a0fbed4..af3471d 100644
--- a/spec/xref_spec.rb
+++ b/spec/xref_spec.rb
@@ -51,18 +51,18 @@ describe 'Asciidoctor::Epub3::Converter - Xref' do
it 'adds xref id to paragraph' do
book = to_epub <<~EOS
-= Article
+ = Article
-[id=one]
-One
+ [id=one]
+ One
-[[two]]
-Two
+ [[two]]
+ Two
-[#three]
-Three
+ [#three]
+ Three
-More text
+ More text
EOS
article = book.item_by_href '_article.xhtml'
expect(article).not_to be_nil
@@ -73,11 +73,11 @@ More text
it 'displays anchor text' do
book = to_epub <<~EOS
-= Article
+ = Article
-<<_subsection,link text>>
+ <<_subsection,link text>>
-== Subsection
+ == Subsection
EOS
article = book.item_by_href '_article.xhtml'
expect(article).not_to be_nil