Skip to content

Commit

Permalink
add additional test for Asciidoctor Diagram integration
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Jan 8, 2025
1 parent df85b99 commit b736f9a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/diagram_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit b736f9a

Please sign in to comment.