metanorma-iso 1.1.5 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,284 +1,8 @@
1
1
  require "spec_helper"
2
- require "isobib"
3
- require "ietfbib"
2
+ require "relaton_iso"
3
+ require "relaton_ietf"
4
4
 
5
5
  RSpec.describe Asciidoctor::ISO do
6
- it "processes simple ISO reference" do
7
- expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
8
- #{ASCIIDOC_BLANK_HDR}
9
- [bibliography]
10
- == Normative References
11
-
12
- * [[[iso123,ISO 123]]] _Standard_
13
- INPUT
14
- #{BLANK_HDR}
15
- <sections>
16
- </sections><bibliography><references id="_" obligation="informative">
17
- <title>Normative References</title>
18
- <bibitem id="iso123" type="standard">
19
- <title format="text/plain">Standard</title>
20
- <docidentifier>ISO 123</docidentifier>
21
- <contributor>
22
- <role type="publisher"/>
23
- <organization>
24
- <name>International Organization for Standardization</name>
25
- <abbreviation>ISO</abbreviation>
26
- </organization>
27
- </contributor>
28
- </bibitem>
29
- </references>
30
- </bibliography>
31
- </iso-standard>
32
- OUTPUT
33
- end
34
-
35
- it "processes simple ISO reference with date range" do
36
- expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
37
- #{ASCIIDOC_BLANK_HDR}
38
- [bibliography]
39
- == Normative References
40
-
41
- * [[[iso123,ISO 123:1066-1067]]] _Standard_
42
- INPUT
43
- #{BLANK_HDR}
44
- <sections>
45
- </sections><bibliography><references id="_" obligation="informative">
46
- <title>Normative References</title>
47
- <bibitem id="iso123" type="standard">
48
- <title format="text/plain">Standard</title>
49
- <docidentifier>ISO 123:1066-1067</docidentifier>
50
- <date type="published">
51
- <from>1066</from>
52
- <to>1067</to>
53
- </date>
54
- <contributor>
55
- <role type="publisher"/>
56
- <organization>
57
- <name>International Organization for Standardization</name>
58
- <abbreviation>ISO</abbreviation>
59
- </organization>
60
- </contributor>
61
- </bibitem>
62
- </references>
63
- </bibliography>
64
- </iso-standard>
65
- OUTPUT
66
- end
67
-
68
-
69
- it "fetches simple ISO reference" do
70
- mock_isobib_get_123
71
- expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
72
- #{ISOBIB_BLANK_HDR}
73
- [bibliography]
74
- == Normative References
75
-
76
- * [[[iso123,ISO 123]]] _Standard_
77
- INPUT
78
- #{BLANK_HDR}
79
- <sections>
80
- </sections><bibliography><references id="_" obligation="informative">
81
- <title>Normative References</title>
82
- <bibitem type="international-standard" id="iso123">
83
- <fetched>#{Date.today}</fetched>
84
- <title format="text/plain" language="en" script="Latn">Rubber latex — Sampling</title>
85
- <title format="text/plain" language="fr" script="Latn">Latex de caoutchouc — ?chantillonnage</title>
86
- <uri type="src">https://www.iso.org/standard/23281.html</uri>
87
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
88
- <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
89
- <docidentifier type="ISO">ISO 123:2001</docidentifier>
90
- <date type="published">
91
- <on>2001</on>
92
- </date>
93
- <contributor>
94
- <role type="publisher"/>
95
- <organization>
96
- <name>International Organization for Standardization</name>
97
- <abbreviation>ISO</abbreviation>
98
- <uri>www.iso.org</uri>
99
- </organization>
100
- </contributor>
101
- <edition>3</edition>
102
- <language>en</language>
103
- <language>fr</language>
104
- <script>Latn</script>
105
- <status>Published</status>
106
- <copyright>
107
- <from>2001</from>
108
- <owner>
109
- <organization>
110
- <name>ISO</name>
111
- <abbreviation/>
112
- </organization>
113
- </owner>
114
- </copyright>
115
- <relation type="obsoletes">
116
- <bibitem>
117
- <formattedref>ISO 123:1985</formattedref>
118
- </bibitem>
119
- </relation>
120
- <relation type="updates">
121
- <bibitem>
122
- <formattedref>ISO 123:2001</formattedref>
123
- </bibitem>
124
- </relation>
125
- </bibitem>
126
- </references></bibliography>
127
- </iso-standard>
128
- OUTPUT
129
- end
130
-
131
- it "processes simple IEC reference" do
132
- expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
133
- #{ASCIIDOC_BLANK_HDR}
134
- [bibliography]
135
- == Normative References
136
-
137
- * [[[iso123,IEC 123]]] _Standard_
138
- INPUT
139
- #{BLANK_HDR}
140
- <sections>
141
- </sections><bibliography><references id="_" obligation="informative">
142
- <title>Normative References</title>
143
- <bibitem id="iso123" type="standard">
144
- <title format="text/plain">Standard</title>
145
- <docidentifier>IEC 123</docidentifier>
146
- <contributor>
147
- <role type="publisher"/>
148
- <organization>
149
- <name>International Electrotechnical Commission</name>
150
- <abbreviation>IEC</abbreviation>
151
- </organization>
152
- </contributor>
153
- </bibitem>
154
- </references>
155
- </bibliography>
156
- </iso-standard>
157
- OUTPUT
158
- end
159
-
160
- it "processes dated ISO reference and joint ISO/IEC references" do
161
- mock_isobib_get_iec12382
162
- mock_isobib_get_124
163
- expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
164
- #{ISOBIB_BLANK_HDR}
165
- [bibliography]
166
- == Normative References
167
-
168
- * [[[iso123,ISO/IEC TR 12382:1992]]] _Standard_
169
- * [[[iso124,ISO 124:2014]]] _Standard_
170
- INPUT
171
- #{BLANK_HDR}
172
- <sections>
173
-
174
- </sections><bibliography><references id="_" obligation="informative">
175
- <title>Normative References</title>
176
- <bibitem type="international-standard" id="iso123">
177
- <fetched>#{Date.today}</fetched>
178
- <title format="text/plain" language="en" script="Latn">Permuted index of the vocabulary of information technology</title>
179
- <title format="text/plain" language="fr" script="Latn">Index permuté du vocabulaire des technologies de l’information</title>
180
- <uri type="src">https://www.iso.org/standard/21071.html</uri>
181
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:21071:en</uri>
182
- <uri type="rss">https://www.iso.org/contents/data/standard/02/10/21071.detail.rss</uri>
183
- <docidentifier type="ISO">ISO/IEC 12382:1992</docidentifier>
184
- <date type="published">
185
- <on>1992</on>
186
- </date>
187
- <contributor>
188
- <role type="publisher"/>
189
- <organization>
190
- <name>International Organization for Standardization</name>
191
- <abbreviation>ISO</abbreviation>
192
- <uri>www.iso.org</uri>
193
- </organization>
194
- </contributor>
195
- <contributor>
196
- <role type="publisher"/>
197
- <organization>
198
- <name>International Electrotechnical Commission</name>
199
- <abbreviation>IEC</abbreviation>
200
- <uri>www.iec.ch</uri>
201
- </organization>
202
- </contributor>
203
- <edition>2</edition>
204
- <language>en</language>
205
- <language>fr</language>
206
- <script>Latn</script>
207
- <abstract format="plain" language="en" script="Latn">Contains a permuted index of all terms included in the parts 1 - 28 of ISO 2382. If any of these parts has been revised, the present TR refers to the revision.</abstract>
208
- <status>Published</status>
209
- <copyright>
210
- <from>1992</from>
211
- <owner>
212
- <organization>
213
- <name>ISO/IEC</name>
214
- <abbreviation/>
215
- </organization>
216
- </owner>
217
- </copyright>
218
- <relation type="updates">
219
- <bibitem>
220
- <formattedref>ISO/IEC TR 12382:1992</formattedref>
221
- </bibitem>
222
- </relation>
223
- <ics>
224
- <code>35.020</code>
225
- <text>Information technology (IT) in general</text>
226
- </ics>
227
- <ics>
228
- <code>01.040.35</code>
229
- <text>Information technology (Vocabularies)</text>
230
- </ics>
231
- </bibitem>
232
- <bibitem type="international-standard" id="iso124">
233
- <fetched>#{Date.today}</fetched>
234
- <title format="text/plain" language="en" script="Latn">Latex, rubber — Determination of total solids content</title>
235
- <title format="text/plain" language="fr" script="Latn">Latex de caoutchouc — Détermination des matières solides totales</title>
236
- <uri type="src">https://www.iso.org/standard/61884.html</uri>
237
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:61884:en</uri>
238
- <uri type="rss">https://www.iso.org/contents/data/standard/06/18/61884.detail.rss</uri>
239
- <docidentifier type="ISO">ISO 124:2014</docidentifier>
240
- <date type="published">
241
- <on>2014</on>
242
- </date>
243
- <contributor>
244
- <role type="publisher"/>
245
- <organization>
246
- <name>International Organization for Standardization</name>
247
- <abbreviation>ISO</abbreviation>
248
- <uri>www.iso.org</uri>
249
- </organization>
250
- </contributor>
251
- <edition>7</edition>
252
- <language>en</language>
253
- <language>fr</language>
254
- <script>Latn</script>
255
- <abstract format="plain" language="en" script="Latn">ISO 124:2014 specifies methods for the determination of the total solids content of natural rubber field and concentrated latices and synthetic rubber latex. These methods are not necessarily suitable for latex from natural sources other than the Hevea brasiliensis, for vulcanized latex, for compounded latex, or for artificial dispersions of rubber.</abstract>
256
- <status>Published</status>
257
- <copyright>
258
- <from>2014</from>
259
- <owner>
260
- <organization>
261
- <name>ISO</name>
262
- <abbreviation/>
263
- </organization>
264
- </owner>
265
- </copyright>
266
- <relation type="obsoletes">
267
- <bibitem>
268
- <formattedref>ISO 124:2011</formattedref>
269
- </bibitem>
270
- </relation>
271
- <ics>
272
- <code>83.040.10</code>
273
- <text>Latex and raw rubber</text>
274
- </ics>
275
- </bibitem>
276
- </references>
277
- </bibliography>
278
- </iso-standard>
279
- OUTPUT
280
- end
281
-
282
6
  it "processes draft ISO reference" do
