mods 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,57 +4,58 @@ require 'spec_helper'
4
4
  describe "Mods <originInfo> Element" do
5
5
  before(:all) do
6
6
  @mods_rec = Mods::Record.new
7
- @kolb = '<mods>
7
+ @ns_decl = "xmlns='#{Mods::MODS_NS}'"
8
+ @kolb = "<mods>
8
9
  <originInfo>
9
10
  <dateCreated>1537-1553.</dateCreated>
10
- <dateCreated point="start">1537</dateCreated>
11
- <dateCreated point="end">1553</dateCreated>
12
- </originInfo></mods>'
13
- @reid_dennis = '<mods><originInfo><dateIssued>1852</dateIssued></originInfo></mods>'
14
- @walters = '<mods><originInfo>
11
+ <dateCreated point='start'>1537</dateCreated>
12
+ <dateCreated point='end'>1553</dateCreated>
13
+ </originInfo></mods>"
14
+ @reid_dennis = "<mods><originInfo><dateIssued>1852</dateIssued></originInfo></mods>"
15
+ @walters = "<mods><originInfo>
15
16
  <place>
16
- <placeTerm type="text">Iran</placeTerm>
17
+ <placeTerm type='text'>Iran</placeTerm>
17
18
  </place>
18
19
  <dateIssued>22 Rabīʿ II 889 AH / 1484 CE</dateIssued>
19
20
  <issuance>monographic</issuance>
20
21
  </originInfo>
21
- </mods>'
22
- @simple = '<mods><originInfo><dateIssued>circa 1900</dateIssued></originInfo></mods>'
23
- @ew = '<mods><originInfo>
22
+ </mods>"
23
+ @simple = "<mods><originInfo><dateIssued>circa 1900</dateIssued></originInfo></mods>"
24
+ @ew = "<mods><originInfo>
24
25
  <place>
25
- <placeTerm type="text">Reichenau Abbey, Lake Constance, Germany</placeTerm>
26
+ <placeTerm type='text'>Reichenau Abbey, Lake Constance, Germany</placeTerm>
26
27
  </place>
27
28
  <dateIssued>Middle of the 11th century CE</dateIssued>
28
29
  <issuance>monographic</issuance>
29
30
  </originInfo>
30
- </mods>'
31
- @e = '<mods><originInfo>
31
+ </mods>"
32
+ @e = "<mods><originInfo>
32
33
  <place>
33
- <placeTerm type="code" authority="marccountry">au</placeTerm>
34
+ <placeTerm type='code' authority='marccountry'>au</placeTerm>
34
35
  </place>
35
36
  <place>
