stanford-mods 1.1.2 → 1.1.3

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.
@@ -32,28 +32,28 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
32
32
  <subject><occupation>#{@occupation}</occupation></subject>
33
33
  <subject><temporal>#{@temporal}</temporal></subject>
34
34
  <subject><titleInfo><title>#{@s_title}</title></titleInfo></subject>
35
- <subject><topic>#{@topic}</topic></subject>
35
+ <subject><topic>#{@topic}</topic></subject>
36
36
  </mods>"
37
37
  @smods_rec.from_str m
38
- @sw_geographic_search = @smods_rec.sw_geographic_search
39
- @sw_subject_titles = @smods_rec.sw_subject_titles
40
- @sw_subject_names = @smods_rec.sw_subject_names
38
+ @sw_geographic_search = @smods_rec.sw_geographic_search
39
+ @sw_subject_titles = @smods_rec.sw_subject_titles
40
+ @sw_subject_names = @smods_rec.sw_subject_names
41
41
  end
42
-
42
+
43
43
  context "sw_subject_names" do
44
44
  it "should contain <subject><name><namePart> values" do
45
- @sw_subject_names.should include(@s_name)
45
+ expect(@sw_subject_names).to include(@s_name)
46
46
  end
47
47
  it "should not contain non-name subject subelements" do
48
- @sw_subject_names.should_not include(@cart_coord)
49
- @sw_subject_names.should_not include(@s_genre)
50
- @sw_subject_names.should_not include(@geo)
51
- @sw_subject_names.should_not include(@geo_code)
52
- @sw_subject_names.should_not include(@hier_geo_country)
53
- @sw_subject_names.should_not include(@occupation)
54
- @sw_subject_names.should_not include(@temporal)
55
- @sw_subject_names.should_not include(@topic)
56
- @sw_subject_names.should_not include(@s_title)
48
+ expect(@sw_subject_names).not_to include(@cart_coord)
49
+ expect(@sw_subject_names).not_to include(@s_genre)
50
+ expect(@sw_subject_names).not_to include(@geo)
51
+ expect(@sw_subject_names).not_to include(@geo_code)
52
+ expect(@sw_subject_names).not_to include(@hier_geo_country)
53
+ expect(@sw_subject_names).not_to include(@occupation)
54
+ expect(@sw_subject_names).not_to include(@temporal)
55
+ expect(@sw_subject_names).not_to include(@topic)
56
+ expect(@sw_subject_names).not_to include(@s_title)
57
57
  end
58
58
  it "should not contain subject/name/role" do
59
59
  m = "<mods #{@ns_decl}>
@@ -66,7 +66,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
66
66
  </role>
67
67
  </name></subject></mods>"
68
68
  @smods_rec.from_str m
69
- @smods_rec.sw_subject_names.find { |sn| sn =~ /cre/ }.should == nil
69
+ expect(@smods_rec.sw_subject_names.find { |sn| sn =~ /cre/ }).to be_nil
70
70
  end
71
71
  it "should not contain subject/name/affiliation" do
72
72
  m = "<mods #{@ns_decl}>
@@ -76,7 +76,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
76
76
  <affiliation>Chemistry Dept., American University</affiliation>
77
77
  </name></subject></mods>"
78
78
  @smods_rec.from_str m
79
- @smods_rec.sw_subject_names.find { |sn| sn =~ /Chemistry/ }.should == nil
79
+ expect(@smods_rec.sw_subject_names.find { |sn| sn =~ /Chemistry/ }).to be_nil
80
80
  end
81
81
  it "should not contain subject/name/description" do
82
82
  m = "<mods #{@ns_decl}>
@@ -85,7 +85,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
85
85
  <description>American artist, 20th c.</description>
86
86
  </name></subject></mods>"
87
87
  @smods_rec.from_str m
88
- @smods_rec.sw_subject_names.find { |sn| sn =~ /artist/ }.should == nil
88
+ expect(@smods_rec.sw_subject_names.find { |sn| sn =~ /artist/ }).to be_nil
89
89
  end
90
90
  it "should not include top level name element" do
91
91
  m = "<mods #{@ns_decl}>
