From e2ca9b57f10843826ea9941fdf3a552f05edf4d2 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sun, 29 Oct 2023 12:40:50 +0800 Subject: [PATCH] Add spec tests for FDroid link inline macro --- spec/fdroid_link_inline_macro_spec.rb | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 spec/fdroid_link_inline_macro_spec.rb diff --git a/spec/fdroid_link_inline_macro_spec.rb b/spec/fdroid_link_inline_macro_spec.rb new file mode 100644 index 0000000..fb94a3c --- /dev/null +++ b/spec/fdroid_link_inline_macro_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +describe FDroidLinkInlineMacro do + it 'should create a FDroid link' do + input = 'fdroid:org.moire.ultrasonic[]' + + expected = <<~RESULT + Ultrasonic + RESULT + + actual = (Asciidoctor.convert input).tr_s '\n', '\n' + (expect actual).to include expected.chomp + end + + it 'should create a FDroid link with replaced caption' do + input = 'fdroid:org.moire.ultrasonic[a Subsonic client]' + + expected = <<~RESULT + a Subsonic client + RESULT + + actual = (Asciidoctor.convert input).tr_s '\n', '\n' + (expect actual).to include expected.chomp + end + + it 'should fail to create a link due to non-existent app' do + input = 'fdroid:com.example.NonExistentAppOrSomething[]' + + expect { Asciidoctor.convert input }.to raise_error StandardError + end + + it 'should fail to create a link due to non-existent app even with replaced caption' do + input = 'fdroid:com.example.NonExistentAppOrSomething[non-existent app]' + + expect { Asciidoctor.convert input }.to raise_error StandardError + end +end