36
- <placeTerm type="text">[Austria?</placeTerm>
37
+ <placeTerm type='text'>[Austria?</placeTerm>
37
38
  </place>
38
39
  <dateIssued>circa 1180-1199]</dateIssued>
39
40
  <issuance>monographic</issuance>
40
- </originInfo></mods>'
41
- @f = '<mods> <originInfo>
41
+ </originInfo></mods>"
42
+ @f = "<mods> <originInfo>
42
43
  <place>
43
- <placeTerm authority="marccountry" type="code">cau</placeTerm>
44
+ <placeTerm authority='marccountry' type='code'>cau</placeTerm>
44
45
  </place>
45
- <dateIssued encoding="marc" keyDate="yes" point="start">1850</dateIssued>
46
- <dateIssued encoding="marc" point="end">1906</dateIssued>
46
+ <dateIssued encoding='marc' keyDate='yes' point='start'>1850</dateIssued>
47
+ <dateIssued encoding='marc' point='end'>1906</dateIssued>
47
48
  <issuance>monographic</issuance>
48
49
  </originInfo>
49
- </mods>'
50
- @ex = '<mods><originInfo>
50
+ </mods>"
51
+ @ex = "<mods><originInfo>
51
52
  <place>
52
53
  <placeTerm>France and Italy</placeTerm>
53
54
  </place>
54
- <dateCreated keyDate="yes" qualifier="inferred">173-?</dateCreated>
55
+ <dateCreated keyDate='yes' qualifier='inferred'>173-?</dateCreated>
55
56
  </originInfo>
56
- </mods>'
57
- @ex1 = '<mods><originInfo>
57
+ </mods>"
58
+ @ex1 = "<mods><originInfo>
58
59
  <publisher>Robot Publishing</publisher>
59
60
  <place>
60
61
  <placeTerm>France</placeTerm>
@@ -62,94 +63,94 @@ describe "Mods <originInfo> Element" do
62
63
  <place>
63
64
  <placeTerm>Italy</placeTerm>
64
65
  </place>
65
- <dateCreated keyDate="yes" qualifier="inferred">173-?</dateCreated>
66
+ <dateCreated keyDate='yes' qualifier='inferred'>173-?</dateCreated>
66
67
  <dateIssued>1850</dateIssued>
67
68
  </originInfo>
68
- </mods>'
69
- @ex2 = '<mods><originInfo>
69
+ </mods>"
70
+ @ex2 = "<mods><originInfo>
70
71
  <place>
71
- <placeTerm type="code" authority="marccountry">enk</placeTerm>
72
+ <placeTerm type='code' authority='marccountry'>enk</placeTerm>
72
73
  </place>
73
74
  <place>
74
- <placeTerm type="text">[London]</placeTerm>
75
+ <placeTerm type='text'>[London]</placeTerm>
75
76
  </place>
76
77
  <publisher>Bunney &amp; Gold</publisher>
77
78
  <dateIssued>1799</dateIssued>
78
- <dateIssued encoding="marc" keyDate="yes">1799</dateIssued>
79
+ <dateIssued encoding='marc' keyDate='yes'>1799</dateIssued>
79
80
  <issuance>monographic</issuance>
80
81
  </originInfo>
81
- </mods>'
82
- @ex3 = '<mods><originInfo>
82
+ </mods>"
83
+ @ex3 = "<mods><originInfo>
83
84
  <place>
84
- <placeTerm type="code" authority="marccountry">xx</placeTerm>
85
+ <placeTerm type='code' authority='marccountry'>xx</placeTerm>
85
86
  </place>
86
87
  <place>
87
- <placeTerm type="text">[s.l. : s.n.]</placeTerm>
88
+ <placeTerm type='text'>[s.l. : s.n.]</placeTerm>
88
89
  </place>
89
90
  <dateIssued>1780?]</dateIssued>
90
- <dateIssued encoding="marc" keyDate="yes">178u</dateIssued>
91
+ <dateIssued encoding='marc' keyDate='yes'>178u</dateIssued>
91
92
  <issuance>monographic</issuance>
92
93
  </originInfo>
93
- </mods>'
94
- @ex4 = '<mods><originInfo>
94
+ </mods>"
95
+ @ex4 = "<mods><originInfo>
95
96
  <place>
96
- <placeTerm type="code" authority="marccountry">fr</placeTerm>
97
+ <placeTerm type='code' authority='marccountry'>fr</placeTerm>
97
98
  </place>
98
99
  <place>
99
- <placeTerm type="text">[S.l.]</placeTerm>
100
+ <placeTerm type='text'>[S.l.]</placeTerm>
100
101
  </place>
101
102
  <publisher>[s.n.]</publisher>
102
103
  <dateIssued>[1740.]</dateIssued>
103
- <dateIssued encoding="marc" point="start" qualifier="questionable" keyDate="yes">1740</dateIssued>
104
- <dateIssued encoding="marc" point="end" qualifier="questionable">1749</dateIssued>
104
+ <dateIssued encoding='marc' point='start' qualifier='questionable' keyDate='yes'>1740</dateIssued>
105
+ <dateIssued encoding='marc' point='end' qualifier='questionable'>1749</dateIssued>
105
106
  <issuance>monographic</issuance>
106
107
  </originInfo>
107
- </mods>'
108
- @ex5 = '<mods><originInfo>
108
+ </mods>"
109
+ @ex5 = "<mods><originInfo>
109
110
  <place>
110
- <placeTerm type="code" authority="marccountry">xx</placeTerm>
111
+ <placeTerm type='code' authority='marccountry'>xx</placeTerm>
111
112
  </place>
112
113
  <place>
