stanford-mods 1.1.5 → 1.2.0

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/spec/name_spec.rb CHANGED
@@ -1,242 +1,421 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "name/author concepts" do
4
- before(:all) do
5
- @smods_rec = Stanford::Mods::Record.new
6
- @ns_decl = "xmlns='#{Mods::MODS_NS}'"
7
- end
4
+ let(:smods_rec) { Stanford::Mods::Record.new }
5
+ let(:mods_start) { "<mods xmlns=\"#{Mods::MODS_NS}\">" }
6
+ let(:mods_end) { "</mods>" }
7
+
8
8
  context "main_author_w_date" do
9
- before(:all) do
10
- @mods_start = "<mods #{@ns_decl}>"
11
- @mods_end = "</mods>"
12
- @plain_no_role = "<name><namePart>plain_no_role</namePart></name>"
13
- @plain_creator_code = "<name>
14
- <namePart>plain_creator_code</namePart>
15
- <role><roleTerm type='code' authority='marcrelator'>cre</roleTerm></role>
16
- </name>"
17
- @plain_creator_text = "<name>
18
- <namePart>plain_creator_text</namePart>
19
- <role><roleTerm type='text' authority='marcrelator'>Creator</roleTerm></role>
20
- </name>"
21
- @plain_creator_non_mr = "<name>
22
- <namePart>plain_creator_non_mr</namePart>
23
- <role><roleTerm type='text'>Creator</roleTerm></role>
24
- </name>"
25
- @plain_author_code = "<name>
26
- <namePart>plain_author_code</namePart>
27
- <role><roleTerm type='code' authority='marcrelator'>aut</roleTerm></role>
28
- </name>"
29
- @plain_author_text = "<name>
30
- <namePart>plain_author_text</namePart>
31
- <role><roleTerm type='text' authority='marcrelator'>Author</roleTerm></role>
32
- </name>"
33
- @plain_author_non_mr = "<name>
34
- <namePart>plain_author_non_mr</namePart>
35
- <role><roleTerm type='text'>Author</roleTerm></role>
36
- </name>"
37
- @plain_other_role_mr = "<name>
38
- <namePart>plain_other_role_mr</namePart>
39
- <role><roleTerm type='text' authority='marcrelator'>Actor</roleTerm></role>
40
- </name>"
9
+ let(:plain_no_role) { "<name><namePart>plain_no_role</namePart></name>" }
10
+ let(:plain_creator_code) { "<name>
11
+ <namePart>plain_creator_code</namePart>
12
+ <role><roleTerm type='code' authority='marcrelator'>cre</roleTerm></role>
13
+ </name>" }
14
+ let(:plain_creator_text) { "<name>
15
+ <namePart>plain_creator_text</namePart>
16
+ <role><roleTerm type='text' authority='marcrelator'>Creator</roleTerm></role>
17
+ </name>" }
18
+ let(:plain_creator_non_mr) { "<name>
19
+ <namePart>plain_creator_non_mr</namePart>
20
+ <role><roleTerm type='text'>Creator</roleTerm></role>
21
+ </name>" }
22
+ let(:plain_author_code) { "<name>
23
+ <namePart>plain_author_code</namePart>
24
+ <role><roleTerm type='code' authority='marcrelator'>aut</roleTerm></role>
25
+ </name>" }
26
+ let(:plain_author_text) { "<name>
27
+ <namePart>plain_author_text</namePart>
28
+ <role><roleTerm type='text' authority='marcrelator'>Author</roleTerm></role>
29
+ </name>" }
30
+ let(:plain_author_non_mr) { "<name>
31
+ <namePart>plain_author_non_mr</namePart>
32
+ <role><roleTerm type='text'>Author</roleTerm></role>
33
+ </name>" }
34
+ let(:plain_other_role_mr) { "<name>
35
+ <namePart>plain_other_role_mr</namePart>
36
+ <role><roleTerm type='text' authority='marcrelator'>Actor</roleTerm></role>
37
+ </name>" }
41
38
 
42
- @personal_no_role = "<name><namePart type='personal'>personal_no_role</namePart></name>"
43
- @personal_creator_code = "<name>
44
- <namePart type='personal'>personal_creator_code</namePart>
45
- <role><roleTerm type='code' authority='marcrelator'>cre</roleTerm></role>
46
- </name>"
47
- @personal_author_text = "<name>
48
- <namePart type='personal'>personal_author_text</namePart>
49
- <role><roleTerm type='text' authority='marcrelator'>Author</roleTerm></role>
50
- </name>"
51
- @personal_other_role = "<name>
39
+ let(:personal_no_role) { "<name><namePart type='personal'>personal_no_role</namePart></name>" }
40
+ let(:personal_creator_code) { "<name>
41
+ <namePart type='personal'>personal_creator_code</namePart>
42
+ <role><roleTerm type='code' authority='marcrelator'>cre</roleTerm></role>
43
+ </name>" }
44
+ let(:personal_author_text) { "<name>
52
45
  <namePart type='personal'>personal_author_text</namePart>
53
- <role><roleTerm type='text' authority='marcrelator'>Auctioneer</roleTerm></role>
54
- </name>"
55
- @corp_no_role = "<name><namePart type='corporate'>corp_no_role</namePart></name>"
56
- @corp_author_code = "<name>
57
- <namePart type='corporate'>corp_author_code</namePart>
58
- <role><roleTerm type='code' authority='marcrelator'>aut</roleTerm></role>
59
- </name>"
60
- @corp_creator_text = "<name>
61
- <namePart type='corporate'>corp_creator_text</namePart>
62
- <role><roleTerm type='text' authority='marcrelator'>Creator</roleTerm></role>
63
- </name>"
64
- @other_no_role = "<name><namePart type='conference'>conference_no_role</namePart></name>"
65
- end
46
+ <role><roleTerm type='text' authority='marcrelator'>Author</roleTerm></role>
47
+ </name>" }
48
+ let(:personal_other_role) { "<name>
49
+ <namePart type='personal'>personal_author_text</namePart>
50
+ <role><roleTerm type='text' authority='marcrelator'>Auctioneer</roleTerm></role>
51
+ </name>" }
52
+ let(:corp_no_role) { "<name><namePart type='corporate'>corp_no_role</namePart></name>" }
53
+ let(:corp_author_code) { "<name>
54
+ <namePart type='corporate'>corp_author_code</namePart>
55
+ <role><roleTerm type='code' authority='marcrelator'>aut</roleTerm></role>
56
+ </name>" }
57
+ let(:corp_creator_text) { "<name>
58
+ <namePart type='corporate'>corp_creator_text</namePart>
59
+ <role><roleTerm type='text' authority='marcrelator'>Creator</roleTerm></role>
60
+ </name>" }
61
+ let(:other_no_role) { "<name><namePart type='conference'>conference_no_role</namePart></name>" }
66
62
  context "marcrelator role Creator" do
67
- it "should find role with roleTerm type text" do
68
- @smods_rec.from_str(@mods_start + @plain_creator_text + @mods_end)
69
- expect(@smods_rec.main_author_w_date).to eq('plain_creator_text')
63
+ it "finds role with roleTerm type text" do
64
+ smods_rec.from_str(mods_start + plain_creator_text + mods_end)
65
+ expect(smods_rec.main_author_w_date).to eq('plain_creator_text')
70
66
  end
71
- it "should find role with roleTerm type code" do
72
- @smods_rec.from_str(@mods_start + @plain_creator_code + @mods_end)
73
- expect(@smods_rec.main_author_w_date).to eq('plain_creator_code')
67
+ it "finds role with roleTerm type code" do
68
+ smods_rec.from_str(mods_start + plain_creator_code + mods_end)
69
+ expect(smods_rec.main_author_w_date).to eq('plain_creator_code')
74
70
  end
75
- it "should skip names when role isn't marcrelator authority" do
76
- @smods_rec.from_str(@mods_start + @plain_creator_non_mr + @mods_end)
77
- expect(@smods_rec.main_author_w_date).to be_nil
71
+ it "skips names when role isn't marcrelator authority" do
72
+ smods_rec.from_str(mods_start + plain_creator_non_mr + mods_end)
73
+ expect(smods_rec.main_author_w_date).to be_nil
78
74
  end
79
- it "should skip names without roles in favor of marcrelator role of 'Creator'" do
80
- @smods_rec.from_str(@mods_start + @personal_no_role + @plain_creator_text + @other_no_role + @mods_end)
81
- expect(@smods_rec.main_author_w_date).to eq('plain_creator_text')
82
- @smods_rec.from_str(@mods_start + @corp_no_role + @plain_creator_code + @mods_end)
83
- expect(@smods_rec.main_author_w_date).to eq('plain_creator_code')
75
+ it "skips names without roles in favor of marcrelator role of 'Creator'" do
76
+ smods_rec.from_str(mods_start + personal_no_role + plain_creator_text + other_no_role + mods_end)
77
+ expect(smods_rec.main_author_w_date).to eq('plain_creator_text')
78
+ smods_rec.from_str(mods_start + corp_no_role + plain_creator_code + mods_end)
79
+ expect(smods_rec.main_author_w_date).to eq('plain_creator_code')
84
80
  end
85
- it "shouldn't care about name type" do
86
- @smods_rec.from_str(@mods_start + @personal_creator_code + @corp_creator_text + @mods_end)
87
- expect(@smods_rec.main_author_w_date).to eq('personal_creator_code')
88
- @smods_rec.from_str(@mods_start + @personal_no_role + @corp_creator_text + @mods_end)
89
- expect(@smods_rec.main_author_w_date).to eq('corp_creator_text')
81
+ it "does not care about name type" do
82
+ smods_rec.from_str(mods_start + personal_creator_code + corp_creator_text + mods_end)
83
+ expect(smods_rec.main_author_w_date).to eq('personal_creator_code')
84
+ smods_rec.from_str(mods_start + personal_no_role + corp_creator_text + mods_end)
85
+ expect(smods_rec.main_author_w_date).to eq('corp_creator_text')
90
86
  end
91
- end
87
+ end # marcrelator role Creator
92
88
 
93
89
  context "marcrelator role Author" do
94
- it "should find role with roleTerm type text" do
95
- @smods_rec.from_str(@mods_start + @plain_author_text + @mods_end)
96
- expect(@smods_rec.main_author_w_date).to eq('plain_author_text')
90
+ it "finds role with roleTerm type text" do
91
+ smods_rec.from_str(mods_start + plain_author_text + mods_end)
92
+ expect(smods_rec.main_author_w_date).to eq('plain_author_text')
97
93
  end
98
- it "should find role with roleTerm type code" do
99
- @smods_rec.from_str(@mods_start + @plain_author_code + @mods_end)
100
- expect(@smods_rec.main_author_w_date).to eq('plain_author_code')
94
+ it "finds role with roleTerm type code" do
95
+ smods_rec.from_str(mods_start + plain_author_code + mods_end)
96
+ expect(smods_rec.main_author_w_date).to eq('plain_author_code')
101
97
  end
102
- it "should skip names when role isn't marcrelator authority" do
103
- @smods_rec.from_str(@mods_start + @plain_author_non_mr + @mods_end)
104
- expect(@smods_rec.main_author_w_date).to be_nil
98
+ it "skips names when role isn't marcrelator authority" do
99
+ smods_rec.from_str(mods_start + plain_author_non_mr + mods_end)
100
+ expect(smods_rec.main_author_w_date).to be_nil
105
101
  end
106
- it "should skip names without roles in favor of marcrelator role of 'Author'" do
107
- @smods_rec.from_str(@mods_start + @personal_no_role + @plain_author_text + @other_no_role + @mods_end)
108
- expect(@smods_rec.main_author_w_date).to eq('plain_author_text')
109
- @smods_rec.from_str(@mods_start + @corp_no_role + @personal_no_role + @plain_author_code + @mods_end)
110
- expect(@smods_rec.main_author_w_date).to eq('plain_author_code')
102
+ it "skips names without roles in favor of marcrelator role of 'Author'" do
103
+ smods_rec.from_str(mods_start + personal_no_role + plain_author_text + other_no_role + mods_end)
104
+ expect(smods_rec.main_author_w_date).to eq('plain_author_text')
105
+ smods_rec.from_str(mods_start + corp_no_role + personal_no_role + plain_author_code + mods_end)
106
+ expect(smods_rec.main_author_w_date).to eq('plain_author_code')
111
107
  end
112
- it "shouldn't care about name type" do
113
- @smods_rec.from_str(@mods_start + @personal_author_text + @corp_author_code + @mods_end)
114
- expect(@smods_rec.main_author_w_date).to eq('personal_author_text')
115
- @smods_rec.from_str(@mods_start + @personal_no_role + @corp_author_code + @mods_end)
116
- expect(@smods_rec.main_author_w_date).to eq('corp_author_code')
108
+ it "doesn't care about name type" do
109
+ smods_rec.from_str(mods_start + personal_author_text + corp_author_code + mods_end)
110
+ expect(smods_rec.main_author_w_date).to eq('personal_author_text')
111
+ smods_rec.from_str(mods_start + personal_no_role + corp_author_code + mods_end)
112
+ expect(smods_rec.main_author_w_date).to eq('corp_author_code')
117
113
  end
118
- end
114
+ end # marcrelator role Author
119
115
 
120
- it "should be a String" do
121
- @smods_rec.from_str(@mods_start + @personal_author_text + @corp_creator_text + @mods_end)
122
- expect(@smods_rec.main_author_w_date).to be_an_instance_of(String)
116
+ it "is a String" do
117
+ smods_rec.from_str(mods_start + personal_author_text + corp_creator_text + mods_end)
118
+ expect(smods_rec.main_author_w_date).to be_an_instance_of(String)
123
119
  end
124
120
 
125
- it "should take first name with marcrelator role of 'Creator' or 'Author'" do
126
- @smods_rec.from_str(@mods_start + @personal_author_text + @corp_creator_text + @mods_end)
127
- expect(@smods_rec.main_author_w_date).to eq('personal_author_text')
128
- @smods_rec.from_str(@mods_start + @corp_creator_text + @personal_creator_code + @mods_end)
129
- expect(@smods_rec.main_author_w_date).to eq('corp_creator_text')
121
+ it "takes first name with marcrelator role of 'Creator' or 'Author'" do
122
+ smods_rec.from_str(mods_start + personal_author_text + corp_creator_text + mods_end)
123
+ expect(smods_rec.main_author_w_date).to eq('personal_author_text')
124
+ smods_rec.from_str(mods_start + corp_creator_text + personal_creator_code + mods_end)
125
+ expect(smods_rec.main_author_w_date).to eq('corp_creator_text')
130
126
  end
131
127
 
132
- it "should take the first name without a role if there are no instances of marcrelator role 'Creator' or 'Actor'" do
133
- @smods_rec.from_str(@mods_start + @plain_author_non_mr + @personal_other_role + @personal_no_role + @plain_no_role + @mods_end)
134
- expect(@smods_rec.main_author_w_date).to eq('personal_no_role')
128
+ it "takes the first name without a role if there are no instances of marcrelator role 'Creator' or 'Actor'" do
129
+ smods_rec.from_str(mods_start + plain_author_non_mr + personal_other_role + personal_no_role + plain_no_role + mods_end)
130
+ expect(smods_rec.main_author_w_date).to eq('personal_no_role')
135
131
  end
136
132
 
137
- it "should be nil if there is no name with marcrelator role of 'Creator' or 'Author' and no name without a role" do
138
- @smods_rec.from_str(@mods_start + @plain_author_non_mr + @personal_other_role + @mods_end)
139
- expect(@smods_rec.main_author_w_date).to be_nil
133
+ it "nil if there is no name with marcrelator role of 'Creator' or 'Author' and no name without a role" do
134
+ smods_rec.from_str(mods_start + plain_author_non_mr + personal_other_role + mods_end)
135
+ expect(smods_rec.main_author_w_date).to be_nil
140
136
  end
141
137
 
142
- it "should use the display name if it is present" do
143
- m = "<mods #{@ns_decl}><name type='personal'>
144
- <namePart type='given'>John</namePart>
145
- <namePart type='family'>Huston</namePart>
146
- <displayForm>q</displayForm>
147
- </name>
148
- <name type='personal'><namePart>Crusty The Clown</namePart></name>
149
- <name type='corporate'><namePart>Watchful Eye</namePart></name>
150
- <name type='corporate'>
151
- <namePart>Exciting Prints</namePart>
152
- <role><roleTerm type='text'>lithographer</roleTerm></role>
153
- </name>
154
- </mods>"
155
- @smods_rec.from_str(m)
156
- expect(@smods_rec.main_author_w_date).to eq('q')
157
- end
158
- it "should include dates, when available" do
159
- m = "<mods #{@ns_decl}><name type='personal'>
160
- <namePart>personal</namePart>
161
- <namePart type='date'>1984-</namePart>
162
- </name></mods>"
163
- @smods_rec.from_str(m)
164
- expect(@smods_rec.main_author_w_date).to eq('personal, 1984-')
165
- m = "<mods #{@ns_decl}><name>
166
- <namePart>plain</namePart>
167
- <namePart type='date'>1954-</namePart>
168
- </name></mods>"
169
- @smods_rec.from_str(m)
170
- expect(@smods_rec.main_author_w_date).to eq('plain, 1954-')
171
- m = "<mods #{@ns_decl}><name type='corporate'>
172
- <namePart>corporate</namePart>
173
- <namePart type='date'>1990-</namePart>
174
- </name></mods>"
175
- @smods_rec.from_str(m)
176
- expect(@smods_rec.main_author_w_date).to eq('corporate, 1990-')
138
+ it "uses the display name if it is present" do
139
+ m = "<mods xmlns=\"#{Mods::MODS_NS}\">
140
+ <name type='personal'>
141
+ <namePart type='given'>John</namePart>
142
+ <namePart type='family'>Huston</namePart>
143
+ <displayForm>q</displayForm>
144
+ </name>
145
+ <name type='personal'><namePart>Crusty The Clown</namePart></name>
146
+ <name type='corporate'><namePart>Watchful Eye</namePart></name>
147
+ <name type='corporate'>
148
+ <namePart>Exciting Prints</namePart>
149
+ <role><roleTerm type='text'>lithographer</roleTerm></role>
150
+ </name>
151
+ </mods>"
152
+ smods_rec.from_str(m)
153
+ expect(smods_rec.main_author_w_date).to eq('q')
154
+ end
155
+ it "includes dates, when available" do
156
+ m = "<mods xmlns=\"#{Mods::MODS_NS}\">
157
+ <name type='personal'>
158
+ <namePart>personal</namePart>
159
+ <namePart type='date'>1984-</namePart>
160
+ </name>
161
+ </mods>"
162
+ smods_rec.from_str(m)
163
+ expect(smods_rec.main_author_w_date).to eq('personal, 1984-')
164
+ m = "<mods xmlns=\"#{Mods::MODS_NS}\">
165
+ <name>
166
+ <namePart>plain</namePart>
167
+ <namePart type='date'>1954-</namePart>
168
+ </name>
169
+ </mods>"
170
+ smods_rec.from_str(m)
171
+ expect(smods_rec.main_author_w_date).to eq('plain, 1954-')
172
+ m = "<mods xmlns=\"#{Mods::MODS_NS}\">
173
+ <name type='corporate'>
174
+ <namePart>corporate</namePart>
175
+ <namePart type='date'>1990-</namePart>
176
+ </name>
177
+ </mods>"
178
+ smods_rec.from_str(m)
179
+ expect(smods_rec.main_author_w_date).to eq('corporate, 1990-')
177
180
  end
178
181
  end # main_author_w_date
179
182
 
180
183
  context "additional_authors_w_dates" do
181
- before(:all) do
182
- m = "<mods #{@ns_decl}><name type='personal'>
183
- <namePart type='given'>John</namePart>
184
- <namePart type='family'>Huston</namePart>
185
- <displayForm>q</displayForm>
186
- </name>
187
- <name type='personal'>
188
- <namePart>Crusty The Clown</namePart>
189
- <namePart type='date'>1990-</namePart>
190
- </name>
191
- <name type='corporate'>
192
- <namePart>Watchful Eye</namePart>
193
- <namePart type='date'>1850-</namePart>
194
- </name>
195
- <name type='corporate'>
196
- <namePart>Exciting Prints</namePart>
197
- <role><roleTerm type='text'>lithographer</roleTerm></role>
198
- </name>
199
- <name>
200
- <namePart>plain</namePart>
201
- </name>
202
- <name type='conference'>
203
- <namePart>conference</namePart>
204
- </name>
205
- <name type='family'>
206
- <namePart>family</namePart>
207
- </name>
208
- </mods>"
209
- @smods_rec.from_str(m)
210
- @addl_authors = @smods_rec.additional_authors_w_dates
211
- end
212
- it "should be an Array of Strings" do
213
- expect(@addl_authors).to be_an_instance_of(Array)
214
- expect(@addl_authors.first).to be_an_instance_of(String)
215
- end
216
- it "should not include main author" do
217
- expect(@addl_authors).not_to include(@smods_rec.main_author_w_date)
218
- end
219
- it "should include personal authors that are not main author" do
220
- expect(@addl_authors).to include('Crusty The Clown, 1990-')
221
- end
222
- it "should include corporate (and other) authors that are not main author" do
223
- expect(@addl_authors).to include('Watchful Eye, 1850-')
224
- expect(@addl_authors).to include('Exciting Prints')
225
- end
226
- it "should include plain authors" do
227
- expect(@addl_authors).to include('plain')
228
- end
229
- it "should include conference and other typed authors" do
230
- expect(@addl_authors).to include('conference')
231
- expect(@addl_authors).to include('family')
232
- end
233
- it "should include dates, when available" do
234
- expect(@addl_authors).to include('Crusty The Clown, 1990-')
235
- expect(@addl_authors).to include('Watchful Eye, 1850-')
236
- end
237
- it "should not include roles" do
238
- expect(@addl_authors.find { |a| a =~ Regexp.new('lithographer') }).to be_nil
184
+ let(:addl_authors) do
185
+ m = "<mods xmlns=\"#{Mods::MODS_NS}\">
186
+ <name type='personal'>
187
+ <namePart type='given'>John</namePart>
188
+ <namePart type='family'>Huston</namePart>
189
+ <displayForm>q</displayForm>
190
+ </name>
191
+ <name type='personal'>
192
+ <namePart>Crusty The Clown</namePart>
193
+ <namePart type='date'>1990-</namePart>
194
+ </name>
195
+ <name type='corporate'>
196
+ <namePart>Watchful Eye</namePart>
197
+ <namePart type='date'>1850-</namePart>
198
+ </name>
199
+ <name type='corporate'>
200
+ <namePart>Exciting Prints</namePart>
201
+ <role><roleTerm type='text'>lithographer</roleTerm></role>
202
+ </name>
203
+ <name>
204
+ <namePart>plain</namePart>
205
+ </name>
206
+ <name type='conference'>
207
+ <namePart>conference</namePart>
208
+ </name>
209
+ <name type='family'>
210
+ <namePart>family</namePart>
211
+ </name>
212
+ </mods>"
213
+ smods_rec.from_str(m)
214
+ smods_rec.additional_authors_w_dates
215
+ end
216
+ it "is an Array of Strings" do
217
+ expect(addl_authors).to be_an_instance_of(Array)
218
+ expect(addl_authors.first).to be_an_instance_of(String)
219
+ end
220
+ it "does not include main author" do
221
+ expect(addl_authors).not_to include(smods_rec.main_author_w_date)
222
+ end
223
+ it "includes personal authors that are not main author" do
224
+ expect(addl_authors).to include('Crusty The Clown, 1990-')
225
+ end
226
+ it "includes corporate (and other) authors that are not main author" do
227
+ expect(addl_authors).to include('Watchful Eye, 1850-')
228
+ expect(addl_authors).to include('Exciting Prints')
229
+ end
230
+ it "includes plain authors" do
231
+ expect(addl_authors).to include('plain')
232
+ end
233
+ it "includes conference and other typed authors" do
234
+ expect(addl_authors).to include('conference')
235
+ expect(addl_authors).to include('family')
236
+ end
237
+ it "includes dates, when available" do
238
+ expect(addl_authors).to include('Crusty The Clown, 1990-')
239
+ expect(addl_authors).to include('Watchful Eye, 1850-')
240
+ end
241
+ it "does not include roles" do
242
+ expect(addl_authors.find { |a| a =~ Regexp.new('lithographer') }).to be_nil
239
243
  end
240
244
  end # additional_authors_w_dates
241
245
 
246
+ context '#non_collector_person_authors' do
247
+ let(:name) { 'Hermione Grainger' }
248
+ let(:name2) { 'Ron Weasley' }
249
+ context 'has personal names that are not collectors' do
250
+ it 'only non-collector persons' do
251
+ name_snippet =
252
+ <<-EOF
253
+ <name type="personal">
254
+ <namePart>#{name}</namePart>
255
+ <role>
256
+ <roleTerm type="code" authority="marcrelator">cre</roleTerm>
257
+ </role>
258
+ </name>
259
+ <name type="personal">
260
+ <namePart>#{name2}</namePart>
261
+ <role>
262
+ <roleTerm type="code" authority="marcrelator">con</roleTerm>
263
+ </role>
264
+ </name>
265
+ EOF
266
+ smods_rec.from_str(mods_start + name_snippet + mods_end)
267
+ expect(smods_rec.non_collector_person_authors).to include(name, name2)
268
+ end
269
+ it 'some collectors, some non-collectors' do
270
+ name_snippet =
271
+ <<-EOF
272
+ <name type="personal">
273
+ <namePart>#{name}</namePart>
274
+ <role>
275
+ <roleTerm type="code" authority="marcrelator">cre</roleTerm>
276
+ </role>
277
+ </name>
278
+ <name type="personal">
279
+ <namePart>#{name2}</namePart>
280
+ <role>
281
+ <roleTerm type="code" authority="marcrelator">col</roleTerm>
282
+ </role>
283
+ </name>
284
+ EOF
285
+ smods_rec.from_str(mods_start + name_snippet + mods_end)
286
+ expect(smods_rec.non_collector_person_authors).to eq [name]
287
+ end
288
+ end
289
+ it 'nil if only collectors' do
290
+ name_snippet =
291
+ <<-EOF
292
+ <name type="personal">
293
+ <namePart>#{name}</namePart>
294
+ <role>
295
+ <roleTerm type="code" authority="marcrelator">col</roleTerm>
296
+ </role>
297
+ </name>
298
+ <name type="personal">
299
+ <namePart>Ron Weasley</namePart>
300
+ <role>
301
+ <roleTerm type="code" authority="marcrelator">col</roleTerm>
302
+ </role>
303
+ </name>
304
+ EOF
305
+ smods_rec.from_str(mods_start + name_snippet + mods_end)
306
+ expect(smods_rec.non_collector_person_authors).to eq nil
307
+ end
308
+ end
309
+
310
+ context '#collectors_w_dates' do
311
+ let(:collector_name) { 'Dr. Seuss' }
312
+ context 'valueURI for roleTerm' do
313
+ it 'roleTerm has value' do
314
+ name_snippet =
315
+ <<-EOF
316
+ <name type="personal">
317
+ <namePart>#{collector_name}</namePart>
318
+ <role>
319
+ <roleTerm type="text" authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/col">Collector</roleTerm>
320
+ </role>
321
+ </name>
322
+ EOF
323
+ smods_rec.from_str(mods_start + name_snippet + mods_end)
324
+ expect(smods_rec.collectors_w_dates).to eq [collector_name]
325
+ end
326
+ it 'empty roleTerm' do
327
+ name_snippet =
328
+ <<-EOF
329
+ <name type="personal">
330
+ <namePart>#{collector_name}</namePart>
331
+ <role>
332
+ <roleTerm authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/col" />
333
+ </role>
334
+ </name>
335
+ EOF
336
+ smods_rec.from_str(mods_start + name_snippet + mods_end)
337
+ expect(smods_rec.collectors_w_dates).to eq [collector_name]
338
+ end
339
+ end
340
+ context 'no valueURI for roleTerm' do
341
+ it 'collector marc relator code' do
342
+ name_snippet =
343
+ <<-EOF
344
+ <name type="personal">
345
+ <namePart>#{collector_name}</namePart>
346
+ <role>
347
+ <roleTerm type="code" authority="marcrelator">col</roleTerm>
348
+ </role>
349
+ </name>
350
+ EOF
351
+ smods_rec.from_str(mods_start + name_snippet + mods_end)
352
+ expect(smods_rec.collectors_w_dates).to eq [collector_name]
353
+ end
354
+ it 'collector marc relator text' do
355
+ name_snippet =
356
+ <<-EOF
357
+ <name type="personal">
358
+ <namePart>#{collector_name}</namePart>
359
+ <role>
360
+ <roleTerm type="text" authority="marcrelator">Collector</roleTerm>
361
+ </role>
362
+ </name>
363
+ EOF
364
+ smods_rec.from_str(mods_start + name_snippet + mods_end)
365
+ expect(smods_rec.collectors_w_dates).to eq [collector_name]
366
+ end
367
+ end
368
+ it 'does not include non-collectors' do
369
+ name_snippet =
370
+ <<-EOF
371
+ <name type="personal">
372
+ <namePart>#{collector_name}</namePart>
373
+ <role>
374
+ <roleTerm type="text" authority="marcrelator">Collector</roleTerm>
375
+ </role>
376
+ </name>
377
+ <name type="personal">
378
+ <namePart>Freddy</namePart>
379
+ <role>
380
+ <roleTerm type='code' authority='marcrelator'>cre</roleTerm>
381
+ </role>
382
+ </name>
383
+ EOF
384
+ smods_rec.from_str(mods_start + name_snippet + mods_end)
385
+ expect(smods_rec.collectors_w_dates).to eq [collector_name]
386
+ end
387
+ it 'multiple collectors' do
388
+ addl_name = 'Feigenbaum, Edward A.'
389
+ name_snippet =
390
+ <<-EOF
391
+ <name type="personal">
392
+ <namePart>#{collector_name}</namePart>
393
+ <role>
394
+ <roleTerm type="text" authority="marcrelator">Collector</roleTerm>
395
+ </role>
396
+ </name>
397
+ <name type="personal">
398
+ <namePart>#{addl_name}</namePart>
399
+ <role>
400
+ <roleTerm type='code' authority='marcrelator'>col</roleTerm>
401
+ </role>
402
+ </name>
403
+ EOF
404
+ smods_rec.from_str(mods_start + name_snippet + mods_end)
405
+ expect(smods_rec.collectors_w_dates).to include(collector_name, addl_name)
406
+ end
407
+ it 'nil if no collectors' do
408
+ name_snippet =
409
+ <<-EOF
410
+ <name type="personal">
411
+ <namePart>Freddy</namePart>
412
+ <role>
413
+ <roleTerm type='code' authority='marcrelator'>cre</roleTerm>
414
+ </role>
415
+ </name>
416
+ EOF
417
+ smods_rec.from_str(mods_start + name_snippet + mods_end)
418
+ expect(smods_rec.collectors_w_dates).to eq nil
419
+ end
420
+ end
242
421
  end