From b736f9afc24849aeb749651b59430267cced42f6 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Wed, 8 Jan 2025 04:37:36 -0700 Subject: [PATCH] add additional test for Asciidoctor Diagram integration --- spec/diagram_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/diagram_spec.rb b/spec/diagram_spec.rb index 9848c4f51..fd11994b8 100644 --- a/spec/diagram_spec.rb +++ b/spec/diagram_spec.rb @@ -25,6 +25,27 @@ (expect Pathname.new fixture_file 'images/sequence-diagram-b.png.cache').not_to exist end + it 'should be able to control display size of image using pdfwidth attribute on diagram block' do + require 'asciidoctor-diagram' + pdf = to_pdf <<~'EOS', safe: :unsafe, attributes: { 'docdir' => fixtures_dir, 'outdir' => output_dir, 'imagesdir' => 'images' }, analyze: :image + + [plantuml,pdfwidth-test,png,pdfwidth=1in] + .... + scale 4 + start + :Work; + end + .... + EOS + + (expect Pathname.new output_file 'images/pdfwidth-test.png').to exist + images = pdf.images + (expect images).to have_size 1 + image_data = JSON.parse (Pathname.new output_file '.asciidoctor/diagram/pdfwidth-test.png.cache').read + (expect images[0][:intrinsic_width].to_f).to eql image_data['width'].to_f + (expect images[0][:width].to_f).to eql 72.0 + end + it 'should not crash when both Asciidoctor Diagram and pdfmark are active' do require 'asciidoctor-diagram' input_file = Pathname.new fixture_file 'diagrams.adoc'