require "spec_helper"
RSpec.describe Asciidoctor::ISO do
it "processes simple ISO reference" do
stub_fetch_ref
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 ReferencesRubber latex -- Sampling -- Latex de caoutchouc -- Échantillonnage -- ISO 1232001International Organization for StandardizationISOwww.iso.org3enfrPublished2001ISOISO 123:1985ISO 123:1985ISO 123:2001ISO 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 ReferencesStandardIEC 123International Electrotechnical CommissionIEC
OUTPUT
end
it "processes dated ISO reference and joint ISO/IEC references" do
stub_fetch_ref
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO/IEC 12382:1066]]] _Standard_
* [[[iso124,ISO 124:1066-1067]]] _Standard_
INPUT
#{BLANK_HDR}
Normative ReferencesPermuted index of the vocabulary of information technology -- -- Index permuté du vocabulaire des technologies de l'information -- -- ISO/IEC 123821992International Organization for StandardizationISOwww.iso.orgInternational Electrotechnical CommissionIECwww.iec.ch2enfrContains 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.Published1992ISO/IECISO/IEC TR 12382:1992ISO/IEC TR 12382:1992Latex, rubber -- Determination of total solids content -- Latex de caoutchouc -- Détermination des matières solides totales -- ISO 1242014International Organization for StandardizationISOwww.iso.org7enfrISO 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.Published2014ISOISO 124:2011ISO 124:2011
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 ReferencesRubber latex -- Sampling -- Latex de caoutchouc -- Échantillonnage -- ISO 123--International Organization for StandardizationISOwww.iso.org3enfrPublished2001ISOISO 123:1985ISO 123:1985ISO 123:2001ISO 123:2001ISO 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 ReferencesRubber latex -- Sampling -- Latex de caoutchouc -- Échantillonnage -- ISO 123:All Parts2001International Organization for StandardizationISOwww.iso.org3enfrPublished2001ISOISO 123:1985ISO 123:1985ISO 123:2001ISO 123:2001
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 ReferencesStandardXYZ 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}
BibliographyStandard[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"
#{ASCIIDOC_BLANK_HDR}
[bibliography]
== Normative References
* [[[iso123,ISO 123]]] _Standard_
INPUT
International Organization for StandardizationISOInternational Organization for StandardizationISO60602018International Organization for StandardizationISONormative ReferencesStandardISO 123International Organization for StandardizationISO
OUTPUT
end
end