summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2020-09-28 23:58:11 -0600
committerDan Allen <dan.j.allen@gmail.com>2020-09-29 14:32:47 -0600
commit1fc3faebfba39fc8d966d2be02b9a67f1bbb4d17 (patch)
tree6a1945cc463f7eeeaa575f129da10d841a8474fa
parent5fd09c0630400fee72d65733385e5e108d142568 (diff)
better group conditional tests
-rw-r--r--spec/cli_spec.rb4
-rw-r--r--spec/image_spec.rb86
2 files changed, 47 insertions, 43 deletions
diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb
index 53ac5d47..5dfcb3f8 100644
--- a/spec/cli_spec.rb
+++ b/spec/cli_spec.rb
@@ -62,8 +62,8 @@ describe 'asciidoctor-pdf' do
run_command asciidoctor_pdf_bin, '-o', '-', (fixture_file 'book.adoc'), out: (to_file = output_file 'book.pdf')
(expect Pathname.new to_file).to exist
(expect { PDF::Reader.new to_file }).not_to raise_exception
- end unless windows? && RUBY_ENGINE == 'jruby'
- end
+ end
+ end unless windows? && RUBY_ENGINE == 'jruby'
context 'pdfmark' do
it 'should generate pdfmark file if pdfmark attribute is set', cli: true do
diff --git a/spec/image_spec.rb b/spec/image_spec.rb
index ec30453c..f82a5fd8 100644
--- a/spec/image_spec.rb
+++ b/spec/image_spec.rb
@@ -780,52 +780,56 @@ describe 'Asciidoctor::PDF::Converter - Image' do
end
context 'BMP' do
- it 'should warn and replace block image with alt text if image format is unsupported' do
- (expect do
- pdf = to_pdf 'image::waterfall.bmp[Waterfall,240]', analyze: true
- (expect pdf.lines).to eql ['[Waterfall] | waterfall.bmp']
- end).to log_message severity: :WARN, message: '~could not embed image'
- end unless defined? GMagick::Image
-
- it 'should embed image if prawn-gmagick is available' do
- pdf = to_pdf 'image::waterfall.bmp[Waterfall,240]', analyze: :image
- (expect pdf.images).to have_size 1
- image = pdf.images[0]
- (expect image[:intrinsic_width]).to eql 240
- (expect image[:width]).to eql 180.0
- end if defined? GMagick::Image
+ if defined? GMagick::Image
+ it 'should embed image if prawn-gmagick is available' do
+ pdf = to_pdf 'image::waterfall.bmp[Waterfall,240]', analyze: :image
+ (expect pdf.images).to have_size 1
+ image = pdf.images[0]
+ (expect image[:intrinsic_width]).to eql 240
+ (expect image[:width]).to eql 180.0
+ end
+ else
+ it 'should warn and replace block image with alt text if image format is unsupported' do
+ (expect do
+ pdf = to_pdf 'image::waterfall.bmp[Waterfall,240]', analyze: true
+ (expect pdf.lines).to eql ['[Waterfall] | waterfall.bmp']
+ end).to log_message severity: :WARN, message: '~could not embed image'
+ end
+ end
end
context 'GIF' do
- it 'should warn and replace block image with alt text if image format is unsupported' do
- (expect do
- pdf = to_pdf 'image::tux.gif[Tux]', analyze: true
- (expect pdf.lines).to eql ['[Tux] | tux.gif']
- end).to log_message severity: :WARN, message: '~GIF image format not supported. Install the prawn-gmagick gem or convert tux.gif to PNG.'
- end unless defined? GMagick::Image
-
- it 'should warn and replace inline image with alt text if image format is unsupported' do
- (expect do
- pdf = to_pdf 'image:tux.gif[Tux,16] is always a good sign.', analyze: true
- (expect pdf.lines).to eql ['[Tux] is always a good sign.']
- end).to log_message severity: :WARN, message: '~GIF image format not supported. Install the prawn-gmagick gem or convert tux.gif to PNG.'
- end unless defined? GMagick::Image
+ if defined? GMagick::Image
+ it 'should embed block image if prawn-gmagick is available' do
+ pdf = to_pdf 'image::tux.gif[Tux]', analyze: :image
+ (expect pdf.images).to have_size 1
+ image = pdf.images[0]
+ (expect image[:intrinsic_width]).to eql 204
+ (expect image[:width]).to eql 153.0
+ end
- it 'should embed block image if prawn-gmagick is available' do
- pdf = to_pdf 'image::tux.gif[Tux]', analyze: :image
- (expect pdf.images).to have_size 1
- image = pdf.images[0]
- (expect image[:intrinsic_width]).to eql 204
- (expect image[:width]).to eql 153.0
- end if defined? GMagick::Image
+ it 'should embed inline image if prawn-gmagick is available' do
+ pdf = to_pdf 'image:tux.gif[Tux,16] is always a good sign.', analyze: :image
+ (expect pdf.images).to have_size 1
+ image = pdf.images[0]
+ (expect image[:intrinsic_width]).to eql 204
+ (expect image[:width]).to eql 12.0
+ end
+ else
+ it 'should warn and replace block image with alt text if image format is unsupported' do
+ (expect do
+ pdf = to_pdf 'image::tux.gif[Tux]', analyze: true
+ (expect pdf.lines).to eql ['[Tux] | tux.gif']
+ end).to log_message severity: :WARN, message: '~GIF image format not supported. Install the prawn-gmagick gem or convert tux.gif to PNG.'
+ end
- it 'should embed inline image if prawn-gmagick is available' do
- pdf = to_pdf 'image:tux.gif[Tux,16] is always a good sign.', analyze: :image
- (expect pdf.images).to have_size 1
- image = pdf.images[0]
- (expect image[:intrinsic_width]).to eql 204
- (expect image[:width]).to eql 12.0
- end if defined? GMagick::Image
+ it 'should warn and replace inline image with alt text if image format is unsupported' do
+ (expect do
+ pdf = to_pdf 'image:tux.gif[Tux,16] is always a good sign.', analyze: true
+ (expect pdf.lines).to eql ['[Tux] is always a good sign.']
+ end).to log_message severity: :WARN, message: '~GIF image format not supported. Install the prawn-gmagick gem or convert tux.gif to PNG.'
+ end
+ end
end
context 'PDF' do