283
7
  #stub_fetch_ref no_year: true, note: "The standard is in press"
284
8
 
@@ -341,7 +65,7 @@ RSpec.describe Asciidoctor::ISO do
341
65
  <abbreviation>ISO</abbreviation>
342
66
  </organization>
343
67
  </contributor>
344
- <allparts>true</allparts>
68
+ <extent type="part"><referenceFrom>all</referenceFrom></extent>
345
69
  </bibitem>
346
70
  </references>
347
71
  </bibliography>
@@ -349,34 +73,6 @@ RSpec.describe Asciidoctor::ISO do
349
73
  OUTPUT
350
74
  end
351
75
 
352
- it "processes RFC reference in Normative References" do
353
- mock_rfcbib_get_rfc8341
354
- expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
355
- #{ISOBIB_BLANK_HDR}
356
- [bibliography]
357
- == Normative References
358
-
359
- * [[[iso123,IETF(RFC 8341)]]] _Standard_
360
- INPUT
361
- #{BLANK_HDR}
362
- <sections>
363
-
364
- </sections><bibliography><references id="_" obligation="informative">
365
- <title>Normative References</title>
366
- <bibitem id="iso123">
367
- <fetched>#{Date.today}</fetched>
368
- <title format="plain" language="en" script="Latn">Network Configuration Access Control Model</title>
369
- <docidentifier type="IETF">RFC 8341</docidentifier>
370
- <date type="published">
371
- <on>2018</on>
372
- </date>
373
- </bibitem>
374
- </references>
375
- </bibliography>
376
- </iso-standard>
377
- OUTPUT
378
- end
379
-
380
76
  it "processes non-ISO reference in Normative References" do
