mods 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/lib/mods/nom_terminology.rb +248 -249
- data/lib/mods/reader.rb +2 -4
- data/lib/mods/record.rb +5 -1
- data/lib/mods/version.rb +1 -1
- data/mods.gemspec +4 -4
- data/spec/language_spec.rb +30 -30
- data/spec/location_spec.rb +44 -44
- data/spec/name_spec.rb +155 -155
- data/spec/origin_info_spec.rb +32 -32
- data/spec/part_spec.rb +122 -122
- data/spec/physical_description_spec.rb +18 -18
- data/spec/reader_spec.rb +41 -40
- data/spec/record_info_spec.rb +120 -120
- data/spec/record_spec.rb +63 -58
- data/spec/related_item_spec.rb +76 -76
- data/spec/subject_spec.rb +165 -165
- data/spec/title_spec.rb +44 -44
- data/spec/top_level_elmnts_simple_spec.rb +61 -61
- metadata +28 -27
data/spec/subject_spec.rb
CHANGED
@@ -90,17 +90,17 @@ describe "Mods <subject> Element" do
|
|
90
90
|
</name></subject></mods>").subject
|
91
91
|
end
|
92
92
|
it "should be able to identify corporate names" do
|
93
|
-
@both_types_sub.corporate_name.namePart.map { |e| e.text }.
|
93
|
+
expect(@both_types_sub.corporate_name.namePart.map { |e| e.text }).to eq(['Britton & Rey.'])
|
94
94
|
end
|
95
95
|
it "should be able to identify personal names" do
|
96
|
-
@both_types_sub.personal_name.namePart.map { |e| e.text }.
|
97
|
-
@pers_name_sub.personal_name.displayForm.map { |e| e.text }.
|
96
|
+
expect(@both_types_sub.personal_name.namePart.map { |e| e.text }).to eq(['Bridgens, R.P'])
|
97
|
+
expect(@pers_name_sub.personal_name.displayForm.map { |e| e.text }).to eq(['Edward VI , king of England, 1537-1553'])
|
98
98
|
end
|
99
99
|
it "should be able to identify roles associated with a name" do
|
100
|
-
@mult_corp_name_sub.corporate_name.role.roleTerm.map { |e| e.text }.
|
100
|
+
expect(@mult_corp_name_sub.corporate_name.role.roleTerm.map { |e| e.text }).to eq(['lithographers.'])
|
101
101
|
end
|
102
102
|
it "should be able to identify dates associated with a name" do
|
103
|
-
@mult_pers_name_sub.personal_name.date.map { |e| e.text }.
|
103
|
+
expect(@mult_pers_name_sub.personal_name.date.map { |e| e.text }).to include("1818-1878")
|
104
104
|
end
|
105
105
|
it "should do the appropriate thing with the role for the value of a name" do
|
106
106
|
skip "name objects to be implemented"
|
@@ -141,16 +141,16 @@ describe "Mods <subject> Element" do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
it "should be a NodeSet" do
|
144
|
-
@four_subjects.
|
145
|
-
@lcsh_subject.
|
144
|
+
expect(@four_subjects).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
145
|
+
expect(@lcsh_subject).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
146
146
|
end
|
147
147
|
it "should have as many members as there are <subject> elements in the xml" do
|
148
|
-
@four_subjects.size.
|
149
|
-
@lcsh_subject.size.
|
148
|
+
expect(@four_subjects.size).to eq(4)
|
149
|
+
expect(@lcsh_subject.size).to eq(1)
|
150
150
|
end
|
151
151
|
it "should recognize authority attribute on <subject> element" do
|
152
152
|
['lcsh', 'ingest', 'lctgm'].each { |a|
|
153
|
-
@mods_rec.from_str("<mods #{@ns_decl}><subject authority='#{a}'><topic>Ruler, English.</topic></subject></mods>").subject.authority.
|
153
|
+
expect(@mods_rec.from_str("<mods #{@ns_decl}><subject authority='#{a}'><topic>Ruler, English.</topic></subject></mods>").subject.authority).to eq([a])
|
154
154
|
}
|
155
155
|
end
|
156
156
|
|
@@ -166,42 +166,42 @@ describe "Mods <subject> Element" do
|
|
166
166
|
@multi_topic = @mods_rec.from_str(multi_topic).subject.topic
|
167
167
|
end
|
168
168
|
it "should be a NodeSet" do
|
169
|
-
@topic_simple.
|
170
|
-
@multi_topic.
|
169
|
+
expect(@topic_simple).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
170
|
+
expect(@multi_topic).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
171
171
|
end
|
172
172
|
it "topic NodeSet should have as many Nodes as there are <topic> elements in the xml" do
|
173
|
-
@topic_simple.size.
|
174
|
-
@multi_topic.size.
|
175
|
-
@four_subjects.topic.size.
|
176
|
-
@geo_code_subject.topic.size.
|
173
|
+
expect(@topic_simple.size).to eq(1)
|
174
|
+
expect(@multi_topic.size).to eq(3)
|
175
|
+
expect(@four_subjects.topic.size).to eq(3)
|
176
|
+
expect(@geo_code_subject.topic.size).to eq(0)
|
177
177
|
end
|
178
178
|
it "text should get element value" do
|
179
|
-
@topic_simple.text.
|
180
|
-
@multi_topic.text.
|
181
|
-
@multi_topic.text.
|
182
|
-
@multi_topic.text.
|
183
|
-
@four_subjects.topic.text.
|
179
|
+
expect(@topic_simple.text).to eq("History")
|
180
|
+
expect(@multi_topic.text).to include("California as an island--Maps--1662?")
|
181
|
+
expect(@multi_topic.text).to include("North America--Maps--To 1800")
|
182
|
+
expect(@multi_topic.text).to include("North America--Maps--1662?")
|
183
|
+
expect(@four_subjects.topic.text).to include("History")
|
184
184
|
end
|
185
185
|
end # <topic>
|
186
186
|
|
187
187
|
context "<geographic> child element" do
|
188
188
|
it "should be a NodeSet" do
|
189
|
-
@four_subjects.geographic.
|
190
|
-
@lcsh_subject.geographic.
|
191
|
-
@geo_code_subject.geographic.
|
189
|
+
expect(@four_subjects.geographic).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
190
|
+
expect(@lcsh_subject.geographic).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
191
|
+
expect(@geo_code_subject.geographic).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
192
192
|
end
|
193
193
|
it "geographic NodeSet should have as many Nodes as there are <geographic> elements in the xml" do
|
194
|
-
@four_subjects.geographic.size.
|
195
|
-
@lcsh_subject.geographic.size.
|
196
|
-
@geo_code_subject.geographic.size.
|
194
|
+
expect(@four_subjects.geographic.size).to eq(3)
|
195
|
+
expect(@lcsh_subject.geographic.size).to eq(1)
|
196
|
+
expect(@geo_code_subject.geographic.size).to eq(0)
|
197
197
|
end
|
198
198
|
it "text should get element value" do
|
199
|
-
@four_subjects.geographic.text.
|
200
|
-
@four_subjects.geographic.text.
|
201
|
-
@four_subjects.geographic.text.
|
199
|
+
expect(@four_subjects.geographic.text).to include("San Francisco (Calif.)")
|
200
|
+
expect(@four_subjects.geographic.text).to include("San Diego (Calif.)")
|
201
|
+
expect(@four_subjects.geographic.text).to include("San Luis Rey (Calif.)")
|
202
202
|
end
|
203
203
|
it "should not include <geographicCode> element" do
|
204
|
-
@geo_code_subject.geographic.size.
|
204
|
+
expect(@geo_code_subject.geographic.size).to eq(0)
|
205
205
|
end
|
206
206
|
end # <geographic>
|
207
207
|
|
@@ -214,60 +214,60 @@ describe "Mods <subject> Element" do
|
|
214
214
|
end
|
215
215
|
|
216
216
|
it "should recognize the date attributes" do
|
217
|
-
@temporal.encoding.
|
217
|
+
expect(@temporal.encoding).to eq(['iso8601'])
|
218
218
|
Mods::DATE_ATTRIBS.each { |a|
|
219
|
-
@mods_rec.from_str("<mods #{@ns_decl}><subject><temporal #{a}='val'>now</temporal></subject></mods>").subject.temporal.send(a.to_sym).
|
219
|
+
expect(@mods_rec.from_str("<mods #{@ns_decl}><subject><temporal #{a}='val'>now</temporal></subject></mods>").subject.temporal.send(a.to_sym)).to eq(['val'])
|
220
220
|
}
|
221
221
|
end
|
222
222
|
it "should be a NodeSet" do
|
223
|
-
@lcsh_subject.temporal.
|
224
|
-
@temporal.
|
223
|
+
expect(@lcsh_subject.temporal).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
224
|
+
expect(@temporal).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
225
225
|
end
|
226
226
|
it "temporal NodeSet should have as many Nodes as there are <temporal> elements in the xml" do
|
227
|
-
@lcsh_subject.temporal.size.
|
228
|
-
@temporal.size.
|
227
|
+
expect(@lcsh_subject.temporal.size).to eq(1)
|
228
|
+
expect(@temporal.size).to eq(1)
|
229
229
|
end
|
230
230
|
it "text should get element value" do
|
231
|
-
@lcsh_subject.temporal.map { |n| n.text }.
|
232
|
-
@temporal.map { |n| n.text }.
|
231
|
+
expect(@lcsh_subject.temporal.map { |n| n.text }).to eq(['500-1400'])
|
232
|
+
expect(@temporal.map { |n| n.text }).to eq(['20010203T040506+0700'])
|
233
233
|
end
|
234
234
|
end # <temporal>
|
235
235
|
|
236
236
|
context "<genre> child element" do
|
237
237
|
it "should be a NodeSet" do
|
238
|
-
@lcsh_subject.genre.
|
239
|
-
@four_subjects.genre.
|
238
|
+
expect(@lcsh_subject.genre).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
239
|
+
expect(@four_subjects.genre).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
240
240
|
end
|
241
241
|
it "genre NodeSet should have as many Nodes as there are <genre> elements in the xml" do
|
242
|
-
@lcsh_subject.genre.size.
|
243
|
-
@four_subjects.genre.size.
|
242
|
+
expect(@lcsh_subject.genre.size).to eq(1)
|
243
|
+
expect(@four_subjects.genre.size).to eq(4)
|
244
244
|
end
|
245
245
|
it "text should get element value" do
|
246
|
-
@lcsh_subject.genre.map { |n| n.text }.
|
247
|
-
@four_subjects.genre.map { |n| n.text }.
|
246
|
+
expect(@lcsh_subject.genre.map { |n| n.text }).to eq(['Maps'])
|
247
|
+
expect(@four_subjects.genre.map { |n| n.text }).to include("Pictorial works")
|
248
248
|
end
|
249
249
|
end # <genre>
|
250
250
|
|
251
251
|
context "<geographicCode> child element" do
|
252
252
|
it "should be a NodeSet" do
|
253
|
-
@geo_code_subject.geographicCode.
|
253
|
+
expect(@geo_code_subject.geographicCode).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
254
254
|
end
|
255
255
|
it "cartographics NodeSet should have as many Nodes as there are <geographicCode> elements in the xml" do
|
256
|
-
@geo_code_subject.geographicCode.size.
|
256
|
+
expect(@geo_code_subject.geographicCode.size).to eq(1)
|
257
257
|
end
|
258
258
|
it "text should get element value" do
|
259
|
-
@geo_code_subject.geographicCode.map { |n| n.text }.
|
259
|
+
expect(@geo_code_subject.geographicCode.map { |n| n.text }).to eq(['f------'])
|
260
260
|
end
|
261
261
|
it "should recognize authority attributes" do
|
262
262
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
263
263
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><geographicCode #{a}='attr_val'>f------</geographicCode></subject></mods>")
|
264
|
-
@mods_rec.subject.geographicCode.send(a.to_sym).
|
264
|
+
expect(@mods_rec.subject.geographicCode.send(a.to_sym)).to eq(['attr_val'])
|
265
265
|
}
|
266
266
|
end
|
267
267
|
it "should recognize the sanctioned authorities" do
|
268
268
|
Mods::Subject::GEO_CODE_AUTHORITIES.each { |a|
|
269
269
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><geographicCode authority='#{a}'>f------</geographicCode></subject></mods>")
|
270
|
-
@mods_rec.subject.geographicCode.authority.
|
270
|
+
expect(@mods_rec.subject.geographicCode.authority).to eq([a])
|
271
271
|
}
|
272
272
|
end
|
273
273
|
it "should not recognize unsanctioned authorities?" do
|
@@ -278,23 +278,23 @@ describe "Mods <subject> Element" do
|
|
278
278
|
context "translated_value convenience method" do
|
279
279
|
it "should be the translation of the code if it is a marcgac code" do
|
280
280
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><geographicCode authority='marcgac'>e-er</geographicCode></subject></mods>")
|
281
|
-
@mods_rec.subject.geographicCode.translated_value.
|
281
|
+
expect(@mods_rec.subject.geographicCode.translated_value).to eq(["Estonia"])
|
282
282
|
end
|
283
283
|
it "should be the translation of the code if it is a marccountry code" do
|
284
284
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><geographicCode authority='marccountry'>mg</geographicCode></subject></mods>")
|
285
|
-
@mods_rec.subject.geographicCode.translated_value.
|
285
|
+
expect(@mods_rec.subject.geographicCode.translated_value).to eq(["Madagascar"])
|
286
286
|
end
|
287
287
|
it "should be nil if the code is invalid" do
|
288
288
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><geographicCode authority='marcgac'>zzz</geographicCode></subject></mods>")
|
289
|
-
@mods_rec.subject.geographicCode.translated_value.size.
|
289
|
+
expect(@mods_rec.subject.geographicCode.translated_value.size).to eq(0)
|
290
290
|
end
|
291
291
|
it "should be nil if we don't have a translation for the authority" do
|
292
292
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><geographicCode authority='iso3166'>zzz</geographicCode></subject></mods>")
|
293
|
-
@mods_rec.subject.geographicCode.translated_value.size.
|
293
|
+
expect(@mods_rec.subject.geographicCode.translated_value.size).to eq(0)
|
294
294
|
end
|
295
295
|
it "should work with non-ascii characters" do
|
296
296
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><geographicCode authority='marccountry'>co</geographicCode></subject></mods>")
|
297
|
-
@mods_rec.subject.geographicCode.translated_value.
|
297
|
+
expect(@mods_rec.subject.geographicCode.translated_value).to eq(["Curaçao"])
|
298
298
|
end
|
299
299
|
end
|
300
300
|
end # <geographicCode>
|
@@ -313,24 +313,24 @@ describe "Mods <subject> Element" do
|
|
313
313
|
Mods::TitleInfo::ATTRIBUTES.each { |a|
|
314
314
|
ti = @mods_rec.from_str("<mods #{@ns_decl}><subject><titleInfo #{a}='attr_val'>THE</titleInfo></subject></mods>").subject.titleInfo
|
315
315
|
if (a == 'type')
|
316
|
-
ti.type_at.
|
316
|
+
expect(ti.type_at).to eq(['attr_val'])
|
317
317
|
else
|
318
|
-
ti.send(a.to_sym).
|
318
|
+
expect(ti.send(a.to_sym)).to eq(['attr_val'])
|
319
319
|
end
|
320
320
|
}
|
321
321
|
end
|
322
322
|
it "should understand all immediate child elements allowed on a <titleInfo> element" do
|
323
323
|
Mods::TitleInfo::CHILD_ELEMENTS.each { |e|
|
324
|
-
@mods_rec.from_str("<mods #{@ns_decl}><subject><titleInfo><#{e}>el_val</#{e}></titleInfo></subject></mods>").subject.titleInfo.send(e.to_sym).text.
|
324
|
+
expect(@mods_rec.from_str("<mods #{@ns_decl}><subject><titleInfo><#{e}>el_val</#{e}></titleInfo></subject></mods>").subject.titleInfo.send(e.to_sym).text).to eq('el_val')
|
325
325
|
}
|
326
|
-
@title_info.nonSort.map {|n| n.text}.
|
326
|
+
expect(@title_info.nonSort.map {|n| n.text}).to eq(["The"])
|
327
327
|
end
|
328
328
|
|
329
329
|
it "should recognize authority attribute on the <titleInfo> element" do
|
330
|
-
@mods_rec.from_str("<mods #{@ns_decl}><subject>
|
330
|
+
expect(@mods_rec.from_str("<mods #{@ns_decl}><subject>
|
331
331
|
<titleInfo type='uniform' authority='naf'>
|
332
332
|
<title>Missale Carnotense</title>
|
333
|
-
</titleInfo></subject></mods>").subject.titleInfo.authority.
|
333
|
+
</titleInfo></subject></mods>").subject.titleInfo.authority).to eq(["naf"])
|
334
334
|
end
|
335
335
|
end # <titleInfo>
|
336
336
|
|
@@ -339,9 +339,9 @@ describe "Mods <subject> Element" do
|
|
339
339
|
Mods::Name::ATTRIBUTES.each { |a|
|
340
340
|
name = @mods_rec.from_str("<mods #{@ns_decl}><subject><name #{a}='attr_val'>Obadiah</name></subject></mods>").subject.name_el
|
341
341
|
if (a == 'type')
|
342
|
-
name.type_at.
|
342
|
+
expect(name.type_at).to eq(['attr_val'])
|
343
343
|
else
|
344
|
-
name.send(a.to_sym).
|
344
|
+
expect(name.send(a.to_sym)).to eq(['attr_val'])
|
345
345
|
end
|
346
346
|
}
|
347
347
|
end
|
@@ -349,18 +349,18 @@ describe "Mods <subject> Element" do
|
|
349
349
|
Mods::Name::CHILD_ELEMENTS.each { |e|
|
350
350
|
name = @mods_rec.from_str("<mods #{@ns_decl}><subject><name><#{e}>el_val</#{e}></name></subject></mods>").subject.name_el
|
351
351
|
if (e == 'description')
|
352
|
-
name.description_el.text.
|
352
|
+
expect(name.description_el.text).to eq('el_val')
|
353
353
|
elsif (e != 'role')
|
354
|
-
name.send(e.to_sym).text.
|
354
|
+
expect(name.send(e.to_sym).text).to eq('el_val')
|
355
355
|
end
|
356
356
|
}
|
357
357
|
end
|
358
358
|
it "should recognize authority attribute on the <name> element" do
|
359
|
-
@mods_rec.from_str("<mods #{@ns_decl}><subject>
|
359
|
+
expect(@mods_rec.from_str("<mods #{@ns_decl}><subject>
|
360
360
|
<name type='personal' authority='lcsh'>
|
361
361
|
<namePart>Nahl, Charles Christian</namePart>
|
362
362
|
<namePart type='date'>1818-1878</namePart>
|
363
|
-
</name></mods>").subject.name_el.authority.
|
363
|
+
</name></mods>").subject.name_el.authority).to eq(["lcsh"])
|
364
364
|
end
|
365
365
|
end # <name>
|
366
366
|
|
@@ -368,15 +368,15 @@ describe "Mods <subject> Element" do
|
|
368
368
|
it "should recognize authority attributes" do
|
369
369
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
370
370
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><hierarchicalGeographic #{a}='attr_val'><country>Albania</country></hierarchicalGeographic></subject></mods>")
|
371
|
-
@mods_rec.subject.hierarchicalGeographic.send(a.to_sym).
|
371
|
+
expect(@mods_rec.subject.hierarchicalGeographic.send(a.to_sym)).to eq(['attr_val'])
|
372
372
|
}
|
373
373
|
end
|
374
374
|
it "should recognize allowed child elements" do
|
375
375
|
Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |e|
|
376
376
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><hierarchicalGeographic><#{e}>el_val</#{e}></hierarchicalGeographic></subject></mods>")
|
377
|
-
@mods_rec.subject.hierarchicalGeographic.send(e.to_sym).text.
|
377
|
+
expect(@mods_rec.subject.hierarchicalGeographic.send(e.to_sym).text).to eq('el_val')
|
378
378
|
}
|
379
|
-
Mods::Subject::HIER_GEO_CHILD_ELEMENTS.size.
|
379
|
+
expect(Mods::Subject::HIER_GEO_CHILD_ELEMENTS.size).to eq(12)
|
380
380
|
end
|
381
381
|
end # <hierarchicalGeographic>
|
382
382
|
|
@@ -408,31 +408,31 @@ describe "Mods <subject> Element" do
|
|
408
408
|
</subject></mods>").subject.cartographics
|
409
409
|
end
|
410
410
|
it "should be a NodeSet" do
|
411
|
-
@carto_scale.
|
412
|
-
@carto_empties.
|
413
|
-
@multi_carto.
|
411
|
+
expect(@carto_scale).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
412
|
+
expect(@carto_empties).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
413
|
+
expect(@multi_carto).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
414
414
|
end
|
415
415
|
it "cartographics NodeSet should have as many Nodes as there are <cartographics> elements in the xml" do
|
416
|
-
@carto_scale.size.
|
417
|
-
@carto_empties.size.
|
418
|
-
@multi_carto.size.
|
416
|
+
expect(@carto_scale.size).to eq(1)
|
417
|
+
expect(@carto_empties.size).to eq(1)
|
418
|
+
expect(@multi_carto.size).to eq(3)
|
419
419
|
end
|
420
420
|
it "should recognize allowed child elements" do
|
421
421
|
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |e|
|
422
422
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><cartographics><#{e}>el_val</#{e}></cartographics></subject></mods>")
|
423
|
-
@mods_rec.subject.cartographics.send(e.to_sym).text.
|
423
|
+
expect(@mods_rec.subject.cartographics.send(e.to_sym).text).to eq('el_val')
|
424
424
|
}
|
425
|
-
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.size.
|
425
|
+
expect(Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.size).to eq(3)
|
426
426
|
end
|
427
427
|
it "should get the number of populated <coordinates> elements for coordinates term" do
|
428
428
|
@multi_carto.coordinates.size == 2
|
429
429
|
end
|
430
430
|
it "should be able to get the value of populated elements" do
|
431
|
-
@carto_scale.scale.map { |n| n.text }.
|
432
|
-
@carto_empties.coordinates.map { |n| n.text }.
|
431
|
+
expect(@carto_scale.scale.map { |n| n.text }).to eq(['[ca.1:90,000,000], [173'])
|
432
|
+
expect(@carto_empties.coordinates.map { |n| n.text }).to eq(['W1730000 W0100000 N840000 N071000'])
|
433
433
|
end
|
434
434
|
it "should get the empty string for empty elements?" do
|
435
|
-
@carto_empties.projection.map { |n| n.text }.
|
435
|
+
expect(@carto_empties.projection.map { |n| n.text }).to eq([''])
|
436
436
|
end
|
437
437
|
end # <cartographics>
|
438
438
|
|
@@ -441,18 +441,18 @@ describe "Mods <subject> Element" do
|
|
441
441
|
@occupation = @mods_rec.from_str("<mods #{@ns_decl}><subject><occupation>Migrant laborers</occupation></mods>").subject.occupation
|
442
442
|
end
|
443
443
|
it "should be a NodeSet" do
|
444
|
-
@occupation.
|
444
|
+
expect(@occupation).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
445
445
|
end
|
446
446
|
it "occupation NodeSet should have as many Nodes as there are <occupation> elements in the xml" do
|
447
|
-
@occupation.size.
|
447
|
+
expect(@occupation.size).to eq(1)
|
448
448
|
end
|
449
449
|
it "text should get element value" do
|
450
|
-
@occupation.map { |n| n.text }.
|
450
|
+
expect(@occupation.map { |n| n.text }).to eq(['Migrant laborers'])
|
451
451
|
end
|
452
452
|
it "should recognize authority attributes" do
|
453
453
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
454
454
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><occupation #{a}='attr_val'>Flunkie</occupation></subject></mods>")
|
455
|
-
@mods_rec.subject.occupation.send(a.to_sym).
|
455
|
+
expect(@mods_rec.subject.occupation.send(a.to_sym)).to eq(['attr_val'])
|
456
456
|
}
|
457
457
|
end
|
458
458
|
end # <occupation>
|
@@ -487,16 +487,16 @@ describe "Mods <subject> Element" do
|
|
487
487
|
end
|
488
488
|
|
489
489
|
it "should be a NodeSet" do
|
490
|
-
@four_subjects.
|
491
|
-
@lcsh_subject.
|
490
|
+
expect(@four_subjects).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
491
|
+
expect(@lcsh_subject).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
492
492
|
end
|
493
493
|
it "should have as many members as there are <subject> elements in the xml" do
|
494
|
-
@four_subjects.size.
|
495
|
-
@lcsh_subject.size.
|
494
|
+
expect(@four_subjects.size).to eq(4)
|
495
|
+
expect(@lcsh_subject.size).to eq(1)
|
496
496
|
end
|
497
497
|
it "should recognize authority attribute on <subject> element" do
|
498
498
|
['lcsh', 'ingest', 'lctgm'].each { |a|
|
499
|
-
@mods_rec.from_str("<mods><subject authority='#{a}'><topic>Ruler, English.</topic></subject></mods>", false).subject.authority.
|
499
|
+
expect(@mods_rec.from_str("<mods><subject authority='#{a}'><topic>Ruler, English.</topic></subject></mods>", false).subject.authority).to eq([a])
|
500
500
|
}
|
501
501
|
end
|
502
502
|
|
@@ -512,42 +512,42 @@ describe "Mods <subject> Element" do
|
|
512
512
|
@multi_topic = @mods_rec.from_str(multi_topic, false).subject.topic
|
513
513
|
end
|
514
514
|
it "should be a NodeSet" do
|
515
|
-
@topic_simple.
|
516
|
-
@multi_topic.
|
515
|
+
expect(@topic_simple).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
516
|
+
expect(@multi_topic).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
517
517
|
end
|
518
518
|
it "topic NodeSet should have as many Nodes as there are <topic> elements in the xml" do
|
519
|
-
@topic_simple.size.
|
520
|
-
@multi_topic.size.
|
521
|
-
@four_subjects.topic.size.
|
522
|
-
@geo_code_subject.topic.size.
|
519
|
+
expect(@topic_simple.size).to eq(1)
|
520
|
+
expect(@multi_topic.size).to eq(3)
|
521
|
+
expect(@four_subjects.topic.size).to eq(3)
|
522
|
+
expect(@geo_code_subject.topic.size).to eq(0)
|
523
523
|
end
|
524
524
|
it "text should get element value" do
|
525
|
-
@topic_simple.text.
|
526
|
-
@multi_topic.text.
|
527
|
-
@multi_topic.text.
|
528
|
-
@multi_topic.text.
|
529
|
-
@four_subjects.topic.text.
|
525
|
+
expect(@topic_simple.text).to eq("History")
|
526
|
+
expect(@multi_topic.text).to include("California as an island--Maps--1662?")
|
527
|
+
expect(@multi_topic.text).to include("North America--Maps--To 1800")
|
528
|
+
expect(@multi_topic.text).to include("North America--Maps--1662?")
|
529
|
+
expect(@four_subjects.topic.text).to include("History")
|
530
530
|
end
|
531
531
|
end # <topic>
|
532
532
|
|
533
533
|
context "<geographic> child element" do
|
534
534
|
it "should be a NodeSet" do
|
535
|
-
@four_subjects.geographic.
|
536
|
-
@lcsh_subject.geographic.
|
537
|
-
@geo_code_subject.geographic.
|
535
|
+
expect(@four_subjects.geographic).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
536
|
+
expect(@lcsh_subject.geographic).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
537
|
+
expect(@geo_code_subject.geographic).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
538
538
|
end
|
539
539
|
it "geographic NodeSet should have as many Nodes as there are <geographic> elements in the xml" do
|
540
|
-
@four_subjects.geographic.size.
|
541
|
-
@lcsh_subject.geographic.size.
|
542
|
-
@geo_code_subject.geographic.size.
|
540
|
+
expect(@four_subjects.geographic.size).to eq(3)
|
541
|
+
expect(@lcsh_subject.geographic.size).to eq(1)
|
542
|
+
expect(@geo_code_subject.geographic.size).to eq(0)
|
543
543
|
end
|
544
544
|
it "text should get element value" do
|
545
|
-
@four_subjects.geographic.text.
|
546
|
-
@four_subjects.geographic.text.
|
547
|
-
@four_subjects.geographic.text.
|
545
|
+
expect(@four_subjects.geographic.text).to include("San Francisco (Calif.)")
|
546
|
+
expect(@four_subjects.geographic.text).to include("San Diego (Calif.)")
|
547
|
+
expect(@four_subjects.geographic.text).to include("San Luis Rey (Calif.)")
|
548
548
|
end
|
549
549
|
it "should not include <geographicCode> element" do
|
550
|
-
@geo_code_subject.geographic.size.
|
550
|
+
expect(@geo_code_subject.geographic.size).to eq(0)
|
551
551
|
end
|
552
552
|
end # <geographic>
|
553
553
|
|
@@ -560,60 +560,60 @@ describe "Mods <subject> Element" do
|
|
560
560
|
end
|
561
561
|
|
562
562
|
it "should recognize the date attributes" do
|
563
|
-
@temporal.encoding.
|
563
|
+
expect(@temporal.encoding).to eq(['iso8601'])
|
564
564
|
Mods::DATE_ATTRIBS.each { |a|
|
565
|
-
@mods_rec.from_str("<mods><subject><temporal #{a}='val'>now</temporal></subject></mods>", false).subject.temporal.send(a.to_sym).
|
565
|
+
expect(@mods_rec.from_str("<mods><subject><temporal #{a}='val'>now</temporal></subject></mods>", false).subject.temporal.send(a.to_sym)).to eq(['val'])
|
566
566
|
}
|
567
567
|
end
|
568
568
|
it "should be a NodeSet" do
|
569
|
-
@lcsh_subject.temporal.
|
570
|
-
@temporal.
|
569
|
+
expect(@lcsh_subject.temporal).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
570
|
+
expect(@temporal).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
571
571
|
end
|
572
572
|
it "temporal NodeSet should have as many Nodes as there are <temporal> elements in the xml" do
|
573
|
-
@lcsh_subject.temporal.size.
|
574
|
-
@temporal.size.
|
573
|
+
expect(@lcsh_subject.temporal.size).to eq(1)
|
574
|
+
expect(@temporal.size).to eq(1)
|
575
575
|
end
|
576
576
|
it "text should get element value" do
|
577
|
-
@lcsh_subject.temporal.map { |n| n.text }.
|
578
|
-
@temporal.map { |n| n.text }.
|
577
|
+
expect(@lcsh_subject.temporal.map { |n| n.text }).to eq(['500-1400'])
|
578
|
+
expect(@temporal.map { |n| n.text }).to eq(['20010203T040506+0700'])
|
579
579
|
end
|
580
580
|
end # <temporal>
|
581
581
|
|
582
582
|
context "<genre> child element" do
|
583
583
|
it "should be a NodeSet" do
|
584
|
-
@lcsh_subject.genre.
|
585
|
-
@four_subjects.genre.
|
584
|
+
expect(@lcsh_subject.genre).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
585
|
+
expect(@four_subjects.genre).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
586
586
|
end
|
587
587
|
it "genre NodeSet should have as many Nodes as there are <genre> elements in the xml" do
|
588
|
-
@lcsh_subject.genre.size.
|
589
|
-
@four_subjects.genre.size.
|
588
|
+
expect(@lcsh_subject.genre.size).to eq(1)
|
589
|
+
expect(@four_subjects.genre.size).to eq(4)
|
590
590
|
end
|
591
591
|
it "text should get element value" do
|
592
|
-
@lcsh_subject.genre.map { |n| n.text }.
|
593
|
-
@four_subjects.genre.map { |n| n.text }.
|
592
|
+
expect(@lcsh_subject.genre.map { |n| n.text }).to eq(['Maps'])
|
593
|
+
expect(@four_subjects.genre.map { |n| n.text }).to include("Pictorial works")
|
594
594
|
end
|
595
595
|
end # <genre>
|
596
596
|
|
597
597
|
context "<geographicCode> child element" do
|
598
598
|
it "should be a NodeSet" do
|
599
|
-
@geo_code_subject.geographicCode.
|
599
|
+
expect(@geo_code_subject.geographicCode).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
600
600
|
end
|
601
601
|
it "cartographics NodeSet should have as many Nodes as there are <geographicCode> elements in the xml" do
|
602
|
-
@geo_code_subject.geographicCode.size.
|
602
|
+
expect(@geo_code_subject.geographicCode.size).to eq(1)
|
603
603
|
end
|
604
604
|
it "text should get element value" do
|
605
|
-
@geo_code_subject.geographicCode.map { |n| n.text }.
|
605
|
+
expect(@geo_code_subject.geographicCode.map { |n| n.text }).to eq(['f------'])
|
606
606
|
end
|
607
607
|
it "should recognize authority attributes" do
|
608
608
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
609
609
|
@mods_rec.from_str("<mods><subject><geographicCode #{a}='attr_val'>f------</geographicCode></subject></mods>", false)
|
610
|
-
@mods_rec.subject.geographicCode.send(a.to_sym).
|
610
|
+
expect(@mods_rec.subject.geographicCode.send(a.to_sym)).to eq(['attr_val'])
|
611
611
|
}
|
612
612
|
end
|
613
613
|
it "should recognize the sanctioned authorities" do
|
614
614
|
Mods::Subject::GEO_CODE_AUTHORITIES.each { |a|
|
615
615
|
@mods_rec.from_str("<mods><subject><geographicCode authority='#{a}'>f------</geographicCode></subject></mods>", false)
|
616
|
-
@mods_rec.subject.geographicCode.authority.
|
616
|
+
expect(@mods_rec.subject.geographicCode.authority).to eq([a])
|
617
617
|
}
|
618
618
|
end
|
619
619
|
it "should not recognize unsanctioned authorities?" do
|
@@ -624,23 +624,23 @@ describe "Mods <subject> Element" do
|
|
624
624
|
context "translated_value convenience method" do
|
625
625
|
it "should be the translation of the code if it is a marcgac code" do
|
626
626
|
@mods_rec.from_str("<mods><subject><geographicCode authority='marcgac'>e-er</geographicCode></subject></mods>", false)
|
627
|
-
@mods_rec.subject.geographicCode.translated_value.
|
627
|
+
expect(@mods_rec.subject.geographicCode.translated_value).to eq(["Estonia"])
|
628
628
|
end
|
629
629
|
it "should be the translation of the code if it is a marccountry code" do
|
630
630
|
@mods_rec.from_str("<mods><subject><geographicCode authority='marccountry'>mg</geographicCode></subject></mods>", false)
|
631
|
-
@mods_rec.subject.geographicCode.translated_value.
|
631
|
+
expect(@mods_rec.subject.geographicCode.translated_value).to eq(["Madagascar"])
|
632
632
|
end
|
633
633
|
it "should be empty if the code is invalid" do
|
634
634
|
@mods_rec.from_str("<mods><subject><geographicCode authority='marcgac'>zzz</geographicCode></subject></mods>", false)
|
635
|
-
@mods_rec.subject.geographicCode.translated_value.size.
|
635
|
+
expect(@mods_rec.subject.geographicCode.translated_value.size).to eq(0)
|
636
636
|
end
|
637
637
|
it "should be empty if we don't have a translation for the authority" do
|
638
638
|
@mods_rec.from_str("<mods><subject><geographicCode authority='iso3166'>zzz</geographicCode></subject></mods>", false)
|
639
|
-
@mods_rec.subject.geographicCode.translated_value.size.
|
639
|
+
expect(@mods_rec.subject.geographicCode.translated_value.size).to eq(0)
|
640
640
|
end
|
641
641
|
it "should work with non-ascii characters" do
|
642
642
|
@mods_rec.from_str("<mods><subject><geographicCode authority='marccountry'>co</geographicCode></subject></mods>", false)
|
643
|
-
@mods_rec.subject.geographicCode.translated_value.
|
643
|
+
expect(@mods_rec.subject.geographicCode.translated_value).to eq(["Curaçao"])
|
644
644
|
end
|
645
645
|
end
|
646
646
|
end # <geographicCode>
|
@@ -659,24 +659,24 @@ describe "Mods <subject> Element" do
|
|
659
659
|
Mods::TitleInfo::ATTRIBUTES.each { |a|
|
660
660
|
ti = @mods_rec.from_str("<mods><subject><titleInfo #{a}='attr_val'>THE</titleInfo></subject></mods>", false).subject.titleInfo
|
661
661
|
if (a == 'type')
|
662
|
-
ti.type_at.
|
662
|
+
expect(ti.type_at).to eq(['attr_val'])
|
663
663
|
else
|
664
|
-
ti.send(a.to_sym).
|
664
|
+
expect(ti.send(a.to_sym)).to eq(['attr_val'])
|
665
665
|
end
|
666
666
|
}
|
667
667
|
end
|
668
668
|
it "should understand all immediate child elements allowed on a <titleInfo> element" do
|
669
669
|
Mods::TitleInfo::CHILD_ELEMENTS.each { |e|
|
670
|
-
@mods_rec.from_str("<mods><subject><titleInfo><#{e}>el_val</#{e}></titleInfo></subject></mods>", false).subject.titleInfo.send(e.to_sym).text.
|
670
|
+
expect(@mods_rec.from_str("<mods><subject><titleInfo><#{e}>el_val</#{e}></titleInfo></subject></mods>", false).subject.titleInfo.send(e.to_sym).text).to eq('el_val')
|
671
671
|
}
|
672
|
-
@title_info.nonSort.map {|n| n.text}.
|
672
|
+
expect(@title_info.nonSort.map {|n| n.text}).to eq(["The"])
|
673
673
|
end
|
674
674
|
|
675
675
|
it "should recognize authority attribute on the <titleInfo> element" do
|
676
|
-
@mods_rec.from_str("<mods><subject>
|
676
|
+
expect(@mods_rec.from_str("<mods><subject>
|
677
677
|
<titleInfo type='uniform' authority='naf'>
|
678
678
|
<title>Missale Carnotense</title>
|
679
|
-
</titleInfo></subject></mods>", false).subject.titleInfo.authority.
|
679
|
+
</titleInfo></subject></mods>", false).subject.titleInfo.authority).to eq(["naf"])
|
680
680
|
end
|
681
681
|
end # <titleInfo>
|
682
682
|
|
@@ -685,9 +685,9 @@ describe "Mods <subject> Element" do
|
|
685
685
|
Mods::Name::ATTRIBUTES.each { |a|
|
686
686
|
name = @mods_rec.from_str("<mods><subject><name #{a}='attr_val'>Obadiah</name></subject></mods>", false).subject.name_el
|
687
687
|
if (a == 'type')
|
688
|
-
name.type_at.
|
688
|
+
expect(name.type_at).to eq(['attr_val'])
|
689
689
|
else
|
690
|
-
name.send(a.to_sym).
|
690
|
+
expect(name.send(a.to_sym)).to eq(['attr_val'])
|
691
691
|
end
|
692
692
|
}
|
693
693
|
end
|
@@ -695,18 +695,18 @@ describe "Mods <subject> Element" do
|
|
695
695
|
Mods::Name::CHILD_ELEMENTS.each { |e|
|
696
696
|
name = @mods_rec.from_str("<mods><subject><name><#{e}>el_val</#{e}></name></subject></mods>", false).subject.name_el
|
697
697
|
if (e == 'description')
|
698
|
-
name.description_el.text.
|
698
|
+
expect(name.description_el.text).to eq('el_val')
|
699
699
|
elsif (e != 'role')
|
700
|
-
name.send(e.to_sym).text.
|
700
|
+
expect(name.send(e.to_sym).text).to eq('el_val')
|
701
701
|
end
|
702
702
|
}
|
703
703
|
end
|
704
704
|
it "should recognize authority attribute on the <name> element" do
|
705
|
-
@mods_rec.from_str("<mods><subject>
|
705
|
+
expect(@mods_rec.from_str("<mods><subject>
|
706
706
|
<name type='personal' authority='lcsh'>
|
707
707
|
<namePart>Nahl, Charles Christian</namePart>
|
708
708
|
<namePart type='date'>1818-1878</namePart>
|
709
|
-
</name></mods>", false).subject.name_el.authority.
|
709
|
+
</name></mods>", false).subject.name_el.authority).to eq(["lcsh"])
|
710
710
|
end
|
711
711
|
end # <name>
|
712
712
|
|
@@ -714,15 +714,15 @@ describe "Mods <subject> Element" do
|
|
714
714
|
it "should recognize authority attributes" do
|
715
715
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
716
716
|
@mods_rec.from_str("<mods><subject><hierarchicalGeographic #{a}='attr_val'><country>Albania</country></hierarchicalGeographic></subject></mods>", false)
|
717
|
-
@mods_rec.subject.hierarchicalGeographic.send(a.to_sym).
|
717
|
+
expect(@mods_rec.subject.hierarchicalGeographic.send(a.to_sym)).to eq(['attr_val'])
|
718
718
|
}
|
719
719
|
end
|
720
720
|
it "should recognize allowed child elements" do
|
721
721
|
Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |e|
|
722
722
|
@mods_rec.from_str("<mods><subject><hierarchicalGeographic><#{e}>el_val</#{e}></hierarchicalGeographic></subject></mods>", false)
|
723
|
-
@mods_rec.subject.hierarchicalGeographic.send(e.to_sym).text.
|
723
|
+
expect(@mods_rec.subject.hierarchicalGeographic.send(e.to_sym).text).to eq('el_val')
|
724
724
|
}
|
725
|
-
Mods::Subject::HIER_GEO_CHILD_ELEMENTS.size.
|
725
|
+
expect(Mods::Subject::HIER_GEO_CHILD_ELEMENTS.size).to eq(12)
|
726
726
|
end
|
727
727
|
end # <hierarchicalGeographic>
|
728
728
|
|
@@ -754,31 +754,31 @@ describe "Mods <subject> Element" do
|
|
754
754
|
</subject></mods>", false).subject.cartographics
|
755
755
|
end
|
756
756
|
it "should be a NodeSet" do
|
757
|
-
@carto_scale.
|
758
|
-
@carto_empties.
|
759
|
-
@multi_carto.
|
757
|
+
expect(@carto_scale).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
758
|
+
expect(@carto_empties).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
759
|
+
expect(@multi_carto).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
760
760
|
end
|
761
761
|
it "cartographics NodeSet should have as many Nodes as there are <cartographics> elements in the xml" do
|
762
|
-
@carto_scale.size.
|
763
|
-
@carto_empties.size.
|
764
|
-
@multi_carto.size.
|
762
|
+
expect(@carto_scale.size).to eq(1)
|
763
|
+
expect(@carto_empties.size).to eq(1)
|
764
|
+
expect(@multi_carto.size).to eq(3)
|
765
765
|
end
|
766
766
|
it "should recognize allowed child elements" do
|
767
767
|
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |e|
|
768
768
|
@mods_rec.from_str("<mods><subject><cartographics><#{e}>el_val</#{e}></cartographics></subject></mods>", false)
|
769
|
-
@mods_rec.subject.cartographics.send(e.to_sym).text.
|
769
|
+
expect(@mods_rec.subject.cartographics.send(e.to_sym).text).to eq('el_val')
|
770
770
|
}
|
771
|
-
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.size.
|
771
|
+
expect(Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.size).to eq(3)
|
772
772
|
end
|
773
773
|
it "should get the number of populated <coordinates> elements for coordinates term" do
|
774
774
|
@multi_carto.coordinates.size == 2
|
775
775
|
end
|
776
776
|
it "should be able to get the value of populated elements" do
|
777
|
-
@carto_scale.scale.map { |n| n.text }.
|
778
|
-
@carto_empties.coordinates.map { |n| n.text }.
|
777
|
+
expect(@carto_scale.scale.map { |n| n.text }).to eq(['[ca.1:90,000,000], [173'])
|
778
|
+
expect(@carto_empties.coordinates.map { |n| n.text }).to eq(['W1730000 W0100000 N840000 N071000'])
|
779
779
|
end
|
780
780
|
it "should get the empty string for empty elements?" do
|
781
|
-
@carto_empties.projection.map { |n| n.text }.
|
781
|
+
expect(@carto_empties.projection.map { |n| n.text }).to eq([''])
|
782
782
|
end
|
783
783
|
end # <cartographics>
|
784
784
|
|
@@ -787,18 +787,18 @@ describe "Mods <subject> Element" do
|
|
787
787
|
@occupation = @mods_rec.from_str("<mods><subject><occupation>Migrant laborers</occupation></mods>", false).subject.occupation
|
788
788
|
end
|
789
789
|
it "should be a NodeSet" do
|
790
|
-
@occupation.
|
790
|
+
expect(@occupation).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
791
791
|
end
|
792
792
|
it "occupation NodeSet should have as many Nodes as there are <occupation> elements in the xml" do
|
793
|
-
@occupation.size.
|
793
|
+
expect(@occupation.size).to eq(1)
|
794
794
|
end
|
795
795
|
it "text should get element value" do
|
796
|
-
@occupation.map { |n| n.text }.
|
796
|
+
expect(@occupation.map { |n| n.text }).to eq(['Migrant laborers'])
|
797
797
|
end
|
798
798
|
it "should recognize authority attributes" do
|
799
799
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
800
800
|
@mods_rec.from_str("<mods><subject><occupation #{a}='attr_val'>Flunkie</occupation></subject></mods>", false)
|
801
|
-
@mods_rec.subject.occupation.send(a.to_sym).
|
801
|
+
expect(@mods_rec.subject.occupation.send(a.to_sym)).to eq(['attr_val'])
|
802
802
|
}
|
803
803
|
end
|
804
804
|
end # <occupation>
|