mods 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
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 }.should == ['Britton & Rey.']
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 }.should == ['Bridgens, R.P']
97
- @pers_name_sub.personal_name.displayForm.map { |e| e.text }.should == ['Edward VI , king of England, 1537-1553']
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 }.should == ['lithographers.']
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 }.should include("1818-1878")
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
145
- @lcsh_subject.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 4
149
- @lcsh_subject.size.should == 1
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.should == [a]
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
170
- @multi_topic.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
174
- @multi_topic.size.should == 3
175
- @four_subjects.topic.size.should == 3
176
- @geo_code_subject.topic.size.should == 0
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.should == "History"
180
- @multi_topic.text.should include("California as an island--Maps--1662?")
181
- @multi_topic.text.should include("North America--Maps--To 1800")
182
- @multi_topic.text.should include("North America--Maps--1662?")
183
- @four_subjects.topic.text.should include("History")
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
190
- @lcsh_subject.geographic.should be_an_instance_of(Nokogiri::XML::NodeSet)
191
- @geo_code_subject.geographic.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 3
195
- @lcsh_subject.geographic.size.should == 1
196
- @geo_code_subject.geographic.size.should == 0
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.should include("San Francisco (Calif.)")
200
- @four_subjects.geographic.text.should include("San Diego (Calif.)")
201
- @four_subjects.geographic.text.should include("San Luis Rey (Calif.)")
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.should == 0
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.should == ['iso8601']
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).should == ['val']
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
224
- @temporal.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
228
- @temporal.size.should == 1
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 }.should == ['500-1400']
232
- @temporal.map { |n| n.text }.should == ['20010203T040506+0700']
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
239
- @four_subjects.genre.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
243
- @four_subjects.genre.size.should == 4
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 }.should == ['Maps']
247
- @four_subjects.genre.map { |n| n.text }.should include("Pictorial works")
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
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 }.should == ['f------']
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).should == ['attr_val']
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.should == [a]
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.should == ["Estonia"]
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.should == ["Madagascar"]
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.should == 0
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.should == 0
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.should == ["Curaçao"]
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.should == ['attr_val']
316
+ expect(ti.type_at).to eq(['attr_val'])
317
317
  else
318
- ti.send(a.to_sym).should == ['attr_val']
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.should == 'el_val'
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}.should == ["The"]
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.should == ["naf"]
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.should == ['attr_val']
342
+ expect(name.type_at).to eq(['attr_val'])
343
343
  else
344
- name.send(a.to_sym).should == ['attr_val']
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.should == 'el_val'
352
+ expect(name.description_el.text).to eq('el_val')
353
353
  elsif (e != 'role')
354
- name.send(e.to_sym).text.should == 'el_val'
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.should == ["lcsh"]
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).should == ['attr_val']
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.should == 'el_val'
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.should == 12
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
412
- @carto_empties.should be_an_instance_of(Nokogiri::XML::NodeSet)
413
- @multi_carto.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
417
- @carto_empties.size.should == 1
418
- @multi_carto.size.should == 3
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.should == 'el_val'
423
+ expect(@mods_rec.subject.cartographics.send(e.to_sym).text).to eq('el_val')
424
424
  }
425
- Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.size.should == 3
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 }.should == ['[ca.1:90,000,000], [173']
432
- @carto_empties.coordinates.map { |n| n.text }.should == ['W1730000 W0100000 N840000 N071000']
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 }.should == ['']
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
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 }.should == ['Migrant laborers']
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).should == ['attr_val']
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
491
- @lcsh_subject.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 4
495
- @lcsh_subject.size.should == 1
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.should == [a]
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
516
- @multi_topic.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
520
- @multi_topic.size.should == 3
521
- @four_subjects.topic.size.should == 3
522
- @geo_code_subject.topic.size.should == 0
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.should == "History"
526
- @multi_topic.text.should include("California as an island--Maps--1662?")
527
- @multi_topic.text.should include("North America--Maps--To 1800")
528
- @multi_topic.text.should include("North America--Maps--1662?")
529
- @four_subjects.topic.text.should include("History")
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
536
- @lcsh_subject.geographic.should be_an_instance_of(Nokogiri::XML::NodeSet)
537
- @geo_code_subject.geographic.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 3
541
- @lcsh_subject.geographic.size.should == 1
542
- @geo_code_subject.geographic.size.should == 0
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.should include("San Francisco (Calif.)")
546
- @four_subjects.geographic.text.should include("San Diego (Calif.)")
547
- @four_subjects.geographic.text.should include("San Luis Rey (Calif.)")
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.should == 0
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.should == ['iso8601']
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).should == ['val']
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
570
- @temporal.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
574
- @temporal.size.should == 1
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 }.should == ['500-1400']
578
- @temporal.map { |n| n.text }.should == ['20010203T040506+0700']
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
585
- @four_subjects.genre.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
589
- @four_subjects.genre.size.should == 4
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 }.should == ['Maps']
593
- @four_subjects.genre.map { |n| n.text }.should include("Pictorial works")
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
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 }.should == ['f------']
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).should == ['attr_val']
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.should == [a]
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.should == ["Estonia"]
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.should == ["Madagascar"]
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.should == 0
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.should == 0
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.should == ["Curaçao"]
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.should == ['attr_val']
662
+ expect(ti.type_at).to eq(['attr_val'])
663
663
  else
664
- ti.send(a.to_sym).should == ['attr_val']
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.should == 'el_val'
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}.should == ["The"]
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.should == ["naf"]
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.should == ['attr_val']
688
+ expect(name.type_at).to eq(['attr_val'])
689
689
  else
690
- name.send(a.to_sym).should == ['attr_val']
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.should == 'el_val'
698
+ expect(name.description_el.text).to eq('el_val')
699
699
  elsif (e != 'role')
700
- name.send(e.to_sym).text.should == 'el_val'
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.should == ["lcsh"]
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).should == ['attr_val']
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.should == 'el_val'
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.should == 12
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
758
- @carto_empties.should be_an_instance_of(Nokogiri::XML::NodeSet)
759
- @multi_carto.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
763
- @carto_empties.size.should == 1
764
- @multi_carto.size.should == 3
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.should == 'el_val'
769
+ expect(@mods_rec.subject.cartographics.send(e.to_sym).text).to eq('el_val')
770
770
  }
771
- Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.size.should == 3
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 }.should == ['[ca.1:90,000,000], [173']
778
- @carto_empties.coordinates.map { |n| n.text }.should == ['W1730000 W0100000 N840000 N071000']
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 }.should == ['']
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.should be_an_instance_of(Nokogiri::XML::NodeSet)
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.should == 1
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 }.should == ['Migrant laborers']
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).should == ['attr_val']
801
+ expect(@mods_rec.subject.occupation.send(a.to_sym)).to eq(['attr_val'])
802
802
  }
803
803
  end
804
804
  end # <occupation>