113
- <placeTerm type="text">[S.l.]</placeTerm>
114
+ <placeTerm type='text'>[S.l.]</placeTerm>
114
115
  </place>
115
116
  <publisher>Olney</publisher>
116
117
  <dateIssued>1844</dateIssued>
117
- <dateIssued encoding="marc" keyDate="yes">1844</dateIssued>
118
+ <dateIssued encoding='marc' keyDate='yes'>1844</dateIssued>
118
119
  <issuance>monographic</issuance>
119
120
  </originInfo>
120
- </mods>'
121
- @ex6 = '<mods><originInfo>
121
+ </mods>"
122
+ @ex6 = "<mods><originInfo>
122
123
  <place>
123
- <placeTerm type="code" authority="marccountry">enk</placeTerm>
124
+ <placeTerm type='code' authority='marccountry'>enk</placeTerm>
124
125
  </place>
125
126
  <place>
126
- <placeTerm type="text">[London</placeTerm>
127
+ <placeTerm type='text'>[London</placeTerm>
127
128
  </place>
128
129
  <publisher>Printed for William Innys and Joseph Richardson ... [et al.]</publisher>
129
130
  <dateIssued>1752]</dateIssued>
130
- <dateIssued encoding="marc" keyDate="yes">1752</dateIssued>
131
+ <dateIssued encoding='marc' keyDate='yes'>1752</dateIssued>
131
132
  <issuance>monographic</issuance>
132
133
  </originInfo>
133
- </mods>'
134
- @ex7 = '<mods><originInfo>
134
+ </mods>"
135
+ @ex7 = "<mods><originInfo>
135
136
  <place>
136
- <placeTerm authority="marccountry" type="code">fr</placeTerm>
137
+ <placeTerm authority='marccountry' type='code'>fr</placeTerm>
137
138
  </place>
138
139
  <place>
139
- <placeTerm type="text">[S.l.]</placeTerm>
140
+ <placeTerm type='text'>[S.l.]</placeTerm>
140
141
  </place>
141
142
  <publisher>[s.n.]</publisher>
142
143
  <dateIssued>[1740.]</dateIssued>
143
- <dateIssued encoding="marc" keyDate="yes" point="start" qualifier="questionable">1740</dateIssued>
144
- <dateIssued encoding="marc" point="end" qualifier="questionable">1749</dateIssued>
144
+ <dateIssued encoding='marc' keyDate='yes' point='start' qualifier='questionable'>1740</dateIssued>
145
+ <dateIssued encoding='marc' point='end' qualifier='questionable'>1749</dateIssued>
145
146
  <issuance>monographic</issuance>
146
147
  </originInfo>
147
- </mods>'
148
+ </mods>"
148
149
 
149
- xml = '<originInfo>
150
- <dateCreated encoding="w3cdtf" keyDate="yes" point="start" qualifier="approximate">250 B.C.</dateCreated>
151
- <dateCreated encoding="w3cdtf" keyDate="yes" point="end" qualifier="approximate">150 B.C.</dateCreated>
152
- </originInfo>'
150
+ xml = "<originInfo>
151
+ <dateCreated encoding='w3cdtf' keyDate='yes' point='start' qualifier='approximate'>250 B.C.</dateCreated>
152
+ <dateCreated encoding='w3cdtf' keyDate='yes' point='end' qualifier='approximate'>150 B.C.</dateCreated>
153
+ </originInfo>"
153
154
 
154
155
  end
155
156
 
@@ -157,152 +158,276 @@ describe "Mods <originInfo> Element" do
157
158
  it "should cope with slop" do
158
159
  pending "to be implemented"
159
160
  end
160
-
161
+ it "should know something about various date encodings: w3cdtf, iso8601, marc, edtf, temper" do
162
+ pending "to be implemented"
163
+ end
164
+ it "should know the only valid values for point attribute are 'start' and 'end'" do
165
+ pending "to be implemented"
166
+ end
167
+ it "should know the only valid value for keyDate attribute is 'yes" do
168
+ pending "to be implemented"
169
+ end
170
+ it "should know the only valid values for qualifier attribute: approximate, inferred, questionable" do
171
+ pending "to be implemented"
172
+ end
173
+ end
174
+
175
+ context "parsing issuance" do
176
+ it "should know the only valid values are: continuing, monographic, single unit, multipart monograph, serial, integrating resource" do
177
+ pending "to be implemented"
178
+ end
161
179
  end
180
+
181
+ context "parsing publisher" do
182
+ it "should ignore s.n. value (from MARC)" do
183
+ pending "to be implemented"
184
+ end
185
+ it "should leave square brackets alone, except for s.n." do
186
+ pending "to be implemented"
187
+ end
188
+ end
189
+
190
+ context "parsing placeTerm" do
191
+ it "should be able to translate marccountry codes" do
192
+ pending "to be implemented"
193
+ end
194
+ it "should ignore s.l. value (from MARC)" do
195
+ pending "to be implemented"
196
+ end
197
+ it "should be forgiving of square brackets (from MARC), matched or unmatched" do
198
+ pending "to be implemented"
199
+ end
200
+ end
201
+
162
202
 
163
203
  context "basic <originInfo> terminology pieces" do
204
+
205
+ context "WITH namespaces" do
206
+ context "<place> child element" do
207
+ before(:all) do
208
+ @place_term_text = "<mods #{@ns_decl}><originInfo><place><placeTerm type='text'>Iran</placeTerm></place></originInfo></mods>"
209
+ @place_term_plain_mult = "<mods #{@ns_decl}><originInfo>
210
+ <place><placeTerm>France</placeTerm></place>
211
+ <place><placeTerm>Italy</placeTerm></place></originInfo></mods>"
212
+ @place_term_code = "<mods #{@ns_decl}><originInfo><place><placeTerm authority='marccountry' type='code'>fr</placeTerm></place></originInfo></mods>"
213
+ @yuck1 = "<mods #{@ns_decl}><originInfo><place><placeTerm type='text'>[S.l.]</placeTerm></place></originInfo></mods>"
214
+ @yuck2 = "<mods #{@ns_decl}><originInfo><place><placeTerm type='text'>[London</placeTerm></place></originInfo></mods>"
215
+ @yuck3 = "<mods #{@ns_decl}><originInfo><place><placeTerm type='text'>[s.l. : s.n.]</placeTerm></place></originInfo></mods>"
216
+ @yuck4 = "<mods #{@ns_decl}><originInfo><place><placeTerm type='text'>[London]</placeTerm></place></originInfo></mods>"
217
+ end
218
+ context "<placeTerm> child element" do
219
+ it "should get element values" do
220
+ vals = @mods_rec.from_str(@place_term_plain_mult).origin_info.place.placeTerm.map { |e| e.text}
221
+ vals.size.should == 2
222
+ vals.should include("France")
223
+ vals.should include("Italy")
224
+ end
225
+ it "should get authority attribute" do
226
+ @mods_rec.from_str(@place_term_code).origin_info.place.placeTerm.authority.should == ["marccountry"]
227
+ end
228
+ it "should get type(_at) attribute" do
229
+ @mods_rec.from_str(@place_term_code).origin_info.place.placeTerm.type_at.should == ["code"]
230
+ end
231
+ end # placeTerm
232
+ end # place
164
233
 
165
- context "<place> child element" do
166
- before(:all) do
167
- @place_term_text = '<mods><originInfo><place><placeTerm type="text">Iran</placeTerm></place></originInfo></mods>'
168
- @place_term_plain_mult = '<mods><originInfo>
169
- <place><placeTerm>France</placeTerm></place>
170
- <place><placeTerm>Italy</placeTerm></place></originInfo></mods>'
171
- @place_term_code = '<mods><originInfo><place><placeTerm authority="marccountry" type="code">fr</placeTerm></place></originInfo></mods>'
172
- @yuck1 = '<mods><originInfo><place><placeTerm type="text">[S.l.]</placeTerm></place></originInfo></mods>'
173
- @yuck2 = '<mods><originInfo><place><placeTerm type="text">[London</placeTerm></place></originInfo></mods>'
174
- @yuck3 = '<mods><originInfo><place><placeTerm type="text">[s.l. : s.n.]</placeTerm></place></originInfo></mods>'
175
- @yuck4 = '<mods><originInfo><place><placeTerm type="text">[London]</placeTerm></place></originInfo></mods>'
176
- end
177
- context "<placeTerm> child element" do
234
+ context "<publisher> child element" do
235
+ before(:all) do
236
+ @ex = "<mods #{@ns_decl}><originInfo><publisher>Olney</publisher></origin_info></mods>"
237
+ @yuck1 = "<mods #{@ns_decl}><originInfo><publisher>[s.n.]</publisher></originInfo></mods>"
238
+ @yuck2 = "<mods #{@ns_decl}><originInfo><publisher>Printed for William Innys and Joseph Richardson ... [et al.]</publisher></originInfo></mods>"
239
+ end
178
240
  it "should get element values" do
179
- vals = @mods_rec.from_str(@place_term_plain_mult).origin_info.place.placeTerm.map { |e| e.text}
180
- vals.size.should == 2
181
- vals.should include("France")
182
- vals.should include("Italy")
241
+ vals = @mods_rec.from_str("<mods #{@ns_decl}><originInfo><publisher>Olney</publisher></origin_info></mods>").origin_info.publisher
242
+ vals.map { |n| n.text }.should == ["Olney"]
243
+ end
244
+ end
245
+
246
+ context "<xxxDate> child elements" do
247
+ it "should recognize each element" do
248
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
249
+ @mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname}>date</#{elname}></originInfo></mods>")
250
+ @mods_rec.origin_info.send(elname.to_sym).map { |n| n.text }.should == ["date"]
251
+ }
183
252
  end
