require "spec_helper"
RSpec.describe Asciidoctor::Standoc do
it "processes the Asciidoctor::Standoc inline macros" do
expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
alt:[term1]
deprecated:[term1]
domain:[term1]
INPUT
#{BLANK_HDR}
term1term1term1
OUTPUT
end
it "processes the Asciidoctor::Standoc concept macros" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
{{clause1}}
{{clause1,w\[o\]rd}}
{{clause1,w\[o\]rd,term}}
{{blah}}
{{blah,word}}
{{blah,word,term}}
{{blah,clause=3.1}}
{{blah,clause=3.1,word}}
{{blah,clause=3.1,word,term}}
{{blah,clause=3.1,figure=a}}
{{blah,clause=3.1,figure=a,word}}
{{blah,clause=3.1,figure=a,word,term}}
{{IEV:135-13-13}}
{{IEV:135-13-13,word}}
{{IEV:135-13-13,word,term}}
[[clause1]]
== Clause
Terms are defined here
[bibliography]
== Bibliography
* [[[blah,blah]]] _Blah_
INPUT
#{BLANK_HDR}
Foreword
w[o]rdw[o]rdwordword3.13.1
word
3.1
word
3.1a3.1a
word
3.1a
word
wordword
Clause
Terms are defined here
BibliographyBlahblah
OUTPUT
end
it "processes the TODO custom admonition" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
TODO: Note1
[TODO]
====
Note2
====
[TODO]
Note3
INPUT
#{BLANK_HDR}
Note2
Note3
OUTPUT
end
it "generates pseudocode examples, with formatting and initial indentation" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
[pseudocode]
====
*A* +
[smallcap]#B#
_C_
====
INPUT
#{BLANK_HDR}
OUTPUT
end
it "supplies line breaks in pseudocode" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
[pseudocode]
====
A
B
D
E
====
INPUT
#{BLANK_HDR}
OUTPUT
end
it "processes the Ruby markups" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
ruby:楽聖少女[がくせいしょうじょ]
INPUT
#{BLANK_HDR}
楽聖少女
OUTPUT
end
it "processes the PlantUML macro" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).gsub(%r{plantuml/plantuml[^./]+\.}, "plantuml/_."))).to be_equivalent_to xmlpp(<<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
[plantuml]
....
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
....
[plantuml]
....
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
....
[plantuml]
....
@startuml filename
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
....
INPUT
#{BLANK_HDR}
OUTPUT
end
it "processes the PlantUML macro with imagesdir" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).gsub(%r{spec/assets/[^./]+\.}, "spec/assets/_."))).to be_equivalent_to xmlpp(<<~"OUTPUT")
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:no-isobib:
:imagesdir: spec/assets
[plantuml]
....
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
....
INPUT
#{BLANK_HDR}
OUTPUT
end
it "processes the PlantUML macro with PlantUML disabled" do
mock_plantuml_disabled
expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(%r{PlantUML not installed}).to_stderr
#{ASCIIDOC_BLANK_HDR}
[plantuml]
....
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
....
INPUT
mock_plantuml_disabled
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
[plantuml]
....
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
....
INPUT
#{BLANK_HDR}
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
OUTPUT
end
private
def mock_plantuml_disabled
expect(Asciidoctor::Standoc::PlantUMLBlockMacroBackend).to receive(:plantuml_installed?) do
false
end
end
end