require "spec_helper" require "metanorma" require "fileutils" RSpec.describe Metanorma::Standoc::Processor do registry = Metanorma::Registry.instance registry.register(Metanorma::Standoc::Processor) processor = registry.find_processor(:standoc) it "registers against metanorma" do expect(processor).not_to be nil end it "registers output formats against metanorma" do expect(processor.output_formats.sort.to_s).to be_equivalent_to <<~"OUTPUT" [[:doc, "doc"], [:html, "html"], [:rxl, "rxl"], [:xml, "xml"]] OUTPUT end it "registers version against metanorma" do expect(processor.version.to_s).to match(%r{^Metanorma::Standoc }) expect(processor.version.to_s).to match(%r{/IsoDoc }) end it "generates IsoDoc XML from a blank document" do expect(processor.input_to_isodoc(<<~"INPUT", "test")).to be_equivalent_to <<~"OUTPUT" #{ASCIIDOC_BLANK_HDR} INPUT #{BLANK_HDR} OUTPUT end it "generates HTML from IsoDoc XML" do FileUtils.rm_f "test.html" processor.output(<<~"INPUT", "test.html", :html) Terms, Definitions, Symbols and Abbreviated Terms Term2 INPUT expect(File.read("test.html", encoding: "utf-8").gsub(%r{^.*.*}m, "")).to be_equivalent_to <<~"OUTPUT"

1.  Terms and definitions

For the purposes of this document, the following terms and definitions apply.

ISO and IEC maintain terminological databases for use in standardization at the following addresses:

1.1.

Term2

OUTPUT end it "generates HTML from IsoDoc XML" do FileUtils.rm_f "test.doc" processor.output(<<~"INPUT", "test.doc", :doc) Terms, Definitions, Symbols and Abbreviated Terms Term2 INPUT expect(File.read("test.doc", encoding: "utf-8")).to match(/Electropedia/) end it "generates XML from IsoDoc XML" do FileUtils.rm_f "test.xml" processor.output(<<~"INPUT", "test.xml", :xml) Terms, Definitions, Symbols and Abbreviated Terms Term2 INPUT expect(File.exist?("test.xml")).to be true end end