184
- it "should get authority attribute" do
185
- @mods_rec.from_str(@place_term_code).origin_info.place.placeTerm.authority.should == ["marccountry"]
253
+ it "should recognize encoding attribute on each element" do
254
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
255
+ @mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname} encoding='foo'>date</#{elname}></originInfo></mods>")
256
+ @mods_rec.origin_info.send(elname.to_sym).encoding.should == ["foo"]
257
+ }
186
258
  end
187
- it "should get type(_at) attribute" do
188
- @mods_rec.from_str(@place_term_code).origin_info.place.placeTerm.type_at.should == ["code"]
259
+ it "should recognize keyDate attribute" do
260
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
261
+ @mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname} keyDate='foo'>date</#{elname}></originInfo></mods>")
262
+ @mods_rec.origin_info.send(elname.to_sym).keyDate.should == ["foo"]
263
+ }
189
264
  end
190
- it "should be able to translate marccountry codes" do
191
- pending "to be implemented"
265
+ it "should recognize point attribute" do
266
+ # NOTE: values allowed are 'start' and 'end'
267
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
268
+ @mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname} point='foo'>date</#{elname}></originInfo></mods>")
269
+ @mods_rec.origin_info.send(elname.to_sym).point.should == ["foo"]
270
+ }
192
271
  end
