require "spec_helper"
require "relaton_iso"
require "relaton_ietf"
RSpec.describe Asciidoctor::Standoc do
it "processes simple ISO reference" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
#{NORM_REF_BOILERPLATE}
Standard
ISO 123
ISO
OUTPUT
end
it "processes simple ISO reference with date range" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123:1066-1067]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
#{NORM_REF_BOILERPLATE}
Standard
ISO 123:1066-1067
1066
1067
ISO
OUTPUT
end
it "repairs simple fetched ISO reference" do
mock_isobib_get_123_no_docid
input = <<~"INPUT"
#{ISOBIB_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123]]] _Standard_
INPUT
expect(xmlpp(strip_guid(Asciidoctor.convert(input, backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{BLANK_HDR}
Normative References
#{NORM_REF_BOILERPLATE}
https://www.iso.org/standard/23281.html
https://www.iso.org/obp/ui/#!iso:std:23281:en
https://www.iso.org/contents/data/standard/02/32/23281.detail.rss
2001
International Organization for Standardization
ISO
www.iso.org
3
en
fr
Published
2001
ISO
ISO 123:1985
ISO 123:2001
ISO 123
Standard
OUTPUT
expect { Asciidoctor.convert(input, backend: :standoc, header_footer: true) }.to output(/ERROR: No document identifier retrieved for ISO 123/).to_stderr
end
it "fetches simple ISO reference" do
# mock_isobib_get_123
VCR.use_cassette "isobib_get_123" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ISOBIB_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
#{NORM_REF_BOILERPLATE}
#{Date.today}
Rubber latex
Sampling
Rubber latex – Sampling
Latex de caoutchouc
Échantillonnage
Latex de caoutchouc – Échantillonnage
https://www.iso.org/standard/23281.html
https://www.iso.org/obp/ui/#!iso:std:23281:en
https://www.iso.org/contents/data/standard/02/32/23281.detail.rss
ISO 123:2001
123
2001
International Organization for Standardization
ISO
www.iso.org
3
en
fr
90
93
2001
ISO
ISO 123:1985
OUTPUT
=begin
#{Date.today}
Rubber latex – Sampling
Rubber latex – Sampling
Latex de caoutchouc – Échantillonnage
Latex de caoutchouc – Échantillonnage
https://www.iso.org/standard/23281.html
https://www.iso.org/obp/ui/#!iso:std:23281:en
https://www.iso.org/contents/data/standard/02/32/23281.detail.rss
ISO 123:2001
123
2001
International Organization for Standardization
ISO
www.iso.org
3
en
fr
90
93
2001
ISO
ISO 123:1985
OUTPUT
=end
end
end
it "processes simple IEC reference" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,IEC 123]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
#{NORM_REF_BOILERPLATE}
Standard
IEC 123
IEC
OUTPUT
end
it "processes dated ISO reference and joint ISO/IEC references" do
# mock_isobib_get_iec12382
# mock_isobib_get_124
VCR.use_cassette "dated_iso_ref_joint_iso_iec" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ISOBIB_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO/IEC TR 12382:1992]]] _Standard_
* [[[iso124,ISO 124:2014]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
#{NORM_REF_BOILERPLATE}
#{Date.today}
Permuted index of the vocabulary of information technology
Permuted index of the vocabulary of information technology
Index permuté du vocabulaire des technologies de l’information
Index permuté du vocabulaire des technologies de l’information
https://www.iso.org/standard/21071.html
https://www.iso.org/obp/ui/#!iso:std:21071:en
https://www.iso.org/contents/data/standard/02/10/21071.detail.rss
ISO/IEC TR 12382:1992
12382
1992
International Organization for Standardization
ISO
www.iso.org
International Electrotechnical Commission
IEC
www.iec.ch
2
en
fr
Contains a permuted index of all terms included in the parts 1 – 28 of ISO 2382. If any of these parts has been revised, the present TR refers to the revision.
90
93
1992
ISO/IEC
#{Date.today}
Latex, rubber
Determination of total solids content
Latex, rubber – Determination of total solids content
Latex de caoutchouc
Détermination des matières solides totales
Latex de caoutchouc – Détermination des matières solides totales
https://www.iso.org/standard/61884.html
https://www.iso.org/obp/ui/#!iso:std:61884:en
https://www.iso.org/contents/data/standard/06/18/61884.detail.rss
ISO 124:2014
124
2014
International Organization for Standardization
ISO
www.iso.org
7
en
fr
ISO 124:2014 specifies methods for the determination of the total solids content of natural rubber field and concentrated latices and synthetic rubber latex. These methods are not necessarily suitable for latex from natural sources other than the Hevea brasiliensis, for vulcanized latex, for compounded latex, or for artificial dispersions of rubber.
L’ISO 124:2014 spécifie des méthodes pour la détermination des matières solides totales dans le latex de plantation, le latex de concentré de caoutchouc naturel et le latex de caoutchouc synthétique. Ces méthodes ne conviennent pas nécessairement au latex d’origine naturelle autre que celui de l’Hevea brasiliensis, au latex vulcanisé, aux mélanges de latex, ou aux dispersions artificielles de caoutchouc.
90
93
2014
ISO
ISO 124:2011
OUTPUT
end
end
it "declines to fetch individual references" do
VCR.use_cassette "dated_iso_ref_joint_iso_iec" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ISOBIB_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,nofetch(ISO/IEC TR 12382:1992)]]] _Standard_
* [[[iso124,ISO 124:2014]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
#{NORM_REF_BOILERPLATE}
Standard
ISO/IEC TR 12382:1992
#{Date.today}
Latex, rubber
Determination of total solids content
Latex, rubber – Determination of total solids content
Latex de caoutchouc
Détermination des matières solides totales
Latex de caoutchouc – Détermination des matières solides totales
https://www.iso.org/standard/61884.html
https://www.iso.org/obp/ui/#!iso:std:61884:en
https://www.iso.org/contents/data/standard/06/18/61884.detail.rss
ISO 124:2014
124
2014
International Organization for Standardization
ISO
www.iso.org
7
en
fr
ISO 124:2014 specifies methods for the determination of the total solids content of natural rubber field and concentrated latices and synthetic rubber latex. These methods are not necessarily suitable for latex from natural sources other than the Hevea brasiliensis, for vulcanized latex, for compounded latex, or for artificial dispersions of rubber.
L’ISO 124:2014 spécifie des méthodes pour la détermination des matières solides totales dans le latex de plantation, le latex de concentré de caoutchouc naturel et le latex de caoutchouc synthétique. Ces méthodes ne conviennent pas nécessairement au latex d’origine naturelle autre que celui de l’Hevea brasiliensis, au latex vulcanisé, aux mélanges de latex, ou aux dispersions artificielles de caoutchouc.
90
93
2014
ISO
ISO 124:2011
OUTPUT
end
end
it "processes draft ISO reference" do
#stub_fetch_ref no_year: true, note: "The standard is in press"
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123:--]]] _Standard_
* [[[iso124,ISO 124:—]]]{blank}footnote:[The standard is in press] _Standard_
* [[[iso125,ISO 125:–]]], footnote:[The standard is in press] _Standard_
INPUT
#{BLANK_HDR}
Normative References
#{NORM_REF_BOILERPLATE}
Standard
ISO 123:–
--
ISO
Standard
ISO 124:–
--
ISO
ISO DATE: The standard is in press
Standard
ISO 125:–
--
ISO
ISO DATE: The standard is in press
OUTPUT
end
it "processes all-parts ISO reference" do
#stub_fetch_ref(all_parts: true)
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123:1066 (all parts)]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
#{NORM_REF_BOILERPLATE}
Standard
ISO 123:1066 (all parts)
1066
ISO
all
OUTPUT
end
it "processes RFC reference in Normative References" do
# mock_rfcbib_get_rfc8341
VCR.use_cassette "rfcbib_get_rfc8341" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ISOBIB_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,IETF(RFC 8341)]]], _Standard_
== Clause 4
<>
INPUT
#{BLANK_HDR}
Clause 4
Normative References
#{NORM_REF_BOILERPLATE}
#{Date.today}
Network Configuration Access Control Model
https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8341.xml
https://www.rfc-editor.org/info/rfc8341
RFC 8341
10.17487/RFC8341
2018-03
A. Bierman
IETF
IETF
M. Bjorklund
IETF
IETF
en
The standardization of network configuration interfaces for use with the Network Configuration Protocol (NETCONF) or the RESTCONF protocol requires a structured and secure operating environment that promotes human usability and multi-vendor interoperability. There is a need for standard mechanisms to restrict NETCONF or RESTCONF protocol access for particular users to a preconfigured subset of all available NETCONF or RESTCONF protocol operations and content. This document defines such an access control model.This document obsoletes RFC 6536.
STD
91
RFC
8341
OUTPUT
end
end
it "processes non-ISO reference in Normative References" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,XYZ 123:1066 (all parts)]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
#{NORM_REF_BOILERPLATE}
Standard
XYZ 123:1066 (all parts)
OUTPUT
end
it "processes non-ISO reference in Bibliography" do
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Bibliography
* [[[iso123,2]]] _Standard_
* [[[iso124,(B)]]] _Standard_
* [[[iso125,1]]] _Standard_
* [[[iso126,(A)]]] _Standard_
INPUT
#{BLANK_HDR}
Bibliography
Standard
[1]
Standard
[B]
Standard
[3]
Standard
[A]
OUTPUT
end
it "process ISO reference without an Internet connection" do
expect(RelatonIso::IsoBibliography).to receive(:search).with("ISO 123") do
raise RelatonBib::RequestError.new "getaddrinfo"
end.at_least :once
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
#{ISOBIB_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123]]] _Standard_
INPUT
Document title
en
published
#{Date.today.year}
article
Normative References
#{NORM_REF_BOILERPLATE}
Standard
ISO 123
ISO
OUTPUT
end
private
private
def mock_isobib_get_123
expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", nil, {}) do
IsoBibItem::XMLParser.from_xml(<<~"OUTPUT")
\n Rubber latex -- Sampling\n Latex de caoutchouc -- ?chantillonnage\n https://www.iso.org/standard/23281.html\n https://www.iso.org/obp/ui/#!iso:std:23281:en\n https://www.iso.org/contents/data/standard/02/32/23281.detail.rss\n ISO 123\n \n 2001\n \n \n \n \n International Organization for Standardization\n ISO\n www.iso.org\n \n \n 3\n en\n fr\n \n Published\n \n 2001\n \n \n ISO\n \n \n \n \n \n \n ISO 123:1985\n \n \n \n \n ISO 123:2001\n \n \n
OUTPUT
end
end
def mock_isobib_get_123_no_docid
expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", nil, {:title=>"Standard"}) do
RelatonBib::XMLParser.from_xml(<<~"OUTPUT")
\n https://www.iso.org/standard/23281.html\n https://www.iso.org/obp/ui/#!iso:std:23281:en\n https://www.iso.org/contents/data/standard/02/32/23281.detail.rss\n \n 2001\n \n \n \n \n International Organization for Standardization\n ISO\n www.iso.org\n \n \n 3\n en\n fr\n \n Published\n \n 2001\n \n \n ISO\n \n \n \n \n \n \n ISO 123:1985\n \n \n \n \n ISO 123:2001\n \n \n
OUTPUT
end.exactly(2).times
end
def mock_isobib_get_124
expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 124", "2014", {}) do
IsoBibItem::XMLParser.from_xml(<<~"OUTPUT")
Latex, rubber -- Determination of total solids content
Latex de caoutchouc -- Détermination des matières solides totales
https://www.iso.org/standard/61884.html
https://www.iso.org/obp/ui/#!iso:std:61884:en
https://www.iso.org/contents/data/standard/06/18/61884.detail.rss
ISO 124
2014
International Organization for Standardization
ISO
www.iso.org
7
en
fr
ISO 124:2014 specifies methods for the determination of the total solids content of natural rubber field and concentrated latices and synthetic rubber latex. These methods are not necessarily suitable for latex from natural sources other than the Hevea brasiliensis, for vulcanized latex, for compounded latex, or for artificial dispersions of rubber.
Published
2014
ISO
ISO 124:2011
83.040.10
Latex and raw rubber
OUTPUT
end
end
def mock_isobib_get_iec12382
expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO/IEC TR 12382", "1992", {}) do
IsoBibItem::XMLParser.from_xml(<<~"OUTPUT")
Permuted index of the vocabulary of information technology
Index permuté du vocabulaire des technologies de l'information
https://www.iso.org/standard/21071.html
https://www.iso.org/obp/ui/#!iso:std:21071:en
https://www.iso.org/contents/data/standard/02/10/21071.detail.rss
ISO/IEC 12382
1992
International Organization for Standardization
ISO
www.iso.org
International Electrotechnical Commission
IEC
www.iec.ch
2
en
fr
Contains a permuted index of all terms included in the parts 1 – 28 of ISO 2382. If any of these parts has been revised, the present TR refers to the revision.
Published
1992
ISO/IEC
ISO/IEC TR 12382:1992
35.020
Information technology (IT) in general
01.040.35
Information technology (Vocabularies)
OUTPUT
end
end
def mock_rfcbib_get_rfc8341
expect(IETFBib::RfcBibliography).to receive(:get).with("RFC 8341", nil, {}) do
IsoBibItem::XMLParser.from_xml(<<~"OUTPUT")
Network Configuration Access Control Model
10.17487/RFC8341
RFC 8341
2018
published
OUTPUT
end
end
end