require "spec_helper"
RSpec.describe IsoDoc do
system "rm -f test.html"
it "processes isodoc as ISO: HTML output" do
IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", false)
These results are based on a study carried out on three different types of kernel.
INPUT
html = File.read("test.html", encoding: "utf-8")
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Cambria", serif;]m)
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Cambria", serif;]m)
end
it "processes isodoc as ISO: alt HTML output" do
system "rm -f test.html"
IsoDoc::Iso::HtmlConvert.new({alt: true}).convert("test", <<~"INPUT", false)
These results are based on a study carried out on three different types of kernel.
INPUT
html = File.read("test.html", encoding: "utf-8")
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Space Mono", monospace;]m)
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
end
it "processes isodoc as ISO: Chinese HTML output" do
system "rm -f test.html"
IsoDoc::Iso::HtmlConvert.new({script: "Hans"}).convert("test", <<~"INPUT", false)
These results are based on a study carried out on three different types of kernel.
INPUT
html = File.read("test.html", encoding: "utf-8")
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "SimSun", serif;]m)
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "SimHei", sans-serif;]m)
end
it "processes isodoc as ISO: user nominated fonts" do
system "rm -f test.html"
IsoDoc::Iso::HtmlConvert.new({bodyfont: "Zapf Chancery", headerfont: "Comic Sans", monospacefont: "Andale Mono"}).convert("test", <<~"INPUT", false)
These results are based on a study carried out on three different types of kernel.
INPUT
html = File.read("test.html", encoding: "utf-8")
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: Andale Mono;]m)
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: Zapf Chancery;]m)
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: Comic Sans;]m)
end
it "processes isodoc as ISO: Word output" do
system "rm -f test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", <<~"INPUT", false)
These results are based on a study carried out on three different types of kernel.
INPUT
html = File.read("test.doc", encoding: "utf-8")
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
expect(html).to match(%r[Quote[^{]+\{[^{]+font-family: "Cambria", serif;]m)
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Cambria", serif;]m)
end
it "does not include IEV in references" do
expect(IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
Normative ReferencesElectropedia:
The World's Online Electrotechnical VocabularyIEV2018International Electrotechnical CommissionIECwww.iec.chenfr2018International Electrotechnical CommissionIECwww.iec.chIEC 60050Cereals and pulsesISO 2048320132014International Organization for Standardization
INPUT
#{HTML_HDR}
The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.