193
- it "should ignore s.l. value (from MARC)" do
194
- pending "to be implemented"
272
+ it "should recognize qualifier attribute" do
273
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
274
+ @mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname} qualifier='foo'>date</#{elname}></originInfo></mods>")
275
+ @mods_rec.origin_info.send(elname.to_sym).qualifier.should == ["foo"]
276
+ }
195
277
  end
196
- it "should be forgiving of square brackets (from MARC), matched or unmatched" do
197
- pending "to be implemented"
278
+ it "should recognize type attribute only on dateOther" do
279
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
280
+ @mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname} type='foo'>date</#{elname}></originInfo></mods>")
281
+ if elname == 'dateOther'
282
+ @mods_rec.origin_info.send(elname.to_sym).type_at.should == ["foo"]
283
+ else
284
+ expect { @mods_rec.origin_info.send(elname.to_sym).type_at}.to raise_exception(NoMethodError, /type_at/)
285
+ end
286
+ }
198
287
  end
199
- end # placeTerm
200
- end # place
201
-
202
- context "<publisher> child element" do
203
- before(:all) do
204
- @ex = '<mods><originInfo><publisher>Olney</publisher></origin_info></mods>'
205
- @yuck1 = '<mods><originInfo><publisher>[s.n.]</publisher></originInfo></mods>'
206
- @yuck2 = '<mods><originInfo><publisher>Printed for William Innys and Joseph Richardson ... [et al.]</publisher></originInfo></mods>'
207
- end
208
- it "should get element values" do
209
- vals = @mods_rec.from_str('<mods><originInfo><publisher>Olney</publisher></origin_info></mods>').origin_info.publisher
210
- vals.map { |n| n.text }.should == ["Olney"]
211
- end
212
- it "should ignore s.n. value (from MARC)" do
213
- pending "to be implemented"
214
- end
215
- it "should leave square brackets alone, except for s.n." do
216
- pending "to be implemented"
217
- end
218
- end
219
-
220
- context "<xxxDate> child elements" do
221
- it "should recognize each element" do
222
- Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
223
- @mods_rec.from_str("<mods><originInfo><#{elname}>date</#{elname}></originInfo></mods>")
224
- @mods_rec.origin_info.send(elname.to_sym).map { |n| n.text }.should == ["date"]
225
- }
226
- end
227
- it "should recognize encoding attribute on each element" do
228
- Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
229
- @mods_rec.from_str("<mods><originInfo><#{elname} encoding='foo'>date</#{elname}></originInfo></mods>")
230
- @mods_rec.origin_info.send(elname.to_sym).encoding.should == ["foo"]
231
- }
232
- end
233
- it "should recognize keyDate attribute" do
234
- Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
235
- @mods_rec.from_str("<mods><originInfo><#{elname} keyDate='foo'>date</#{elname}></originInfo></mods>")
236
- @mods_rec.origin_info.send(elname.to_sym).keyDate.should == ["foo"]
237
- }
288
+ end # <xxxDate> child elements
289
+
290
+ it "<edition> child element" do
291
+ xml = "<mods #{@ns_decl}><originInfo><edition>7th ed.</edition></originInfo></mods>"
292
+ @mods_rec.from_str(xml).origin_info.edition.map { |n| n.text }.should == ['7th ed.']
238
293
  end
