Skip to content

Commit

Permalink
rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Oct 9, 2023
1 parent 0e64a56 commit bda0514
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 36 deletions.
20 changes: 18 additions & 2 deletions lib/metanorma/un/basicdoc.rng
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@
<ref name="keyword"/>
<ref name="xref"/>
<ref name="hyperlink"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</oneOrMore>
</element>
Expand Down Expand Up @@ -623,6 +625,8 @@
<ref name="eref"/>
<ref name="xref"/>
<ref name="hyperlink"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</zeroOrMore>
</element>
Expand All @@ -636,6 +640,8 @@
<ref name="eref"/>
<ref name="xref"/>
<ref name="hyperlink"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</zeroOrMore>
</element>
Expand All @@ -648,14 +654,20 @@
<ref name="eref"/>
<ref name="xref"/>
<ref name="hyperlink"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</zeroOrMore>
</element>
</define>
<define name="keyword">
<element name="keyword">
<zeroOrMore>
<ref name="PureTextElement"/>
<choice>
<ref name="PureTextElement"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</zeroOrMore>
</element>
</define>
Expand All @@ -676,7 +688,11 @@
<define name="strike">
<element name="strike">
<zeroOrMore>
<ref name="PureTextElement"/>
<choice>
<ref name="PureTextElement"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</zeroOrMore>
</element>
</define>
Expand Down
2 changes: 1 addition & 1 deletion lib/metanorma/un/biblio.rng
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@
<value>mergedInto</value>
<value>splits</value>
<value>splitInto</value>
<value>instance</value>
<value>instanceOf</value>
<value>hasInstance</value>
<value>exemplarOf</value>
<value>hasExemplar</value>
Expand Down
19 changes: 18 additions & 1 deletion lib/metanorma/un/isodoc.rng
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
these elements; we just want one namespace for any child grammars
of this.
-->
<!-- VERSION v1.2.4 -->
<!-- VERSION v1.2.5 -->
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<include href="reqt.rng"/>
<include href="basicdoc.rng">
Expand Down Expand Up @@ -485,6 +485,8 @@
<choice>
<text/>
<ref name="callout"/>
<ref name="xref"/>
<ref name="eref"/>
</choice>
</oneOrMore>
<zeroOrMore>
Expand Down Expand Up @@ -865,6 +867,7 @@
<ref name="PureTextElement"/>
<ref name="stem"/>
<ref name="index"/>
<ref name="index-xref"/>
<ref name="eref"/>
<ref name="erefstack"/>
<ref name="xref"/>
Expand All @@ -880,6 +883,7 @@
<ref name="PureTextElement"/>
<ref name="stem"/>
<ref name="index"/>
<ref name="index-xref"/>
<ref name="eref"/>
<ref name="erefstack"/>
<ref name="xref"/>
Expand All @@ -894,6 +898,7 @@
<choice>
<ref name="PureTextElement"/>
<ref name="index"/>
<ref name="index-xref"/>
<ref name="eref"/>
<ref name="erefstack"/>
<ref name="xref"/>
Expand All @@ -908,6 +913,7 @@
<choice>
<ref name="PureTextElement"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</zeroOrMore>
</element>
Expand All @@ -918,6 +924,7 @@
<choice>
<ref name="PureTextElement"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</zeroOrMore>
</element>
Expand All @@ -928,6 +935,7 @@
<choice>
<ref name="PureTextElement"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</zeroOrMore>
</element>
Expand All @@ -938,6 +946,7 @@
<choice>
<ref name="PureTextElement"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</zeroOrMore>
</element>
Expand Down Expand Up @@ -1047,6 +1056,8 @@
<ref name="keyword"/>
<ref name="xref"/>
<ref name="hyperlink"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</element>
</define>
Expand All @@ -1060,6 +1071,8 @@
<ref name="keyword"/>
<ref name="xref"/>
<ref name="hyperlink"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</element>
</define>
Expand Down Expand Up @@ -1126,6 +1139,8 @@
<choice>
<ref name="PureTextElement"/>
<ref name="stem"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</zeroOrMore>
</element>
Expand All @@ -1136,6 +1151,8 @@
<choice>
<ref name="PureTextElement"/>
<ref name="stem"/>
<ref name="index"/>
<ref name="index-xref"/>
</choice>
</zeroOrMore>
</element>
Expand Down
62 changes: 30 additions & 32 deletions spec/metanorma/validate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RSpec.describe Metanorma::UN do
context "when xref_error.adoc compilation" do
around do |example|
FileUtils.rm_f "spec/assets/xref_error.err"
FileUtils.rm_f "spec/assets/xref_error.err.html"
example.run
Dir["spec/assets/xref_error*"].each do |file|
next if file.match?(/adoc$/)
Expand All @@ -19,40 +19,38 @@
Metanorma::Compile
.new
.compile("spec/assets/xref_error.adoc", type: "un", no_install_fonts: true)
end.to(change { File.exist?("spec/assets/xref_error.err") }
end.to(change { File.exist?("spec/assets/xref_error.err.html") }
.from(false).to(true))
end
end

it "Warns of illegal doctype" do
FileUtils.rm_f "test.err"
Asciidoctor.convert(<<~"INPUT", backend: :un, header_footer: true)
= Document title
Author
:docfile: test.adoc
:nodoc:
:no-isobib:
:doctype: pizza
text
INPUT
expect(File.read("test.err")).to include "pizza is not a legal document type"
end

it "Warns of illegal status" do
FileUtils.rm_f "test.err"
Asciidoctor.convert(<<~"INPUT", backend: :un, header_footer: true)
= Document title
Author
:docfile: test.adoc
:nodoc:
:no-isobib:
:status: pizza
text
INPUT
expect(File.read("test.err")).to include "pizza is not a recognised status"
end
it "Warns of illegal doctype" do
FileUtils.rm_f "test.err.html"
Asciidoctor.convert(<<~INPUT, backend: :un, header_footer: true)
= Document title
Author
:docfile: test.adoc
:nodoc:
:no-isobib:
:doctype: pizza
text
INPUT
expect(File.read("test.err.html")).to include "pizza is not a legal document type"
end

it "Warns of illegal status" do
FileUtils.rm_f "test.err.html"
Asciidoctor.convert(<<~INPUT, backend: :un, header_footer: true)
= Document title
Author
:docfile: test.adoc
:nodoc:
:no-isobib:
:status: pizza
text
INPUT
expect(File.read("test.err.html")).to include "pizza is not a recognised status"
end
end

0 comments on commit bda0514

Please sign in to comment.