From 1e0fe61e5b4779a1a1471e6197b56843a902cc24 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sun, 29 Oct 2023 11:09:44 +0800 Subject: [PATCH] Add spec tests for man inline macro --- spec/man_inline_macro_spec.rb | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 spec/man_inline_macro_spec.rb diff --git a/spec/man_inline_macro_spec.rb b/spec/man_inline_macro_spec.rb new file mode 100644 index 0000000..2c26dfb --- /dev/null +++ b/spec/man_inline_macro_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +describe ManInlineMacro do + it 'should process with the default manpage service' do + input = 'man:ls[1]' + + expected = <<~RESULT + ls(1) + RESULT + + actual = (Asciidoctor.convert input).tr_s '\n', '\n' + (expect actual).to include expected.chomp + end + + it 'should link to the Arch Linux manpage' do + input = 'man:ls[volnum=1, service=arch]' + + expected = <<~RESULT + ls(1) + RESULT + + actual = (Asciidoctor.convert input).tr_s '\n', '\n' + (expect actual).to include expected.chomp + end + + it 'should link to the empty service' do + input = 'man:ls[volnum=1, service=none]' + + expected = '

ls(1)

' + + actual = (Asciidoctor.convert input).tr_s '\n', '\n' + (expect actual).to include expected + end + + it 'should raise an error from non-existent service type' do + input = 'man:ls[volnum=1, service=manpageservicexyz]' + + expect { Asciidoctor.convert input }.to raise_error StandardError + end +end