diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2024-03-07 15:48:37 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2024-03-07 15:48:37 -0700 |
| commit | 62ec257cc3eb9ae55f84258a6fceea3179f2282e (patch) | |
| tree | 78c96280f209dfcfd29105edc5f6d409e98c452e | |
| parent | 2baa8147630ec4c89b43e90971d2c7ad92e9bc67 (diff) | |
remove use of base64 library in test suite
| -rw-r--r-- | spec/converter_spec.rb | 6 | ||||
| -rw-r--r-- | spec/cover_page_spec.rb | 4 | ||||
| -rw-r--r-- | spec/image_spec.rb | 10 | ||||
| -rw-r--r-- | spec/page_spec.rb | 4 | ||||
| -rw-r--r-- | spec/running_content_spec.rb | 2 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 1 | ||||
| -rw-r--r-- | spec/title_page_spec.rb | 4 |
7 files changed, 15 insertions, 16 deletions
diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb index 1f379ed1..261f3036 100644 --- a/spec/converter_spec.rb +++ b/spec/converter_spec.rb @@ -142,7 +142,7 @@ describe Asciidoctor::PDF::Converter do it 'should not fail to remove tmp files if already removed' do image_data = File.read (fixture_file 'square.jpg'), mode: 'r:UTF-8' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' doc = Asciidoctor.load <<~EOS, backend: 'pdf' :page-background-image: image:data:image/png;base64,#{encoded_image_data}[Square,fit=cover] EOS @@ -158,7 +158,7 @@ describe Asciidoctor::PDF::Converter do it 'should not fail to remove tmp files if they are not writable' do (expect do image_data = File.read (fixture_file 'square.jpg'), mode: 'r:UTF-8' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' doc = Asciidoctor.load <<~EOS, backend: 'pdf' :page-background-image: image:data:image/png;base64,#{encoded_image_data}[Square,fit=cover] EOS @@ -180,7 +180,7 @@ describe Asciidoctor::PDF::Converter do it 'should keep tmp files if KEEP_ARTIFACTS environment variable is set' do image_data = File.read (fixture_file 'square.jpg'), mode: 'r:UTF-8' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' doc = Asciidoctor.load <<~EOS, backend: 'pdf' :page-background-image: image:data:image/png;base64,#{encoded_image_data}[Square,fit=cover] EOS diff --git a/spec/cover_page_spec.rb b/spec/cover_page_spec.rb index 388ed07e..bd487eb1 100644 --- a/spec/cover_page_spec.rb +++ b/spec/cover_page_spec.rb @@ -35,7 +35,7 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should add front cover page if front-cover-image attribute is set to data URI' do image_data = File.binread fixture_file 'cover.jpg' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' pdf = to_pdf <<~EOS = Document Title :front-cover-image: image:data:image/jpg;base64,#{encoded_image_data}[] @@ -187,7 +187,7 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should add back cover page if back-cover-image attribute is set to data URI' do image_data = File.binread fixture_file 'cover.jpg' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' pdf = to_pdf <<~EOS = Document Title :front-cover-image: image:data:image/jpg;base64,#{encoded_image_data}[] diff --git a/spec/image_spec.rb b/spec/image_spec.rb index 5c6e3087..f6298827 100644 --- a/spec/image_spec.rb +++ b/spec/image_spec.rb @@ -43,7 +43,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should not crash if doctitle contains inline image with data URI target' do image_data = File.binread fixture_file 'square.jpg' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' pdf = to_pdf <<~EOS, analyze: :image = Document Title image:data:image/jpg;base64,#{encoded_image_data}[] @@ -1814,7 +1814,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do context 'Data URI' do it 'should embed block image if target is a JPG data URI' do image_data = File.binread fixture_file 'square.jpg' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' pdf = to_pdf %(image::data:image/jpg;base64,#{encoded_image_data}[]) images = get_images pdf, 1 (expect images).to have_size 1 @@ -1825,14 +1825,14 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should embed block image if target is an SVG data URI' do image_data = File.read (fixture_file 'square.svg'), mode: 'r:UTF-8' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' pdf = to_pdf %(image::data:image/svg+xml;base64,#{encoded_image_data}[]), analyze: :rect (expect pdf.rectangles).to have_size 1 end it 'should embed inline image if target is a JPG data URI' do image_data = File.binread fixture_file 'square.jpg' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' pdf = to_pdf %(image:data:image/jpg;base64,#{encoded_image_data}[] base64) images = get_images pdf, 1 (expect images).to have_size 1 @@ -1843,7 +1843,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should embed inline image if target is an SVG data URI' do image_data = File.read (fixture_file 'square.svg'), mode: 'r:UTF-8' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' pdf = to_pdf %(image:data:image/svg+xml;base64,#{encoded_image_data}[]), analyze: :rect (expect pdf.rectangles).to have_size 1 end diff --git a/spec/page_spec.rb b/spec/page_spec.rb index 52c3f377..6ebf76f6 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -1022,7 +1022,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should use data URI specified by page-background-image attribute as page background', visual: true do image_data = File.binread fixture_file 'square.png' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' to_file = to_pdf_file <<~EOS, %(page-background-image-attr-data-uri.pdf) = Document Title :page-background-image: image:data:image/png;base64,#{encoded_image_data}[fit=fill] @@ -1035,7 +1035,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should use data URI specified in theme as page background', visual: true do image_data = File.binread fixture_file 'square.png' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' pdf_theme = { page_background_image: %(image:data:image/png;base64,#{encoded_image_data}[fit=fill]) } to_file = to_pdf_file <<~EOS, %(page-background-image-attr-data-uri.pdf), pdf_theme: pdf_theme = Document Title diff --git a/spec/running_content_spec.rb b/spec/running_content_spec.rb index ceb504bb..8e1264dd 100644 --- a/spec/running_content_spec.rb +++ b/spec/running_content_spec.rb @@ -3129,7 +3129,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should support data URI image', visual: true do image_data = File.binread fixture_file 'tux.png' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' image_url = %(data:image/png;base64,#{encoded_image_data}) pdf_theme = { footer_columns: '>50% <50%', diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 365cdc6f..4559d7e6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,7 +12,6 @@ when 'true' end require 'asciidoctor/pdf' -require 'base64' require 'fileutils' require 'pathname' require_relative 'spec_helper/ext' diff --git a/spec/title_page_spec.rb b/spec/title_page_spec.rb index 5640dbc9..4adc0970 100644 --- a/spec/title_page_spec.rb +++ b/spec/title_page_spec.rb @@ -230,7 +230,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should add logo specified by title-logo-image document attribute with data URI to title page' do image_data = File.binread fixture_file 'tux.png' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' image_url = %(image:data:image/jpg;base64,#{encoded_image_data}[]) pdf = to_pdf <<~EOS = Document Title @@ -854,7 +854,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should add logo specified by title-logo-image document attribute with data URI to title page' do image_data = File.binread fixture_file 'tux.png' - encoded_image_data = Base64.strict_encode64 image_data + encoded_image_data = [image_data].pack 'm0' image_url = %(image:data:image/jpg;base64,#{encoded_image_data}[]) pdf = to_pdf <<~'EOS', pdf_theme: { title_page_logo_image: image_url } = Document Title |