381
77
  expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
382
78
  #{ASCIIDOC_BLANK_HDR}
@@ -427,81 +123,6 @@ RSpec.describe Asciidoctor::ISO do
427
123
  OUTPUT
428
124
  end
429
125
 
430
- it "process ISO reference without an Internet connection" do
431
- expect(Isobib::IsoBibliography).to receive(:search).with("ISO 123") do
432
- raise Algolia::AlgoliaProtocolError.new "getaddrinfo", "nodename nor servname provided, or not known (JCL49WV5AR-dsn.algolia.net:443)"
433
- end.at_least :once
434
- expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
435
- #{ISOBIB_BLANK_HDR}
436
- [bibliography]
437
- == Normative References
438
-
439
- * [[[iso123,ISO 123]]] _Standard_
440
- INPUT
441
- <?xml version="1.0" encoding="UTF-8"?>
442
- <iso-standard xmlns="http://riboseinc.com/isoxml">
443
- <bibdata type="article">
444
- <title>
445
-
446
- </title>
447
- <title>
448
-
449
- </title>
450
- <contributor>
451
- <role type="author"/>
452
- <organization>
453
- <name>International Organization for Standardization</name>
454
- <abbreviation>ISO</abbreviation>
455
- </organization>
456
- </contributor>
457
- <contributor>
458
- <role type="publisher"/>
459
- <organization>
460
- <name>International Organization for Standardization</name>
461
- <abbreviation>ISO</abbreviation>
462
- </organization>
463
- </contributor>
464
- <language>en</language>
465
- <script>Latn</script>
466
- <status>
467
- <stage>60</stage>
468
- <substage>60</substage>
469
- </status>
470
- <copyright>
471
- <from>#{Time.now.year}</from>
472
- <owner>
473
- <organization>
474
- <name>International Organization for Standardization</name>
475
- <abbreviation>ISO</abbreviation>
476
- </organization>
477
- </owner>
478
- </copyright>
479
- <editorialgroup>
480
- <technical-committee/>
481
- <subcommittee/>
482
- <workgroup/>
483
- </editorialgroup>
484
- </bibdata>
485
- <sections>
486
-
487
- </sections><bibliography><references id="_" obligation="informative">
488
- <title>Normative References</title>
489
- <bibitem id="iso123" type="standard">
490
- <title format="text/plain">Standard</title>
491
- <docidentifier type="ISO">ISO 123</docidentifier>
492
- <contributor>
493
- <role type="publisher"/>
494
- <organization>
495
- <name>International Organization for Standardization</name>
496
- <abbreviation>ISO</abbreviation>
497
- </organization>
498
- </contributor>
499
- </bibitem>
500
- </references></bibliography>
501
- </iso-standard>
502
- OUTPUT
503
- end
504
-
505
126
  private
