summaryrefslogtreecommitdiff
path: root/spec/video_spec.rb
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2020-09-15 23:59:07 -0600
committerDan Allen <dan.j.allen@gmail.com>2020-09-16 02:06:11 -0600
commita57c50ebf0c306495b210c828b8f89601a812719 (patch)
treeffc7b5351c77b035967fe0c88ced45f9128bd83f /spec/video_spec.rb
parent07b581aefbd71904fdad93d676fa1fc7ce3277e5 (diff)
do not crash if Vimeo video is not found (or an error occurs when fetching video metadata)
Diffstat (limited to 'spec/video_spec.rb')
-rw-r--r--spec/video_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/video_spec.rb b/spec/video_spec.rb
index 3eda01ef..9d412663 100644
--- a/spec/video_spec.rb
+++ b/spec/video_spec.rb
@@ -108,5 +108,22 @@ describe 'Asciidoctor::PDF::Converter - Video' do
expected_strings = [%(\u25ba\u00a0), %(https://vimeo.com/#{video_id}), ' ', '(Vimeo video)']
(expect pdf.text.map {|it| it[:string] }).to eql expected_strings
end
+
+ it 'should replace video with link if allow-uri-read attribute is set and video is not found' do
+ video_id = '0'
+ input = %(video::#{video_id}[vimeo])
+
+ pdf = to_pdf input, attribute_overrides: { 'allow-uri-read' => '' }
+
+ annotations = get_annotations pdf, 1
+ (expect annotations).to have_size 1
+ link_annotation = annotations[0]
+ (expect link_annotation[:Subtype]).to be :Link
+ (expect link_annotation[:A][:URI]).to eql %(https://vimeo.com/#{video_id})
+
+ pdf = to_pdf input, attribute_overrides: { 'allow-uri-read' => '' }, analyze: true
+ expected_strings = [%(\u25ba\u00a0), %(https://vimeo.com/#{video_id}), ' ', '(Vimeo video)']
+ (expect pdf.text.map {|it| it[:string] }).to eql expected_strings
+ end
end
end