239
- it "should recognize point attribute" do
240
- # NOTE: values allowed are 'start' and 'end'
241
- Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
242
- @mods_rec.from_str("<mods><originInfo><#{elname} point='foo'>date</#{elname}></originInfo></mods>")
243
- @mods_rec.origin_info.send(elname.to_sym).point.should == ["foo"]
244
- }
294
+
295
+ context "<issuance> child element" do
296
+ before(:all) do
297
+ @ex = "<mods #{@ns_decl}><originInfo><issuance>monographic</issuance></originInfo></mods>"
298
+ end
299
+ it "should get element value" do
300
+ @mods_rec.from_str(@ex).origin_info.issuance.map { |n| n.text }.should == ['monographic']
301
+ end
245
302
  end
246
- it "should recognize qualifier attribute" do
247
- Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
248
- @mods_rec.from_str("<mods><originInfo><#{elname} qualifier='foo'>date</#{elname}></originInfo></mods>")
249
- @mods_rec.origin_info.send(elname.to_sym).qualifier.should == ["foo"]
250
- }
303
+
304
+ context "<frequency> child element" do
305
+ before(:all) do
306
+ xml = "<mods #{@ns_decl}><originInfo><frequency authority='marcfrequency'>Annual</frequency></originInfo></mods>"
307
+ @origin_info = @mods_rec.from_str(xml).origin_info
308
+ end
309
+ it "should get element value" do
310
+ @origin_info.frequency.map { |n| n.text }.should == ["Annual"]
311
+ end
312
+ it "should recognize the authority attribute" do
313
+ @origin_info.frequency.authority.should == ["marcfrequency"]
314
+ end
251
315
  end