@@ -94,7 +94,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
94
94
  <description>American artist, 20th c.</description>
95
95
  </name></mods>"
96
96
  @smods_rec.from_str m
97
- @smods_rec.sw_subject_names.should == []
97
+ expect(@smods_rec.sw_subject_names).to eq([])
98
98
  end
99
99
  it "should have one value for each name element" do
100
100
  m = "<mods #{@ns_decl}>
@@ -107,17 +107,17 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
107
107
  </subject>
108
108
  </mods>"
109
109
  @smods_rec.from_str m
110
- @smods_rec.sw_subject_names.should == ['first', 'second', 'third']
110
+ expect(@smods_rec.sw_subject_names).to eq(['first', 'second', 'third'])
111
111
  end
112
112
  it "should be an empty Array if there are no values in the mods" do
113
113
  m = "<mods #{@ns_decl}><note>notit</note></mods>"
114
114
  @smods_rec.from_str m
115
- @smods_rec.sw_subject_names.should == []
115
+ expect(@smods_rec.sw_subject_names).to eq([])
116
116
  end
117
117
  it "should be an empty Array if there are empty values in the mods" do
118
118
  m = "<mods #{@ns_decl}><subject><name><namePart/></name></subject><note>notit</note></mods>"
119
119
  @smods_rec.from_str m
120
- @smods_rec.sw_subject_names.should == []
120
+ expect(@smods_rec.sw_subject_names).to eq([])
121
121
  end
122
122
  context "combining subelements" do
123
123
  before(:all) do
@@ -132,33 +132,33 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
132
132
  @smods_rec.from_str m
133
133
  end
134
134
  it "uses a ', ' as the separator by default" do
135
- @smods_rec.sw_subject_names.should == ['first, second']
136
- end
135
+ expect(@smods_rec.sw_subject_names).to eq ['first, second']
136
+ end
137
137
  it "honors any string value passed in for the separator" do
138
- @smods_rec.sw_subject_names(' --').should == ['first --second']
138
+ expect(@smods_rec.sw_subject_names(' --')).to eq(['first --second'])
139
139
  end
140
140
  end
141
141
  end # sw_subject_names
142
-
142
+
143
143
  context "sw_subject_titles" do
144
144
  it "should contain <subject><titleInfo> subelement values" do
145
- @sw_subject_titles.should include(@s_title)
145
+ expect(@sw_subject_titles).to include(@s_title)
146
146
  end
147
147
  it "should not contain non-name subject subelements" do
148
- @sw_subject_titles.should_not include(@cart_coord)
149
- @sw_subject_titles.should_not include(@s_genre)
150
- @sw_subject_titles.should_not include(@geo)
151
- @sw_subject_titles.should_not include(@geo_code)
152
- @sw_subject_titles.should_not include(@hier_geo_country)
153
- @sw_subject_titles.should_not include(@s_name)
154
- @sw_subject_titles.should_not include(@occupation)
155
- @sw_subject_titles.should_not include(@temporal)
156
- @sw_subject_titles.should_not include(@topic)
148
+ expect(@sw_subject_titles).not_to include(@cart_coord)
149
+ expect(@sw_subject_titles).not_to include(@s_genre)
150
+ expect(@sw_subject_titles).not_to include(@geo)
151
+ expect(@sw_subject_titles).not_to include(@geo_code)
152
+ expect(@sw_subject_titles).not_to include(@hier_geo_country)
153
+ expect(@sw_subject_titles).not_to include(@s_name)
154
+ expect(@sw_subject_titles).not_to include(@occupation)
155
+ expect(@sw_subject_titles).not_to include(@temporal)
156
+ expect(@sw_subject_titles).not_to include(@topic)
157
157
  end
158
158
  it "should not include top level titleInfo element" do
159
159
  m = "<mods #{@ns_decl}><titleInfo><title>Oklahoma</title></titleInfo></mods>"
160
160
  @smods_rec.from_str m
161
- @smods_rec.sw_subject_titles.should == []
161
+ expect(@smods_rec.sw_subject_titles).to eq([])
162
162
  end
163
163
  it "should have one value for each titleInfo element" do
164
164
  m = "<mods #{@ns_decl}>
