require "spec_helper"
require "fileutils"
RSpec.describe Asciidoctor::Standoc do
it "has a version number" do
expect(Metanorma::Standoc::VERSION).not_to be nil
end
it "processes a blank document" do
expect(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
#{ASCIIDOC_BLANK_HDR}
INPUT
#{BLANK_HDR}
OUTPUT
end
it "converts a blank document" do
FileUtils.rm_f "test.doc"
expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
= Document title
Author
:docfile: test.adoc
:novalid:
INPUT
#{BLANK_HDR}
OUTPUT
expect(File.exist?("test.doc")).to be true
expect(File.exist?("htmlstyle.css")).to be false
end
it "processes default metadata" do
expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~'OUTPUT')
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:docnumber: 1000
:partnumber: 1
:edition: 2
:revdate: 2000-01-01
:published-date: 1000-01-01
:accessed-date: 1001-01-01
:created-date: 1002-01-01
:implemented-date: 1003-01-01
:obsoleted-date: 1004-01-01
:confirmed-date: 1005-01-01
:updated-date: 1006-01-01
:issued-date: 1007-01-01
:circulated-date: 1008-01-01
:unchanged-date: 1009-01-01
:date: Fred 1010-01-01
:date_2: Jack 1010-01-01
:draft: 3.4
:technical-committee: TC
:technical-committee-number: 1
:technical-committee-type: A
:subcommittee: SC
:subcommittee-number: 2
:subcommittee-type: B
:workgroup: WG
:workgroup-number: 3
:workgroup-type: C
:technical-committee_2: TC1
:technical-committee-number_2: 11
:technical-committee-type_2: A1
:subcommittee_2: SC1
:subcommittee-number_2: 21
:subcommittee-type_2: B1
:workgroup_2: WG1
:workgroup-number_2: 31
:workgroup-type_2: C1
:secretariat: SECRETARIAT
:copyright-year: 2001
:docstage: 10
:docsubstage: 20
:iteration: 3
:language: en
:title: Main Title -- Title
:library-ics: 1,2,3
:fullname: Fred Flintstone
:role: author
:affiliation: Slate Rock and Gravel Company
:affiliation_abbrev: SRG
:address: 6 Rubble Way, Bedrock
:contributor-uri: http://slate.example.com
:phone: 123
:fax: 456
:surname_2: Rubble
:givenname_2: Barney
:initials_2: B. X.
:role_2: editor
:affiliation_2: Rockhead and Quarry Cave Construction Company
:affiliation_abbrev_2: RQCCC
:address_2: 6A Rubble Way, Bedrock
:email_2: barney@rockhead.example.com
:phone_2: 789
:fax_2: 012
:publisher: Hanna Barbera, Cartoon Network
:part-of: ABC
:translated-from: DEF,GHI;JKL MNO,PQR
:keywords: a, b, c
INPUT
Main Title — Title1000-110001000-01-011001-01-011002-01-011003-01-011004-01-011005-01-011006-01-011007-01-011008-01-011009-01-011010-01-011010-01-01Hanna BarberaCartoon NetworkFred FlintstoneSlate Rock and Gravel CompanySRG6 Rubble Way, Bedrock123456http://slate.example.comBarneyB. X.RubbleRockhead and Quarry Cave Construction CompanyRQCCC6A Rubble Way, Bedrock789012barney@rockhead.example.comHanna BarberaCartoon Network22000-01-013.4en102032001Hanna Barbera2001Cartoon Network--ABCGHIDEFPQRJKL MNOabcarticleTCTC1123
OUTPUT
end
it "processes complex metadata" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:docnumber: 1000
:partnumber: 1-1
:tc-docnumber: 2000
:language: el
:script: Grek
:publisher: IEC,IETF,ISO
:uri: A
:xml-uri: B
:html-uri: C
:pdf-uri: D
:doc-uri: E
:relaton-uri: F
:title-eo: Dokumenttitolo
[abstract]
== Abstract
This is the abstract of the document
This is the second paragraph of the abstract of the document.
[language=en]
== Clause 1
INPUT
Document titleDokumenttitoloABCDEF1000-1-11000IECIETFISOIECIETFISOel
This is the abstract of the document
This is the second paragraph of the abstract of the document.