mods 2.4.1 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +24 -0
  3. data/.gitignore +1 -0
  4. data/README.md +0 -1
  5. data/lib/mods/date.rb +54 -17
  6. data/lib/mods/marc_country_codes.rb +12 -10
  7. data/lib/mods/nom_terminology.rb +109 -845
  8. data/lib/mods/reader.rb +9 -39
  9. data/lib/mods/record.rb +13 -28
  10. data/lib/mods/version.rb +1 -1
  11. data/mods.gemspec +2 -2
  12. data/spec/fixture_data/hp566jq8781.xml +334 -0
  13. data/spec/integration/parker_spec.rb +217 -0
  14. data/spec/{date_spec.rb → lib/date_spec.rb} +9 -1
  15. data/spec/lib/language_spec.rb +123 -0
  16. data/spec/lib/location_spec.rb +175 -0
  17. data/spec/lib/name_spec.rb +368 -0
  18. data/spec/lib/origin_info_spec.rb +134 -0
  19. data/spec/lib/part_spec.rb +162 -0
  20. data/spec/lib/physical_description_spec.rb +72 -0
  21. data/spec/{reader_spec.rb → lib/reader_spec.rb} +1 -41
  22. data/spec/lib/record_info_spec.rb +114 -0
  23. data/spec/lib/record_spec.rb +287 -0
  24. data/spec/lib/related_item_spec.rb +124 -0
  25. data/spec/lib/subject_spec.rb +427 -0
  26. data/spec/lib/title_spec.rb +108 -0
  27. data/spec/lib/top_level_elmnts_simple_spec.rb +169 -0
  28. data/spec/spec_helper.rb +86 -5
  29. data/spec/support/fixtures.rb +9 -0
  30. metadata +49 -44
  31. data/.travis.yml +0 -16
  32. data/spec/language_spec.rb +0 -118
  33. data/spec/location_spec.rb +0 -295
  34. data/spec/name_spec.rb +0 -759
  35. data/spec/origin_info_spec.rb +0 -447
  36. data/spec/part_spec.rb +0 -471
  37. data/spec/physical_description_spec.rb +0 -144
  38. data/spec/record_info_spec.rb +0 -493
  39. data/spec/record_spec.rb +0 -356
  40. data/spec/related_item_spec.rb +0 -305
  41. data/spec/subject_spec.rb +0 -809
  42. data/spec/title_spec.rb +0 -226
  43. data/spec/top_level_elmnts_simple_spec.rb +0 -369