@@ -171,17 +171,17 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
171
171
  </subject>
172
172
  </mods>"
173
173
  @smods_rec.from_str m
174
- @smods_rec.sw_subject_titles.should == ['first', 'second', 'third']
174
+ expect(@smods_rec.sw_subject_titles).to eq(['first', 'second', 'third'])
175
175
  end
176
176
  it "should be an empty Array if there are no values in the mods" do
177
177
  m = "<mods #{@ns_decl}><note>notit</note></mods>"
178
178
  @smods_rec.from_str m
179
- @smods_rec.sw_subject_titles.should == []
179
+ expect(@smods_rec.sw_subject_titles).to eq([])
180
180
  end
181
181
  it "should be an empty Array if there are empty values in the mods" do
182
182
  m = "<mods #{@ns_decl}><subject><titleInfo><title/></titleInfo></subject><note>notit</note></mods>"
183
183
  @smods_rec.from_str m
184
- @smods_rec.sw_subject_titles.should == []
184
+ expect(@smods_rec.sw_subject_titles).to eq([])
185
185
  end
186
186
  context "combining subelements" do
187
187
  before(:all) do
@@ -196,10 +196,10 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
196
196
  @smods_rec.from_str m
197
197
  end
198
198
  it "uses a ' ' as the separator by default" do
199
- @smods_rec.sw_subject_titles.should == ['first second']
200
- end
199
+ expect(@smods_rec.sw_subject_titles).to eq ['first second']
200
+ end
201
201
  it "honors any string value passed in for the separator" do
202
- @smods_rec.sw_subject_titles(' --').should == ['first --second']
202
+ expect(@smods_rec.sw_subject_titles(' --')).to eq(['first --second'])
203
203
  end
204
204
  it "includes all subelements in the order of occurrence" do
205
205
  m = "<mods #{@ns_decl}>
@@ -214,53 +214,53 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
214
214
  </subject>
215
215
  </mods>"
216
216
  @smods_rec.from_str m
217
- @smods_rec.sw_subject_titles.should == ['1 2 3 4 5']
217
+ expect(@smods_rec.sw_subject_titles).to eq(['1 2 3 4 5'])
218
218
  end
219
219
  end
220
220
  end # sw_subject_titles
221
-
222
-
221
+
222
+
223
223
  context "sw_geographic_search" do
224
224
  it "should contain subject <geographic> subelement data" do
225
- @sw_geographic_search.should include(@geo)
225
+ expect(@sw_geographic_search).to include(@geo)
226
226
  end
227
227
  it "should contain subject <hierarchicalGeographic> subelement data" do
228
- @sw_geographic_search.should include(@hier_geo_country)
228
+ expect(@sw_geographic_search).to include(@hier_geo_country)
229
229
  end
230
230
  it "should contain translation of <geographicCode> subelement data with translated authorities" do
231
231
  m = "<mods #{@ns_decl}><subject><geographicCode authority='marcgac'>e-er</geographicCode></subject></mods>"
232
232
  @smods_rec.from_str m
233
- @smods_rec.sw_geographic_search.should include('Estonia')
233
+ expect(@smods_rec.sw_geographic_search).to include('Estonia')
234
234
  end
235
235
  it "should not contain other subject element data" do
236
- @sw_geographic_search.should_not include(@genre)
237
- @sw_geographic_search.should_not include(@cart_coord)
238
- @sw_geographic_search.should_not include(@s_genre)
239
- @sw_geographic_search.should_not include(@s_name)
240
- @sw_geographic_search.should_not include(@occupation)
241
- @sw_geographic_search.should_not include(@temporal)
242
- @sw_geographic_search.should_not include(@topic)
243
- @sw_geographic_search.should_not include(@s_title)
236
+ expect(@sw_geographic_search).not_to include(@genre)
237
+ expect(@sw_geographic_search).not_to include(@cart_coord)
238
+ expect(@sw_geographic_search).not_to include(@s_genre)
239
+ expect(@sw_geographic_search).not_to include(@s_name)
240
+ expect(@sw_geographic_search).not_to include(@occupation)
241
+ expect(@sw_geographic_search).not_to include(@temporal)
242
+ expect(@sw_geographic_search).not_to include(@topic)
243
+ expect(@sw_geographic_search).not_to include(@s_title)
244
244
  end
