mods 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/record_spec.rb
CHANGED
@@ -4,10 +4,10 @@ describe "Mods::Record" do
|
|
4
4
|
before(:all) do
|
5
5
|
@ns_hash = {'mods' => Mods::MODS_NS}
|
6
6
|
@def_ns_decl = "xmlns='#{Mods::MODS_NS}'"
|
7
|
-
@example_ns_str
|
8
|
-
@example_no_ns_str
|
7
|
+
@example_ns_str = "<mods #{@def_ns_decl}><note>default ns</note></mods>"
|
8
|
+
@example_no_ns_str = '<mods><note>no ns</note></mods>'
|
9
9
|
@example_record_url = 'http://www.loc.gov/standards/mods/modsrdf/examples/0001.xml'
|
10
|
-
@doc_from_str_ns
|
10
|
+
@doc_from_str_ns = Mods::Reader.new.from_str(@example_ns_str)
|
11
11
|
@doc_from_str_no_ns = Mods::Reader.new.from_str(@example_no_ns_str)
|
12
12
|
end
|
13
13
|
|
@@ -15,19 +15,22 @@ describe "Mods::Record" do
|
|
15
15
|
before(:all) do
|
16
16
|
@mods_ng_doc_w_ns = Mods::Record.new.from_str(@example_ns_str)
|
17
17
|
end
|
18
|
+
it "should return a mods record" do
|
19
|
+
expect(@mods_ng_doc_w_ns).to be_a_kind_of(Mods::Record)
|
20
|
+
end
|
18
21
|
it "should have namespace aware parsing turned on by default" do
|
19
|
-
@mods_ng_doc_w_ns.namespaces.size.
|
22
|
+
expect(@mods_ng_doc_w_ns.namespaces.size).to be > 0
|
20
23
|
end
|
21
24
|
it "terminology should work with Record object defaults when mods string has namespaces" do
|
22
|
-
@mods_ng_doc_w_ns.note.map { |e| e.text }.
|
25
|
+
expect(@mods_ng_doc_w_ns.note.map { |e| e.text }).to eq(['default ns'])
|
23
26
|
end
|
24
27
|
it "terminology should not work with Record object defaults when mods string has NO namespaces" do
|
25
28
|
mods_ng_doc = Mods::Record.new.from_str(@example_no_ns_str)
|
26
|
-
mods_ng_doc.note.size.
|
29
|
+
expect(mods_ng_doc.note.size).to eq(0)
|
27
30
|
end
|
28
31
|
it "should be allowed not to care about namespaces" do
|
29
32
|
mods_ng_doc = Mods::Record.new.from_str(@example_no_ns_str, false)
|
30
|
-
mods_ng_doc.note.map { |e| e.text }.
|
33
|
+
expect(mods_ng_doc.note.map { |e| e.text }).to eq(['no ns'])
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
@@ -40,7 +43,7 @@ describe "Mods::Record" do
|
|
40
43
|
expect(@mods_doc).to be_a_kind_of(Mods::Record)
|
41
44
|
end
|
42
45
|
it "should raise an error on a bad url" do
|
43
|
-
|
46
|
+
expect{Mods::Record.new.from_url("http://example.org/fake.xml")}.to raise_error
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
@@ -48,8 +51,7 @@ describe "Mods::Record" do
|
|
48
51
|
context "from_file" do
|
49
52
|
before(:all) do
|
50
53
|
@fixture_dir = File.join(File.dirname(__FILE__), 'fixture_data')
|
51
|
-
@
|
52
|
-
@mods_doc = Mods::Record.new.from_file(@fixture_mods_file)
|
54
|
+
@mods_doc = Mods::Record.new.from_file(File.join(@fixture_dir, 'shpc1.mods.xml'))
|
53
55
|
end
|
54
56
|
it "should return a mods record" do
|
55
57
|
expect(@mods_doc).to be_a_kind_of(Mods::Record)
|
@@ -92,19 +94,22 @@ describe "Mods::Record" do
|
|
92
94
|
ng_xml = Nokogiri::XML(bad_ns_wrapped)
|
93
95
|
@mods_node_no_ns = ng_xml.xpath('//n:mods', {'n'=>'http://www.not.mods.org'}).first
|
94
96
|
end
|
97
|
+
it "should return a mods record" do
|
98
|
+
expect(@mods_ng_doc).to be_a_kind_of(Mods::Record)
|
99
|
+
end
|
95
100
|
it "should have namespace aware parsing turned on by default" do
|
96
|
-
@mods_ng_doc.namespaces.size.
|
101
|
+
expect(@mods_ng_doc.namespaces.size).to be > 0
|
97
102
|
end
|
98
103
|
it "terminology should work with Record object defaults when mods string has namespaces" do
|
99
|
-
@mods_ng_doc.title_info.title.map { |e| e.text }.
|
104
|
+
expect(@mods_ng_doc.title_info.title.map { |e| e.text }).to eq(["boo"])
|
100
105
|
end
|
101
106
|
it "terminology should not work with Record object defaults when mods node has NO namespaces" do
|
102
107
|
mods_ng_doc = Mods::Record.new.from_nk_node(@mods_node_no_ns)
|
103
|
-
mods_ng_doc.title_info.title.size.
|
108
|
+
expect(mods_ng_doc.title_info.title.size).to eq(0)
|
104
109
|
end
|
105
110
|
it "should be allowed not to care about namespaces" do
|
106
111
|
mods_ng_doc = Mods::Record.new.from_nk_node(@mods_node_no_ns, false)
|
107
|
-
mods_ng_doc.title_info.title.map { |e| e.text }.
|
112
|
+
expect(mods_ng_doc.title_info.title.map { |e| e.text }).to eq(["What? No namespaces?"])
|
108
113
|
end
|
109
114
|
end # context from_nk_node
|
110
115
|
|
@@ -124,43 +129,43 @@ describe "Mods::Record" do
|
|
124
129
|
|
125
130
|
context "term_value (single value result)" do
|
126
131
|
it "should return nil if there are no such values in the MODS" do
|
127
|
-
@mods_rec.term_value(:identifier).
|
132
|
+
expect(@mods_rec.term_value(:identifier)).to be_nil
|
128
133
|
end
|
129
134
|
it "should return nil if there are only empty values in the MODS" do
|
130
|
-
@mods_rec.term_value(:genre).
|
135
|
+
expect(@mods_rec.term_value(:genre)).to be_nil
|
131
136
|
end
|
132
137
|
it "should return a String for a single value" do
|
133
|
-
@mods_rec.term_value(:abstract).
|
138
|
+
expect(@mods_rec.term_value(:abstract)).to eq('single')
|
134
139
|
end
|
135
140
|
it "should return a String containing all values, with separator, for multiple values" do
|
136
|
-
@mods_rec.term_value(:note).
|
141
|
+
expect(@mods_rec.term_value(:note)).to eq('mult1 mult2')
|
137
142
|
end
|
138
143
|
it "should work with an Array of messages passed as the argument" do
|
139
|
-
@mods_rec.term_value([:subject, 'topic']).
|
144
|
+
expect(@mods_rec.term_value([:subject, 'topic'])).to eq('topic1 topic2 topic3')
|
140
145
|
end
|
141
146
|
it "should take a separator argument" do
|
142
|
-
@mods_rec.term_value(:note, ' -|-').
|
147
|
+
expect(@mods_rec.term_value(:note, ' -|-')).to eq('mult1 -|-mult2')
|
143
148
|
end
|
144
149
|
end
|
145
150
|
|
146
151
|
context "term_values (multiple values)" do
|
147
152
|
it "should return nil if there are no such values in the MODS" do
|
148
|
-
@mods_rec.term_values(:identifier).
|
153
|
+
expect(@mods_rec.term_values(:identifier)).to be_nil
|
149
154
|
end
|
150
155
|
it "should return nil if there are only empty values in the MODS" do
|
151
|
-
@mods_rec.term_values(:genre).
|
156
|
+
expect(@mods_rec.term_values(:genre)).to be_nil
|
152
157
|
end
|
153
158
|
it "should return an array of size one for a single value" do
|
154
|
-
@mods_rec.term_values(:abstract).
|
159
|
+
expect(@mods_rec.term_values(:abstract)).to eq(['single'])
|
155
160
|
end
|
156
161
|
it "should return an array of values for multiple values" do
|
157
|
-
@mods_rec.term_values(:note).
|
162
|
+
expect(@mods_rec.term_values(:note)).to eq(['mult1', 'mult2'])
|
158
163
|
end
|
159
164
|
it "should work with an Array of messages passed as the argument" do
|
160
|
-
@mods_rec.term_values([:subject, 'topic']).
|
165
|
+
expect(@mods_rec.term_values([:subject, 'topic'])).to eq(['topic1', 'topic2', 'topic3'])
|
161
166
|
end
|
162
167
|
it "should work with a String passed as the argument" do
|
163
|
-
@mods_rec.term_values('abstract').
|
168
|
+
expect(@mods_rec.term_values('abstract')).to eq(['single'])
|
164
169
|
end
|
165
170
|
it "should raise an error for an unrecognized message symbol" do
|
166
171
|
expect { @mods_rec.term_values(:not_there) }.to raise_error(ArgumentError, "term_values called with unknown argument: :not_there")
|
@@ -181,21 +186,21 @@ describe "Mods::Record" do
|
|
181
186
|
context "title methods" do
|
182
187
|
it "short_titles should return an Array of Strings (multiple titles are legal in Mods)" do
|
183
188
|
@mods_rec.from_str("<mods #{@def_ns_decl}><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo><titleInfo><title>Joke</title></titleInfo></mods>")
|
184
|
-
@mods_rec.short_titles.
|
189
|
+
expect(@mods_rec.short_titles).to eq(["The Jerk", "Joke"])
|
185
190
|
end
|
186
191
|
it "full_titles should return an Array of Strings (multiple titles are legal in Mods)" do
|
187
192
|
@mods_rec.from_str("<mods #{@def_ns_decl}><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo><titleInfo><title>Joke</title></titleInfo></mods>")
|
188
|
-
@mods_rec.full_titles.
|
193
|
+
expect(@mods_rec.full_titles).to eq(["The Jerk", "Joke"])
|
189
194
|
end
|
190
195
|
it "sort_title should return a String (sortable fields are single valued)" do
|
191
196
|
@mods_rec.from_str("<mods #{@def_ns_decl}><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>")
|
192
|
-
@mods_rec.sort_title.
|
197
|
+
expect(@mods_rec.sort_title).to eq("Jerk A Tale of Tourettes")
|
193
198
|
end
|
194
199
|
it "alternative_titles should return an Array of Strings (multiple alternative titles when there are multiple titleInfo elements)" do
|
195
200
|
@mods_rec.from_str("<mods #{@def_ns_decl}><titleInfo type='alternative'><title>1</title></titleInfo><titleInfo type='alternative'><title>2</title></titleInfo></mods>")
|
196
|
-
@mods_rec.alternative_titles.
|
201
|
+
expect(@mods_rec.alternative_titles).to eq(['1', '2'])
|
197
202
|
@mods_rec.from_str("<mods #{@def_ns_decl}><titleInfo type='alternative'><title>1</title><title>2</title></titleInfo></mods>")
|
198
|
-
@mods_rec.alternative_titles.
|
203
|
+
expect(@mods_rec.alternative_titles).to eq(['12'])
|
199
204
|
end
|
200
205
|
end
|
201
206
|
|
@@ -215,17 +220,17 @@ describe "Mods::Record" do
|
|
215
220
|
<namePart type="termsOfAddress">Mr.</namePart>
|
216
221
|
<namePart type="date">date</namePart></name></mods>'
|
217
222
|
@family_only = '<mods xmlns="http://www.loc.gov/mods/v3"><name type="personal"><namePart type="family">Family</namePart></name></mods>'
|
218
|
-
@given_only
|
223
|
+
@given_only = '<mods xmlns="http://www.loc.gov/mods/v3"><name type="personal"><namePart type="given">Given</namePart></name></mods>'
|
219
224
|
end
|
220
225
|
|
221
226
|
it "should return an Array of Strings" do
|
222
227
|
@mods_rec.from_str(@mods_w_pers_name)
|
223
|
-
@mods_rec.personal_names.
|
228
|
+
expect(@mods_rec.personal_names).to eq([@pers_name])
|
224
229
|
end
|
225
230
|
|
226
231
|
it "should not include the role text" do
|
227
232
|
@mods_rec.from_str(@mods_w_pers_name_role)
|
228
|
-
@mods_rec.personal_names.first.
|
233
|
+
expect(@mods_rec.personal_names.first).not_to match(@pers_role)
|
229
234
|
end
|
230
235
|
|
231
236
|
it "should prefer displayForm over namePart pieces" do
|
@@ -233,38 +238,38 @@ describe "Mods::Record" do
|
|
233
238
|
<namePart type="family">Borges</namePart>
|
234
239
|
<displayForm>display form</displayForm></name></mods>'
|
235
240
|
@mods_rec.from_str(display_form_and_name_parts)
|
236
|
-
@mods_rec.personal_names.
|
241
|
+
expect(@mods_rec.personal_names).to include("display form")
|
237
242
|
end
|
238
243
|
|
239
244
|
it "should put the family namePart first" do
|
240
245
|
@mods_rec.from_str(@given_family)
|
241
|
-
@mods_rec.personal_names.first.
|
246
|
+
expect(@mods_rec.personal_names.first).to match(/^Borges/)
|
242
247
|
@mods_rec.from_str(@given_family_date)
|
243
|
-
@mods_rec.personal_names.first.
|
248
|
+
expect(@mods_rec.personal_names.first).to match(/^Beeblebrox/)
|
244
249
|
end
|
245
250
|
it "should not include date" do
|
246
251
|
@mods_rec.from_str(@given_family_date)
|
247
|
-
@mods_rec.personal_names.first.
|
252
|
+
expect(@mods_rec.personal_names.first).not_to match(/19/)
|
248
253
|
@mods_rec.from_str(@all_name_parts)
|
249
|
-
@mods_rec.personal_names.first.
|
254
|
+
expect(@mods_rec.personal_names.first).not_to match('date')
|
250
255
|
end
|
251
256
|
it "should include a comma when there is both a family and a given name" do
|
252
257
|
@mods_rec.from_str(@all_name_parts)
|
253
|
-
@mods_rec.personal_names.
|
258
|
+
expect(@mods_rec.personal_names).to include("Family, Given Mr.")
|
254
259
|
end
|
255
260
|
it "should include multiple words in a namePart" do
|
256
261
|
@mods_rec.from_str(@given_family)
|
257
|
-
@mods_rec.personal_names.
|
262
|
+
expect(@mods_rec.personal_names).to include("Borges, Jorge Luis")
|
258
263
|
end
|
259
264
|
it "should not include a comma when there is only a family or given name" do
|
260
265
|
[@family_only, @given_only].each { |mods_str|
|
261
266
|
@mods_rec.from_str(mods_str)
|
262
|
-
@mods_rec.personal_names.first.
|
267
|
+
expect(@mods_rec.personal_names.first).not_to match(/,/)
|
263
268
|
}
|
264
269
|
end
|
265
270
|
it "should include terms of address" do
|
266
271
|
@mods_rec.from_str(@all_name_parts)
|
267
|
-
@mods_rec.personal_names.first.
|
272
|
+
expect(@mods_rec.personal_names.first).to match(/Mr./)
|
268
273
|
end
|
269
274
|
end # personal_names
|
270
275
|
|
@@ -282,17 +287,17 @@ describe "Mods::Record" do
|
|
282
287
|
end
|
283
288
|
it "should return an Array of Strings" do
|
284
289
|
@mods_rec.from_str(@given_family_date)
|
285
|
-
@mods_rec.personal_names_w_dates.
|
290
|
+
expect(@mods_rec.personal_names_w_dates).to be_an_instance_of(Array)
|
286
291
|
end
|
287
292
|
it "should include the date when it is available" do
|
288
293
|
@mods_rec.from_str(@given_family_date)
|
289
|
-
@mods_rec.personal_names_w_dates.first.
|
294
|
+
expect(@mods_rec.personal_names_w_dates.first).to match(/, 1912-2362$/)
|
290
295
|
@mods_rec.from_str(@all_name_parts)
|
291
|
-
@mods_rec.personal_names_w_dates.first.
|
296
|
+
expect(@mods_rec.personal_names_w_dates.first).to match(/, date$/)
|
292
297
|
end
|
293
298
|
it "should be just the personal_name if no date is available" do
|
294
299
|
@mods_rec.from_str(@given_family)
|
295
|
-
@mods_rec.personal_names_w_dates.first.
|
300
|
+
expect(@mods_rec.personal_names_w_dates.first).to eq('Borges, Jorge Luis')
|
296
301
|
end
|
297
302
|
end
|
298
303
|
|
@@ -302,48 +307,48 @@ describe "Mods::Record" do
|
|
302
307
|
end
|
303
308
|
it "should return an Array of Strings" do
|
304
309
|
@mods_rec.from_str("<mods #{@def_ns_decl}><name type='corporate'><namePart>#{@corp_name}</namePart></name></mods>")
|
305
|
-
@mods_rec.corporate_names.
|
310
|
+
expect(@mods_rec.corporate_names).to eq([@corp_name])
|
306
311
|
end
|
307
312
|
it "should not include the role text" do
|
308
313
|
corp_role = 'lithographer'
|
309
314
|
mods_w_corp_name_role = "<mods #{@def_ns_decl}><name type='corporate'><namePart>#{@corp_name}</namePart>
|
310
315
|
<role><roleTerm type='text'>#{corp_role}</roleTerm></role></name></mods>"
|
311
316
|
@mods_rec.from_str(mods_w_corp_name_role)
|
312
|
-
@mods_rec.corporate_names.first.
|
317
|
+
expect(@mods_rec.corporate_names.first).not_to match(corp_role)
|
313
318
|
end
|
314
319
|
|
315
320
|
it "should prefer displayForm over namePart pieces" do
|
316
321
|
display_form_and_name_parts = "<mods #{@def_ns_decl}><name type='corporate'><namePart>Food, Inc.</namePart>
|
317
322
|
<displayForm>display form</displayForm></name></mods>"
|
318
323
|
@mods_rec.from_str(display_form_and_name_parts)
|
319
|
-
@mods_rec.corporate_names.
|
324
|
+
expect(@mods_rec.corporate_names).to include("display form")
|
320
325
|
end
|
321
326
|
end # corporate_names
|
322
327
|
|
323
328
|
context "languages" do
|
324
329
|
before(:all) do
|
325
|
-
@simple
|
330
|
+
@simple = "<mods #{@def_ns_decl}><language>Greek</language></mods>"
|
326
331
|
@iso639_2b_code = "<mods #{@def_ns_decl}><language><languageTerm authority='iso639-2b' type='code'>fre</languageTerm></language></mods>"
|
327
332
|
@iso639_2b_text = "<mods #{@def_ns_decl}><language><languageTerm authority='iso639-2b' type='text'>English</languageTerm></language></mods>"
|
328
|
-
@mult_codes
|
333
|
+
@mult_codes = "<mods #{@def_ns_decl}><language><languageTerm authority='iso639-2b' type='code'>per ara, dut</languageTerm></language></mods>"
|
329
334
|
end
|
330
335
|
it "should translate iso639-2b codes to English" do
|
331
336
|
@mods_rec.from_str(@iso639_2b_code)
|
332
|
-
@mods_rec.languages.
|
337
|
+
expect(@mods_rec.languages).to eq(["French"])
|
333
338
|
end
|
334
339
|
it "should pass thru language values that are already text (not code)" do
|
335
340
|
@mods_rec.from_str(@iso639_2b_text)
|
336
|
-
@mods_rec.languages.
|
341
|
+
expect(@mods_rec.languages).to eq(["English"])
|
337
342
|
end
|
338
343
|
it "should keep values that are not inside <languageTerm> elements" do
|
339
344
|
@mods_rec.from_str(@simple)
|
340
|
-
@mods_rec.languages.
|
345
|
+
expect(@mods_rec.languages).to eq(["Greek"])
|
341
346
|
end
|
342
347
|
it "should create a separate value for each language in a comma, space, or | separated list " do
|
343
348
|
@mods_rec.from_str(@mult_codes)
|
344
|
-
@mods_rec.languages.
|
345
|
-
@mods_rec.languages.
|
346
|
-
@mods_rec.languages.
|
349
|
+
expect(@mods_rec.languages).to include("Arabic")
|
350
|
+
expect(@mods_rec.languages).to include("Persian")
|
351
|
+
expect(@mods_rec.languages).to include("Dutch; Flemish")
|
347
352
|
end
|
348
353
|
end
|
349
354
|
end # convenience methods for tricky bits of terminology
|
data/spec/related_item_spec.rb
CHANGED
@@ -59,98 +59,98 @@ describe "Mods <relatedItem> Element" do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it ".relatedItem should be a NodeSet" do
|
62
|
-
[@rel_it1, @rel_it_mult, @rel_it2, @coll_ex].each { |ri| ri.
|
62
|
+
[@rel_it1, @rel_it_mult, @rel_it2, @coll_ex].each { |ri| expect(ri).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
63
63
|
end
|
64
64
|
it ".relatedItem should have as many members as there are <recordInfo> elements in the xml" do
|
65
|
-
[@rel_it1, @rel_it2, @coll_ex].each { |ri| ri.size.
|
66
|
-
@rel_it_mult.size.
|
65
|
+
[@rel_it1, @rel_it2, @coll_ex].each { |ri| expect(ri.size).to eq(1) }
|
66
|
+
expect(@rel_it_mult.size).to eq(2)
|
67
67
|
end
|
68
68
|
it "relatedItem.type_at should match type attribute" do
|
69
|
-
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| ri.type_at.
|
70
|
-
@rel_it2.type_at.
|
69
|
+
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| expect(ri.type_at).to eq(['host']) }
|
70
|
+
expect(@rel_it2.type_at).to eq(['constituent'])
|
71
71
|
end
|
72
72
|
it "relatedItem.id_at should match ID attribute" do
|
73
|
-
@rel_it2.id_at.
|
74
|
-
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| ri.id_at.size.
|
73
|
+
expect(@rel_it2.id_at).to eq(['MODSMD_ARTICLE1'])
|
74
|
+
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| expect(ri.id_at.size).to eq(0) }
|
75
75
|
end
|
76
76
|
it "relatedItem.displayLabel should match displayLabel attribute" do
|
77
|
-
@rel_it1.displayLabel.
|
78
|
-
@rel_it_mult.displayLabel.
|
79
|
-
[@rel_it2, @coll_ex].each { |ri| ri.displayLabel.size.
|
77
|
+
expect(@rel_it1.displayLabel).to eq(['Bibliography'])
|
78
|
+
expect(@rel_it_mult.displayLabel).to eq(['From:'])
|
79
|
+
[@rel_it2, @coll_ex].each { |ri| expect(ri.displayLabel.size).to eq(0) }
|
80
80
|
end
|
81
81
|
|
82
82
|
context "<genre> child element" do
|
83
83
|
it "relatedItem.genre should match <relatedItem><genre>" do
|
84
|
-
@rel_it2.genre.map { |ri| ri.text }.
|
84
|
+
expect(@rel_it2.genre.map { |ri| ri.text }).to eq(['article'])
|
85
85
|
end
|
86
86
|
end # <genre> child element
|
87
87
|
|
88
88
|
context "<identifier> child element" do
|
89
89
|
it "relatedItem.identifier.type_at should match <relatedItem><identifier type=''> attribute" do
|
90
|
-
@rel_it_mult.identifier.type_at.
|
90
|
+
expect(@rel_it_mult.identifier.type_at).to eq(['local'])
|
91
91
|
end
|
92
92
|
it "relatedItem.identifier should match <relatedItem><identifier>" do
|
93
|
-
@rel_it_mult.identifier.map { |n| n.text }.
|
93
|
+
expect(@rel_it_mult.identifier.map { |n| n.text }).to eq(['(AuCNL)1669726'])
|
94
94
|
end
|
95
95
|
end # <identifier> child element
|
96
96
|
|
97
97
|
context "<name> child element" do
|
98
98
|
it "relatedItem.personal_name.namePart should match <relatedItem><name type='personal'><namePart>" do
|
99
|
-
@rel_it_mult.personal_name.namePart.map { |n| n.text }.size.
|
100
|
-
@rel_it_mult.personal_name.namePart.map { |n| n.text }.
|
101
|
-
@rel_it_mult.personal_name.namePart.map { |n| n.text }.
|
102
|
-
@rel_it_mult.personal_name.namePart.map { |n| n.text }.
|
99
|
+
expect(@rel_it_mult.personal_name.namePart.map { |n| n.text }.size).to eq(2)
|
100
|
+
expect(@rel_it_mult.personal_name.namePart.map { |n| n.text }).to include('Bowen, Emanuel,')
|
101
|
+
expect(@rel_it_mult.personal_name.namePart.map { |n| n.text }).to include('d. 1767')
|
102
|
+
expect(@rel_it_mult.personal_name.namePart.map { |n| n.text }).not_to include('Bowen, Emanuel, d. 1767.')
|
103
103
|
end
|
104
104
|
it "relatedItem.personal_name.date should match <relatedItem><name type='personal'><namePart type='date'>" do
|
105
|
-
@rel_it_mult.personal_name.date.map { |n| n.text }.
|
105
|
+
expect(@rel_it_mult.personal_name.date.map { |n| n.text }).to eq(['d. 1767'])
|
106
106
|
end
|
107
107
|
it "relatedItem.name_el.namePart should match <relatedItem><name><namePart>" do
|
108
|
-
@rel_it_mult.name_el.namePart.map { |n| n.text }.size.
|
109
|
-
@rel_it_mult.name_el.namePart.map { |n| n.text }.
|
110
|
-
@rel_it_mult.name_el.namePart.map { |n| n.text }.
|
111
|
-
@rel_it_mult.name_el.namePart.map { |n| n.text }.
|
108
|
+
expect(@rel_it_mult.name_el.namePart.map { |n| n.text }.size).to eq(3)
|
109
|
+
expect(@rel_it_mult.name_el.namePart.map { |n| n.text }).to include('Bowen, Emanuel,')
|
110
|
+
expect(@rel_it_mult.name_el.namePart.map { |n| n.text }).to include('d. 1767')
|
111
|
+
expect(@rel_it_mult.name_el.namePart.map { |n| n.text }).to include('Bowen, Emanuel, d. 1767.')
|
112
112
|
end
|
113
113
|
end # <name> child element
|
114
114
|
|
115
115
|
context "<part> child element" do
|
116
116
|
it "relatedItem.part.type_at should match <relatedItem><part type=''> attribute" do
|
117
|
-
@rel_it2.part.type_at.
|
117
|
+
expect(@rel_it2.part.type_at).to eq(['paragraph', 'paragraph', 'paragraph'])
|
118
118
|
end
|
119
119
|
it "relatedItem.part.id_at should match <relatedItem><part ID=''> attribute" do
|
120
|
-
@rel_it2.part.id_at.size.
|
121
|
-
@rel_it2.part.id_at.
|
122
|
-
@rel_it2.part.id_at.
|
123
|
-
@rel_it2.part.id_at.
|
120
|
+
expect(@rel_it2.part.id_at.size).to eq(3)
|
121
|
+
expect(@rel_it2.part.id_at).to include('DIVL15')
|
122
|
+
expect(@rel_it2.part.id_at).to include('DIVL17')
|
123
|
+
expect(@rel_it2.part.id_at).to include('DIVL19')
|
124
124
|
end
|
125
125
|
it "relatedItem.part.order should match <relatedItem><part order=''> attribute" do
|
126
|
-
@rel_it2.part.order.size.
|
127
|
-
@rel_it2.part.order.
|
128
|
-
@rel_it2.part.order.
|
129
|
-
@rel_it2.part.order.
|
126
|
+
expect(@rel_it2.part.order.size).to eq(3)
|
127
|
+
expect(@rel_it2.part.order).to include('1')
|
128
|
+
expect(@rel_it2.part.order).to include('2')
|
129
|
+
expect(@rel_it2.part.order).to include('3')
|
130
130
|
end
|
131
131
|
end # <part> child element
|
132
132
|
|
133
133
|
context "<recordInfo> child element" do
|
134
134
|
it "relatedItem.recordInfo.recordIdentifier.source should match <relatedItem><recordInfo><recordIdentifier source> attribute" do
|
135
|
-
@rel_it1.recordInfo.recordIdentifier.source.
|
135
|
+
expect(@rel_it1.recordInfo.recordIdentifier.source).to eq(['Gallica ARK'])
|
136
136
|
end
|
137
137
|
end # <recordInfo> child element
|
138
138
|
|
139
139
|
context "<titleInfo> child element" do
|
140
140
|
it "relatedItem.titleInfo.title should access <relatedItem><titleInfo><title>" do
|
141
|
-
@rel_it1.titleInfo.title.map { |n| n.text }.
|
142
|
-
@rel_it_mult.titleInfo.title.map { |n| n.text }.
|
143
|
-
@rel_it2.titleInfo.title.map { |n| n.text }.
|
144
|
-
@coll_ex.titleInfo.title.map { |n| n.text }.
|
141
|
+
expect(@rel_it1.titleInfo.title.map { |n| n.text }).to eq([''])
|
142
|
+
expect(@rel_it_mult.titleInfo.title.map { |n| n.text }).to eq(['Complete atlas, or, Distinct view of the known world', 'Complete atlas, or, Distinct view of the known world'])
|
143
|
+
expect(@rel_it2.titleInfo.title.map { |n| n.text }).to eq(['Nuppineula.'])
|
144
|
+
expect(@coll_ex.titleInfo.title.map { |n| n.text }).to eq(['The Collier Collection of the Revs Institute for Automotive Research'])
|
145
145
|
end
|
146
146
|
end # <titleInfo> child element
|
147
147
|
|
148
148
|
context "<typeOfResource> child element" do
|
149
149
|
it "relatedItem.typeOfResource should access <relatedItem><typeOfResource>" do
|
150
|
-
@rel_it1.typeOfResource.map { |n| n.text }.
|
150
|
+
expect(@rel_it1.typeOfResource.map { |n| n.text }).to eq(['text'])
|
151
151
|
end
|
152
152
|
it "relatedItem.typeOfResource.collection should access <relatedItem><typeOfResource collection='yes'> attribute" do
|
153
|
-
@coll_ex.typeOfResource.collection.
|
153
|
+
expect(@coll_ex.typeOfResource.collection).to eq(['yes'])
|
154
154
|
end
|
155
155
|
end # <typeOfResource> child element
|
156
156
|
|
@@ -203,98 +203,98 @@ describe "Mods <relatedItem> Element" do
|
|
203
203
|
end
|
204
204
|
|
205
205
|
it ".relatedItem should be a NodeSet" do
|
206
|
-
[@rel_it1, @rel_it_mult, @rel_it2, @coll_ex].each { |ri| ri.
|
206
|
+
[@rel_it1, @rel_it_mult, @rel_it2, @coll_ex].each { |ri| expect(ri).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
207
207
|
end
|
208
208
|
it ".relatedItem should have as many members as there are <recordInfo> elements in the xml" do
|
209
|
-
[@rel_it1, @rel_it2, @coll_ex].each { |ri| ri.size.
|
210
|
-
@rel_it_mult.size.
|
209
|
+
[@rel_it1, @rel_it2, @coll_ex].each { |ri| expect(ri.size).to eq(1) }
|
210
|
+
expect(@rel_it_mult.size).to eq(2)
|
211
211
|
end
|
212
212
|
it "relatedItem.type_at should match type attribute" do
|
213
|
-
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| ri.type_at.
|
214
|
-
@rel_it2.type_at.
|
213
|
+
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| expect(ri.type_at).to eq(['host']) }
|
214
|
+
expect(@rel_it2.type_at).to eq(['constituent'])
|
215
215
|
end
|
216
216
|
it "relatedItem.id_at should match ID attribute" do
|
217
|
-
@rel_it2.id_at.
|
218
|
-
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| ri.id_at.size.
|
217
|
+
expect(@rel_it2.id_at).to eq(['MODSMD_ARTICLE1'])
|
218
|
+
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| expect(ri.id_at.size).to eq(0) }
|
219
219
|
end
|
220
220
|
it "relatedItem.displayLabel should match displayLabel attribute" do
|
221
|
-
@rel_it1.displayLabel.
|
222
|
-
@rel_it_mult.displayLabel.
|
223
|
-
[@rel_it2, @coll_ex].each { |ri| ri.displayLabel.size.
|
221
|
+
expect(@rel_it1.displayLabel).to eq(['Bibliography'])
|
222
|
+
expect(@rel_it_mult.displayLabel).to eq(['From:'])
|
223
|
+
[@rel_it2, @coll_ex].each { |ri| expect(ri.displayLabel.size).to eq(0) }
|
224
224
|
end
|
225
225
|
|
226
226
|
context "<genre> child element" do
|
227
227
|
it "relatedItem.genre should match <relatedItem><genre>" do
|
228
|
-
@rel_it2.genre.map { |ri| ri.text }.
|
228
|
+
expect(@rel_it2.genre.map { |ri| ri.text }).to eq(['article'])
|
229
229
|
end
|
230
230
|
end # <genre> child element
|
231
231
|
|
232
232
|
context "<identifier> child element" do
|
233
233
|
it "relatedItem.identifier.type_at should match <relatedItem><identifier type=''> attribute" do
|
234
|
-
@rel_it_mult.identifier.type_at.
|
234
|
+
expect(@rel_it_mult.identifier.type_at).to eq(['local'])
|
235
235
|
end
|
236
236
|
it "relatedItem.identifier should match <relatedItem><identifier>" do
|
237
|
-
@rel_it_mult.identifier.map { |n| n.text }.
|
237
|
+
expect(@rel_it_mult.identifier.map { |n| n.text }).to eq(['(AuCNL)1669726'])
|
238
238
|
end
|
239
239
|
end # <identifier> child element
|
240
240
|
|
241
241
|
context "<name> child element" do
|
242
242
|
it "relatedItem.personal_name.namePart should match <relatedItem><name type='personal'><namePart>" do
|
243
|
-
@rel_it_mult.personal_name.namePart.map { |n| n.text }.size.
|
244
|
-
@rel_it_mult.personal_name.namePart.map { |n| n.text }.
|
245
|
-
@rel_it_mult.personal_name.namePart.map { |n| n.text }.
|
246
|
-
@rel_it_mult.personal_name.namePart.map { |n| n.text }.
|
243
|
+
expect(@rel_it_mult.personal_name.namePart.map { |n| n.text }.size).to eq(2)
|
244
|
+
expect(@rel_it_mult.personal_name.namePart.map { |n| n.text }).to include('Bowen, Emanuel,')
|
245
|
+
expect(@rel_it_mult.personal_name.namePart.map { |n| n.text }).to include('d. 1767')
|
246
|
+
expect(@rel_it_mult.personal_name.namePart.map { |n| n.text }).not_to include('Bowen, Emanuel, d. 1767.')
|
247
247
|
end
|
248
248
|
it "relatedItem.personal_name.date should match <relatedItem><name type='personal'><namePart type='date'>" do
|
249
|
-
@rel_it_mult.personal_name.date.map { |n| n.text }.
|
249
|
+
expect(@rel_it_mult.personal_name.date.map { |n| n.text }).to eq(['d. 1767'])
|
250
250
|
end
|
251
251
|
it "relatedItem.name_el.namePart should match <relatedItem><name><namePart>" do
|
252
|
-
@rel_it_mult.name_el.namePart.map { |n| n.text }.size.
|
253
|
-
@rel_it_mult.name_el.namePart.map { |n| n.text }.
|
254
|
-
@rel_it_mult.name_el.namePart.map { |n| n.text }.
|
255
|
-
@rel_it_mult.name_el.namePart.map { |n| n.text }.
|
252
|
+
expect(@rel_it_mult.name_el.namePart.map { |n| n.text }.size).to eq(3)
|
253
|
+
expect(@rel_it_mult.name_el.namePart.map { |n| n.text }).to include('Bowen, Emanuel,')
|
254
|
+
expect(@rel_it_mult.name_el.namePart.map { |n| n.text }).to include('d. 1767')
|
255
|
+
expect(@rel_it_mult.name_el.namePart.map { |n| n.text }).to include('Bowen, Emanuel, d. 1767.')
|
256
256
|
end
|
257
257
|
end # <name> child element
|
258
258
|
|
259
259
|
context "<part> child element" do
|
260
260
|
it "relatedItem.part.type_at should match <relatedItem><part type=''> attribute" do
|
261
|
-
@rel_it2.part.type_at.
|
261
|
+
expect(@rel_it2.part.type_at).to eq(['paragraph', 'paragraph', 'paragraph'])
|
262
262
|
end
|
263
263
|
it "relatedItem.part.id_at should match <relatedItem><part ID=''> attribute" do
|
264
|
-
@rel_it2.part.id_at.size.
|
265
|
-
@rel_it2.part.id_at.
|
266
|
-
@rel_it2.part.id_at.
|
267
|
-
@rel_it2.part.id_at.
|
264
|
+
expect(@rel_it2.part.id_at.size).to eq(3)
|
265
|
+
expect(@rel_it2.part.id_at).to include('DIVL15')
|
266
|
+
expect(@rel_it2.part.id_at).to include('DIVL17')
|
267
|
+
expect(@rel_it2.part.id_at).to include('DIVL19')
|
268
268
|
end
|
269
269
|
it "relatedItem.part.order should match <relatedItem><part order=''> attribute" do
|
270
|
-
@rel_it2.part.order.size.
|
271
|
-
@rel_it2.part.order.
|
272
|
-
@rel_it2.part.order.
|
273
|
-
@rel_it2.part.order.
|
270
|
+
expect(@rel_it2.part.order.size).to eq(3)
|
271
|
+
expect(@rel_it2.part.order).to include('1')
|
272
|
+
expect(@rel_it2.part.order).to include('2')
|
273
|
+
expect(@rel_it2.part.order).to include('3')
|
274
274
|
end
|
275
275
|
end # <part> child element
|
276
276
|
|
277
277
|
context "<recordInfo> child element" do
|
278
278
|
it "relatedItem.recordInfo.recordIdentifier.source should match <relatedItem><recordInfo><recordIdentifier source> attribute" do
|
279
|
-
@rel_it1.recordInfo.recordIdentifier.source.
|
279
|
+
expect(@rel_it1.recordInfo.recordIdentifier.source).to eq(['Gallica ARK'])
|
280
280
|
end
|
281
281
|
end # <recordInfo> child element
|
282
282
|
|
283
283
|
context "<titleInfo> child element" do
|
284
284
|
it "relatedItem.titleInfo.title should access <relatedItem><titleInfo><title>" do
|
285
|
-
@rel_it1.titleInfo.title.map { |n| n.text }.
|
286
|
-
@rel_it_mult.titleInfo.title.map { |n| n.text }.
|
287
|
-
@rel_it2.titleInfo.title.map { |n| n.text }.
|
288
|
-
@coll_ex.titleInfo.title.map { |n| n.text }.
|
285
|
+
expect(@rel_it1.titleInfo.title.map { |n| n.text }).to eq([''])
|
286
|
+
expect(@rel_it_mult.titleInfo.title.map { |n| n.text }).to eq(['Complete atlas, or, Distinct view of the known world', 'Complete atlas, or, Distinct view of the known world'])
|
287
|
+
expect(@rel_it2.titleInfo.title.map { |n| n.text }).to eq(['Nuppineula.'])
|
288
|
+
expect(@coll_ex.titleInfo.title.map { |n| n.text }).to eq(['The Collier Collection of the Revs Institute for Automotive Research'])
|
289
289
|
end
|
290
290
|
end # <titleInfo> child element
|
291
291
|
|
292
292
|
context "<typeOfResource> child element" do
|
293
293
|
it "relatedItem.typeOfResource should access <relatedItem><typeOfResource>" do
|
294
|
-
@rel_it1.typeOfResource.map { |n| n.text }.
|
294
|
+
expect(@rel_it1.typeOfResource.map { |n| n.text }).to eq(['text'])
|
295
295
|
end
|
296
296
|
it "relatedItem.typeOfResource.collection should access <relatedItem><typeOfResource collection='yes'> attribute" do
|
297
|
-
@coll_ex.typeOfResource.collection.
|
297
|
+
expect(@coll_ex.typeOfResource.collection).to eq(['yes'])
|
298
298
|
end
|
299
299
|
end # <typeOfResource> child element
|
300
300
|
|