summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2019-05-14 01:03:00 -0600
committerDan Allen <dan.j.allen@gmail.com>2019-05-14 01:03:00 -0600
commitbdcc4a34cb890f746dcb6c6c0dece098cb40da43 (patch)
tree81d17ef7c5c9dba9ce2cd36ee704c342cec4fb08
parent4e1b17a77a52b760aace841d7e6eca6c2da4bca6 (diff)
fix warnings in test suite; enable warnings when running tests
-rw-r--r--spec/footnotes_spec.rb2
-rw-r--r--spec/running_content_spec.rb1
-rw-r--r--spec/spec_helper.rb24
-rw-r--r--tasks/rspec.rake7
4 files changed, 28 insertions, 6 deletions
diff --git a/spec/footnotes_spec.rb b/spec/footnotes_spec.rb
index b0800578..f394db7c 100644
--- a/spec/footnotes_spec.rb
+++ b/spec/footnotes_spec.rb
@@ -54,7 +54,7 @@ describe 'Asciidoctor::PDF::Converter - Footnotes' do
(expect text[2][:font_size]).to be < text[1][:font_size]
# footnote item
(expect (pdf.find_text 'Section B')[0][:order]).to be < (pdf.find_text '] More about that thing.')[0][:order]
- (expect (strings.slice -3, 3).join).to eql '[1] More about that thing.'
+ (expect (strings.slice(-3, 3)).join).to eql '[1] More about that thing.'
(expect text[-1][:page_number]).to eql 2
(expect text[-1][:font_size]).to eql 8
end
diff --git a/spec/running_content_spec.rb b/spec/running_content_spec.rb
index 062d16c4..30e417f4 100644
--- a/spec/running_content_spec.rb
+++ b/spec/running_content_spec.rb
@@ -176,7 +176,6 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do
second page
EOS
- expected_x_positions = [541.009, 49.24]
expected_page_numbers = %w(1 2)
header_texts = pdf.find_text '(Document Title)'
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index f7614696..251dfc70 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -2,7 +2,23 @@ require 'asciidoctor/pdf'
require 'pathname'
require 'pdf/inspector'
-PDF::Reader.prepend(Module.new do
+# NOTE fix warning in Prawn::Font:TTF
+Prawn::Font::TTF.prepend (Module.new do
+ def initialize *args
+ @italic_angle = nil
+ super
+ end
+end)
+
+# NOTE fix warning in TTFunk::Table
+TTFunk::Table.prepend (Module.new do
+ def initialize *args
+ @offset = nil
+ super
+ end
+end)
+
+PDF::Reader.prepend (Module.new do
def source
objects.instance_variable_get :@io
end
@@ -16,7 +32,7 @@ PDF::Reader.prepend(Module.new do
end
end)
-PDF::Inspector::Text.prepend(Module.new do
+PDF::Inspector::Text.prepend (Module.new do
def page= page
@page_number = page.number
super
@@ -150,6 +166,8 @@ RSpec.configure do |config|
line: PDF::Inspector::Graphics::Line,
}).default = EnhancedPDFTextInspector
+ alias :original_to_pdf :to_pdf
+
def to_pdf input, opts = {}
analyze = opts.delete :analyze
opts[:attributes] = 'nofooter' unless opts.key? :attributes
@@ -176,7 +194,7 @@ RSpec.configure do |config|
title = (((title = entry[:Title]).slice 2, title.size).unpack 'n*').pack 'U*'
dest = entry[:Dest]
dest_page_object = objects[dest[0]]
- dest_page = pdf.pages.find {|candidate| candidate.page_object == dest_page_object }
+ dest_page = pages.find {|candidate| candidate.page_object == dest_page_object }
top = dest_page.attributes[:MediaBox][3] == dest[3]
children = entry[:Count] > 0 ? (extract_outline pdf, entry) : []
result << { title: title, dest: { pagenum: dest_page.number, x: dest[2], y: dest[3], top: top }, children: children }
diff --git a/tasks/rspec.rake b/tasks/rspec.rake
index 244d17db..51dfb0bb 100644
--- a/tasks/rspec.rake
+++ b/tasks/rspec.rake
@@ -1,6 +1,11 @@
begin
require 'rspec/core/rake_task'
- RSpec::Core::RakeTask.new :spec
+ RSpec::Core::RakeTask.new :spec do |t|
+ t.verbose = true
+ opts = %w(-f progress)
+ opts.unshift '-w' if !ENV['CI'] || ENV['COVERAGE']
+ t.rspec_opts = opts
+ end
rescue LoadError
warn $!.message
end