require "spec_helper"
RSpec.describe Metanorma::ISO do
it "processes amendment sections" do
input = <<~INPUT
#{AMD_BLANK_HDR}
== Foreword
Text
== Introduction
=== Introduction Subsection
== Scope
Text
== Acknowledgements
== Normative References
== Terms and Definitions
=== Term1
== Terms, Definitions, Symbols and Abbreviated Terms
=== Normal Terms
==== Term2
=== Symbols and Abbreviated Terms
== Symbols and Abbreviated Terms
== Clause 4
=== Introduction
=== Clause 4.2
== Terms and Definitions
[appendix]
== Annex
=== Annex A.1
[%appendix]
=== Appendix 1
== Bibliography
=== Bibliography Subsection
INPUT
output = <<~OUTPUT
#{BLANK_HDR.sub(%r{standard}, 'amendment')}
Foreword
Text
Introduction
Introduction Subsection
Scope
Text
Acknowledgements
Normative References
Terms and Definitions
Term1
Terms, Definitions, Symbols and Abbreviated Terms
Normal Terms
Term2
Symbols and Abbreviated Terms
Symbols and Abbreviated Terms
Clause 4
Introduction
Clause 4.2
Terms and Definitions
Bibliography
Bibliography Subsection
Annex
Annex A.1
Appendix 1
OUTPUT
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to xmlpp(output)
end
it "processes default metadata, amendment" do
input = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:no-isobib:
:docnumber: 17301
:partnumber: 1
:edition: 2
:revdate: 2000-01-01
:draft: 0.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
:docstage: 10
:docsubstage: 20
:iteration: 3
:language: en
:title-intro-en: Introduction
:title-main-en: Main Title -- Title
:title-part-en: Title Part
:title-intro-fr: Introduction Française
:title-main-fr: Titre Principal
:title-part-fr: Part du Titre
:library-ics: 1,2,3
:copyright-year: 2017
:updates: ISO 17301-1:2016
:created-date: 2016-05-01
:amendment-number: 1
:title-amendment-en: Mass fraction of extraneous matter, milled rice (nonglutinous), sample dividers and recommendations relating to storage and transport conditions
:title-amendment-fr: Fraction massique de matière étrangère, riz usiné (non gluant), diviseurs d’échantillon et recommandations relatives aux conditions d’entreposage et de transport
:doctype: amendment
:updates-document-type: international-standard
INPUT
output = <<~OUTPUT
Introduction — Main Title — Title — Title Part — Mass fraction of
extraneous matter, milled rice (nonglutinous), sample dividers and
recommendations relating to storage and transport conditions
Introduction
Main Title — Title
Title Part
Mass fraction of extraneous matter, milled rice (nonglutinous), sample
dividers and recommendations relating to storage and transport conditions
Introduction Française — Titre Principal — Part du Titre — Fraction
massique de matière étrangère, riz usiné (non gluant), diviseurs
d’échantillon et recommandations relatives aux conditions d’entreposage et
de transport
Introduction Française
Titre Principal
Part du Titre
Fraction massique de matière étrangère, riz usiné (non gluant), diviseurs
d’échantillon et recommandations relatives aux conditions d’entreposage et
de transport
ISO 17301-1:2016/PreNP Amd 1
ISO 17301-1/PreNP Amd 1
ISO 17301-1:2016/PreNP Amd 1(E)
ISO 17301-1:2016/PreNP Amd 1:2017(E)
17301
2016-05-01
International Organization for Standardization
ISO
International Organization for Standardization
ISO
2
2000-01-01
0.3.4
en
10
20
3
2017
International Organization for Standardization
ISO
amendment
ISO
TC
TC1
SC
SC1
WG
WG1
SECRETARIAT
ISO
TC
TC1
SC
SC1
WG
WG1
1
2
3
17301
New work item proposal
international-standard
OUTPUT
expect(xmlpp(input.sub(%r{.*}m, "")))
.to be_equivalent_to xmlpp(output)
end
it "processes metadata, amendment, stage 30" do
input = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:no-isobib:
:docnumber: 17301
:partnumber: 1
:doctype: amendment
:docstage: 30
:updates: ISO 17301-1:2030
:amendment-number: 1
INPUT
output = <<~OUTPUT
ISO 17301-1:2030/CD Amd 1
ISO 17301-1/CD Amd 1
ISO 17301-1:2030/CD Amd 1(E)
ISO 17301-1:2030/CD Amd 1(E)
17301
International Organization for Standardization
ISO
International Organization for Standardization
ISO
en
30
00
#{Time.now.year}
International Organization for Standardization
ISO
amendment
ISO
ISO
17301
Committee draft
OUTPUT
expect(xmlpp(input.sub(%r{.*}m, "")))
.to be_equivalent_to xmlpp(output)
end
it "processes metadata, amendment, stage 40" do
input = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:no-isobib:
:docnumber: 17301
:partnumber: 1
:doctype: amendment
:docstage: 40
:updates: ISO 17301-1:2030
:amendment-number: 1
INPUT
output = <<~OUTPUT
ISO 17301-1:2030/DAmd 1
ISO 17301-1/DAmd 1
ISO 17301-1:2030/DAmd 1(E)
ISO 17301-1:2030/DAmd 1(E)
17301
International Organization for Standardization
ISO
International Organization for Standardization
ISO
en
40
00
#{Time.now.year}
International Organization for Standardization
ISO
amendment
ISO
ISO
17301
Draft
OUTPUT
expect(xmlpp(input.sub(%r{.*}m, "")))
.to be_equivalent_to xmlpp(output)
end
it "processes metadata, amendment, published" do
input = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:no-isobib:
:docnumber: 17301
:partnumber: 1
:doctype: amendment
:updates: ISO 17301-1:2030
:amendment-number: 1
INPUT
output = <<~OUTPUT
ISO 17301-1:2030/Amd 1
ISO 17301-1/Amd 1
ISO 17301-1:2030/Amd 1(E)
ISO 17301-1:2030/Amd 1(E)
17301
International Organization for Standardization
ISO
International Organization for Standardization
ISO
en
60
60
#{Time.now.year}
International Organization for Standardization
ISO
amendment
ISO
ISO
17301
International standard
OUTPUT
expect(xmlpp(input.sub(%r{.*}m, "")))
.to be_equivalent_to xmlpp(output)
end
it "processes metadata, corrigendum, stage 30" do
input = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:no-isobib:
:docnumber: 17301
:partnumber: 1
:doctype: technical-corrigendum
:docstage: 30
:updates: ISO 17301-1:2030
:corrigendum-number: 3
INPUT
output = <<~OUTPUT
ISO 17301-1:2030/CD Cor.3
ISO 17301-1/CD Cor.3
ISO 17301-1:2030/CD Cor.3(E)
ISO 17301-1:2030/CD Cor.3(E)
17301
International Organization for Standardization
ISO
International Organization for Standardization
ISO
en
30
00
#{Time.now.year}
International Organization for Standardization
ISO
technical-corrigendum
ISO
ISO
17301
Committee draft
OUTPUT
expect(xmlpp(input.sub(%r{.*}m, "")))
.to be_equivalent_to xmlpp(output)
end
it "processes metadata, corrigendum, stage 50" do
input = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:no-isobib:
:docnumber: 17301
:partnumber: 1
:doctype: technical-corrigendum
:docstage: 50
:updates: ISO 17301-1:2030
:corrigendum-number: 3
INPUT
output = <<~OUTPUT
ISO 17301-1:2030/FDCor.3
ISO 17301-1/FDCor.3
ISO 17301-1:2030/FDCor.3(E)
ISO 17301-1:2030/FDCor.3(E)
17301
International Organization for Standardization
ISO
International Organization for Standardization
ISO
en
50
00
#{Time.now.year}
International Organization for Standardization
ISO
technical-corrigendum
ISO
ISO
17301
Final draft
OUTPUT
expect(xmlpp(input.sub(%r{.*}m, "")))
.to be_equivalent_to xmlpp(output)
end
it "processes metadata, corrigendum, published" do
input = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:no-isobib:
:docnumber: 17301
:partnumber: 1
:doctype: technical-corrigendum
:updates: ISO 17301-1:2030
:corrigendum-number: 3
INPUT
output = <<~OUTPUT
ISO 17301-1:2030/Cor.3
ISO 17301-1/Cor.3
ISO 17301-1:2030/Cor.3(E)
ISO 17301-1:2030/Cor.3(E)
17301
International Organization for Standardization
ISO
International Organization for Standardization
ISO
en
60
60
#{Time.now.year}
International Organization for Standardization
ISO
technical-corrigendum
ISO
ISO
17301
International standard
OUTPUT
expect(xmlpp(input.sub(%r{.*}m, "")))
.to be_equivalent_to xmlpp(output)
end
end