require "spec_helper"
require "metanorma"
require "fileutils"
#RSpec.describe Asciidoctor::Gb do
RSpec.describe Metanorma::Iec::Processor do
registry = Metanorma::Registry.instance
registry.register(Metanorma::Iec::Processor)
processor = registry.find_processor(:iec)
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"], [:pdf, "pdf"], [:presentation, "presentation.xml"], [:rxl, "rxl"], [:xml, "xml"]]
OUTPUT
end
it "registers version against metanorma" do
expect(processor.version.to_s).to match(%r{^Metanorma::Iec })
end
it "generates IsoDoc XML from a blank document" do
expect(xmlpp(strip_guid(processor.input_to_isodoc(<<~"INPUT", nil)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
#{ASCIIDOC_BLANK_HDR}
INPUT
#{blank_hdr_gen}
OUTPUT
end
it "generates HTML from IsoDoc XML" do
FileUtils.rm_f "test.xml"
processor.output(<<~"INPUT", "test.xml", "test.html", :html)
1Terms, Definitions, Symbols and Abbreviated Terms1.1Term2
INPUT
expect(xmlpp(File.read("test.html", encoding: "utf-8").gsub(%r{^.*.*}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
INTERNATIONAL ELECTROTECHNICAL COMMISSION
____________
FOREWORD
1 Terms, Definitions, Symbols and Abbreviated Terms