252
- it "should recognize type attribute only on dateOther" do
253
- Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
254
- @mods_rec.from_str("<mods><originInfo><#{elname} type='foo'>date</#{elname}></originInfo></mods>")
255
- if elname == 'dateOther'
256
- @mods_rec.origin_info.send(elname.to_sym).type_at.should == ["foo"]
257
- else
258
- expect { @mods_rec.origin_info.send(elname.to_sym).type_at}.to raise_exception(NoMethodError, /type_at/)
316
+ end # WITH namspaces
317
+
318
+ context "WITHOUT namespaces" do
319
+ context "<place> child element" do
320
+ before(:all) do
321
+ @place_term_text = "<mods><originInfo><place><placeTerm type='text'>Iran</placeTerm></place></originInfo></mods>"
322
+ @place_term_plain_mult = "<mods><originInfo>
323
+ <place><placeTerm>France</placeTerm></place>
324
+ <place><placeTerm>Italy</placeTerm></place></originInfo></mods>"
325
+ @place_term_code = "<mods><originInfo><place><placeTerm authority='marccountry' type='code'>fr</placeTerm></place></originInfo></mods>"
326
+ @yuck1 = "<mods><originInfo><place><placeTerm type='text'>[S.l.]</placeTerm></place></originInfo></mods>"
327
+ @yuck2 = "<mods><originInfo><place><placeTerm type='text'>[London</placeTerm></place></originInfo></mods>"
328
+ @yuck3 = "<mods><originInfo><place><placeTerm type='text'>[s.l. : s.n.]</placeTerm></place></originInfo></mods>"
329
+ @yuck4 = "<mods><originInfo><place><placeTerm type='text'>[London]</placeTerm></place></originInfo></mods>"
330
+ end
331
+ context "<placeTerm> child element" do
332
+ it "should get element values" do
333
+ vals = @mods_rec.from_str(@place_term_plain_mult, false).origin_info.place.placeTerm.map { |e| e.text}
334
+ vals.size.should == 2
335
+ vals.should include("France")
336
+ vals.should include("Italy")
259
337
  end
260
- }
261
- end
262
- it "should know something about various date encodings: w3cdtf, iso8601, marc, edtf, temper" do
263
- pending "to be implemented"
264
- end
265
- it "should know the only valid values for point attribute are 'start' and 'end'" do
266
- pending "to be implemented"
267
- end
268
- it "should know the only valid value for keyDate attribute is 'yes" do
269
- pending "to be implemented"
270
- end
271
- it "should know the only valid values for qualifier attribute: approximate, inferred, questionable" do
272
- pending "to be implemented"
273
- end
274
- end # <xxxDate> child elements
275
-
276
- it "<edition> child element" do
277
- xml = '<mods><originInfo><edition>7th ed.</edition></originInfo></mods>'
278
- @mods_rec.from_str(xml).origin_info.edition.map { |n| n.text }.should == ['7th ed.']
279
- end
280
-
281
- context "<issuance> child element" do
282
- before(:all) do
283
- @ex = '<mods><originInfo><issuance>monographic</issuance></originInfo></mods>'
284
- end
285
- it "should get element value" do
286
- @mods_rec.from_str(@ex).origin_info.issuance.map { |n| n.text }.should == ['monographic']
287
- end
288
- it "should know the only valid values are: continuing, monographic, single unit, multipart monograph, serial, integrating resource" do
289
- pending "to be implemented"
338
+ it "should get authority attribute" do
339
+ @mods_rec.from_str(@place_term_code, false).origin_info.place.placeTerm.authority.should == ["marccountry"]
340
+ end
341
+ it "should get type(_at) attribute" do
342
+ @mods_rec.from_str(@place_term_code, false).origin_info.place.placeTerm.type_at.should == ["code"]
343
+ end
344
+ end # placeTerm
345
+ end # place
346
+
347
+ context "<publisher> child element" do
348
+ before(:all) do
349
+ @ex = "<mods><originInfo><publisher>Olney</publisher></origin_info></mods>"
350
+ @yuck1 = "<mods><originInfo><publisher>[s.n.]</publisher></originInfo></mods>"
351
+ @yuck2 = "<mods><originInfo><publisher>Printed for William Innys and Joseph Richardson ... [et al.]</publisher></originInfo></mods>"
352
+ end
353
+ it "should get element values" do
354
+ vals = @mods_rec.from_str("<mods><originInfo><publisher>Olney</publisher></origin_info></mods>", false).origin_info.publisher
355
+ vals.map { |n| n.text }.should == ["Olney"]
356
+ end
290
357
  end
