Sha256: 32fe8fba7aa222e1a49be6388cd82d9bcf4e8c40b9af69b0f77f48c82557409e

Contents?: true

Size: 1.93 KB

Versions: 15

Compression:

Stored size: 1.93 KB

Contents

require "spec_helper"
require "metanorma"
require "fileutils"

#RSpec.describe Asciidoctor::Gb do
RSpec.describe Metanorma::Iso::Processor do

  registry = Metanorma::Registry.instance
  registry.register(Metanorma::Iso::Processor)
  processor = registry.find_processor(:iso)

  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"], [:html_alt, "alt.html"], [:rxl, "rxl"], [:xml, "xml"]]
    OUTPUT
  end

  it "registers version against metanorma" do
    expect(processor.version.to_s).to match(%r{^Metanorma::ISO })
  end

  it "generates IsoDoc XML from a blank document" do
    expect(xmlpp(processor.input_to_isodoc(<<~"INPUT", nil))).to be_equivalent_to xmlpp(<<~"OUTPUT")
    #{ASCIIDOC_BLANK_HDR}
    INPUT
    #{BLANK_HDR}
<sections/>
</iso-standard>
    OUTPUT
  end

  it "generates HTML from IsoDoc XML" do
    FileUtils.rm_f "test.xml"
    processor.output(<<~"INPUT", "test.html", :html)
               <iso-standard xmlns="http://riboseinc.com/isoxml">
       <sections>
       <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
         <term id="J">
         <preferred>Term2</preferred>
       </term>
        </terms>
        </sections>
        </iso-standard>
    INPUT
    expect(xmlpp(File.read("test.html", encoding: "utf-8").gsub(%r{^.*<main}m, "<main").gsub(%r{</main>.*}m, "</main>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
           <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
             <p class="zzSTDTitle1"></p>
             <div id="H"><h1>1&#xA0; Terms and definitions</h1>
       <h2 class="TermNum" id="J">1.1</h2>
         <p class="Terms" style="text-align:left;">Term2</p>
       </div>
           </main>
    OUTPUT
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
metanorma-iso-1.3.22 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.21 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.20 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.19 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.18 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.17 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.16 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.15 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.13 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.12 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.11 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.10 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.9 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.8 spec/metanorma/processor_spec.rb
metanorma-iso-1.3.7 spec/metanorma/processor_spec.rb