require "spec_helper" require "fileutils" RSpec.describe Asciidoctor::Standoc do it "has a version number" do expect(Metanorma::Standoc::VERSION).not_to be nil end it "processes a blank document" do expect(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).to be_equivalent_to <<~"OUTPUT" #{ASCIIDOC_BLANK_HDR} INPUT #{BLANK_HDR} OUTPUT end it "converts a blank document" do FileUtils.rm_f "test.doc" expect(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).to be_equivalent_to <<~"OUTPUT" = Document title Author :docfile: test.adoc :novalid: 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(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).to be_equivalent_to <<~'OUTPUT' = Document title Author :docfile: test.adoc :nodoc: :novalid: :docnumber: 1000 :partnumber: 1 :edition: 2 :revdate: 2000-01-01 :draft: 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 :copyright-year: 2001 :docstage: 10 :docsubstage: 20 :iteration: 3 :language: en :title: Main Title -- Title :library-ics: 1,2,3 INPUT Main Title — Title 1000 en published 2001 TC TC1 1 2 3 2 2000-01-01 3.4 OUTPUT end it "processes complex metadata" do expect(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).to be_equivalent_to <<~'OUTPUT' = Document title Author :docfile: test.adoc :nodoc: :novalid: :docnumber: 1000 :partnumber: 1-1 :tc-docnumber: 2000 :language: el :script: Grek :publisher: IEC,IETF,ISO :uri: A :xml-uri: B :html-uri: C :pdf-uri: D :doc-uri: E :relaton-uri: F INPUT A B C D E F ISO/IEC/IETF 1000 IEC IETF ISO IEC IETF ISO el published 2018 IEC 2018 IETF 2018 ISO OUTPUT end it "reads scripts into blank HTML document" do FileUtils.rm_f "test.html" Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) = Document title Author :docfile: test.adoc :novalid: :scripts: spec/assets/scripts.html INPUT html = File.read("test.html", encoding: "utf-8") expect(html).to match(%r{