291
- end
292
-
293
- context "<frequency> child element" do
294
- before(:all) do
295
- xml = '<mods><originInfo><frequency authority="marcfrequency">Annual</frequency></originInfo></mods>'
296
- @origin_info = @mods_rec.from_str(xml).origin_info
358
+
359
+ context "<xxxDate> child elements" do
360
+ it "should recognize each element" do
361
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
362
+ @mods_rec.from_str("<mods><originInfo><#{elname}>date</#{elname}></originInfo></mods>", false)
363
+ @mods_rec.origin_info.send(elname.to_sym).map { |n| n.text }.should == ["date"]
364
+ }
365
+ end
366
+ it "should recognize encoding attribute on each element" do
367
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
368
+ @mods_rec.from_str("<mods><originInfo><#{elname} encoding='foo'>date</#{elname}></originInfo></mods>", false)
369
+ @mods_rec.origin_info.send(elname.to_sym).encoding.should == ["foo"]
370
+ }
371
+ end
372
+ it "should recognize keyDate attribute" do
373
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
374
+ @mods_rec.from_str("<mods><originInfo><#{elname} keyDate='foo'>date</#{elname}></originInfo></mods>", false)
375
+ @mods_rec.origin_info.send(elname.to_sym).keyDate.should == ["foo"]
376
+ }
377
+ end
378
+ it "should recognize point attribute" do
379
+ # NOTE: values allowed are 'start' and 'end'
380
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
381
+ @mods_rec.from_str("<mods><originInfo><#{elname} point='foo'>date</#{elname}></originInfo></mods>", false)
382
+ @mods_rec.origin_info.send(elname.to_sym).point.should == ["foo"]
383
+ }
384
+ end
385
+ it "should recognize qualifier attribute" do
386
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
387
+ @mods_rec.from_str("<mods><originInfo><#{elname} qualifier='foo'>date</#{elname}></originInfo></mods>", false)
388
+ @mods_rec.origin_info.send(elname.to_sym).qualifier.should == ["foo"]
389
+ }
390
+ end
391
+ it "should recognize type attribute only on dateOther" do
392
+ Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
393
+ @mods_rec.from_str("<mods><originInfo><#{elname} type='foo'>date</#{elname}></originInfo></mods>", false)
394
+ if elname == 'dateOther'
395
+ @mods_rec.origin_info.send(elname.to_sym).type_at.should == ["foo"]
396
+ else
397
+ expect { @mods_rec.origin_info.send(elname.to_sym).type_at}.to raise_exception(NoMethodError, /type_at/)
398
+ end
399
+ }
400
+ end
401
+ end # <xxxDate> child elements
402
+
403
+ it "<edition> child element" do
404
+ xml = "<mods><originInfo><edition>7th ed.</edition></originInfo></mods>"
405
+ @mods_rec.from_str(xml, false).origin_info.edition.map { |n| n.text }.should == ['7th ed.']
297
406
  end
298
- it "should get element value" do
299
- @origin_info.frequency.map { |n| n.text }.should == ["Annual"]
407
+
408
+ context "<issuance> child element" do
409
+ before(:all) do
410
+ @ex = "<mods><originInfo><issuance>monographic</issuance></originInfo></mods>"
411
+ end
412
+ it "should get element value" do
413
+ @mods_rec.from_str(@ex, false).origin_info.issuance.map { |n| n.text }.should == ['monographic']
414
+ end
300
415
  end
301
- it "should recognize the authority attribute" do
302
- @origin_info.frequency.authority.should == ["marcfrequency"]
416
+
417
+ context "<frequency> child element" do
418
+ before(:all) do
419
+ xml = "<mods><originInfo><frequency authority='marcfrequency'>Annual</frequency></originInfo></mods>"
420
+ @origin_info = @mods_rec.from_str(xml, false).origin_info
421
+ end
422
+ it "should get element value" do
423
+ @origin_info.frequency.map { |n| n.text }.should == ["Annual"]
424
+ end
425
+ it "should recognize the authority attribute" do
426
+ @origin_info.frequency.authority.should == ["marcfrequency"]
427
+ end
303
428
  end
304
- end
305
- end # basic terminology
429
+ end # WITHOUT namspaces
306
430
 
431
+ end # basic terminology
307
432
 
308
433
  end