245
245
  it "should be [] if there are no values in the MODS" do
246
246
  m = "<mods #{@ns_decl}><note>notit</note></mods>"
247
247
  @smods_rec.from_str m
248
- @smods_rec.sw_geographic_search.should == []
248
+ expect(@smods_rec.sw_geographic_search).to eq([])
249
249
  end
250
250
  it "should not be empty Array if there are only subject/geographic elements" do
251
251
  m = "<mods #{@ns_decl}><subject><geographic>#{@geo}</geographic></subject></mods>"
252
252
  @smods_rec.from_str m
253
- @smods_rec.sw_geographic_search.should == [@geo]
253
+ expect(@smods_rec.sw_geographic_search).to eq([@geo])
254
254
  end
255
255
  it "should not be empty Array if there are only subject/hierarchicalGeographic" do
256
256
  m = "<mods #{@ns_decl}><subject><hierarchicalGeographic><country>#{@hier_geo_country}</country></hierarchicalGeographic></subject></mods>"
257
257
  @smods_rec.from_str m
258
- @smods_rec.sw_geographic_search.should == [@hier_geo_country]
258
+ expect(@smods_rec.sw_geographic_search).to eq([@hier_geo_country])
259
259
  end
260
260
  it "should not be empty Array if there are only subject/geographicCode elements" do
261
261
  m = "<mods #{@ns_decl}><subject><geographicCode authority='marcgac'>e-er</geographicCode></subject></mods>"
262
262
  @smods_rec.from_str m
263
- @smods_rec.sw_geographic_search.should == ['Estonia']
263
+ expect(@smods_rec.sw_geographic_search).to eq(['Estonia'])
264
264
  end
265
265
  context "geographic subelement" do
266
266
  it "should have a separate value for each geographic element" do
@@ -272,12 +272,12 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
272
272
  <subject><geographic>Washington (D.C.)</geographic></subject>
273
273
  </mods>"
274
274
  @smods_rec.from_str m
275
- @smods_rec.sw_geographic_search.should == ['Mississippi', 'Tippah County', 'Washington (D.C.)']
275
+ expect(@smods_rec.sw_geographic_search).to eq(['Mississippi', 'Tippah County', 'Washington (D.C.)'])
276
276
  end
277
277
  it "should be empty Array if there are only empty values in the MODS" do
278
278
  m = "<mods #{@ns_decl}><subject><geographic/></subject><note>notit</note></mods>"
279
279
  @smods_rec.from_str m
280
- @smods_rec.sw_geographic_search.should == []
280
+ expect(@smods_rec.sw_geographic_search).to eq([])
281
281
  end
282
282
  end
283
283
  context "hierarchicalGeographic subelement" do
@@ -290,12 +290,12 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
290
290
  <subject><hierarchicalGeographic><area>third</area></hierarchicalGeographic></subject>
291
291
  </mods>"
292
292
  @smods_rec.from_str m
293
- @smods_rec.sw_geographic_search.should == ['first', 'second', 'third']
293
+ expect(@smods_rec.sw_geographic_search).to eq(['first', 'second', 'third'])
294
294
  end
295
295
  it "should be empty Array if there are only empty values in the MODS" do
296
296
  m = "<mods #{@ns_decl}><subject><hierarchicalGeographic/></subject><note>notit</note></mods>"
297
297
  @smods_rec.from_str m
298
- @smods_rec.sw_geographic_search.should == []
298
+ expect(@smods_rec.sw_geographic_search).to eq([])
299
299
  end
300
300
  context "combining subelements" do
301
301
  before(:all) do
@@ -310,10 +310,10 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
310
310
  @smods_rec.from_str m
311
311
  end
312
312
  it "uses a space as the separator by default" do
313
- @smods_rec.sw_geographic_search.should == ['Canada British Columbia Vancouver']
314
- end
313
+ expect(@smods_rec.sw_geographic_search).to eq ['Canada British Columbia Vancouver']
314
+ end
315
315
  it "honors any string value passed in for the separator" do
