require "spec_helper" require "relaton_iso" require "relaton_ietf" RSpec.describe Asciidoctor::ISO do it "processes draft ISO reference" do mock_fdis input = <<~INPUT #{ISOBIB_BLANK_HDR} == Clause <> <> A.footnote:[a footnote] <> <> [bibliography] == Normative References * [[[iso123,ISO 123:--]]] footnote:[The standard is in press] _Standard_ * [[[fdis,ISO/FDIS 17664-1]]] Title INPUT output = <<~OUTPUT #{BLANK_HDR} Clause

The standard is in press

A.

a footnote

Under preparation. (Stage at the time of publication ISO/FDIS 17664-1).

Normative references

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.

Standard ISO 123:— 123 International Organization for Standardization ISO The standard is in press #{Date.today} Traitement de produits de soins de santé Informations relatives au traitement des dispositifs médicaux à fournir par le fabricant du dispositif Partie 1: Titre manque Traitement de produits de soins de santé — Informations relatives au traitement des dispositifs médicaux à fournir par le fabricant du dispositif — Partie 1: Titre manque https://www.iso.org/standard/81720.html https://www.iso.org/contents/data/standard/08/17/81720.detail.rss ISO/FDIS 17664-1 urn:iso:std:iso-fdis:17664:-1:stage-50.00:ed-1:fr 17664 International Organization for Standardization ISO www.iso.org 1

Under preparation. (Stage at the time of publication ISO/FDIS 17664-1).

en fr 50 00 unknown ISO/FDIS ISO 17664:2017 2020-11-03 Traitement de produits de soins de santé Informations relatives au traitement des dispositifs médicaux à fournir par le fabricant du dispositif Partie 1: Titre manque Traitement de produits de soins de santé — Informations relatives au traitement des dispositifs médicaux à fournir par le fabricant du dispositif — Partie 1: Titre manque https://www.iso.org/standard/81720.html https://www.iso.org/contents/data/standard/08/17/81720.detail.rss ISO/FDIS 17664-1 urn:iso:std:iso-fdis:17664:-1:stage-50.00:ed-1:fr 17664 International Organization for Standardization ISO www.iso.org 1

Under preparation. (Stage at the time of publication ISO/FDIS 17664-1).

en fr 50 00 unknown ISO/FDIS ISO 17664:2017 Geneva
Geneva
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes all-parts ISO reference" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Clause <> [bibliography] == Normative References * [[[iso123,ISO 123:1066 (all parts)]]] _Standard_ INPUT output = <<~OUTPUT #{BLANK_HDR} Clause

Normative references

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.

Standard ISO 123:1066 (all parts) 123 1066 International Organization for Standardization ISO all
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes non-ISO reference in Normative References" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [bibliography] == Normative References * [[[iso123,XYZ 123:1066 (all parts)]]] _Standard_ INPUT output = <<~OUTPUT #{BLANK_HDR} Normative references

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.

Standard XYZ 123:1066 (all parts) 123:1066 (all parts)
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes non-ISO reference in Bibliography" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [bibliography] == Bibliography * [[[iso123,1]]] _Standard_ INPUT output = <<~OUTPUT #{BLANK_HDR} Bibliography Standard [1] OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "sort ISO references in Bibliography" do VCR.use_cassette "sortrefs" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [bibliography] == Bibliography * [[[iso1,ISO 8000-110]]] * [[[iso2,ISO 8000-61]]] * [[[iso3,ISO 8000-8]]] * [[[iso4,ISO 9]]] INPUT output = <<~OUTPUT #{BLANK_HDR} Bibliography ISO 9 9 International Organization for Standardization ISO ISO 8000-8 8000-8 International Organization for Standardization ISO ISO 8000-61 8000-61 International Organization for Standardization ISO ISO 8000-110 8000-110 International Organization for Standardization ISO OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end end private def mock_fdis expect(RelatonIso::IsoBibliography).to receive(:get) .with("ISO/FDIS 17664-1", nil, lang: "en", title: "Title", usrlbl: nil) do RelatonIsoBib::XMLParser.from_xml(<<~"OUTPUT") #{Date.today} Traitement de produits de soins de santé Informations relatives au traitement des dispositifs médicaux à fournir par le fabricant du dispositif Partie 1: Titre manque Traitement de produits de soins de santé — Informations relatives au traitement des dispositifs médicaux à fournir par le fabricant du dispositif — Partie 1: Titre manque https://www.iso.org/standard/81720.html https://www.iso.org/contents/data/standard/08/17/81720.detail.rss ISO/FDIS 17664-1 urn:iso:std:iso-fdis:17664:-1:stage-50.00:ed-1:fr 17664 International Organization for Standardization ISO www.iso.org 1 en fr 50 00 unknown ISO/FDIS ISO 17664:2017 2020-11-03 Traitement de produits de soins de santé Informations relatives au traitement des dispositifs médicaux à fournir par le fabricant du dispositif Partie 1: Titre manque Traitement de produits de soins de santé — Informations relatives au traitement des dispositifs médicaux à fournir par le fabricant du dispositif — Partie 1: Titre manque https://www.iso.org/standard/81720.html https://www.iso.org/contents/data/standard/08/17/81720.detail.rss ISO/FDIS 17664-1 urn:iso:std:iso-fdis:17664:-1:stage-50.00:ed-1:fr 17664 International Organization for Standardization ISO www.iso.org 1 en fr 50 00 unknown ISO/FDIS ISO 17664:2017 Geneva Geneva OUTPUT end end end