506
127
 
507
128
  private
@@ -3,6 +3,87 @@ require "fileutils"
3
3
 
4
4
  RSpec.describe Asciidoctor::ISO do
5
5
 
6
+ it "Warns of illegal doctype" do
7
+ expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/pizza is not a recognised document type/).to_stderr
8
+ = Document title
9
+ Author
10
+ :docfile: test.adoc
11
+ :nodoc:
12
+ :no-isobib:
13
+ :doctype: pizza
14
+
15
+ text
16
+ INPUT
17
+ end
18
+
19
+ it "Warns of illegal script" do
20
+ expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/pizza is not a recognised script/).to_stderr
21
+ = Document title
22
+ Author
23
+ :docfile: test.adoc
24
+ :nodoc:
25
+ :no-isobib:
26
+ :script: pizza
27
+
28
+ text
29
+ INPUT
30
+ end
31
+
32
+ it "Warns of illegal stage" do
33
+ expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/pizza is not a recognised stage/).to_stderr
34
+ = Document title
35
+ Author
36
+ :docfile: test.adoc
37
+ :nodoc:
38
+ :no-isobib:
39
+ :status: pizza
40
+
41
+ text
42
+ INPUT
43
+ end
44
+
45
+ it "Warns of illegal substage" do
46
+ expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/pizza is not a recognised substage/).to_stderr
47
+ = Document title
48
+ Author
49
+ :docfile: test.adoc
50
+ :nodoc:
51
+ :no-isobib:
52
+ :status: 60
53
+ :docsubstage: pizza
54
+
55
+ text
56
+ INPUT
57
+ end
58
+
59
+ it "Warns of illegal iteration" do
60
+ expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/pizza is not a recognised iteration/).to_stderr
61
+ = Document title
62
+ Author
63
+ :docfile: test.adoc
64
+ :nodoc:
65
+ :no-isobib:
66
+ :status: 60
67
+ :iteration: pizza
68
+
69
+ text
70
+ INPUT
71
+ end
72
+
73
+ it "Warns of illegal script" do
74
+ expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/pizza is not a recognised script/).to_stderr
75
+ = Document title
76
+ Author
77
+ :docfile: test.adoc
78
+ :nodoc:
79
+ :no-isobib:
80
+ :script: pizza
81
+
82
+ text
83
+ INPUT
84
+ end
85
+
86
+
6
87
  it "warns that introduction may contain requirement" do
7
88
  expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/Introduction may contain requirement/).to_stderr
8
89
  #{VALIDATING_BLANK_HDR}