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.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/README.rdoc +12 -13
- data/Rakefile +3 -5
- data/config/mappings_hash.rb +22 -23
- data/lib/stanford-mods/searchworks.rb +91 -93
- data/lib/stanford-mods/version.rb +1 -1
- data/lib/stanford-mods.rb +7 -7
- data/spec/name_spec.rb +43 -43
- data/spec/searchworks_basic_spec.rb +49 -0
- data/spec/searchworks_format_spec.rb +7 -7
- data/spec/searchworks_pub_dates_spec.rb +50 -52
- data/spec/searchworks_spec.rb +25 -25
- data/spec/searchworks_subject_raw_spec.rb +83 -83
- data/spec/searchworks_subject_spec.rb +97 -93
- data/spec/searchworks_title_spec.rb +10 -10
- data/stanford-mods.gemspec +10 -10
- metadata +24 -21
@@ -4,7 +4,6 @@ require 'spec_helper'
|
|
4
4
|
describe "Subject fields (searchworks.rb)" do
|
5
5
|
|
6
6
|
before(:all) do
|
7
|
-
@smods_rec = Stanford::Mods::Record.new
|
8
7
|
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
|
9
8
|
@genre = 'genre top level'
|
10
9
|
@cart_coord = '6 00 S, 71 30 E'
|
@@ -28,7 +27,7 @@ describe "Subject fields (searchworks.rb)" do
|
|
28
27
|
<subject><occupation>#{@occupation}</occupation></subject>
|
29
28
|
<subject><temporal>#{@temporal}</temporal></subject>
|
30
29
|
<subject><titleInfo><title>#{@s_title}</title></titleInfo></subject>
|
31
|
-
<subject><topic>#{@topic}</topic></subject>
|
30
|
+
<subject><topic>#{@topic}</topic></subject>
|
32
31
|
</mods>"
|
33
32
|
@smods_rec = Stanford::Mods::Record.new
|
34
33
|
@smods_rec.from_str(@subject_mods)
|
@@ -43,36 +42,36 @@ describe "Subject fields (searchworks.rb)" do
|
|
43
42
|
m = "<mods #{@ns_decl}></mods>"
|
44
43
|
@smods_rec = Stanford::Mods::Record.new
|
45
44
|
@smods_rec.from_str(m)
|
46
|
-
@smods_rec.topic_search.
|
45
|
+
expect(@smods_rec.topic_search).to be_nil
|
47
46
|
end
|
48
47
|
it "should contain subject <topic> subelement data" do
|
49
|
-
@smods_rec.topic_search.
|
48
|
+
expect(@smods_rec.topic_search).to include(@topic)
|
50
49
|
end
|
51
50
|
it "should contain top level <genre> element data" do
|
52
|
-
@smods_rec.topic_search.
|
51
|
+
expect(@smods_rec.topic_search).to include(@genre)
|
53
52
|
end
|
54
53
|
it "should not contain other subject element data" do
|
55
|
-
@smods_rec.topic_search.
|
56
|
-
@smods_rec.topic_search.
|
57
|
-
@smods_rec.topic_search.
|
58
|
-
@smods_rec.topic_search.
|
59
|
-
@smods_rec.topic_search.
|
60
|
-
@smods_rec.topic_search.
|
61
|
-
@smods_rec.topic_search.
|
62
|
-
@smods_rec.topic_search.
|
63
|
-
@smods_rec.topic_search.
|
54
|
+
expect(@smods_rec.topic_search).not_to include(@cart_coord)
|
55
|
+
expect(@smods_rec.topic_search).not_to include(@s_genre)
|
56
|
+
expect(@smods_rec.topic_search).not_to include(@geo)
|
57
|
+
expect(@smods_rec.topic_search).not_to include(@geo_code)
|
58
|
+
expect(@smods_rec.topic_search).not_to include(@hier_geo_country)
|
59
|
+
expect(@smods_rec.topic_search).not_to include(@s_name)
|
60
|
+
expect(@smods_rec.topic_search).not_to include(@occupation)
|
61
|
+
expect(@smods_rec.topic_search).not_to include(@temporal)
|
62
|
+
expect(@smods_rec.topic_search).not_to include(@s_title)
|
64
63
|
end
|
65
64
|
it "should not be nil if there are only subject/topic elements (no <genre>)" do
|
66
65
|
m = "<mods #{@ns_decl}><subject><topic>#{@topic}</topic></subject></mods>"
|
67
66
|
@smods_rec = Stanford::Mods::Record.new
|
68
67
|
@smods_rec.from_str(m)
|
69
|
-
@smods_rec.topic_search.
|
68
|
+
expect(@smods_rec.topic_search).to eq([@topic])
|
70
69
|
end
|
71
70
|
it "should not be nil if there are only <genre> elements (no subject/topic elements)" do
|
72
71
|
m = "<mods #{@ns_decl}><genre>#{@genre}</genre></mods>"
|
73
72
|
@smods_rec = Stanford::Mods::Record.new
|
74
73
|
@smods_rec.from_str(m)
|
75
|
-
@smods_rec.topic_search.
|
74
|
+
expect(@smods_rec.topic_search).to eq([@genre])
|
76
75
|
end
|
77
76
|
context "topic subelement" do
|
78
77
|
it "should have a separate value for each topic element" do
|
@@ -85,13 +84,13 @@ describe "Subject fields (searchworks.rb)" do
|
|
85
84
|
</mods>"
|
86
85
|
@smods_rec = Stanford::Mods::Record.new
|
87
86
|
@smods_rec.from_str(m)
|
88
|
-
@smods_rec.topic_search.
|
87
|
+
expect(@smods_rec.topic_search).to eq(['first', 'second', 'third'])
|
89
88
|
end
|
90
89
|
it "should be nil if there are only empty values in the MODS" do
|
91
90
|
m = "<mods #{@ns_decl}><subject><topic/></subject><note>notit</note></mods>"
|
92
91
|
@smods_rec = Stanford::Mods::Record.new
|
93
92
|
@smods_rec.from_str(m)
|
94
|
-
@smods_rec.topic_search.
|
93
|
+
expect(@smods_rec.topic_search).to be_nil
|
95
94
|
end
|
96
95
|
end
|
97
96
|
end # topic_search
|
@@ -101,14 +100,14 @@ describe "Subject fields (searchworks.rb)" do
|
|
101
100
|
m = "<mods #{@ns_decl}><subject><geographic>#{@geo}</geographic></subject></mods>"
|
102
101
|
@smods_rec = Stanford::Mods::Record.new
|
103
102
|
@smods_rec.from_str(m)
|
104
|
-
@smods_rec.
|
103
|
+
expect(@smods_rec).to receive(:sw_geographic_search)
|
105
104
|
@smods_rec.geographic_search
|
106
105
|
end
|
107
106
|
it "should log an info message when it encounters a geographicCode encoding it doesn't translate" do
|
108
107
|
m = "<mods #{@ns_decl}><subject><geographicCode authority='iso3166'>ca</geographicCode></subject></mods>"
|
109
108
|
@smods_rec = Stanford::Mods::Record.new
|
110
109
|
@smods_rec.from_str(m)
|
111
|
-
@smods_rec.sw_logger.
|
110
|
+
expect(@smods_rec.sw_logger).to receive(:info).with(/ has subject geographicCode element with untranslated encoding \(iso3166\): <geographicCode authority=.*>ca<\/geographicCode>/)
|
112
111
|
@smods_rec.geographic_search
|
113
112
|
end
|
114
113
|
end # geographic_search
|
@@ -117,57 +116,57 @@ describe "Subject fields (searchworks.rb)" do
|
|
117
116
|
it "should call sw_subject_names (from stanford-mods gem)" do
|
118
117
|
smods_rec = Stanford::Mods::Record.new
|
119
118
|
smods_rec.from_str(@subject_mods)
|
120
|
-
smods_rec.
|
119
|
+
expect(smods_rec).to receive(:sw_subject_names)
|
121
120
|
smods_rec.subject_other_search
|
122
121
|
end
|
123
122
|
it "should call sw_subject_titles (from stanford-mods gem)" do
|
124
|
-
@smods_rec.
|
123
|
+
expect(@smods_rec).to receive(:sw_subject_titles)
|
125
124
|
@smods_rec.subject_other_search
|
126
125
|
end
|
127
126
|
it "should be nil if there are no values in the MODS" do
|
128
127
|
m = "<mods #{@ns_decl}></mods>"
|
129
128
|
@smods_rec = Stanford::Mods::Record.new
|
130
129
|
@smods_rec.from_str(m)
|
131
|
-
@smods_rec.subject_other_search.
|
130
|
+
expect(@smods_rec.subject_other_search).to be_nil
|
132
131
|
end
|
133
132
|
it "should contain subject <name> SUBelement data" do
|
134
|
-
@smods_rec.subject_other_search.
|
133
|
+
expect(@smods_rec.subject_other_search).to include(@s_name)
|
135
134
|
end
|
136
135
|
it "should contain subject <occupation> subelement data" do
|
137
|
-
@smods_rec.subject_other_search.
|
136
|
+
expect(@smods_rec.subject_other_search).to include(@occupation)
|
138
137
|
end
|
139
138
|
it "should contain subject <titleInfo> SUBelement data" do
|
140
139
|
@smods_rec = Stanford::Mods::Record.new
|
141
140
|
@smods_rec.from_str(@subject_mods)
|
142
|
-
@smods_rec.subject_other_search.
|
141
|
+
expect(@smods_rec.subject_other_search).to include(@s_title)
|
143
142
|
end
|
144
143
|
it "should not contain other subject element data" do
|
145
|
-
@smods_rec.subject_other_search.
|
146
|
-
@smods_rec.subject_other_search.
|
147
|
-
@smods_rec.subject_other_search.
|
148
|
-
@smods_rec.subject_other_search.
|
149
|
-
@smods_rec.subject_other_search.
|
150
|
-
@smods_rec.subject_other_search.
|
151
|
-
@smods_rec.subject_other_search.
|
152
|
-
@smods_rec.subject_other_search.
|
144
|
+
expect(@smods_rec.subject_other_search).not_to include(@genre)
|
145
|
+
expect(@smods_rec.subject_other_search).not_to include(@cart_coord)
|
146
|
+
expect(@smods_rec.subject_other_search).not_to include(@s_genre)
|
147
|
+
expect(@smods_rec.subject_other_search).not_to include(@geo)
|
148
|
+
expect(@smods_rec.subject_other_search).not_to include(@geo_code)
|
149
|
+
expect(@smods_rec.subject_other_search).not_to include(@hier_geo_country)
|
150
|
+
expect(@smods_rec.subject_other_search).not_to include(@temporal)
|
151
|
+
expect(@smods_rec.subject_other_search).not_to include(@topic)
|
153
152
|
end
|
154
153
|
it "should not be nil if there are only subject/name elements" do
|
155
154
|
m = "<mods #{@ns_decl}><subject><name><namePart>#{@s_name}</namePart></name></subject></mods>"
|
156
155
|
@smods_rec = Stanford::Mods::Record.new
|
157
156
|
@smods_rec.from_str(m)
|
158
|
-
@smods_rec.subject_other_search.
|
157
|
+
expect(@smods_rec.subject_other_search).to eq([@s_name])
|
159
158
|
end
|
160
159
|
it "should not be nil if there are only subject/occupation elements" do
|
161
160
|
m = "<mods #{@ns_decl}><subject><occupation>#{@occupation}</occupation></subject></mods>"
|
162
161
|
@smods_rec = Stanford::Mods::Record.new
|
163
162
|
@smods_rec.from_str(m)
|
164
|
-
@smods_rec.subject_other_search.
|
163
|
+
expect(@smods_rec.subject_other_search).to eq([@occupation])
|
165
164
|
end
|
166
165
|
it "should not be nil if there are only subject/titleInfo elements" do
|
167
166
|
m = "<mods #{@ns_decl}><subject><titleInfo><title>#{@s_title}</title></titleInfo></subject></mods>"
|
168
167
|
@smods_rec = Stanford::Mods::Record.new
|
169
168
|
@smods_rec.from_str(m)
|
170
|
-
@smods_rec.subject_other_search.
|
169
|
+
expect(@smods_rec.subject_other_search).to eq([@s_title])
|
171
170
|
end
|
172
171
|
context "occupation subelement" do
|
173
172
|
it "should have a separate value for each occupation element" do
|
@@ -180,13 +179,13 @@ describe "Subject fields (searchworks.rb)" do
|
|
180
179
|
</mods>"
|
181
180
|
@smods_rec = Stanford::Mods::Record.new
|
182
181
|
@smods_rec.from_str(m)
|
183
|
-
@smods_rec.subject_other_search.
|
182
|
+
expect(@smods_rec.subject_other_search).to eq(['first', 'second', 'third'])
|
184
183
|
end
|
185
184
|
it "should be nil if there are only empty values in the MODS" do
|
186
185
|
m = "<mods #{@ns_decl}><subject><occupation/></subject><note>notit</note></mods>"
|
187
186
|
@smods_rec = Stanford::Mods::Record.new
|
188
187
|
@smods_rec.from_str(m)
|
189
|
-
@smods_rec.subject_other_search.
|
188
|
+
expect(@smods_rec.subject_other_search).to be_nil
|
190
189
|
end
|
191
190
|
end
|
192
191
|
end # subject_other_search
|
@@ -195,36 +194,36 @@ describe "Subject fields (searchworks.rb)" do
|
|
195
194
|
it "should be nil if there are no values in the MODS" do
|
196
195
|
@smods_rec = Stanford::Mods::Record.new
|
197
196
|
@smods_rec.from_str(@ng_mods_no_subject.to_s)
|
198
|
-
@smods_rec.subject_other_subvy_search.
|
197
|
+
expect(@smods_rec.subject_other_subvy_search).to be_nil
|
199
198
|
end
|
200
199
|
it "should contain subject <temporal> subelement data" do
|
201
|
-
@smods_rec.subject_other_subvy_search.
|
200
|
+
expect(@smods_rec.subject_other_subvy_search).to include(@temporal)
|
202
201
|
end
|
203
202
|
it "should contain subject <genre> SUBelement data" do
|
204
|
-
@smods_rec.subject_other_subvy_search.
|
203
|
+
expect(@smods_rec.subject_other_subvy_search).to include(@s_genre)
|
205
204
|
end
|
206
205
|
it "should not contain other subject element data" do
|
207
|
-
@smods_rec.subject_other_subvy_search.
|
208
|
-
@smods_rec.subject_other_subvy_search.
|
209
|
-
@smods_rec.subject_other_subvy_search.
|
210
|
-
@smods_rec.subject_other_subvy_search.
|
211
|
-
@smods_rec.subject_other_subvy_search.
|
212
|
-
@smods_rec.subject_other_subvy_search.
|
213
|
-
@smods_rec.subject_other_subvy_search.
|
214
|
-
@smods_rec.subject_other_subvy_search.
|
215
|
-
@smods_rec.subject_other_subvy_search.
|
206
|
+
expect(@smods_rec.subject_other_subvy_search).not_to include(@genre)
|
207
|
+
expect(@smods_rec.subject_other_subvy_search).not_to include(@cart_coord)
|
208
|
+
expect(@smods_rec.subject_other_subvy_search).not_to include(@geo)
|
209
|
+
expect(@smods_rec.subject_other_subvy_search).not_to include(@geo_code)
|
210
|
+
expect(@smods_rec.subject_other_subvy_search).not_to include(@hier_geo_country)
|
211
|
+
expect(@smods_rec.subject_other_subvy_search).not_to include(@s_name)
|
212
|
+
expect(@smods_rec.subject_other_subvy_search).not_to include(@occupation)
|
213
|
+
expect(@smods_rec.subject_other_subvy_search).not_to include(@topic)
|
214
|
+
expect(@smods_rec.subject_other_subvy_search).not_to include(@s_title)
|
216
215
|
end
|
217
216
|
it "should not be nil if there are only subject/temporal elements (no subject/genre)" do
|
218
217
|
m = "<mods #{@ns_decl}><subject><temporal>#{@temporal}</temporal></subject></mods>"
|
219
218
|
@smods_rec = Stanford::Mods::Record.new
|
220
219
|
@smods_rec.from_str(m)
|
221
|
-
@smods_rec.subject_other_subvy_search.
|
220
|
+
expect(@smods_rec.subject_other_subvy_search).to eq([@temporal])
|
222
221
|
end
|
223
222
|
it "should not be nil if there are only subject/genre elements (no subject/temporal)" do
|
224
223
|
m = "<mods #{@ns_decl}><subject><genre>#{@s_genre}</genre></subject></mods>"
|
225
224
|
@smods_rec = Stanford::Mods::Record.new
|
226
225
|
@smods_rec.from_str(m)
|
227
|
-
@smods_rec.subject_other_subvy_search.
|
226
|
+
expect(@smods_rec.subject_other_subvy_search).to eq([@s_genre])
|
228
227
|
end
|
229
228
|
context "temporal subelement" do
|
230
229
|
it "should have a separate value for each temporal element" do
|
@@ -237,20 +236,20 @@ describe "Subject fields (searchworks.rb)" do
|
|
237
236
|
</mods>"
|
238
237
|
@smods_rec = Stanford::Mods::Record.new
|
239
238
|
@smods_rec.from_str(m)
|
240
|
-
@smods_rec.subject_other_subvy_search.
|
239
|
+
expect(@smods_rec.subject_other_subvy_search).to eq(['1890-1910', '20th century', 'another'])
|
241
240
|
end
|
242
241
|
it "should log an info message when it encounters an encoding it doesn't translate" do
|
243
242
|
m = "<mods #{@ns_decl}><subject><temporal encoding='iso8601'>197505</temporal></subject></mods>"
|
244
243
|
@smods_rec = Stanford::Mods::Record.new
|
245
244
|
@smods_rec.from_str(m)
|
246
|
-
@smods_rec.sw_logger.
|
245
|
+
expect(@smods_rec.sw_logger).to receive(:info).with(/ has subject temporal element with untranslated encoding: <temporal encoding=.*>197505<\/temporal>/)
|
247
246
|
@smods_rec.subject_other_subvy_search
|
248
247
|
end
|
249
248
|
it "should be nil if there are only empty values in the MODS" do
|
250
249
|
m = "<mods #{@ns_decl}><subject><temporal/></subject><note>notit</note></mods>"
|
251
250
|
@smods_rec = Stanford::Mods::Record.new
|
252
251
|
@smods_rec.from_str(m)
|
253
|
-
@smods_rec.subject_other_subvy_search.
|
252
|
+
expect(@smods_rec.subject_other_subvy_search).to be_nil
|
254
253
|
end
|
255
254
|
end
|
256
255
|
context "genre subelement" do
|
@@ -264,62 +263,67 @@ describe "Subject fields (searchworks.rb)" do
|
|
264
263
|
</mods>"
|
265
264
|
@smods_rec = Stanford::Mods::Record.new
|
266
265
|
@smods_rec.from_str(m)
|
267
|
-
@smods_rec.subject_other_subvy_search.
|
266
|
+
expect(@smods_rec.subject_other_subvy_search).to eq(['first', 'second', 'third'])
|
268
267
|
end
|
269
268
|
it "should be nil if there are only empty values in the MODS" do
|
270
269
|
m = "<mods #{@ns_decl}><subject><genre/></subject><note>notit</note></mods>"
|
271
270
|
@smods_rec = Stanford::Mods::Record.new
|
272
271
|
@smods_rec.from_str(m)
|
273
|
-
@smods_rec.subject_other_subvy_search.
|
272
|
+
expect(@smods_rec.subject_other_subvy_search).to be_nil
|
274
273
|
end
|
275
274
|
end
|
276
275
|
end # subject_other_subvy_search
|
277
276
|
|
278
277
|
context "subject_all_search" do
|
278
|
+
before :each do
|
279
|
+
allow(@smods_rec.sw_logger).to receive(:info).with(/ has subject geographicCode element with untranslated encoding \(iso3166\): <geographicCode authority=.*>us<\/geographicCode>/)
|
280
|
+
end
|
279
281
|
it "should be nil if there are no values in the MODS" do
|
280
282
|
@smods_rec = Stanford::Mods::Record.new
|
281
283
|
@smods_rec.from_str(@ng_mods_no_subject.to_s)
|
282
|
-
@smods_rec.subject_all_search.
|
284
|
+
expect(@smods_rec.subject_all_search).to be_nil
|
283
285
|
end
|
284
286
|
it "should contain top level <genre> element data" do
|
285
|
-
|
287
|
+
expect(@smods_rec.subject_all_search).to include(@genre)
|
286
288
|
end
|
287
289
|
it "should not contain cartographic sub element" do
|
288
|
-
@smods_rec.subject_all_search.
|
290
|
+
expect(@smods_rec.subject_all_search).not_to include(@cart_coord)
|
289
291
|
end
|
290
292
|
it "should not include codes from hierarchicalGeographic sub element" do
|
291
|
-
@smods_rec.subject_all_search.
|
293
|
+
expect(@smods_rec.subject_all_search).not_to include(@geo_code)
|
292
294
|
end
|
293
295
|
it "should contain all other subject subelement data" do
|
294
296
|
@smods_rec = Stanford::Mods::Record.new
|
295
297
|
@smods_rec.from_str(@subject_mods)
|
296
|
-
|
297
|
-
@smods_rec.
|
298
|
-
@smods_rec.subject_all_search.
|
299
|
-
@smods_rec.subject_all_search.
|
300
|
-
@smods_rec.subject_all_search.
|
301
|
-
@smods_rec.subject_all_search.
|
302
|
-
@smods_rec.subject_all_search.
|
303
|
-
@smods_rec.subject_all_search.
|
298
|
+
## need to re-allow/expect :info message with newly assigned object
|
299
|
+
expect(@smods_rec.sw_logger).to receive(:info).with(/ has subject geographicCode element with untranslated encoding \(iso3166\): <geographicCode authority=.*>us<\/geographicCode>/)
|
300
|
+
expect(@smods_rec.subject_all_search).to include(@s_genre)
|
301
|
+
expect(@smods_rec.subject_all_search).to include(@geo)
|
302
|
+
expect(@smods_rec.subject_all_search).to include(@hier_geo_country)
|
303
|
+
expect(@smods_rec.subject_all_search).to include(@s_name)
|
304
|
+
expect(@smods_rec.subject_all_search).to include(@occupation)
|
305
|
+
expect(@smods_rec.subject_all_search).to include(@temporal)
|
306
|
+
expect(@smods_rec.subject_all_search).to include(@s_title)
|
307
|
+
expect(@smods_rec.subject_all_search).to include(@topic)
|
304
308
|
end
|
305
309
|
end # subject_all_search
|
306
|
-
|
310
|
+
|
307
311
|
end # search fields
|
308
312
|
|
309
313
|
context "facet fields" do
|
310
314
|
|
311
315
|
context "topic_facet" do
|
312
316
|
it "should include topic subelement" do
|
313
|
-
@smods_rec.topic_facet.
|
317
|
+
expect(@smods_rec.topic_facet).to include(@topic)
|
314
318
|
end
|
315
319
|
it "should include sw_subject_names" do
|
316
|
-
@smods_rec.topic_facet.
|
320
|
+
expect(@smods_rec.topic_facet).to include(@s_name)
|
317
321
|
end
|
318
322
|
it "should include sw_subject_titles" do
|
319
|
-
@smods_rec.topic_facet.
|
323
|
+
expect(@smods_rec.topic_facet).to include(@s_title)
|
320
324
|
end
|
321
325
|
it "should include occupation subelement" do
|
322
|
-
@smods_rec.topic_facet.
|
326
|
+
expect(@smods_rec.topic_facet).to include(@occupation)
|
323
327
|
end
|
324
328
|
it "should have the trailing punctuation removed" do
|
325
329
|
m = "<mods #{@ns_decl}><subject>
|
@@ -330,21 +334,21 @@ describe "Subject fields (searchworks.rb)" do
|
|
330
334
|
</subject></mods>"
|
331
335
|
@smods_rec = Stanford::Mods::Record.new
|
332
336
|
@smods_rec.from_str(m)
|
333
|
-
@smods_rec.topic_facet.
|
334
|
-
@smods_rec.topic_facet.
|
335
|
-
@smods_rec.topic_facet.
|
336
|
-
@smods_rec.topic_facet.
|
337
|
+
expect(@smods_rec.topic_facet).to include('comma')
|
338
|
+
expect(@smods_rec.topic_facet).to include('semicolon')
|
339
|
+
expect(@smods_rec.topic_facet).to include('backslash')
|
340
|
+
expect(@smods_rec.topic_facet).to include('internal, punct;uation')
|
337
341
|
end
|
338
342
|
it "should be nil if there are no values" do
|
339
343
|
@smods_rec = Stanford::Mods::Record.new
|
340
344
|
@smods_rec.from_str(@ng_mods_no_subject.to_s)
|
341
|
-
@smods_rec.topic_facet.
|
345
|
+
expect(@smods_rec.topic_facet).to be_nil
|
342
346
|
end
|
343
347
|
end
|
344
348
|
|
345
349
|
context "geographic_facet" do
|
346
350
|
it "should call geographic_search" do
|
347
|
-
@smods_rec.
|
351
|
+
expect(@smods_rec).to receive(:geographic_search)
|
348
352
|
@smods_rec.geographic_facet
|
349
353
|
end
|
350
354
|
it "should be like geographic_search with the trailing punctuation (and preceding spaces) removed" do
|
@@ -356,19 +360,19 @@ describe "Subject fields (searchworks.rb)" do
|
|
356
360
|
</subject></mods>"
|
357
361
|
@smods_rec = Stanford::Mods::Record.new
|
358
362
|
@smods_rec.from_str(m)
|
359
|
-
@smods_rec.geographic_facet.
|
360
|
-
@smods_rec.geographic_facet.
|
361
|
-
@smods_rec.geographic_facet.
|
362
|
-
@smods_rec.geographic_facet.
|
363
|
+
expect(@smods_rec.geographic_facet).to include('comma')
|
364
|
+
expect(@smods_rec.geographic_facet).to include('semicolon')
|
365
|
+
expect(@smods_rec.geographic_facet).to include('backslash')
|
366
|
+
expect(@smods_rec.geographic_facet).to include('internal, punct;uation')
|
363
367
|
end
|
364
368
|
it "should be nil if there are no values" do
|
365
369
|
@smods_rec = Stanford::Mods::Record.new
|
366
370
|
@smods_rec.from_str(@ng_mods_no_subject.to_s)
|
367
|
-
@smods_rec.
|
371
|
+
expect(@smods_rec.geographic_facet).to be_nil
|
368
372
|
end
|
369
373
|
end
|
370
374
|
|
371
|
-
context "era_facet" do
|
375
|
+
context "era_facet" do
|
372
376
|
it "should be temporal subelement with the trailing punctuation removed" do
|
373
377
|
m = "<mods #{@ns_decl}><subject>
|
374
378
|
<temporal>comma,</temporal>
|
@@ -378,18 +382,18 @@ describe "Subject fields (searchworks.rb)" do
|
|
378
382
|
</subject></mods>"
|
379
383
|
@smods_rec = Stanford::Mods::Record.new
|
380
384
|
@smods_rec.from_str(m)
|
381
|
-
@smods_rec.era_facet.
|
382
|
-
@smods_rec.era_facet.
|
383
|
-
@smods_rec.era_facet.
|
384
|
-
@smods_rec.era_facet.
|
385
|
+
expect(@smods_rec.era_facet).to include('comma')
|
386
|
+
expect(@smods_rec.era_facet).to include('semicolon')
|
387
|
+
expect(@smods_rec.era_facet).to include('backslash')
|
388
|
+
expect(@smods_rec.era_facet).to include('internal, punct;uation')
|
385
389
|
end
|
386
390
|
it "should be nil if there are no values" do
|
387
391
|
@smods_rec = Stanford::Mods::Record.new
|
388
392
|
@smods_rec.from_str(@ng_mods_no_subject.to_s)
|
389
|
-
@smods_rec.era_facet.
|
393
|
+
expect(@smods_rec.era_facet).to be_nil
|
390
394
|
end
|
391
395
|
end
|
392
396
|
|
393
397
|
end # facet fields
|
394
398
|
|
395
|
-
end
|
399
|
+
end
|
@@ -6,19 +6,19 @@ describe "title fields (searchworks.rb)" do
|
|
6
6
|
@smods_rec = Stanford::Mods::Record.new
|
7
7
|
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
|
8
8
|
m = "<mods #{@ns_decl}><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>"
|
9
|
-
@smods_rec.from_str m
|
9
|
+
@smods_rec.from_str m
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
context "short title (for title_245a_search, title_245a_display) " do
|
13
13
|
it "should call :short_titles" do
|
14
|
-
@smods_rec.
|
14
|
+
expect(@smods_rec).to receive(:short_titles) # in Mods gem
|
15
15
|
@smods_rec.sw_short_title
|
16
16
|
end
|
17
17
|
it "should be a String" do
|
18
18
|
expect(@smods_rec.sw_short_title).to eq 'The Jerk'
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
context "full title (for title_245_search, title_full_display)" do
|
23
23
|
it "should be a String" do
|
24
24
|
expect(@smods_rec.sw_full_title).to eq 'The Jerk : A Tale of Tourettes.'
|
@@ -244,7 +244,7 @@ describe "title fields (searchworks.rb)" do
|
|
244
244
|
end # no partName but partNumber
|
245
245
|
end # punctuation
|
246
246
|
end # sw_full_title
|
247
|
-
|
247
|
+
|
248
248
|
context "sw_title_display removes end punctuation of sw_full_title_display" do
|
249
249
|
|
250
250
|
# title_display = custom, removeTrailingPunct(245abdefghijklmnopqrstuvwxyz, [\\\\,/;:], ([A-Za-z]{4}|[0-9]{3}|\\)|\\,))
|
@@ -515,7 +515,7 @@ describe "title fields (searchworks.rb)" do
|
|
515
515
|
end
|
516
516
|
end # no partName but partNumber
|
517
517
|
end # sw_title_display
|
518
|
-
|
518
|
+
|
519
519
|
context "additional titles (for title_variant_search)" do
|
520
520
|
before(:all) do
|
521
521
|
m = "<mods #{@ns_decl}>
|
@@ -545,14 +545,14 @@ describe "title fields (searchworks.rb)" do
|
|
545
545
|
@smods_rec.from_str(m)
|
546
546
|
expect(@smods_rec.sw_addl_titles).to eq ['Alternative', 'Joke]']
|
547
547
|
end
|
548
|
-
end
|
549
|
-
|
548
|
+
end
|
549
|
+
|
550
550
|
context "sort title" do
|
551
551
|
it "should be a String" do
|
552
552
|
expect(@smods_rec.sw_sort_title).to be_an_instance_of(String)
|
553
553
|
end
|
554
554
|
it "should use the sw_full_title as a starting point" do
|
555
|
-
@smods_rec.
|
555
|
+
expect(@smods_rec).to receive(:sw_full_title)
|
556
556
|
@smods_rec.sw_sort_title
|
557
557
|
end
|
558
558
|
it "should not begin or end with whitespace" do
|
@@ -568,7 +568,7 @@ describe "title fields (searchworks.rb)" do
|
|
568
568
|
expect(r.sw_sort_title).to match /^Jerk$/
|
569
569
|
end
|
570
570
|
end
|
571
|
-
|
571
|
+
|
572
572
|
context "part number should be in full title and sort title", :jira => ['INDEX-31', 'GRYPHONDOR-372'] do
|
573
573
|
before(:all) do
|
574
574
|
@mccarthy_smods_rec = Stanford::Mods::Record.new
|
data/stanford-mods.gemspec
CHANGED
@@ -15,24 +15,24 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
16
|
gem.test_files = gem.files.grep(%r{^spec/})
|
17
17
|
gem.require_paths = ["lib"]
|
18
|
-
|
19
|
-
gem.add_dependency 'mods'
|
20
|
-
|
18
|
+
|
19
|
+
gem.add_dependency 'mods', '~> 2.0.2'
|
20
|
+
|
21
21
|
# Runtime dependencies
|
22
22
|
# gem.add_runtime_dependency 'nokogiri'
|
23
23
|
|
24
24
|
# Development dependencies
|
25
|
-
# Bundler
|
26
|
-
#
|
25
|
+
# Bundler WILL install these gems too if you've checked out from git and run 'bundle install'
|
26
|
+
# Bundler WILL NOT add these as dependencies if you gem install or add this gem to your Gemfile
|
27
27
|
gem.add_development_dependency "rake"
|
28
28
|
# docs
|
29
29
|
gem.add_development_dependency "rdoc"
|
30
30
|
gem.add_development_dependency "yard"
|
31
31
|
# tests
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
gem.add_development_dependency 'rspec'
|
33
|
+
# using coveralls with travis now
|
34
|
+
# gem.add_development_dependency 'simplecov'
|
35
|
+
# gem.add_development_dependency 'simplecov-rcov'
|
36
|
+
# gem.add_development_dependency 'ruby-debug19'
|
37
37
|
|
38
38
|
end
|