mods 0.0.14 → 0.0.15
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.
- data/README.rdoc +1 -1
- data/lib/mods/nom_terminology.rb +445 -8
- data/lib/mods/reader.rb +3 -3
- data/lib/mods/record.rb +6 -7
- data/lib/mods/version.rb +1 -1
- data/spec/language_spec.rb +100 -73
- data/spec/location_spec.rb +269 -119
- data/spec/name_spec.rb +223 -197
- data/spec/origin_info_spec.rb +315 -190
- data/spec/part_spec.rb +411 -176
- data/spec/physical_description_spec.rb +120 -55
- data/spec/reader_spec.rb +76 -61
- data/spec/record_info_spec.rb +448 -206
- data/spec/record_spec.rb +192 -7
- data/spec/related_item_spec.rb +275 -124
- data/spec/subject_spec.rb +666 -339
- data/spec/title_spec.rb +204 -89
- data/spec/top_level_elmnts_simple_spec.rb +324 -145
- metadata +79 -98
data/spec/name_spec.rb
CHANGED
@@ -4,133 +4,127 @@ describe "Mods <name> Element" do
|
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
@mods_rec = Mods::Record.new
|
7
|
+
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
|
8
|
+
|
7
9
|
@corp_name = 'ABC corp'
|
8
10
|
@mods_w_corp_name = "<mods><name type='corporate'><namePart>#{@corp_name}</namePart></name></mods>"
|
11
|
+
@mods_w_corp_name_ns = "<mods #{@ns_decl}><name type='corporate'><namePart>#{@corp_name}</namePart></name></mods>"
|
9
12
|
@mods_w_corp_name_role = "<mods><name type='corporate'><namePart>#{@corp_name}</namePart>
|
10
13
|
<role><roleTerm type='text'>lithographer</roleTerm></role></name></mods>"
|
14
|
+
@mods_w_corp_name_role_ns = "<mods #{@ns_decl}><name type='corporate'><namePart>#{@corp_name}</namePart>
|
15
|
+
<role><roleTerm type='text'>lithographer</roleTerm></role></name></mods>"
|
11
16
|
@pers_name = 'Crusty'
|
12
17
|
@mods_w_pers_name = "<mods><name type='personal'><namePart>#{@pers_name}</namePart></name></mods>"
|
18
|
+
@mods_w_pers_name_ns = "<mods #{@ns_decl}><name type='personal'><namePart>#{@pers_name}</namePart></name></mods>"
|
13
19
|
@mods_w_both = "<mods>
|
14
20
|
<name type='corporate'><namePart>#{@corp_name}</namePart></name>
|
15
21
|
<name type='personal'><namePart>#{@pers_name}</namePart></name></mods>"
|
22
|
+
@mods_w_both_ns = "<mods #{@ns_decl}>
|
23
|
+
<name type='corporate'><namePart>#{@corp_name}</namePart></name>
|
24
|
+
<name type='personal'><namePart>#{@pers_name}</namePart></name></mods>"
|
16
25
|
@pers_role = 'creator'
|
17
26
|
@mods_w_pers_name_role = "<mods><name type='personal'><namePart>#{@pers_name}</namePart>
|
18
27
|
<role><roleTerm authority='marcrelator' type='text'>#{@pers_role}</roleTerm><role></name></mods>"
|
19
|
-
@
|
20
|
-
|
28
|
+
@mods_w_pers_name_role_ns = "<mods #{@ns_decl}><name type='personal'><namePart>#{@pers_name}</namePart>
|
29
|
+
<role><roleTerm authority='marcrelator' type='text'>#{@pers_role}</roleTerm><role></name></mods>"
|
30
|
+
@mods_w_pers_name_role_code = "<mods><name type='personal'><namePart type='given'>John</namePart>
|
31
|
+
<namePart type='family'>Huston</namePart>
|
21
32
|
<role>
|
22
|
-
<roleTerm type=
|
33
|
+
<roleTerm type='code' authority='marcrelator'>drt</roleTerm>
|
23
34
|
</role>
|
24
|
-
</name></mods>
|
35
|
+
</name></mods>"
|
36
|
+
@mods_w_pers_name_role_code_ns = "<mods #{@ns_decl}><name type='personal'><namePart type='given'>John</namePart>
|
37
|
+
<namePart type='family'>Huston</namePart>
|
38
|
+
<role>
|
39
|
+
<roleTerm type='code' authority='marcrelator'>drt</roleTerm>
|
40
|
+
</role>
|
41
|
+
</name></mods>"
|
25
42
|
end
|
26
43
|
|
27
44
|
context "personal name" do
|
28
45
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
it "should include name elements with type attr = personal" do
|
40
|
-
@mods_rec.from_str(@mods_w_pers_name)
|
41
|
-
@mods_rec.personal_name.namePart.text.should == @pers_name
|
42
|
-
@mods_rec.from_str(@mods_w_both).personal_name.namePart.text.should == @pers_name
|
43
|
-
end
|
44
|
-
it "should not include name elements with type attr != personal" do
|
45
|
-
@mods_rec.from_str(@mods_w_corp_name)
|
46
|
-
@mods_rec.personal_name.namePart.text.should == ""
|
47
|
-
@mods_rec.from_str(@mods_w_both).personal_name.namePart.text.should_not match(@corp_name)
|
48
|
-
end
|
49
|
-
|
50
|
-
context "roles" do
|
51
|
-
it "should be possible to access a personal_name role easily" do
|
52
|
-
@mods_rec.from_str(@mods_w_pers_name_role)
|
53
|
-
@mods_rec.personal_name.role.text.should include(@pers_role)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should get role type" do
|
57
|
-
@mods_rec.from_str(@mods_w_pers_name_role)
|
58
|
-
@mods_rec.personal_name.role.type_at.should == ["text"]
|
59
|
-
@mods_rec.from_str(@mods_w_pers_name_role_code)
|
60
|
-
@mods_rec.personal_name.role.type_at.should == ["code"]
|
46
|
+
context "WITH namespaces" do
|
47
|
+
it "should recognize child elements" do
|
48
|
+
Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role"}.each { |e|
|
49
|
+
@mods_rec.from_str("<mods #{@ns_decl}><name type='personal'><#{e}>oofda</#{e}></name></mods>")
|
50
|
+
if e == 'description'
|
51
|
+
@mods_rec.personal_name.description_el.text.should == 'oofda'
|
52
|
+
else
|
53
|
+
@mods_rec.personal_name.send(e).text.should == 'oofda'
|
54
|
+
end
|
55
|
+
}
|
61
56
|
end
|
62
|
-
|
63
|
-
|
64
|
-
@mods_rec.
|
65
|
-
@mods_rec.personal_name.
|
57
|
+
it "should include name elements with type attr = personal" do
|
58
|
+
@mods_rec.from_str(@mods_w_pers_name_ns)
|
59
|
+
@mods_rec.personal_name.namePart.text.should == @pers_name
|
60
|
+
@mods_rec.from_str(@mods_w_both_ns).personal_name.namePart.text.should == @pers_name
|
66
61
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
before(:all) do
|
72
|
-
@given_family = '<mods><name type="personal"><namePart type="given">Jorge Luis</namePart>
|
73
|
-
<namePart type="family">Borges</namePart></name></mods>'
|
74
|
-
@given_family_date = '<mods><name type="personal"><namePart type="given">Zaphod</namePart>
|
75
|
-
<namePart type="family">Beeblebrox</namePart>
|
76
|
-
<namePart type="date">1912-2362</namePart></name></mods>'
|
77
|
-
@all_name_parts = '<mods><name type="personal"><namePart type="given">Given</namePart>
|
78
|
-
<namePart type="family">Family</namePart>
|
79
|
-
<namePart type="termsOfAddress">Mr.</namePart>
|
80
|
-
<namePart type="date">date</namePart></name></mods>'
|
81
|
-
@family_only = '<mods><name type="personal"><namePart type="family">Family</namePart></name></mods>'
|
82
|
-
@given_only = '<mods><name type="personal"><namePart type="given">Given</namePart></name></mods>'
|
62
|
+
it "should not include name elements with type attr != personal" do
|
63
|
+
@mods_rec.from_str(@mods_w_corp_name_ns)
|
64
|
+
@mods_rec.personal_name.namePart.text.should == ""
|
65
|
+
@mods_rec.from_str(@mods_w_both_ns).personal_name.namePart.text.should_not match(@corp_name)
|
83
66
|
end
|
84
67
|
|
85
|
-
|
86
|
-
|
87
|
-
|
68
|
+
context "roles" do
|
69
|
+
it "should be possible to access a personal_name role easily" do
|
70
|
+
@mods_rec.from_str(@mods_w_pers_name_role_ns)
|
71
|
+
@mods_rec.personal_name.role.text.should include(@pers_role)
|
72
|
+
end
|
73
|
+
it "should get role type" do
|
74
|
+
@mods_rec.from_str(@mods_w_pers_name_role_ns)
|
75
|
+
@mods_rec.personal_name.role.type_at.should == ["text"]
|
76
|
+
@mods_rec.from_str(@mods_w_pers_name_role_code_ns)
|
77
|
+
@mods_rec.personal_name.role.type_at.should == ["code"]
|
78
|
+
end
|
79
|
+
it "should get role authority" do
|
80
|
+
@mods_rec.from_str(@mods_w_pers_name_role_ns)
|
81
|
+
@mods_rec.personal_name.role.authority.should == ["marcrelator"]
|
82
|
+
end
|
83
|
+
end # roles
|
84
|
+
end # WITH namespaces
|
85
|
+
|
86
|
+
context "WITHOUT namespaces" do
|
87
|
+
it "should recognize child elements" do
|
88
|
+
Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role"}.each { |e|
|
89
|
+
@mods_rec.from_str("<mods><name type='personal'><#{e}>oofda</#{e}></name></mods>", false)
|
90
|
+
if e == 'description'
|
91
|
+
@mods_rec.personal_name.description_el.text.should == 'oofda'
|
92
|
+
else
|
93
|
+
@mods_rec.personal_name.send(e).text.should == 'oofda'
|
94
|
+
end
|
95
|
+
}
|
88
96
|
end
|
89
|
-
|
90
|
-
|
91
|
-
@mods_rec.
|
92
|
-
@mods_rec.
|
97
|
+
it "should include name elements with type attr = personal" do
|
98
|
+
@mods_rec.from_str(@mods_w_pers_name, false)
|
99
|
+
@mods_rec.personal_name.namePart.text.should == @pers_name
|
100
|
+
@mods_rec.from_str(@mods_w_both, false).personal_name.namePart.text.should == @pers_name
|
93
101
|
end
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
<displayForm>display form</displayForm></name></mods>'
|
99
|
-
@mods_rec.from_str(display_form_and_name_parts)
|
100
|
-
@mods_rec.personal_names.should include("display form")
|
102
|
+
it "should not include name elements with type attr != personal" do
|
103
|
+
@mods_rec.from_str(@mods_w_corp_name, false)
|
104
|
+
@mods_rec.personal_name.namePart.text.should == ""
|
105
|
+
@mods_rec.from_str(@mods_w_both, false).personal_name.namePart.text.should_not match(@corp_name)
|
101
106
|
end
|
102
107
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
it "should not include a comma when there is only a family or given name" do
|
124
|
-
[@family_only, @given_only].each { |mods_str|
|
125
|
-
@mods_rec.from_str(mods_str)
|
126
|
-
@mods_rec.personal_names.first.should_not match(/,/)
|
127
|
-
}
|
128
|
-
end
|
129
|
-
it "should not include terms of address" do
|
130
|
-
@mods_rec.from_str(@all_name_parts)
|
131
|
-
@mods_rec.personal_names.first.should_not match(/Mr./)
|
132
|
-
end
|
133
|
-
end # personal_names convenience method
|
108
|
+
context "roles" do
|
109
|
+
it "should be possible to access a personal_name role easily" do
|
110
|
+
@mods_rec.from_str(@mods_w_pers_name_role, false)
|
111
|
+
@mods_rec.personal_name.role.text.should include(@pers_role)
|
112
|
+
end
|
113
|
+
it "should get role type" do
|
114
|
+
@mods_rec.from_str(@mods_w_pers_name_role, false)
|
115
|
+
@mods_rec.personal_name.role.type_at.should == ["text"]
|
116
|
+
@mods_rec.from_str(@mods_w_pers_name_role_code, false)
|
117
|
+
@mods_rec.personal_name.role.type_at.should == ["code"]
|
118
|
+
end
|
119
|
+
it "should get role authority" do
|
120
|
+
@mods_rec.from_str(@mods_w_pers_name_role, false)
|
121
|
+
@mods_rec.personal_name.role.authority.should == ["marcrelator"]
|
122
|
+
end
|
123
|
+
end # roles
|
124
|
+
end # WITHOUT namespaces
|
125
|
+
|
126
|
+
# note that Mods::Record.personal_names tests are in record_spec
|
127
|
+
|
134
128
|
end # personal name
|
135
129
|
|
136
130
|
context "sort_author" do
|
@@ -139,116 +133,148 @@ describe "Mods <name> Element" do
|
|
139
133
|
end
|
140
134
|
end
|
141
135
|
|
142
|
-
context "corporate name" do
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
<name type="corporate">
|
154
|
-
<namePart>T. Sinclair's, Philadelphia</namePart>
|
155
|
-
<role><roleTerm type="text">lithographer</roleTerm></role>
|
156
|
-
</name>
|
157
|
-
<name type="corporate">
|
158
|
-
<namePart>Potter Collection</namePart>
|
159
|
-
<role><roleTerm type="text">former owner</roleTerm></role>
|
160
|
-
</name></mods>'
|
161
|
-
end
|
162
|
-
|
163
|
-
it "should recognize child elements" do
|
164
|
-
Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role" }.each { |e|
|
165
|
-
@mods_rec.from_str("<mods><name type='corporate'><#{e}>oofda</#{e}></name></mods>")
|
166
|
-
if e == 'description'
|
167
|
-
@mods_rec.corporate_name.description_el.text.should == 'oofda'
|
168
|
-
else
|
169
|
-
@mods_rec.corporate_name.send(e).text.should == 'oofda'
|
170
|
-
end
|
171
|
-
}
|
172
|
-
end
|
173
|
-
it "should include name elements with type attr = corporate" do
|
174
|
-
@mods_rec.from_str(@mods_w_corp_name)
|
175
|
-
@mods_rec.corporate_name.namePart.text.should == @corp_name
|
176
|
-
@mods_rec.from_str(@mods_w_both).corporate_name.namePart.text.should == @corp_name
|
177
|
-
end
|
178
|
-
it "should not include name elements with type attr != corporate" do
|
179
|
-
@mods_rec.from_str(@mods_w_pers_name)
|
180
|
-
@mods_rec.corporate_name.namePart.text.should == ""
|
181
|
-
@mods_rec.from_str(@mods_w_both).corporate_name.namePart.text.should_not match(@pers_name)
|
182
|
-
end
|
183
|
-
|
184
|
-
context "Mods::Record.corporate_names convenience method" do
|
185
|
-
it "should return an Array of Strings" do
|
186
|
-
@mods_rec.from_str(@mods_w_corp_name)
|
187
|
-
@mods_rec.corporate_names.should == [@corp_name]
|
136
|
+
context "corporate name" do
|
137
|
+
context "WITH namespaces" do
|
138
|
+
it "should recognize child elements" do
|
139
|
+
Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role" }.each { |e|
|
140
|
+
@mods_rec.from_str("<mods #{@ns_decl}><name type='corporate'><#{e}>oofda</#{e}></name></mods>")
|
141
|
+
if e == 'description'
|
142
|
+
@mods_rec.corporate_name.description_el.text.should == 'oofda'
|
143
|
+
else
|
144
|
+
@mods_rec.corporate_name.send(e).text.should == 'oofda'
|
145
|
+
end
|
146
|
+
}
|
188
147
|
end
|
189
|
-
|
190
|
-
|
191
|
-
@mods_rec.
|
192
|
-
@mods_rec.
|
148
|
+
it "should include name elements with type attr = corporate" do
|
149
|
+
@mods_rec.from_str(@mods_w_corp_name_ns)
|
150
|
+
@mods_rec.corporate_name.namePart.text.should == @corp_name
|
151
|
+
@mods_rec.from_str(@mods_w_both_ns).corporate_name.namePart.text.should == @corp_name
|
193
152
|
end
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
153
|
+
it "should not include name elements with type attr != corporate" do
|
154
|
+
@mods_rec.from_str(@mods_w_pers_name_ns)
|
155
|
+
@mods_rec.corporate_name.namePart.text.should == ""
|
156
|
+
@mods_rec.from_str(@mods_w_both_ns).corporate_name.namePart.text.should_not match(@pers_name)
|
157
|
+
end
|
158
|
+
end # WITH namespaces
|
159
|
+
context "WITHOUT namespaces" do
|
160
|
+
it "should recognize child elements" do
|
161
|
+
Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role" }.each { |e|
|
162
|
+
@mods_rec.from_str("<mods><name type='corporate'><#{e}>oofda</#{e}></name></mods>", false)
|
163
|
+
if e == 'description'
|
164
|
+
@mods_rec.corporate_name.description_el.text.should == 'oofda'
|
165
|
+
else
|
166
|
+
@mods_rec.corporate_name.send(e).text.should == 'oofda'
|
167
|
+
end
|
168
|
+
}
|
169
|
+
end
|
170
|
+
it "should include name elements with type attr = corporate" do
|
171
|
+
@mods_rec.from_str(@mods_w_corp_name, false)
|
172
|
+
@mods_rec.corporate_name.namePart.text.should == @corp_name
|
173
|
+
@mods_rec.from_str(@mods_w_both, false).corporate_name.namePart.text.should == @corp_name
|
200
174
|
end
|
201
|
-
|
175
|
+
it "should not include name elements with type attr != corporate" do
|
176
|
+
@mods_rec.from_str(@mods_w_pers_name, false)
|
177
|
+
@mods_rec.corporate_name.namePart.text.should == ""
|
178
|
+
@mods_rec.from_str(@mods_w_both, false).corporate_name.namePart.text.should_not match(@pers_name)
|
179
|
+
end
|
180
|
+
end # WITHOUT namespaces
|
181
|
+
|
182
|
+
# note that Mods::Record.corporate_names tests are in record_spec
|
183
|
+
|
202
184
|
end # corporate name
|
203
185
|
|
186
|
+
|
204
187
|
context "(plain) <name> element terminology pieces" do
|
205
|
-
|
206
|
-
it "should recognize child elements" do
|
207
|
-
Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role"}.each { |e|
|
208
|
-
@mods_rec.from_str("<mods><name><#{e}>oofda</#{e}></name></mods>")
|
209
|
-
if e == 'description'
|
210
|
-
@mods_rec.plain_name.description_el.text.should == 'oofda'
|
211
|
-
else
|
212
|
-
@mods_rec.plain_name.send(e).text.should == 'oofda'
|
213
|
-
end
|
214
|
-
}
|
215
|
-
end
|
216
|
-
|
217
|
-
it "should recognize attributes on name node" do
|
218
|
-
Mods::Name::ATTRIBUTES.each { |attrb|
|
219
|
-
@mods_rec.from_str("<mods><name #{attrb}='hello'><displayForm>q</displayForm></name></mods>")
|
220
|
-
if attrb != 'type'
|
221
|
-
@mods_rec.plain_name.send(attrb).should == ['hello']
|
222
|
-
else
|
223
|
-
@mods_rec.plain_name.type_at.should == ['hello']
|
224
|
-
end
|
225
|
-
}
|
226
|
-
end
|
227
188
|
|
228
|
-
context "
|
229
|
-
it "should recognize
|
230
|
-
Mods::Name::
|
231
|
-
@mods_rec.from_str("<mods
|
232
|
-
|
189
|
+
context "WITH namespaces" do
|
190
|
+
it "should recognize child elements" do
|
191
|
+
Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role"}.each { |e|
|
192
|
+
@mods_rec.from_str("<mods #{@ns_decl}><name><#{e}>oofda</#{e}></name></mods>")
|
193
|
+
if e == 'description'
|
194
|
+
@mods_rec.plain_name.description_el.text.should == 'oofda'
|
195
|
+
else
|
196
|
+
@mods_rec.plain_name.send(e).text.should == 'oofda'
|
197
|
+
end
|
233
198
|
}
|
234
199
|
end
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
200
|
+
it "should recognize attributes on name node" do
|
201
|
+
Mods::Name::ATTRIBUTES.each { |attrb|
|
202
|
+
@mods_rec.from_str("<mods #{@ns_decl}><name #{attrb}='hello'><displayForm>q</displayForm></name></mods>")
|
203
|
+
if attrb != 'type'
|
204
|
+
@mods_rec.plain_name.send(attrb).should == ['hello']
|
205
|
+
else
|
206
|
+
@mods_rec.plain_name.type_at.should == ['hello']
|
207
|
+
end
|
208
|
+
}
|
209
|
+
end
|
210
|
+
context "namePart child element" do
|
211
|
+
it "should recognize type attribute on namePart element" do
|
212
|
+
Mods::Name::NAME_PART_TYPES.each { |t|
|
213
|
+
@mods_rec.from_str("<mods #{@ns_decl}><name><namePart type='#{t}'>hi</namePart></name></mods>")
|
214
|
+
@mods_rec.plain_name.namePart.type_at.should == [t]
|
215
|
+
}
|
216
|
+
end
|
243
217
|
end
|
218
|
+
context "role child element" do
|
219
|
+
it "should get role type" do
|
220
|
+
@mods_rec.from_str(@mods_w_pers_name_role_ns)
|
221
|
+
@mods_rec.plain_name.role.type_at.should == ["text"]
|
222
|
+
@mods_rec.from_str(@mods_w_pers_name_role_code_ns)
|
223
|
+
@mods_rec.plain_name.role.type_at.should == ["code"]
|
224
|
+
end
|
225
|
+
it "should get role authority" do
|
226
|
+
@mods_rec.from_str(@mods_w_pers_name_role_ns)
|
227
|
+
@mods_rec.plain_name.role.authority.should == ["marcrelator"]
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
end # context WITH namespaces
|
244
232
|
|
245
|
-
|
246
|
-
|
247
|
-
|
233
|
+
context "WITHOUT namespaces" do
|
234
|
+
it "should recognize child elements" do
|
235
|
+
Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role"}.each { |e|
|
236
|
+
@mods_rec.from_str("<mods><name><#{e}>oofda</#{e}></name></mods>", false)
|
237
|
+
if e == 'description'
|
238
|
+
@mods_rec.plain_name.description_el.text.should == 'oofda'
|
239
|
+
else
|
240
|
+
@mods_rec.plain_name.send(e).text.should == 'oofda'
|
241
|
+
end
|
242
|
+
}
|
248
243
|
end
|
249
|
-
|
244
|
+
it "should recognize attributes on name node" do
|
245
|
+
Mods::Name::ATTRIBUTES.each { |attrb|
|
246
|
+
@mods_rec.from_str("<mods><name #{attrb}='hello'><displayForm>q</displayForm></name></mods>", false)
|
247
|
+
if attrb != 'type'
|
248
|
+
@mods_rec.plain_name.send(attrb).should == ['hello']
|
249
|
+
else
|
250
|
+
@mods_rec.plain_name.type_at.should == ['hello']
|
251
|
+
end
|
252
|
+
}
|
253
|
+
end
|
254
|
+
context "namePart child element" do
|
255
|
+
it "should recognize type attribute on namePart element" do
|
256
|
+
Mods::Name::NAME_PART_TYPES.each { |t|
|
257
|
+
@mods_rec.from_str("<mods><name><namePart type='#{t}'>hi</namePart></name></mods>", false)
|
258
|
+
@mods_rec.plain_name.namePart.type_at.should == [t]
|
259
|
+
}
|
260
|
+
end
|
261
|
+
end
|
262
|
+
context "role child element" do
|
263
|
+
it "should get role type" do
|
264
|
+
@mods_rec.from_str(@mods_w_pers_name_role, false)
|
265
|
+
@mods_rec.plain_name.role.type_at.should == ["text"]
|
266
|
+
@mods_rec.from_str(@mods_w_pers_name_role_code, false)
|
267
|
+
@mods_rec.plain_name.role.type_at.should == ["code"]
|
268
|
+
end
|
269
|
+
it "should get role authority" do
|
270
|
+
@mods_rec.from_str(@mods_w_pers_name_role, false)
|
271
|
+
@mods_rec.plain_name.role.authority.should == ["marcrelator"]
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end # context WITHOUT namespaces
|
250
275
|
|
251
276
|
end # plain name
|
277
|
+
|
252
278
|
|
253
279
|
it "should be able to translate the marc relator code into text" do
|
254
280
|
MARC_RELATOR['drt'].should == "Director"
|