316
- @smods_rec.sw_geographic_search(' --').should == ['Canada --British Columbia --Vancouver']
316
+ expect(@smods_rec.sw_geographic_search(' --')).to eq(['Canada --British Columbia --Vancouver'])
317
317
  end
318
318
  end
319
319
  end # hierarchicalGeographic
@@ -326,22 +326,22 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
326
326
  <subject><geographicCode authority='iso3166'>us</geographicCode></subject>
327
327
  </mods>"
328
328
  @smods_rec.from_str m
329
- @geo_search_from_codes = @smods_rec.sw_geographic_search
329
+ @geo_search_from_codes = @smods_rec.sw_geographic_search
330
330
  end
331
331
  it "should not add untranslated values" do
332
- @geo_search_from_codes.should_not include('n-us-md')
333
- @geo_search_from_codes.should_not include('e-er')
334
- @geo_search_from_codes.should_not include('mg')
335
- @geo_search_from_codes.should_not include('us')
332
+ expect(@geo_search_from_codes).not_to include('n-us-md')
333
+ expect(@geo_search_from_codes).not_to include('e-er')
334
+ expect(@geo_search_from_codes).not_to include('mg')
335
+ expect(@geo_search_from_codes).not_to include('us')
336
336
  end
337
337
  it "should translate marcgac codes" do
338
- @geo_search_from_codes.should include('Estonia')
338
+ expect(@geo_search_from_codes).to include('Estonia')
339
339
  end
340
340
  it "should translate marccountry codes" do
341
- @geo_search_from_codes.should include('Madagascar')
341
+ expect(@geo_search_from_codes).to include('Madagascar')
342
342
  end
343
343
  it "should not translate other codes" do
344
- @geo_search_from_codes.should_not include('United States')
344
+ expect(@geo_search_from_codes).not_to include('United States')
345
345
  end
346
346
  it "should have a separate value for each geographicCode element" do
347
347
  m = "<mods #{@ns_decl}>
@@ -352,12 +352,12 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
352
352
  <subject><geographicCode authority='marcgac'>n-us-md</geographicCode></subject>
353
353
  </mods>"
354
354
  @smods_rec.from_str m
355
- @smods_rec.sw_geographic_search.should == ['Estonia', 'Madagascar', 'Maryland']
355
+ expect(@smods_rec.sw_geographic_search).to eq(['Estonia', 'Madagascar', 'Maryland'])
356
356
  end
357
357
  it "should be empty Array if there are only empty values in the MODS" do
358
358
  m = "<mods #{@ns_decl}><subject><geographicCode/></subject><note>notit</note></mods>"
359
359
  @smods_rec.from_str m
360
- @smods_rec.sw_geographic_search.should == []
360
+ expect(@smods_rec.sw_geographic_search).to eq([])
361
361
  end
362
362
  it "should add the translated value if it wasn't present already" do
363
363
  m = "<mods #{@ns_decl}>
@@ -365,8 +365,8 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
365
365
  <subject><geographicCode authority='marcgac'>e-er</geographicCode></subject>
366
366
  </mods>"
367
367
  @smods_rec.from_str m
368
- @smods_rec.sw_geographic_search.size.should == 2
369
- @smods_rec.sw_geographic_search.should include('Estonia')
368
+ expect(@smods_rec.sw_geographic_search.size).to eq(2)
369
+ expect(@smods_rec.sw_geographic_search).to include('Estonia')
370
370
  end
371
371
  it "should not add the translated value if it was already present" do
372
372
  m = "<mods #{@ns_decl}>
@@ -374,11 +374,11 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
374
374
  <subject><geographicCode authority='marcgac'>e-er</geographicCode></subject>
375
375
  </mods>"
376
376
  @smods_rec.from_str m
377
- @smods_rec.sw_geographic_search.size.should == 1
378
- @smods_rec.sw_geographic_search.should == ['Estonia']
377
+ expect(@smods_rec.sw_geographic_search.size).to eq(1)
378
+ expect(@smods_rec.sw_geographic_search).to eq(['Estonia'])
379
379
  end
380
380
  end
381
381
  end # sw_geographic_search
382
382
  end # context sw subject methods
383
383
 
384
- end
384
+ end