require "spec_helper" require "fileutils" RSpec.describe Asciidoctor::Iec do it "has a version number" do expect(Metanorma::Iec::VERSION).not_to be nil end #it "generates output for the Rice document" do #FileUtils.rm_f %w(spec/examples/rice.xml spec/examples/rice.doc spec/examples/rice.html spec/examples/rice_alt.html) #FileUtils.cd "spec/examples" #Asciidoctor.convert_file "rice.adoc", {:attributes=>{"backend"=>"iso"}, :safe=>0, :header_footer=>true, :requires=>["metanorma-iso"], :failure_level=>4, :mkdirs=>true, :to_file=>nil} #FileUtils.cd "../.." #expect(File.exist?("spec/examples/rice.xml")).to be true #expect(File.exist?("spec/examples/rice.doc")).to be true #expect(File.exist?("spec/examples/rice.html")).to be true #expect(File.exist?("spec/examples/rice_alt.html")).to be true #end it "processes a blank document" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} INPUT #{BLANK_HDR} OUTPUT end it "converts a blank document" do FileUtils.rm_f "test.doc" expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") = Document title Author :docfile: test.adoc :novalid: :no-isobib: INPUT #{BLANK_HDR} OUTPUT expect(File.exist?("test.doc")).to be true expect(File.exist?("htmlstyle.css")).to be false end it "processes default metadata" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :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 INPUT Introduction — Main Title — Title — Title Part Introduction Main Title — Title Title Part Introduction Française — Titre Principal — Part du Titre Introduction Française Titre Principal Part du Titre IEC/3NWIP 1000-1 ED 2 1000 International Electrotechnical Commission IEC International Electrotechnical Commission IEC 2 2000-01-01 0.3.4 en 10 20 3 #{Date.today.year} International Electrotechnical Commission IEC article TC TC1 SC SC1 WG WG1 SECRETARIAT 1 2 3 IEC 1000 New work item proposal #{UNPUBLISHED_BOILERPLATE} OUTPUT end it "processes complex metadata" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :partnumber: 1-1 :tc-docnumber: 2000 :language: el :script: Grek :publisher: IEC,IETF,ISO :copyright-year: 2001 :docstage: A2CD INPUT ISO/IEC/IETF/2CD 1000-1-1 ED 1 2000 1000 International Electrotechnical Commission IEC IETF International Organization for Standardization ISO International Electrotechnical Commission IEC IETF International Organization for Standardization ISO el 30 99 2 2001 International Electrotechnical Commission IEC 2001 IETF 2001 International Organization for Standardization ISO article ISO/IEC/IETF 1000 Committee draft #{UNPUBLISHED_BOILERPLATE.sub(/IEC #{Date.today.year}/, "ISO/IEC/IETF 2001")} OUTPUT end it "processes boilerplate in English" do doc = (strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true))) = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :partnumber: 1-1 :tc-docnumber: 2000 :language: en :script: Latn :publisher: IEC,IETF,ISO :copyright-year: 2001 INPUT expect(doc).to include "including individual experts" expect(doc).not_to include "y compris ses experts particuliers" end it "processes boilerplate in French" do doc = (strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true))) = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :partnumber: 1-1 :tc-docnumber: 2000 :language: fr :script: Latn :publisher: IEC,IETF,ISO :copyright-year: 2001 INPUT expect(doc).not_to include "including individual experts" expect(doc).to include "y compris ses experts particuliers" end it "defaults substage" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :docstage: 50 INPUT IEC/FDIS 1000 ED 1 1000 International Electrotechnical Commission IEC International Electrotechnical Commission IEC en 50 00 #{Date.today.year} International Electrotechnical Commission IEC article IEC 1000 Final draft international standard #{UNPUBLISHED_BOILERPLATE} OUTPUT end it "defaults substage for stage 60" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :docstage: 60 INPUT IEC 1000 ED 1 1000 International Electrotechnical Commission IEC International Electrotechnical Commission IEC en 60 60 #{Date.today.year} International Electrotechnical Commission IEC article IEC 1000 International standard #{BOILERPLATE} OUTPUT end it "populates metadata for PRF" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :docstage: 60 :docsubstage: 00 INPUT IEC 1000 ED 1 1000 International Electrotechnical Commission IEC International Electrotechnical Commission IEC en 60 00 #{Date.today.year} International Electrotechnical Commission IEC article IEC 1000 International standard #{BOILERPLATE} OUTPUT end it "reads scripts into blank HTML document" do FileUtils.rm_f "test.html" Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true) = Document title Author :docfile: test.adoc :novalid: :no-isobib: INPUT html = File.read("test.html", encoding: "utf-8") expect(html).to match(%r{