summaryrefslogtreecommitdiff
path: root/spec/admonition_spec.rb
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2020-08-17 17:57:08 -0600
committerGitHub <noreply@github.com>2020-08-17 17:57:08 -0600
commit80c227be932f8964ff0311e705e1c3e07c7a3d89 (patch)
tree14a99f6ae910fba8e7951016e6d481917564a09c /spec/admonition_spec.rb
parent959ef0189e4a58237957aa48f6716e36f74c9b06 (diff)
resolves #1741 show textual label on admonition if icon image fails to embed (PR #1748)
Diffstat (limited to 'spec/admonition_spec.rb')
-rw-r--r--spec/admonition_spec.rb33
1 files changed, 27 insertions, 6 deletions
diff --git a/spec/admonition_spec.rb b/spec/admonition_spec.rb
index 9ba4deed..4be60f1a 100644
--- a/spec/admonition_spec.rb
+++ b/spec/admonition_spec.rb
@@ -464,9 +464,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do
end).to log_message severity: :WARN, message: %(admonition icon not found or not readable: #{fixture_file 'warning.svg'})
end
- it 'should warn if SVG icon specified by icon attribute cannot be embedded' do
+ it 'should warn and fall back to admonition label if SVG icon specified by icon attribute cannot be embedded' do
(expect do
- pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: :rect
+ pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true
:icons: font
:icontype: svg
@@ -475,7 +475,26 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do
Use the icon attribute to customize the image for an admonition block.
====
EOS
- (expect pdf.rectangles).to be_empty
+ label_text = pdf.find_unique_text 'TIP'
+ (expect label_text).not_to be_nil
+ (expect label_text[:font_name]).to include 'Bold'
+ end).to log_message severity: :WARN, message: %(~could not embed admonition icon: #{fixture_file 'broken.svg'}; Missing end tag for 'rect')
+ end
+
+ it 'should resize fallback admonition label to fit in available space if icon fails to embed' do
+ (expect do
+ pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true
+ :icons: font
+ :icontype: svg
+
+ [WARNING,icon=broken]
+ ====
+ Use the icon attribute to customize the image for an admonition block.
+ ====
+ EOS
+ label_text = pdf.find_unique_text 'WARNING'
+ (expect label_text).not_to be_nil
+ (expect label_text[:font_size]).to be < 10.5
end).to log_message severity: :WARN, message: %(~could not embed admonition icon: #{fixture_file 'broken.svg'}; Missing end tag for 'rect')
end
@@ -495,9 +514,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do
end).to log_message severity: :WARN, message: %(admonition icon not found or not readable: #{fixture_file 'warning.png'})
end
- it 'should warn if raster icon specified by icon attribute cannot be embedded' do
+ it 'should warn and fall back to admonition label if raster icon specified by icon attribute cannot be embedded' do
(expect do
- pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: :image
+ pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true
:icons:
[TIP,icon=corrupt.png]
@@ -505,7 +524,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do
Use the icon attribute to customize the image for an admonition block.
====
EOS
- (expect pdf.images).to be_empty
+ label_text = pdf.find_unique_text 'TIP'
+ (expect label_text).not_to be_nil
+ (expect label_text[:font_name]).to include 'Bold'
end).to log_message severity: :WARN, message: %(~could not embed admonition icon: #{fixture_file 'corrupt.png'}; image file is an unrecognised format)
end