diff options
| -rw-r--r-- | spec/break_spec.rb | 18 | ||||
| -rw-r--r-- | spec/cover_page_spec.rb | 2 | ||||
| -rw-r--r-- | spec/document_title_spec.rb | 14 | ||||
| -rw-r--r-- | spec/footnote_spec.rb | 12 | ||||
| -rw-r--r-- | spec/image_spec.rb | 16 | ||||
| -rw-r--r-- | spec/index_spec.rb | 14 | ||||
| -rw-r--r-- | spec/link_spec.rb | 2 | ||||
| -rw-r--r-- | spec/list_spec.rb | 12 | ||||
| -rw-r--r-- | spec/outline_spec.rb | 18 | ||||
| -rw-r--r-- | spec/page_spec.rb | 14 | ||||
| -rw-r--r-- | spec/paragraph_spec.rb | 6 | ||||
| -rw-r--r-- | spec/preamble_spec.rb | 34 | ||||
| -rw-r--r-- | spec/running_content_spec.rb | 6 | ||||
| -rw-r--r-- | spec/source_spec.rb | 4 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 5 | ||||
| -rw-r--r-- | spec/table_spec.rb | 14 | ||||
| -rw-r--r-- | spec/text_formatter_spec.rb | 16 | ||||
| -rw-r--r-- | spec/toc_spec.rb | 24 | ||||
| -rw-r--r-- | spec/video_spec.rb | 4 |
19 files changed, 120 insertions, 115 deletions
diff --git a/spec/break_spec.rb b/spec/break_spec.rb index e0759cdd..d9c8440d 100644 --- a/spec/break_spec.rb +++ b/spec/break_spec.rb @@ -40,8 +40,8 @@ describe 'Asciidoctor::PDF::Converter - Break' do after_text = (pdf.find_text 'after')[0] pdf = to_pdf input, analyze: :line - (expect pdf.widths.size).to eql 1 - (expect pdf.points.size).to eql 2 + (expect pdf.widths).to have_size 1 + (expect pdf.points).to have_size 2 (expect pdf.widths[0]).to eql 0.5 (expect pdf.points[0][1]).to be < before_text[:y] (expect pdf.points[0][1]).to be > after_text[:y] @@ -58,7 +58,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do bar EOS - (expect pdf.pages.size).to eql 2 + (expect pdf.pages).to have_size 2 (expect pdf.pages[0][:strings]).to include 'foo' (expect pdf.pages[1][:strings]).to include 'bar' end @@ -70,7 +70,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do foo EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 end it 'should not leave blank page at the end of document' do @@ -80,7 +80,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do <<< EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 end it 'should change layout if page break specifies page-layout attribute' do @@ -94,7 +94,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do EOS text = pdf.text - (expect text.size).to eql 2 + (expect text).to have_size 2 (expect text[0].values_at :string, :page_number, :x, :y).to eq ['portrait', 1, 48.24, 793.926] (expect text[1].values_at :string, :page_number, :x, :y).to eq ['landscape', 2, 48.24, 547.316] end @@ -110,7 +110,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do EOS text = pdf.text - (expect text.size).to eql 2 + (expect text).to have_size 2 (expect text[0].values_at :string, :page_number, :x, :y).to eq ['portrait', 1, 48.24, 793.926] (expect text[1].values_at :string, :page_number, :x, :y).to eq ['landscape', 2, 48.24, 547.316] end @@ -136,14 +136,14 @@ describe 'Asciidoctor::PDF::Converter - Break' do EOS portrait_text = pdf.find_text 'portrait' - (expect portrait_text.size).to eql 2 + (expect portrait_text).to have_size 2 portrait_text.each do |text| page = pdf.page text[:page_number] (expect page[:size]).to eql PDF::Core::PageGeometry::SIZES['A4'] end landscape_text = pdf.find_text 'landscape' - (expect landscape_text.size).to eql 2 + (expect landscape_text).to have_size 2 landscape_text.each do |text| page = pdf.page text[:page_number] (expect page[:size]).to eql PDF::Core::PageGeometry::SIZES['A4'].reverse diff --git a/spec/cover_page_spec.rb b/spec/cover_page_spec.rb index d20588aa..e2ddd950 100644 --- a/spec/cover_page_spec.rb +++ b/spec/cover_page_spec.rb @@ -10,7 +10,7 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do content page EOS - (expect pdf.pages.size).to eql 3 + (expect pdf.pages).to have_size 3 (expect pdf.pages[0][:text]).to be_empty end diff --git a/spec/document_title_spec.rb b/spec/document_title_spec.rb index f233fa0b..0507112b 100644 --- a/spec/document_title_spec.rb +++ b/spec/document_title_spec.rb @@ -9,14 +9,14 @@ describe 'Asciidoctor::PDF::Converter - Document Title' do body EOS - (expect pdf.pages.size).to eql 2 + (expect pdf.pages).to have_size 2 text = pdf.text - (expect text.size).to eql 2 - (expect pdf.pages[0][:text].size).to eql 1 + (expect text).to have_size 2 + (expect pdf.pages[0][:text]).to have_size 1 doctitle_text = pdf.pages[0][:text][0] (expect doctitle_text[:string]).to eql 'Document Title' (expect doctitle_text[:font_size]).to eql 27 - (expect pdf.pages[1][:text].size).to eql 1 + (expect pdf.pages[1][:text]).to have_size 1 end it 'should not include title page if notitle attribute is set' do @@ -26,7 +26,7 @@ describe 'Asciidoctor::PDF::Converter - Document Title' do body EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:strings]).to_not include 'Document Title' end @@ -122,7 +122,7 @@ describe 'Asciidoctor::PDF::Converter - Document Title' do body EOS - (expect pdf.pages.size).to eql 2 + (expect pdf.pages).to have_size 2 (expect pdf.pages[0][:strings]).to include 'Document Title' (expect pdf.pages[1][:strings]).to include 'body' end @@ -134,7 +134,7 @@ describe 'Asciidoctor::PDF::Converter - Document Title' do body EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:strings]).to_not include 'Document Title' end end diff --git a/spec/footnote_spec.rb b/spec/footnote_spec.rb index 88a2b19c..bf0d4058 100644 --- a/spec/footnote_spec.rb +++ b/spec/footnote_spec.rb @@ -19,13 +19,13 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do (expect text[2][:font_size]).to be < text[1][:font_size] (expect text[3][:font_color]).to eql '428BCA' # superscript group - (expect (text.slice 2, 3).map {|it| [it[:y], it[:font_size]] }.uniq.size).to eql 1 + (expect (text.slice 2, 3).map {|it| [it[:y], it[:font_size]] }.uniq).to have_size 1 # footnote item (expect (strings.slice 6, 3).join).to eql '[1] More about that thing.' (expect text[6][:y]).to be < text[5][:y] (expect text[6][:page_number]).to eql 1 (expect text[6][:font_size]).to eql 8 - (expect (text.slice 6, 3).map {|it| [it[:y], it[:font_size]] }.uniq.size).to eql 1 + (expect (text.slice 6, 3).map {|it| [it[:y], it[:font_size]] }.uniq).to have_size 1 # next chapter (expect text[9][:page_number]).to eql 2 end @@ -50,7 +50,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do (expect text[2][:font_size]).to be < text[1][:font_size] (expect text[3][:font_color]).to eql '428BCA' # superscript group - (expect (text.slice 2, 3).map {|it| [it[:y], it[:font_size]] }.uniq.size).to eql 1 + (expect (text.slice 2, 3).map {|it| [it[:y], it[:font_size]] }.uniq).to have_size 1 (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] @@ -112,9 +112,9 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do (expect combined_text).to include '[1] money' (expect combined_text).to include 'Make it snow.[2]' (expect combined_text).to include '[2] dollar bills' - (expect (combined_text.scan '[1]').length).to eql 2 - (expect (combined_text.scan '[2]').length).to eql 2 - (expect (combined_text.scan '[3]').length).to eql 0 + (expect combined_text.scan '[1]').to have_size 2 + (expect combined_text.scan '[2]').to have_size 2 + (expect combined_text.scan '[3]').to be_empty end it 'should allow a bibliography ref to be used inside the text of a footnote' do diff --git a/spec/image_spec.rb b/spec/image_spec.rb index 4ca74c50..11e8c9fc 100644 --- a/spec/image_spec.rb +++ b/spec/image_spec.rb @@ -18,7 +18,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do (expect pdf.lines).to eql ['[Missing Image] | no-such-image.png'] if logger - (expect logger.messages.size).to eql 1 + (expect logger.messages).to have_size 1 (expect logger.messages[0][:severity]).to eql :WARN (expect logger.messages[0][:message]).to include 'image to embed not found or not readable' end @@ -41,7 +41,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do (expect pdf.lines).to eql ['You cannot see that which is [not there].'] if logger - (expect logger.messages.size).to eql 1 + (expect logger.messages).to have_size 1 (expect logger.messages[0][:severity]).to eql :WARN (expect logger.messages[0][:message]).to include 'image to embed not found or not readable' end @@ -61,14 +61,14 @@ describe 'Asciidoctor::PDF::Converter - Image' do EOS pdf = to_pdf input, analyze: :rect - (expect pdf.rectangles.size).to eql 1 + (expect pdf.rectangles).to have_size 1 (expect pdf.rectangles[0][:point]).to eql [0.0, 200.0] (expect pdf.rectangles[0][:width]).to eql 200.0 (expect pdf.rectangles[0][:height]).to eql 200.0 pdf = to_pdf input, analyze: true text = pdf.text - (expect text.size).to eql 1 + (expect text).to have_size 1 (expect text[0][:string]).to eql 'after' (expect text[0][:y]).to eql 176.036 end @@ -84,14 +84,14 @@ describe 'Asciidoctor::PDF::Converter - Image' do EOS pdf = to_pdf input, analyze: :rect - (expect pdf.rectangles.size).to eql 1 + (expect pdf.rectangles).to have_size 1 (expect pdf.rectangles[0][:point]).to eql [0.0, 200.0] (expect pdf.rectangles[0][:width]).to eql 200.0 (expect pdf.rectangles[0][:height]).to eql 200.0 pdf = to_pdf input, analyze: true text = pdf.text - (expect text.size).to eql 1 + (expect text).to have_size 1 (expect text[0][:string]).to eql 'after' (expect text[0][:y]).to eql 276.036 end @@ -116,7 +116,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do (expect pdf.lines).to eql ['[Waterfall] | waterfall.bmp'] if logger - (expect logger.messages.size).to eql 1 + (expect logger.messages).to have_size 1 (expect logger.messages[0][:severity]).to eql :WARN (expect logger.messages[0][:message]).to include 'could not embed image' end @@ -135,7 +135,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do EOS pages = pdf.pages - (expect pages.size).to eql 3 + (expect pages).to have_size 3 (expect pages[0][:size]).to eql PDF::Core::PageGeometry::SIZES['A4'] (expect pages[0][:text][-1][:string]).to eql '1' (expect pages[1][:size]).to eql PDF::Core::PageGeometry::SIZES['LETTER'] diff --git a/spec/index_spec.rb b/spec/index_spec.rb index 7b4160f6..817d84d7 100644 --- a/spec/index_spec.rb +++ b/spec/index_spec.rb @@ -30,15 +30,15 @@ describe 'Asciidoctor::PDF::Converter - Index' do EOS index_text = pdf.find_text string: 'Index', page_number: 4, font_size: 22 - (expect index_text.size).to eql 1 + (expect index_text).to have_size 1 category_c_text = pdf.find_text string: 'C', page_number: 4 - (expect category_c_text.size).to eql 1 + (expect category_c_text).to have_size 1 (expect category_c_text[0][:font_name].downcase).to include 'bold' category_d_text = pdf.find_text string: 'D', page_number: 4 - (expect category_d_text.size).to eql 1 + (expect category_d_text).to have_size 1 (expect category_d_text[0][:font_name].downcase).to include 'bold' category_k_text = pdf.find_text string: 'K', page_number: 4 - (expect category_k_text.size).to eql 1 + (expect category_k_text).to have_size 1 (expect category_k_text[0][:font_name].downcase).to include 'bold' (expect (pdf.lines pdf.find_text page_number: 4).join ?\n).to eql <<~'EOS'.chomp Index @@ -72,9 +72,9 @@ describe 'Asciidoctor::PDF::Converter - Index' do EOS index_text = pdf.find_text string: 'Chapter 3. Index', page_number: 4 - (expect index_text.size).to eql 0 + (expect index_text).to be_empty index_text = pdf.find_text string: 'Index', page_number: 4 - (expect index_text.size).to eql 1 + (expect index_text).to have_size 1 end it 'should generate anchor names for indexterms which are reproducible between runs' do @@ -115,7 +115,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do EOS category_c_text = pdf.find_text string: 'C', page_number: 3 - (expect category_c_text.size).to eql 1 + (expect category_c_text).to have_size 1 (expect category_c_text[0][:font_name].downcase).to include 'bold' category_b_text = pdf.find_text string: 'B', page_number: 3 (expect category_b_text).to be_empty diff --git a/spec/link_spec.rb b/spec/link_spec.rb index fc48eea3..4c185d69 100644 --- a/spec/link_spec.rb +++ b/spec/link_spec.rb @@ -5,7 +5,7 @@ describe 'Asciidoctor::PDF::Converter - Link' do input = 'The home page for Asciidoctor is located at https://asciidoctor.org.' pdf = to_pdf input annotations = get_annotations pdf, 1 - (expect annotations.size).to eql 1 + (expect annotations).to have_size 1 link_annotation = annotations[0] (expect link_annotation[:Subtype]).to eql :Link (expect link_annotation[:A][:URI]).to eql 'https://asciidoctor.org' diff --git a/spec/list_spec.rb b/spec/list_spec.rb index f41039c3..d54f17c0 100644 --- a/spec/list_spec.rb +++ b/spec/list_spec.rb @@ -46,8 +46,8 @@ describe 'Asciidoctor::PDF::Converter - List' do (expect pdf.lines[1..-1]).to eql %w(wood hammer nail) left_margin = pdf.text[0][:x] indents = pdf.text[1..-1].map {|it| it[:x] } - (expect indents.size).to eql 3 - (expect indents.uniq.size).to eql 1 + (expect indents).to have_size 3 + (expect indents.uniq).to have_size 1 (expect indents[0]).to be > left_margin end @@ -65,7 +65,7 @@ describe 'Asciidoctor::PDF::Converter - List' do * none EOS - (expect pdf.text.size).to eql 4 + (expect pdf.text).to have_size 4 left_margin = (pdf.find_text 'reference')[0][:x] unstyled_item = (pdf.find_text 'unstyled')[0] (expect unstyled_item[:x]).to eql left_margin @@ -170,8 +170,8 @@ describe 'Asciidoctor::PDF::Converter - List' do (expect pdf.lines[1..-1]).to eql %w(one two three) left_margin = pdf.text[0][:x] indents = pdf.text[1..-1].map {|it| it[:x] } - (expect indents.size).to eql 3 - (expect indents.uniq.size).to eql 1 + (expect indents).to have_size 3 + (expect indents.uniq).to have_size 1 (expect indents[0]).to be > left_margin end @@ -192,7 +192,7 @@ describe 'Asciidoctor::PDF::Converter - List' do . none EOS - (expect pdf.text.size).to eql 5 + (expect pdf.text).to have_size 5 left_margin = (pdf.find_text 'reference')[0][:x] unstyled_item = (pdf.find_text 'unstyled')[0] (expect unstyled_item[:x]).to eql left_margin diff --git a/spec/outline_spec.rb b/spec/outline_spec.rb index d4c8796d..a30c83ae 100644 --- a/spec/outline_spec.rb +++ b/spec/outline_spec.rb @@ -15,15 +15,15 @@ describe 'Asciidoctor::PDF::Converter - Outline' do EOS outline = extract_outline pdf - (expect outline.size).to eql 4 + (expect outline).to have_size 4 (expect outline[0][:title]).to eql 'Document Title' (expect outline[0][:dest][:pagenum]).to eql 1 (expect outline[0][:dest][:top]).to be true - (expect outline[0][:children].size).to eql 0 + (expect outline[0][:children]).to be_empty (expect outline[1][:title]).to eql 'First Chapter' (expect outline[1][:dest][:pagenum]).to eql 2 (expect outline[1][:dest][:top]).to be true - (expect outline[1][:children].size).to eql 1 + (expect outline[1][:children]).to have_size 1 (expect outline[1][:children][0][:title]).to eql 'Chapter Section' (expect outline[1][:children][0][:dest][:pagenum]).to eql 2 (expect outline[1][:children][0][:dest][:top]).to be false @@ -36,7 +36,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do (expect outline[3][:title]).to eql 'Last Chapter' (expect outline[3][:dest][:pagenum]).to eql 4 (expect outline[3][:dest][:top]).to be true - (expect outline[3][:children].size).to eql 0 + (expect outline[3][:children]).to be_empty end it 'should limit outline depth according to value of toclevels attribute' do @@ -54,7 +54,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do EOS outline = extract_outline pdf - (expect outline.size).to eql 4 + (expect outline).to have_size 4 (expect outline[1][:title]).to eq 'First Chapter' (expect outline[1][:children]).to be_empty end @@ -77,7 +77,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do EOS outline = extract_outline pdf - (expect outline.size).to eql 4 + (expect outline).to have_size 4 (expect outline[1][:title]).to eq 'First Chapter' (expect outline[1][:children]).not_to be_empty (expect outline[1][:children][0][:title]).to eq 'Chapter Section' @@ -102,7 +102,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do EOS outline = extract_outline pdf - (expect outline.size).to eql 4 + (expect outline).to have_size 4 (expect outline[1][:title]).to eq 'First Chapter' (expect outline[1][:children]).to be_empty end @@ -115,7 +115,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do EOS outline = extract_outline pdf - (expect outline.size).to eql 2 + (expect outline).to have_size 2 (expect outline[0][:title]).to eql 'Document Title' (expect outline[1][:title]).to eql 'First Chapter' end @@ -128,7 +128,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do EOS outline = extract_outline pdf - (expect outline.size).to eql 2 + (expect outline).to have_size 2 (expect outline[0][:title]).to eql %(ACME\u2122 Catalog <\u2116 1>) (expect outline[1][:title]).to eql %(Paper Clips \u2116 4) end diff --git a/spec/page_spec.rb b/spec/page_spec.rb index 020c160b..8bc0a7cc 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -6,7 +6,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do pdf = to_pdf <<~'EOS', analyze: :page content EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size]).to eql PDF::Core::PageGeometry::SIZES['A4'] end @@ -16,7 +16,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do content EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size]).to eql PDF::Core::PageGeometry::SIZES['LETTER'] end @@ -26,7 +26,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do content EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size]).to eql [600.0, 800.0] end @@ -36,7 +36,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do content EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size]).to eql PDF::Core::PageGeometry::SIZES['LETTER'] end @@ -46,7 +46,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do content EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size]).to eql PDF::Core::PageGeometry::SIZES['LETTER'] end end @@ -56,7 +56,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do pdf = to_pdf <<~'EOS' content EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 (expect pdf.pages[0].orientation).to eql 'portrait' end @@ -66,7 +66,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do content EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 (expect pdf.pages[0].orientation).to eql 'landscape' end end diff --git a/spec/paragraph_spec.rb b/spec/paragraph_spec.rb index 33176a4b..c7c33645 100644 --- a/spec/paragraph_spec.rb +++ b/spec/paragraph_spec.rb @@ -8,7 +8,7 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do Making all his nowhere plans\tfor nobody. EOS text = pdf.text - (expect text.size).to eql 1 + (expect text).to have_size 1 (expect text).not_to include ' ' (expect text).not_to include ?\t (expect text).not_to include ?\n @@ -24,7 +24,7 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do All your base are belong to us. EOS - (expect pdf.text.size).to eql 4 + (expect pdf.text).to have_size 4 (expect pdf.text[0][:x]).to be > pdf.text[1][:x] (expect pdf.text[2][:x]).to be > pdf.text[3][:x] end @@ -39,7 +39,7 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do EOS line_spacing = 1.upto(3).map {|i| (pdf.text[i - 1][:y] - pdf.text[i][:y]).round 2 }.uniq - (expect line_spacing.size).to eql 1 + (expect line_spacing).to have_size 1 (expect line_spacing[0]).to eql 15.78 (expect pdf.text[0][:x]).to be > pdf.text[1][:x] (expect pdf.text[2][:x]).to be > pdf.text[3][:x] diff --git a/spec/preamble_spec.rb b/spec/preamble_spec.rb index f5d43856..d9ad0675 100644 --- a/spec/preamble_spec.rb +++ b/spec/preamble_spec.rb @@ -10,10 +10,10 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do EOS first_paragraph_text = pdf.find_text 'first paragraph' - (expect first_paragraph_text.size).to eql 1 + (expect first_paragraph_text).to have_size 1 (expect first_paragraph_text[0][:font_size]).to eql 10.5 second_paragraph_text = pdf.find_text 'first paragraph' - (expect second_paragraph_text.size).to eql 1 + (expect second_paragraph_text).to have_size 1 (expect second_paragraph_text[0][:font_size]).to eql 10.5 end @@ -27,10 +27,10 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do EOS first_paragraph_text = pdf.find_text 'first paragraph' - (expect first_paragraph_text.size).to eql 1 + (expect first_paragraph_text).to have_size 1 (expect first_paragraph_text[0][:font_size]).to eql 10.5 second_paragraph_text = pdf.find_text 'first paragraph' - (expect second_paragraph_text.size).to eql 1 + (expect second_paragraph_text).to have_size 1 (expect second_paragraph_text[0][:font_size]).to eql 10.5 end @@ -48,13 +48,13 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do EOS preamble_text = pdf.find_text 'preamble content' - (expect preamble_text.size).to eql 1 + (expect preamble_text).to have_size 1 (expect preamble_text[0][:font_size]).to eql 13 more_preamble_text = pdf.find_text 'more preamble content' - (expect more_preamble_text.size).to eql 1 + (expect more_preamble_text).to have_size 1 (expect more_preamble_text[0][:font_size]).to eql 10.5 section_text = pdf.find_text 'section content' - (expect section_text.size).to eql 1 + (expect section_text).to have_size 1 (expect section_text[0][:font_size]).to eql 10.5 end end @@ -68,10 +68,10 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do EOS first_paragraph_text = pdf.find_text 'first paragraph' - (expect first_paragraph_text.size).to eql 1 + (expect first_paragraph_text).to have_size 1 (expect first_paragraph_text[0][:font_size]).to eql 10.5 second_paragraph_text = pdf.find_text 'first paragraph' - (expect second_paragraph_text.size).to eql 1 + (expect second_paragraph_text).to have_size 1 (expect second_paragraph_text[0][:font_size]).to eql 10.5 end @@ -85,10 +85,10 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do EOS first_paragraph_text = pdf.find_text 'first paragraph' - (expect first_paragraph_text.size).to eql 1 + (expect first_paragraph_text).to have_size 1 (expect first_paragraph_text[0][:font_size]).to eql 10.5 second_paragraph_text = pdf.find_text 'first paragraph' - (expect second_paragraph_text.size).to eql 1 + (expect second_paragraph_text).to have_size 1 (expect second_paragraph_text[0][:font_size]).to eql 10.5 end @@ -106,13 +106,13 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do EOS preamble_text = pdf.find_text 'preamble content' - (expect preamble_text.size).to eql 1 + (expect preamble_text).to have_size 1 (expect preamble_text[0][:font_size]).to eql 13 more_preamble_text = pdf.find_text 'more preamble content' - (expect more_preamble_text.size).to eql 1 + (expect more_preamble_text).to have_size 1 (expect more_preamble_text[0][:font_size]).to eql 10.5 section_text = pdf.find_text 'section content' - (expect section_text.size).to eql 1 + (expect section_text).to have_size 1 (expect section_text[0][:font_size]).to eql 10.5 end @@ -128,12 +128,12 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do section content EOS - (expect (pdf.find_text string: 'Preface', page_number: 2, font_size: 22).size).to eql 1 + (expect pdf.find_text string: 'Preface', page_number: 2, font_size: 22).to have_size 1 preamble_text = pdf.find_text 'preamble content' - (expect preamble_text.size).to eql 1 + (expect preamble_text).to have_size 1 (expect preamble_text[0][:font_size]).to eql 10.5 section_text = pdf.find_text 'section content' - (expect section_text.size).to eql 1 + (expect section_text).to have_size 1 (expect section_text[0][:font_size]).to eql 10.5 end end diff --git a/spec/running_content_spec.rb b/spec/running_content_spec.rb index 15a2ce17..72588323 100644 --- a/spec/running_content_spec.rb +++ b/spec/running_content_spec.rb @@ -24,9 +24,9 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do expected_page_numbers = %w(1 2 3 4) expected_x_positions = [541.009, 49.24] - (expect pdf.pages.size).to eql 5 + (expect pdf.pages).to have_size 5 page_number_texts = pdf.find_text %r/^\d+$/ - (expect page_number_texts.size).to eql expected_page_numbers.size + (expect page_number_texts).to have_size expected_page_numbers.size page_number_texts.each_with_index do |page_number_text, idx| (expect page_number_text[:page_number]).to eql idx + 2 (expect page_number_text[:x]).to eql expected_x_positions[idx.even? ? 0 : 1] @@ -196,7 +196,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do page_height = pdf.pages[0][:size][1] header_texts = pdf.find_text '(Document Title)' - (expect header_texts.size).to be expected_page_numbers.size + (expect header_texts).to have_size expected_page_numbers.size expected_page_numbers.each_with_index do |page_number, idx| (expect header_texts[idx][:string]).to eql '(Document Title)' (expect header_texts[idx][:page_number]).to eql page_number.to_i + 1 diff --git a/spec/source_spec.rb b/spec/source_spec.rb index 87c32ebe..86aa7641 100644 --- a/spec/source_spec.rb +++ b/spec/source_spec.rb @@ -53,7 +53,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do (expect year_text[:font_color]).to eql '0000DD' else text = pdf.text - (expect text.size).to eql 1 + (expect text).to have_size 1 (expect text[0][:string]).to eql 'cal_days_in_month(CAL_GREGORIAN, 6, 2019)' (expect text[0][:font_color]).to eql '333333' end @@ -70,7 +70,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do EOS text = pdf.text - (expect text.size).to eql 1 + (expect text).to have_size 1 (expect text[0][:string]).to eql 'cal_days_in_month(CAL_GREGORIAN, 6, 2019)' (expect text[0][:font_color]).to eql '333333' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8d51fff6..b1af20a4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -348,6 +348,11 @@ RSpec.configure do |config| end 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}) } +end + RSpec::Matchers.define :visually_match do |reference_filename| reference_path = (Pathname.new reference_filename).absolute? ? reference_filename : (File.join __dir__, 'reference', reference_filename) match do |actual_path| diff --git a/spec/table_spec.rb b/spec/table_spec.rb index 94b41100..7052f2a2 100644 --- a/spec/table_spec.rb +++ b/spec/table_spec.rb @@ -10,7 +10,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== EOS - (expect pdf.points.size).to eql 32 + (expect pdf.points).to have_size 32 end it 'should allow frame and grid to be specified on table using frame and grid attributes' do @@ -22,7 +22,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== EOS - (expect pdf.points.size).to eql 16 + (expect pdf.points).to have_size 16 end it 'should treat topbot value of frame attribute as an alias for ends' do @@ -42,7 +42,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== EOS - (expect pdf_a.points.size).to eql pdf_b.points.size + (expect pdf_a.points).to have_size pdf_b.points.size end it 'should allow frame and grid to be set globally using table-frame and table-grid attributes' do @@ -56,7 +56,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== EOS - (expect pdf.points.size).to eql 16 + (expect pdf.points).to have_size 16 end if asciidoctor_2_or_better? it 'should apply stripes to specified group of rows as specified by stripes attribute', integration: true do @@ -248,10 +248,10 @@ describe 'Asciidoctor::PDF::Converter - Table' do cell_1_text = pdf.find_text 'all one line' (expect cell_1_text).not_to be_empty cell_2_text = pdf.find_text %r/^line (?:1|2)/ - (expect cell_2_text.size).to eql 2 + (expect cell_2_text).to have_size 2 (expect cell_2_text[0][:y]).to be > cell_2_text[1][:y] cell_3_text = pdf.find_text %r/^paragraph (?:1|2)/ - (expect cell_3_text.size).to eql 2 + (expect cell_3_text).to have_size 2 (expect cell_3_text[0][:y]).to be > cell_3_text[1][:y] (expect cell_3_text[0][:y] - cell_3_text[1][:y]).to be > (cell_2_text[0][:y] - cell_2_text[1][:y]) end @@ -290,7 +290,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do EOS (expect pdf.lines.find {|l| l.include? '!' }).to be_nil - (expect pdf.lines.size).to eql 2 + (expect pdf.lines).to have_size 2 (expect pdf.lines[1]).to eql 'Nested table cell 1Nested table cell 2' nested_cell_1 = (pdf.find_text 'Nested table cell 1')[0] nested_cell_2 = (pdf.find_text 'Nested table cell 2')[0] diff --git a/spec/text_formatter_spec.rb b/spec/text_formatter_spec.rb index f07f0a47..7a940c01 100644 --- a/spec/text_formatter_spec.rb +++ b/spec/text_formatter_spec.rb @@ -4,7 +4,7 @@ describe Asciidoctor::PDF::FormattedText::Formatter do context 'HTML markup' do it 'should format strong text' do output = subject.format '<strong>strong</strong>' - (expect output.size).to eql 1 + (expect output).to have_size 1 (expect output[0][:text]).to eql 'strong' (expect output[0][:styles]).to eql [:bold].to_set end @@ -13,19 +13,19 @@ describe Asciidoctor::PDF::FormattedText::Formatter do context 'character references' do it 'should decode decimal character reference' do output = subject.format '©' - (expect output.size).to eql 1 + (expect output).to have_size 1 (expect output[0][:text]).to eql ?\u00a9 end it 'should decode hexadecimal character reference' do output = subject.format '©' - (expect output.size).to eql 1 + (expect output).to have_size 1 (expect output[0][:text]).to eql ?\u00a9 end it 'should decode recognized named entities' do output = subject.format '< > & ' "' - (expect output.size).to eql 1 + (expect output).to have_size 1 (expect output[0][:text]).to eql %(< > & ' \u00a0 ") end @@ -33,24 +33,24 @@ describe Asciidoctor::PDF::FormattedText::Formatter do with_memory_logger do |logger| output = subject.format '†' if logger - (expect logger.messages.size).to eql 1 + (expect logger.messages).to have_size 1 (expect logger.messages[0][:severity]).to eql :ERROR (expect logger.messages[0][:message]).to include 'failed to parse formatted text' end - (expect output.size).to eql 1 + (expect output).to have_size 1 (expect output[0][:text]).to eql '†' end end it 'should decode decimal character references in link href' do output = subject.format '<a href="https://cast.you?v=999999&list=abcde&index=1">My Playlist</a>' - (expect output.size).to eql 1 + (expect output).to have_size 1 (expect output[0][:link]).to eql 'https://cast.you?v=999999&list=abcde&index=1' end it 'should decode hexidecimal character references in link href' do output = subject.format '<a href="https://cast.you?v=999999&list=abcde&index=1">My Playlist</a>' - (expect output.size).to eql 1 + (expect output).to have_size 1 (expect output[0][:link]).to eql 'https://cast.you?v=999999&list=abcde&index=1' end end diff --git a/spec/toc_spec.rb b/spec/toc_spec.rb index ea10fcd8..65d77f03 100644 --- a/spec/toc_spec.rb +++ b/spec/toc_spec.rb @@ -12,7 +12,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Conclusion EOS - (expect pdf.pages.size).to eql 4 + (expect pdf.pages).to have_size 4 (expect pdf.find_text 'Table of Contents').to be_empty end @@ -27,7 +27,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Conclusion EOS - (expect pdf.pages.size).to eql 5 + (expect pdf.pages).to have_size 5 (expect pdf.find_text string: 'Document Title', page_number: 1).not_to be_empty (expect pdf.find_text string: 'Table of Contents', page_number: 2).not_to be_empty (expect pdf.find_text string: '1', page_number: 2).not_to be_empty @@ -50,7 +50,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do [{ 'toc' => '' }, { 'toc' => '', 'preface-title' => 'Preface' }].each do |attrs| pdf = to_pdf input, doctype: :book, attributes: attrs, analyze: :page - (expect pdf.pages.size).to eql 4 + (expect pdf.pages).to have_size 4 (expect pdf.pages[0][:strings]).to include 'Document Title' (expect pdf.pages[1][:strings]).to include 'Table of Contents' if attrs.include? 'preface-title' @@ -82,7 +82,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do ==== Level 3 EOS - (expect pdf.pages.size).to eql 3 + (expect pdf.pages).to have_size 3 (expect pdf.pages[0][:strings]).to include 'Document Title' (expect pdf.pages[1][:strings]).to include 'Table of Contents' (expect pdf.pages[1][:strings]).to include 'Level 1' @@ -105,7 +105,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Chapter B EOS - (expect pdf.pages.size).to eql 6 + (expect pdf.pages).to have_size 6 (expect pdf.pages[1][:strings]).to include 'Table of Contents' (expect pdf.pages[1][:strings]).to include 'Part One' (expect pdf.pages[1][:strings]).to include 'Part Two' @@ -121,7 +121,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Chapter 1#{sections.join} EOS - (expect pdf.pages.size).to eql 6 + (expect pdf.pages).to have_size 6 (expect pdf.pages[0][:strings]).to include 'Document Title' (expect pdf.pages[1][:strings]).to include 'Table of Contents' (expect pdf.pages[3][:strings]).to include 'Chapter 1' @@ -139,7 +139,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Conclusion EOS - (expect pdf.pages.size).to eql 1 + (expect pdf.pages).to have_size 1 (expect pdf.find_text 'Table of Contents').to be_empty end @@ -164,9 +164,9 @@ describe 'Asciidoctor::PDF::Converter - TOC' do #{lorem} EOS pdf = to_pdf input, analyze: true - (expect pdf.pages.size).to eql 2 - (expect (pdf.find_text string: 'Table of Contents', page_number: 1).size).to eql 1 - (expect (pdf.find_text string: 'Introduction', page_number: 1).size).to eql 2 + (expect pdf.pages).to have_size 2 + (expect pdf.find_text string: 'Table of Contents', page_number: 1).to have_size 1 + (expect pdf.find_text string: 'Introduction', page_number: 1).to have_size 2 doctitle_text = (pdf.find_text 'Document Title')[0] toc_title_text = (pdf.find_text 'Table of Contents')[0] toc_bottom_text = (pdf.find_text '2')[0] @@ -187,7 +187,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do #{sections.join} EOS pdf = to_pdf input, analyze: :page - (expect pdf.pages.size).to eql 4 + (expect pdf.pages).to have_size 4 (expect pdf.pages[0][:strings]).to include 'Document Title' (expect pdf.pages[0][:strings]).to include 'Table of Contents' (expect pdf.pages[0][:strings]).not_to include 'Section 40' @@ -220,7 +220,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Conclusion EOS - (expect pdf.pages.size).to eql 3 + (expect pdf.pages).to have_size 3 (expect pdf.pages[0][:strings]).to include 'Document Title' (expect pdf.pages[1][:strings]).to include 'Table of Contents' (expect pdf.pages[1][:strings]).to include '1' diff --git a/spec/video_spec.rb b/spec/video_spec.rb index b23edcfb..adc319e5 100644 --- a/spec/video_spec.rb +++ b/spec/video_spec.rb @@ -20,7 +20,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do pdf = PDF::Reader.new to_file annotations = get_annotations pdf, 1 - (expect annotations.size).to eql 1 + (expect annotations).to have_size 1 link_annotation = annotations[0] (expect link_annotation[:Subtype]).to eql :Link (expect link_annotation[:A][:URI]).to eql %(https://www.youtube.com/watch?v=#{video_id}) @@ -37,7 +37,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do pdf = PDF::Reader.new to_file annotations = get_annotations pdf, 1 - (expect annotations.size).to eql 1 + (expect annotations).to have_size 1 link_annotation = annotations[0] (expect link_annotation[:Subtype]).to eql :Link (expect link_annotation[:A][:URI]).to eql %(https://vimeo.com/#{video_id}) |