@@ -1,493 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Mods <recordInfo> Element" do
4
- before(:all) do
5
- @mods_rec = Mods::Record.new
6
- @ns_decl = "xmlns='#{Mods::MODS_NS}'"
7
- end
8
-
9
- it "should translate language codes" do
10
- skip "to be implemented"
11
- end
12
-
13
- it "should normalize dates" do
14
- skip "to be implemented"
15
- end
16
-
17
- context "basic <record_info> terminology pieces" do
18
-
19
- context "WITH namespaces" do
20
- before(:all) do
21
- @rec_info = @mods_rec.from_str("<mods #{@ns_decl}><recordInfo>
22
- <recordContentSource authority='marcorg'>RQE</recordContentSource>
23
- <recordCreationDate encoding='marc'>890517</recordCreationDate>
24
- <recordIdentifier source='SIRSI'>a9079953</recordIdentifier>
25
- </recordInfo></mods>").record_info
26
- @rec_info2 = @mods_rec.from_str("<mods #{@ns_decl}><recordInfo>
27
- <descriptionStandard>aacr2</descriptionStandard>
28
- <recordContentSource authority='marcorg'>AU@</recordContentSource>
29
- <recordCreationDate encoding='marc'>050921</recordCreationDate>
30
- <recordIdentifier source='SIRSI'>a8837534</recordIdentifier>
31
- <languageOfCataloging>
32
- <languageTerm authority='iso639-2b' type='code'>eng</languageTerm>
33
- </languageOfCataloging>
34
- </recordInfo></mods>").record_info
35
- @bnf = @mods_rec.from_str("<mods #{@ns_decl}><recordInfo>
36
- <recordContentSource>TEI Description</recordContentSource>
37
- <recordCreationDate encoding='w3cdtf'>2011-12-07</recordCreationDate>
38
- <recordIdentifier source='BNF 2166'/>
39
- <recordOrigin/>
40
- <languageOfCataloging>
41
- <languageTerm authority='iso639-2b'>fra</languageTerm>
42
- </languageOfCataloging>
43
- </recordInfo></mods>").record_info
44
- @rlin = @mods_rec.from_str("<mods #{@ns_decl}><recordInfo>
45
- <descriptionStandard>appm</descriptionStandard>
46
- <recordContentSource authority='marcorg'>CSt</recordContentSource>
47
- <recordCreationDate encoding='marc'>850416</recordCreationDate>
48
- <recordChangeDate encoding='iso8601'>19991012150824.0</recordChangeDate>
49
- <recordIdentifier source='CStRLIN'>a4083219</recordIdentifier>
50
- </recordInfo></mods>").record_info
51
- end
52
-
53
- it "should be a NodeSet" do
54
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri).to be_an_instance_of(Nokogiri::XML::NodeSet) }
55
- end
56
- it "should have as many members as there are <recordInfo> elements in the xml" do
57
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.size).to eq(1) }
58
- end
59
- it "should recognize language attributes on <recordInfo> element" do
60
- skip "problem with xml:lang"
61
- Mods::LANG_ATTRIBS.each { |a|
62
- @mods_rec.from_str("<mods #{@ns_decl}><recordInfo #{a}='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>")
63
- expect(@mods_rec.record_info.send(a.to_sym)).to eq(['val'])
64
- }
65
- end
66
- it "should recognize displayLabel attribute on <recordInfo> element" do
67
- @mods_rec.from_str("<mods #{@ns_decl}><recordInfo displayLabel='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>")
68
- expect(@mods_rec.record_info.displayLabel).to eq(['val'])
69
- end
70
-
71
- context "<recordContentSource> child element" do
72
- it "should be a NodeSet" do
73
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordContentSource).to be_an_instance_of(Nokogiri::XML::NodeSet) }
74
- end
75
- it "recordContentSource NodeSet should have as many Nodes as there are <recordContentSource> elements in the xml" do
76
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordContentSource.size).to eq(1) }
77
- end
78
- it "text should get element value" do
79
- expect(@rec_info.recordContentSource.map { |n| n.text }).to eq(["RQE"])
80
- expect(@rec_info2.recordContentSource.map { |n| n.text }).to eq(["AU@"])
81
- expect(@bnf.recordContentSource.map { |n| n.text }).to eq(["TEI Description"])
82
- expect(@rlin.recordContentSource.map { |n| n.text }).to eq(["CSt"])
83
- end
84
- it "should recognize authority attribute" do
85
- [@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordContentSource.authority).to eq(['marcorg']) }
86
- expect(@bnf.recordContentSource.authority.size).to eq(0)
87
- end
88
- it "should recognize all authority attributes" do
89
- Mods::AUTHORITY_ATTRIBS.each { |a|
90
- @mods_rec.from_str("<mods #{@ns_decl}><recordInfo><recordContentSource #{a}='attr_val'>zzz</recordContentSource></recordInfo></mods>")
91
- expect(@mods_rec.record_info.recordContentSource.send(a.to_sym)).to eq(['attr_val'])
92
- }
93
- end
94
- end # <recordContentSource>
95
-
96
- context "<recordCreationDate> child element" do
97
- it "should be a NodeSet" do
98
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordCreationDate).to be_an_instance_of(Nokogiri::XML::NodeSet) }
99
- end
100
- it "recordCreationDate NodeSet should have as many Nodes as there are <recordCreationDate> elements in the xml" do
101
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordCreationDate.size).to eq(1) }
102
- end
103
- it "text should get element value" do
104
- expect(@rec_info.recordCreationDate.map { |n| n.text }).to eq(['890517'])
105
- expect(@rec_info2.recordCreationDate.map { |n| n.text }).to eq(['050921'])
106
- expect(@bnf.recordCreationDate.map { |n| n.text }).to eq(['2011-12-07'])
107
- expect(@rlin.recordCreationDate.map { |n| n.text }).to eq(['850416'])
108
- end
109
- it "should recognize encoding attribute" do
110
- [@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordCreationDate.encoding).to eq(['marc']) }
111
- expect(@bnf.recordCreationDate.encoding).to eq(['w3cdtf'])
112
- end
113
- it "should recognize all date attributes" do
114
- Mods::DATE_ATTRIBS.each { |a|
115
- @mods_rec.from_str("<mods #{@ns_decl}><recordInfo><recordCreationDate #{a}='attr_val'>zzz</recordCreationDate></recordInfo></mods>")
116
- expect(@mods_rec.record_info.recordCreationDate.send(a.to_sym)).to eq(['attr_val'])
117
- }
118
- end
119
- end # <recordCreationDate>
120
-
121
- context "<recordChangeDate> child element" do
122
- it "should be a NodeSet" do
123
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordChangeDate).to be_an_instance_of(Nokogiri::XML::NodeSet) }
124
- end
125
- it "recordChangeDate NodeSet should have as many Nodes as there are <recordChangeDate> elements in the xml" do
126
- [@rec_info, @rec_info2, @bnf].each { |ri| expect(ri.recordChangeDate.size).to eq(0) }
127
- expect(@rlin.recordChangeDate.size).to eq(1)
128
- end
129
- it "text should get element value" do
130
- expect(@rlin.recordChangeDate.map { |n| n.text }).to eq(['19991012150824.0'])
131
- end
132
- it "should recognize encoding attribute" do
133
- expect(@rlin.recordChangeDate.encoding).to eq(['iso8601'])
134
- end
135
- it "should recognize all date attributes" do
136
- Mods::DATE_ATTRIBS.each { |a|
137
- @mods_rec.from_str("<mods #{@ns_decl}><recordInfo><recordChangeDate #{a}='attr_val'>zzz</recordChangeDate></recordInfo></mods>")
138
- expect(@mods_rec.record_info.recordChangeDate.send(a.to_sym)).to eq(['attr_val'])
139
- }
140
- end
141
- end # <recordChangeDate>
142
-
143
- context "<recordIdentifier> child element" do
144
- it "should be a NodeSet" do
145
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordIdentifier).to be_an_instance_of(Nokogiri::XML::NodeSet) }
146
- end
147
- it "recordIdentifier NodeSet should have as many Nodes as there are <recordIdentifier> elements in the xml" do
148
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordIdentifier.size).to eq(1) }
149
- end
150
- it "text should get element value" do
151
- expect(@rec_info.recordIdentifier.map { |n| n.text }).to eq(['a9079953'])
152
- expect(@rec_info2.recordIdentifier.map { |n| n.text }).to eq(['a8837534'])
153
- expect(@bnf.recordIdentifier.map { |n| n.text }).to eq([''])
154
- expect(@rlin.recordIdentifier.map { |n| n.text }).to eq(['a4083219'])
155
- end
156
- it "should recognize source attribute" do
157
- [@rec_info, @rec_info2].each { |ri| expect(ri.recordIdentifier.source).to eq(['SIRSI']) }
158
- expect(@bnf.recordIdentifier.source).to eq(['BNF 2166'])
159
- expect(@rlin.recordIdentifier.source).to eq(['CStRLIN'])
160
- end
161
- it "should allow a source attribute without element content" do
162
- expect(@bnf.recordIdentifier.source).to eq(['BNF 2166'])
163
- expect(@bnf.recordIdentifier.map { |n| n.text }).to eq([''])
164
- end
165
- end # <recordIdentifier>
166
-
167
- context "<recordOrigin> child element" do
168
- it "should be a NodeSet" do
169
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordOrigin).to be_an_instance_of(Nokogiri::XML::NodeSet) }
170
- end
171
- it "recordOrigin NodeSet should have as many Nodes as there are <recordOrigin> elements in the xml" do
172
- [@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordOrigin.size).to eq(0) }
173
- expect(@bnf.recordOrigin.size).to eq(1)
174
- end
175
- it "text should get element value" do
176
- @mods_rec.from_str("<mods #{@ns_decl}><recordInfo><recordOrigin>human prepared</recordOrigin></recordInfo></mods>")
177
- expect(@mods_rec.record_info.recordOrigin.map {|n| n.text }).to eq(['human prepared'])
178
- expect(@bnf.recordOrigin.map { |n| n.text }).to eq([''])
179
- end
180
- end # <recordOrigin>
181
-
182
- context "<languageOfCataloging> child element" do
183
- it "should be a NodeSet" do
184
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.languageOfCataloging).to be_an_instance_of(Nokogiri::XML::NodeSet) }
185
- end
186
- it "languageOfCataloging NodeSet should have as many Nodes as there are <languageOfCataloging> elements in the xml" do
187
- [@rec_info2, @bnf].each { |ri| expect(ri.languageOfCataloging.size).to eq(1) }
188
- [@rec_info, @rlin].each { |ri| expect(ri.languageOfCataloging.size).to eq(0) }
189
- end
190
- it "text should get element value" do
191
- # this example is from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html
192
- # though it doesn't match the doc at http://www.loc.gov/standards/mods/mods-outline.html#recordInfo
193
- @mods_rec.from_str("<mods #{@ns_decl}><recordInfo><languageOfCataloging authority='iso639-2b'>fre</languageOfCataloging></recordInfo></mods>")
194
- expect(@mods_rec.record_info.languageOfCataloging.map { |n| n.text }).to eq(['fre'])
195
- end
196
- it "authority should get attribute value" do
197
- # this example is from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html
198
- # though it doesn't match the doc at http://www.loc.gov/standards/mods/mods-outline.html#recordInfo
199
- @mods_rec.from_str("<mods #{@ns_decl}><recordInfo><languageOfCataloging authority='iso639-2b'>fre</languageOfCataloging></recordInfo></mods>")
200
- expect(@mods_rec.record_info.languageOfCataloging.authority).to eq(['iso639-2b'])
201
- end
202
-
203
- # from http://www.loc.gov/standards/mods/userguide/recordinfo.html#languageofcataloging
204
- # objectPart attribute defined for consistency with <language> . Unlikely to be used with <languageOfCataloging>
205
- it "objectType should get attribute value" do
206
- skip "<languageOfCataloging objectType=''> to be implemented ... maybe ..."
207
- end
208
-
209
- context "<languageTerm> child element" do
210
- it "text should get element value" do
211
- expect(@rec_info2.languageOfCataloging.languageTerm.map { |n| n.text }).to eq(['eng'])
212
- expect(@bnf.languageOfCataloging.languageTerm.map { |n| n.text }).to eq(['fra'])
213
- end
214
- it "should recognize all authority attributes" do
215
- Mods::AUTHORITY_ATTRIBS.each { |a|
216
- @mods_rec.from_str("<mods #{@ns_decl}><recordInfo><languageOfCataloging><languageTerm #{a}='attr_val'>zzz</languageTerm></languageOfCataloging></recordInfo></mods>")
217
- expect(@mods_rec.record_info.languageOfCataloging.languageTerm.send(a.to_sym)).to eq(['attr_val'])
218
- }
219
- end
220
- it "should recognize the type attribute with type_at term" do
221
- expect(@rec_info2.languageOfCataloging.languageTerm.type_at).to eq(['code'])
222
- end
223
- end # <languageTerm>
224
-
225
- context "<scriptTerm> child element" do
226
- it "should do something" do
227
- skip "<recordInfo><languageOfCataloging><scriptTerm> to be implemented"
228
- end
229
- end
230
- end # <languageOfCataloging>
231
-
232
- context "<descriptionStandard> child element" do
233
- it "should be a NodeSet" do
234
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.descriptionStandard).to be_an_instance_of(Nokogiri::XML::NodeSet) }
235
- end
236
- it "descriptionStandard NodeSet should have as many Nodes as there are <descriptionStandard> elements in the xml" do
237
- [@rec_info, @bnf].each { |ri| expect(ri.descriptionStandard.size).to eq(0) }
238
- [@rec_info2, @rlin].each { |ri| expect(ri.descriptionStandard.size).to eq(1) }
239
- end
240
- it "text should get element value" do
241
- expect(@rec_info2.descriptionStandard.map { |n| n.text }).to eq(['aacr2'])
242
- expect(@rlin.descriptionStandard.map { |n| n.text }).to eq(['appm'])
243
- expect(@bnf.descriptionStandard.map { |n| n.text }).to eq([])
244
- end
245
- it "should recognize all authority attributes" do
246
- Mods::AUTHORITY_ATTRIBS.each { |a|
247
- @mods_rec.from_str("<mods #{@ns_decl}><recordInfo><descriptionStandard #{a}='attr_val'>zzz</descriptionStandard></recordInfo></mods>")
248
- expect(@mods_rec.record_info.descriptionStandard.send(a.to_sym)).to eq(['attr_val'])
249
- }
250
- end
251
- end # <descriptionStandard>
252
-
253
- end # WITH namespaces
254
-
255
- context "WITHOUT namespaces" do
256
- before(:all) do
257
- @rec_info = @mods_rec.from_str("<mods><recordInfo>
258
- <recordContentSource authority='marcorg'>RQE</recordContentSource>
259
- <recordCreationDate encoding='marc'>890517</recordCreationDate>
260
- <recordIdentifier source='SIRSI'>a9079953</recordIdentifier>
261
- </recordInfo></mods>", false).record_info
262
- @rec_info2 = @mods_rec.from_str("<mods><recordInfo>
263
- <descriptionStandard>aacr2</descriptionStandard>
264
- <recordContentSource authority='marcorg'>AU@</recordContentSource>
265
- <recordCreationDate encoding='marc'>050921</recordCreationDate>
266
- <recordIdentifier source='SIRSI'>a8837534</recordIdentifier>
267
- <languageOfCataloging>
268
- <languageTerm authority='iso639-2b' type='code'>eng</languageTerm>
269
- </languageOfCataloging>
270
- </recordInfo></mods>", false).record_info
271
- @bnf = @mods_rec.from_str("<mods><recordInfo>
272
- <recordContentSource>TEI Description</recordContentSource>
273
- <recordCreationDate encoding='w3cdtf'>2011-12-07</recordCreationDate>
274
- <recordIdentifier source='BNF 2166'/>
275
- <recordOrigin/>
276
- <languageOfCataloging>
277
- <languageTerm authority='iso639-2b'>fra</languageTerm>
278
- </languageOfCataloging>
279
- </recordInfo></mods>", false).record_info
280
- @rlin = @mods_rec.from_str("<mods><recordInfo>
281
- <descriptionStandard>appm</descriptionStandard>
282
- <recordContentSource authority='marcorg'>CSt</recordContentSource>
283
- <recordCreationDate encoding='marc'>850416</recordCreationDate>
284
- <recordChangeDate encoding='iso8601'>19991012150824.0</recordChangeDate>
285
- <recordIdentifier source='CStRLIN'>a4083219</recordIdentifier>
286
- </recordInfo></mods>", false).record_info
287
- end
288
-
289
- it "should be a NodeSet" do
290
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri).to be_an_instance_of(Nokogiri::XML::NodeSet) }
291
- end
292
- it "should have as many members as there are <recordInfo> elements in the xml" do
293
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.size).to eq(1) }
294
- end
295
- it "should recognize language attributes on <recordInfo> element" do
296
- skip "problem with xml:lang"
297
- Mods::LANG_ATTRIBS.each { |a|
298
- @mods_rec.from_str("<mods><recordInfo #{a}='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>", false)
299
- expect(@mods_rec.record_info.send(a.to_sym)).to eq(['val'])
300
- }
301
- end
302
- it "should recognize displayLabel attribute on <recordInfo> element" do
303
- @mods_rec.from_str("<mods><recordInfo displayLabel='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>", false)
304
- expect(@mods_rec.record_info.displayLabel).to eq(['val'])
305
- end
306
-
307
- context "<recordContentSource> child element" do
308
- it "should be a NodeSet" do
309
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordContentSource).to be_an_instance_of(Nokogiri::XML::NodeSet) }
310
- end
311
- it "recordContentSource NodeSet should have as many Nodes as there are <recordContentSource> elements in the xml" do
312
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordContentSource.size).to eq(1) }
313
- end
314
- it "text should get element value" do
315
- expect(@rec_info.recordContentSource.map { |n| n.text }).to eq(["RQE"])
316
- expect(@rec_info2.recordContentSource.map { |n| n.text }).to eq(["AU@"])
317
- expect(@bnf.recordContentSource.map { |n| n.text }).to eq(["TEI Description"])
318
- expect(@rlin.recordContentSource.map { |n| n.text }).to eq(["CSt"])
319
- end
320
- it "should recognize authority attribute" do
321
- [@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordContentSource.authority).to eq(['marcorg']) }
322
- expect(@bnf.recordContentSource.authority.size).to eq(0)
323
- end
324
- it "should recognize all authority attributes" do
325
- Mods::AUTHORITY_ATTRIBS.each { |a|
326
- @mods_rec.from_str("<mods><recordInfo><recordContentSource #{a}='attr_val'>zzz</recordContentSource></recordInfo></mods>", false)
327
- expect(@mods_rec.record_info.recordContentSource.send(a.to_sym)).to eq(['attr_val'])
328
- }
329
- end
330
- end # <recordContentSource>
331
-
332
- context "<recordCreationDate> child element" do
333
- it "should be a NodeSet" do
334
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordCreationDate).to be_an_instance_of(Nokogiri::XML::NodeSet) }
335
- end
336
- it "recordCreationDate NodeSet should have as many Nodes as there are <recordCreationDate> elements in the xml" do
337
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordCreationDate.size).to eq(1) }
338
- end
339
- it "text should get element value" do
340
- expect(@rec_info.recordCreationDate.map { |n| n.text }).to eq(['890517'])
341
- expect(@rec_info2.recordCreationDate.map { |n| n.text }).to eq(['050921'])
342
- expect(@bnf.recordCreationDate.map { |n| n.text }).to eq(['2011-12-07'])
343
- expect(@rlin.recordCreationDate.map { |n| n.text }).to eq(['850416'])
344
- end
345
- it "should recognize encoding attribute" do
346
- [@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordCreationDate.encoding).to eq(['marc']) }
347
- expect(@bnf.recordCreationDate.encoding).to eq(['w3cdtf'])
348
- end
349
- it "should recognize all date attributes" do
350
- Mods::DATE_ATTRIBS.each { |a|
351
- @mods_rec.from_str("<mods><recordInfo><recordCreationDate #{a}='attr_val'>zzz</recordCreationDate></recordInfo></mods>", false)
352
- expect(@mods_rec.record_info.recordCreationDate.send(a.to_sym)).to eq(['attr_val'])
353
- }
354
- end
355
- end # <recordCreationDate>
356
-
357
- context "<recordChangeDate> child element" do
358
- it "should be a NodeSet" do
359
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordChangeDate).to be_an_instance_of(Nokogiri::XML::NodeSet) }
360
- end
361
- it "recordChangeDate NodeSet should have as many Nodes as there are <recordChangeDate> elements in the xml" do
362
- [@rec_info, @rec_info2, @bnf].each { |ri| expect(ri.recordChangeDate.size).to eq(0) }
363
- expect(@rlin.recordChangeDate.size).to eq(1)
364
- end
365
- it "text should get element value" do
366
- expect(@rlin.recordChangeDate.map { |n| n.text }).to eq(['19991012150824.0'])
367
- end
368
- it "should recognize encoding attribute" do
369
- expect(@rlin.recordChangeDate.encoding).to eq(['iso8601'])
370
- end
371
- it "should recognize all date attributes" do
372
- Mods::DATE_ATTRIBS.each { |a|
373
- @mods_rec.from_str("<mods><recordInfo><recordChangeDate #{a}='attr_val'>zzz</recordChangeDate></recordInfo></mods>", false)
374
- expect(@mods_rec.record_info.recordChangeDate.send(a.to_sym)).to eq(['attr_val'])
375
- }
376
- end
377
- end # <recordChangeDate>
378
-
379
- context "<recordIdentifier> child element" do
380
- it "should be a NodeSet" do
381
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordIdentifier).to be_an_instance_of(Nokogiri::XML::NodeSet) }
382
- end
383
- it "recordIdentifier NodeSet should have as many Nodes as there are <recordIdentifier> elements in the xml" do
384
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordIdentifier.size).to eq(1) }
385
- end
386
- it "text should get element value" do
387
- expect(@rec_info.recordIdentifier.map { |n| n.text }).to eq(['a9079953'])
388
- expect(@rec_info2.recordIdentifier.map { |n| n.text }).to eq(['a8837534'])
389
- expect(@bnf.recordIdentifier.map { |n| n.text }).to eq([''])
390
- expect(@rlin.recordIdentifier.map { |n| n.text }).to eq(['a4083219'])
391
- end
392
- it "should recognize source attribute" do
393
- [@rec_info, @rec_info2].each { |ri| expect(ri.recordIdentifier.source).to eq(['SIRSI']) }
394
- expect(@bnf.recordIdentifier.source).to eq(['BNF 2166'])
395
- expect(@rlin.recordIdentifier.source).to eq(['CStRLIN'])
396
- end
397
- it "should allow a source attribute without element content" do
398
- expect(@bnf.recordIdentifier.source).to eq(['BNF 2166'])
399
- expect(@bnf.recordIdentifier.map { |n| n.text }).to eq([''])
400
- end
401
- end # <recordIdentifier>
402
-
403
- context "<recordOrigin> child element" do
404
- it "should be a NodeSet" do
405
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordOrigin).to be_an_instance_of(Nokogiri::XML::NodeSet) }
406
- end
407
- it "recordOrigin NodeSet should have as many Nodes as there are <recordOrigin> elements in the xml" do
408
- [@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordOrigin.size).to eq(0) }
409
- expect(@bnf.recordOrigin.size).to eq(1)
410
- end
411
- it "text should get element value" do
412
- @mods_rec.from_str("<mods><recordInfo><recordOrigin>human prepared</recordOrigin></recordInfo></mods>", false)
413
- expect(@mods_rec.record_info.recordOrigin.map {|n| n.text }).to eq(['human prepared'])
414
- expect(@bnf.recordOrigin.map { |n| n.text }).to eq([''])
415
- end
416
- end # <recordOrigin>
417
-
418
- context "<languageOfCataloging> child element" do
419
- it "should be a NodeSet" do
420
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.languageOfCataloging).to be_an_instance_of(Nokogiri::XML::NodeSet) }
421
- end
422
- it "languageOfCataloging NodeSet should have as many Nodes as there are <languageOfCataloging> elements in the xml" do
423
- [@rec_info2, @bnf].each { |ri| expect(ri.languageOfCataloging.size).to eq(1) }
424
- [@rec_info, @rlin].each { |ri| expect(ri.languageOfCataloging.size).to eq(0) }
425
- end
426
- it "text should get element value" do
427
- # this example is from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html
428
- # though it doesn't match the doc at http://www.loc.gov/standards/mods/mods-outline.html#recordInfo
429
- @mods_rec.from_str("<mods><recordInfo><languageOfCataloging authority='iso639-2b'>fre</languageOfCataloging></recordInfo></mods>", false)
430
- expect(@mods_rec.record_info.languageOfCataloging.map { |n| n.text }).to eq(['fre'])
431
- end
432
- it "authority should get attribute value" do
433
- # this example is from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html
434
- # though it doesn't match the doc at http://www.loc.gov/standards/mods/mods-outline.html#recordInfo
435
- @mods_rec.from_str("<mods><recordInfo><languageOfCataloging authority='iso639-2b'>fre</languageOfCataloging></recordInfo></mods>", false)
436
- expect(@mods_rec.record_info.languageOfCataloging.authority).to eq(['iso639-2b'])
437
- end
438
-
439
- # from http://www.loc.gov/standards/mods/userguide/recordinfo.html#languageofcataloging
440
- # objectPart attribute defined for consistency with <language> . Unlikely to be used with <languageOfCataloging>
441
- it "objectType should get attribute value" do
442
- skip "<languageOfCataloging objectType=''> to be implemented ... maybe ..."
443
- end
444
-
445
- context "<languageTerm> child element" do
446
- it "text should get element value" do
447
- expect(@rec_info2.languageOfCataloging.languageTerm.map { |n| n.text }).to eq(['eng'])
448
- expect(@bnf.languageOfCataloging.languageTerm.map { |n| n.text }).to eq(['fra'])
449
- end
450
- it "should recognize all authority attributes" do
451
- Mods::AUTHORITY_ATTRIBS.each { |a|
452
- @mods_rec.from_str("<mods><recordInfo><languageOfCataloging><languageTerm #{a}='attr_val'>zzz</languageTerm></languageOfCataloging></recordInfo></mods>", false)
453
- expect(@mods_rec.record_info.languageOfCataloging.languageTerm.send(a.to_sym)).to eq(['attr_val'])
454
- }
455
- end
456
- it "should recognize the type attribute with type_at term" do
457
- expect(@rec_info2.languageOfCataloging.languageTerm.type_at).to eq(['code'])
458
- end
459
- end # <languageTerm>
460
-
461
- context "<scriptTerm> child element" do
462
- it "should do something" do
463
- skip "<recordInfo><languageOfCataloging><scriptTerm> to be implemented"
464
- end
465
- end
466
- end # <languageOfCataloging>
467
-
468
- context "<descriptionStandard> child element" do
469
- it "should be a NodeSet" do
470
- [@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.descriptionStandard).to be_an_instance_of(Nokogiri::XML::NodeSet) }
471
- end
472
- it "descriptionStandard NodeSet should have as many Nodes as there are <descriptionStandard> elements in the xml" do
473
- [@rec_info, @bnf].each { |ri| expect(ri.descriptionStandard.size).to eq(0) }
474
- [@rec_info2, @rlin].each { |ri| expect(ri.descriptionStandard.size).to eq(1) }
475
- end
476
- it "text should get element value" do
477
- expect(@rec_info2.descriptionStandard.map { |n| n.text }).to eq(['aacr2'])
478
- expect(@rlin.descriptionStandard.map { |n| n.text }).to eq(['appm'])
479
- expect(@bnf.descriptionStandard.map { |n| n.text }).to eq([])
480
- end
481
- it "should recognize all authority attributes" do
482
- Mods::AUTHORITY_ATTRIBS.each { |a|
483
- @mods_rec.from_str("<mods><recordInfo><descriptionStandard #{a}='attr_val'>zzz</descriptionStandard></recordInfo></mods>", false)
484
- expect(@mods_rec.record_info.descriptionStandard.send(a.to_sym)).to eq(['attr_val'])
485
- }
486
- end
487
- end # <descriptionStandard>
488
-
489
- end # WITHOUT namespaces
490
-
491
- end # basic <record_info> terminology pieces
492
-
493
- end