require "spec_helper"
require "isobib"
require "ietfbib"
RSpec.describe Asciidoctor::ISO do
it "processes simple ISO reference" do
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
Standard
ISO 123
International Organization for Standardization
ISO
OUTPUT
end
it "processes simple ISO reference with date range" do
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123:1066-1067]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
Standard
ISO 123:1066-1067
1066
1067
International Organization for Standardization
ISO
OUTPUT
end
it "fetches simple ISO reference" do
mock_isobib_get_123
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ISOBIB_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
Rubber latex -- Sampling
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
2001
International Organization for Standardization
ISO
www.iso.org
3
en
fr
Published
2001
ISO
ISO 123:1985
ISO 123:2001
OUTPUT
end
it "processes simple IEC reference" do
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,IEC 123]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
Standard
IEC 123
International Electrotechnical Commission
IEC
OUTPUT
end
it "processes dated ISO reference and joint ISO/IEC references" do
mock_isobib_get_iec12382
mock_isobib_get_124
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ISOBIB_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO/IEC TR 12382:1992]]] _Standard_
* [[[iso124,ISO 124:2014]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
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
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)
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
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
it "processes draft ISO reference" do
#stub_fetch_ref no_year: true, note: "The standard is in press"
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123:--]]] footnote:[The standard is in press] _Standard_
INPUT
#{BLANK_HDR}
Normative References
Standard
ISO 123:--
--
International Organization for Standardization
ISO
ISO DATE: The standard is in press
OUTPUT
end
it "processes all-parts ISO reference" do
#stub_fetch_ref(all_parts: true)
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123:1066 (all parts)]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
Standard
ISO 123:1066 (all parts)
1066
International Organization for Standardization
ISO
true
OUTPUT
end
it "processes RFC reference in Normative References" do
mock_rfcbib_get_rfc8341
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ISOBIB_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,IETF(RFC 8341)]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
Network Configuration Access Control Model
RFC 8341
2018
published
OUTPUT
end
it "processes non-ISO reference in Normative References" do
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,XYZ 123:1066 (all parts)]]] _Standard_
INPUT
#{BLANK_HDR}
Normative References
Standard
XYZ 123:1066 (all parts)
OUTPUT
end
it "processes non-ISO reference in Bibliography" do
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Bibliography
* [[[iso123,1]]] _Standard_
INPUT
#{BLANK_HDR}
Bibliography
Standard
[1]
OUTPUT
end
it "process ISO reference without an Internet connection" do
expect(Isobib::IsoBibliography).to receive(:search).with("ISO 123") do
raise Algolia::AlgoliaProtocolError.new "getaddrinfo", "nodename nor servname provided, or not known (JCL49WV5AR-dsn.algolia.net:443)"
end.at_least :once
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ISOBIB_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123]]] _Standard_
INPUT
ISO
International Organization for Standardization
ISO
International Organization for Standardization
ISO
en
60
60
2018
International Organization for Standardization
ISO
Normative References
Standard
ISO 123
International Organization for Standardization
ISO
OUTPUT
end
private
private
def mock_isobib_get_123
expect(Isobib::IsoBibliography).to receive(:get).with("ISO 123", nil, {}) do
IsoBibItem.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:2001\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_124
expect(Isobib::IsoBibliography).to receive(:get).with("ISO 124", "2014", {}) do
IsoBibItem.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
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(Isobib::IsoBibliography).to receive(:get).with("ISO/IEC TR 12382", "1992", {}) do
IsoBibItem.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
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.from_xml(<<~"OUTPUT")
Network Configuration Access Control Model
RFC 8341
2018
published
OUTPUT
end
end
end