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/spec/title_spec.rb CHANGED
@@ -4,108 +4,223 @@ describe "Mods <titleInfo> element" do
4
4
 
5
5
  before(:all) do
6
6
  @mods_rec = Mods::Record.new
7
- end
8
-
9
- it "should recognize type attribute on titleInfo element" do
10
- Mods::TitleInfo::TYPES.each { |t|
11
- @mods_rec.from_str("<mods><titleInfo type='#{t}'>hi</titleInfo></mods>")
12
- @mods_rec.title_info.type_at.should == [t]
13
- }
14
- end
15
-
16
- it "should recognize subelements" do
17
- Mods::TitleInfo::CHILD_ELEMENTS.each { |e|
18
- @mods_rec.from_str("<mods><titleInfo><#{e}>oofda</#{e}></titleInfo></mods>")
19
- @mods_rec.title_info.send(e).text.should == 'oofda'
20
- }
7
+ @ns_decl = "xmlns='#{Mods::MODS_NS}'"
21
8
  end
22
9
 
23
- context "short_title" do
24
- it "should start with nonSort element" do
25
- @mods_rec.from_str('<mods><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo></mods>')
26
- @mods_rec.title_info.short_title.should == ["The Jerk"]
27
- end
28
- it "should not include subtitle" do
29
- @mods_rec.from_str('<mods><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>')
30
- @mods_rec.title_info.short_title.should == ["The Jerk"]
31
- end
32
- it "Mods::Record.short_titles convenience method should return an Array (multiple titles are legal in Mods)" do
33
- @mods_rec.from_str('<mods><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo><titleInfo><title>Joke</title></titleInfo></mods>')
34
- @mods_rec.short_titles.should == ["The Jerk", "Joke"]
35
- end
36
- it "should not include alternative titles" do
37
- @mods_rec.from_str('<mods><titleInfo type="alternative"><title>ta da!</title></titleInfo></mods>')
38
- @mods_rec.short_titles.should_not include("ta da!")
39
- @mods_rec.from_str("<mods><titleInfo type='alternative'><title>1</title></titleInfo><titleInfo><title>2</title></titleInfo></mods>")
40
- @mods_rec.short_titles.should == ['2']
41
- end
42
- end
43
-
44
- context "full_title" do
45
- it "should start with nonSort element" do
46
- @mods_rec.from_str('<mods><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo></mods>')
47
- @mods_rec.title_info.full_title.should == ["The Jerk"]
48
- end
49
- it "should include subtitle" do
50
- @mods_rec.from_str('<mods><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>')
51
- @mods_rec.title_info.full_title.should == ["The Jerk A Tale of Tourettes"]
52
- end
53
- it "Mods::Record.full_titles convenience method should return an Array (multiple titles are legal in Mods)" do
54
- @mods_rec.from_str('<mods><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo><titleInfo><title>Joke</title></titleInfo></mods>')
55
- @mods_rec.full_titles.should == ["The Jerk", "Joke"]
10
+ context "WITH namespaces" do
11
+
12
+ it "should recognize type attribute on titleInfo element" do
13
+ Mods::TitleInfo::TYPES.each { |t|
14
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo type='#{t}'>hi</titleInfo></mods>")
15
+ @mods_rec.title_info.type_at.should == [t]
16
+ }
17
+ end
18
+ it "should recognize subelements" do
19
+ Mods::TitleInfo::CHILD_ELEMENTS.each { |e|
20
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo><#{e}>oofda</#{e}></titleInfo></mods>")
21
+ @mods_rec.title_info.send(e).text.should == 'oofda'
22
+ }
56
23
  end
57
- end
58
24
 
59
- context "sort_title" do
60
- it "should skip nonSort element" do
61
- @mods_rec.from_str('<mods><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo></mods>')
62
- @mods_rec.title_info.sort_title.should == ["Jerk"]
63
- end
64
- it "should contain title and subtitle" do
65
- @mods_rec.from_str('<mods><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>')
66
- @mods_rec.title_info.sort_title.should == ["Jerk A Tale of Tourettes"]
67
- end
68
- it "should be an alternative title if there are no other choices" do
69
- @mods_rec.from_str("<mods><titleInfo type='alternative'><title>1</title></titleInfo></mods>")
70
- @mods_rec.title_info.sort_title.should == ['1']
25
+ context "short_title" do
26
+ it "should start with nonSort element" do
27
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo></mods>")
28
+ @mods_rec.title_info.short_title.should == ["The Jerk"]
29
+ end
30
+ it "should not include subtitle" do
31
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>")
32
+ @mods_rec.title_info.short_title.should == ["The Jerk"]
33
+ end
34
+ it "Mods::Record.short_titles convenience method should return an Array (multiple titles are legal in Mods)" do
35
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo><titleInfo><title>Joke</title></titleInfo></mods>")
36
+ @mods_rec.short_titles.should == ["The Jerk", "Joke"]
37
+ end
38
+ it "should not include alternative titles" do
39
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo type='alternative'><title>ta da!</title></titleInfo></mods>")
40
+ @mods_rec.short_titles.should_not include("ta da!")
41
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo type='alternative'><title>1</title></titleInfo><titleInfo><title>2</title></titleInfo></mods>")
42
+ @mods_rec.short_titles.should == ['2']
43
+ end
44
+ # note that Mods::Record.short_title tests are in record_spec
71
45
  end
72
- it "should not be an alternative title if there are other choices" do
73
- @mods_rec.from_str("<mods><titleInfo type='alternative'><title>1</title></titleInfo><titleInfo><title>2</title></titleInfo></mods>")
74
- @mods_rec.title_info.sort_title.should == ['2']
75
- @mods_rec.sort_title.should == '2'
46
+
47
+ context "full_title" do
48
+ it "should start with nonSort element" do
49
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo></mods>")
50
+ @mods_rec.title_info.full_title.should == ["The Jerk"]
51
+ end
52
+ it "should include subtitle" do
53
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>")
54
+ @mods_rec.title_info.full_title.should == ["The Jerk A Tale of Tourettes"]
55
+ end
56
+ it "Mods::Record.full_titles convenience method should return an Array (multiple titles are legal in Mods)" do
57
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo><titleInfo><title>Joke</title></titleInfo></mods>")
58
+ @mods_rec.full_titles.should == ["The Jerk", "Joke"]
59
+ end
60
+ # note that Mods::Record.full_title tests are in record_spec
76
61
  end
77
- it "should have a configurable delimiter between title and subtitle" do
78
- m = Mods::Record.new(' : ')
79
- m.from_str('<mods><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>')
80
- m.title_info.sort_title.should == ["Jerk : A Tale of Tourettes"]
62
+
63
+ context "sort_title" do
64
+ it "should skip nonSort element" do
65
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo></mods>")
66
+ @mods_rec.title_info.sort_title.should == ["Jerk"]
67
+ end
68
+ it "should contain title and subtitle" do
69
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>")
70
+ @mods_rec.title_info.sort_title.should == ["Jerk A Tale of Tourettes"]
71
+ end
72
+ it "should be an alternative title if there are no other choices" do
73
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo type='alternative'><title>1</title></titleInfo></mods>")
74
+ @mods_rec.title_info.sort_title.should == ['1']
75
+ end
76
+ it "should not be an alternative title if there are other choices" do
77
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo type='alternative'><title>1</title></titleInfo><titleInfo><title>2</title></titleInfo></mods>")
78
+ @mods_rec.title_info.sort_title.should == ['2']
79
+ @mods_rec.sort_title.should == '2'
80
+ end
81
+ it "should have a configurable delimiter between title and subtitle" do
82
+ m = Mods::Record.new(' : ')
83
+ m.from_str("<mods #{@ns_decl}><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>")
84
+ m.title_info.sort_title.should == ["Jerk : A Tale of Tourettes"]
85
+ end
86
+ context "Mods::Record.sort_title convenience method" do
87
+ it "convenience method sort_title in Mods::Record should return a string" do
88
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>")
89
+ @mods_rec.sort_title.should == "Jerk A Tale of Tourettes"
90
+ end
91
+ end
92
+ # note that Mods::Record.sort_title tests are in record_spec
81
93
  end
82
- context "Mods::Record.sort_title convenience method" do
83
- it "convenience method sort_title in Mods::Record should return a string" do
84
- @mods_rec.from_str('<mods><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>')
85
- @mods_rec.sort_title.should == "Jerk A Tale of Tourettes"
94
+
95
+ context "alternative_title" do
96
+ it "should get an alternative title, if it exists" do
97
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo type='alternative'><title>ta da!</title></titleInfo></mods>")
98
+ @mods_rec.title_info.alternative_title.should == ["ta da!"]
99
+ end
100
+ it "Mods::Record.alternative_titles convenience method for getting an Array of alternative titles when there are multiple elements" do
101
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo type='alternative'><title>1</title></titleInfo><titleInfo type='alternative'><title>2</title></titleInfo></mods>")
102
+ @mods_rec.alternative_titles.should == ['1', '2']
103
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo type='alternative'><title>1</title><title>2</title></titleInfo></mods>")
104
+ @mods_rec.alternative_titles.should == ['12']
105
+ end
106
+ it "should not get an alternative title if type attribute is absent from titleInfo" do
107
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo><title>ta da!</title></titleInfo></mods>")
108
+ @mods_rec.alternative_titles.should == []
86
109
  end
110
+ it "should not get an alternative title if type attribute from titleInfo is not 'alternative'" do
111
+ @mods_rec.from_str("<mods #{@ns_decl}><titleInfo type='uniform'><title>ta da!</title></titleInfo></mods>")
112
+ @mods_rec.alternative_titles.should == []
113
+ end
114
+ # note that Mods::Record.alternative_title tests are in record_spec
87
115
  end
88
- end
116
+ end # WITH namespaces
89
117
 
90
- context "alternative_title" do
91
- it "should get an alternative title, if it exists" do
92
- @mods_rec.from_str('<mods><titleInfo type="alternative"><title>ta da!</title></titleInfo></mods>')
93
- @mods_rec.title_info.alternative_title.should == ["ta da!"]
118
+ context "WITHOUT namespaces" do
119
+
120
+ it "should recognize type attribute on titleInfo element" do
121
+ Mods::TitleInfo::TYPES.each { |t|
122
+ @mods_rec.from_str("<mods><titleInfo type='#{t}'>hi</titleInfo></mods>", false)
123
+ @mods_rec.title_info.type_at.should == [t]
124
+ }
125
+ end
126
+ it "should recognize subelements" do
127
+ Mods::TitleInfo::CHILD_ELEMENTS.each { |e|
128
+ @mods_rec.from_str("<mods><titleInfo><#{e}>oofda</#{e}></titleInfo></mods>", false)
129
+ @mods_rec.title_info.send(e).text.should == 'oofda'
130
+ }
94
131
  end
95
- it "Mods::Record.alternative_titles convenience method for getting an Array of alternative titles when there are multiple elements" do
96
- @mods_rec.from_str("<mods><titleInfo type='alternative'><title>1</title></titleInfo><titleInfo type='alternative'><title>2</title></titleInfo></mods>")
97
- @mods_rec.alternative_titles.should == ['1', '2']
98
- @mods_rec.from_str("<mods><titleInfo type='alternative'><title>1</title><title>2</title></titleInfo></mods>")
99
- @mods_rec.alternative_titles.should == ['12']
132
+
133
+ context "short_title" do
134
+ it "should start with nonSort element" do
135
+ @mods_rec.from_str("<mods><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo></mods>", false)
136
+ @mods_rec.title_info.short_title.should == ["The Jerk"]
137
+ end
138
+ it "should not include subtitle" do
139
+ @mods_rec.from_str("<mods><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>", false)
140
+ @mods_rec.title_info.short_title.should == ["The Jerk"]
141
+ end
142
+ it "Mods::Record.short_titles convenience method should return an Array (multiple titles are legal in Mods)" do
143
+ @mods_rec.from_str("<mods><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo><titleInfo><title>Joke</title></titleInfo></mods>", false)
144
+ @mods_rec.short_titles.should == ["The Jerk", "Joke"]
145
+ end
146
+ it "should not include alternative titles" do
147
+ @mods_rec.from_str("<mods><titleInfo type='alternative'><title>ta da!</title></titleInfo></mods>", false)
148
+ @mods_rec.short_titles.should_not include("ta da!")
149
+ @mods_rec.from_str("<mods><titleInfo type='alternative'><title>1</title></titleInfo><titleInfo><title>2</title></titleInfo></mods>", false)
150
+ @mods_rec.short_titles.should == ['2']
151
+ end
152
+ # note that Mods::Record.short_title tests are in record_spec
153
+ end
154
+
155
+ context "full_title" do
156
+ it "should start with nonSort element" do
157
+ @mods_rec.from_str("<mods><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo></mods>", false)
158
+ @mods_rec.title_info.full_title.should == ["The Jerk"]
159
+ end
160
+ it "should include subtitle" do
161
+ @mods_rec.from_str("<mods><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>", false)
162
+ @mods_rec.title_info.full_title.should == ["The Jerk A Tale of Tourettes"]
163
+ end
164
+ it "Mods::Record.full_titles convenience method should return an Array (multiple titles are legal in Mods)" do
165
+ @mods_rec.from_str("<mods><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo><titleInfo><title>Joke</title></titleInfo></mods>", false)
166
+ @mods_rec.full_titles.should == ["The Jerk", "Joke"]
167
+ end
168
+ # note that Mods::Record.full_title tests are in record_spec
100
169
  end
101
- it "should not get an alternative title if type attribute is absent from titleInfo" do
102
- @mods_rec.from_str('<mods><titleInfo><title>ta da!</title></titleInfo></mods>')
103
- @mods_rec.alternative_titles.should == []
170
+
171
+ context "sort_title" do
172
+ it "should skip nonSort element" do
173
+ @mods_rec.from_str("<mods><titleInfo><title>Jerk</title><nonSort>The</nonSort></titleInfo></mods>", false)
174
+ @mods_rec.title_info.sort_title.should == ["Jerk"]
175
+ end
176
+ it "should contain title and subtitle" do
177
+ @mods_rec.from_str("<mods><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>", false)
178
+ @mods_rec.title_info.sort_title.should == ["Jerk A Tale of Tourettes"]
179
+ end
180
+ it "should be an alternative title if there are no other choices" do
181
+ @mods_rec.from_str("<mods><titleInfo type='alternative'><title>1</title></titleInfo></mods>", false)
182
+ @mods_rec.title_info.sort_title.should == ['1']
183
+ end
184
+ it "should not be an alternative title if there are other choices" do
185
+ @mods_rec.from_str("<mods><titleInfo type='alternative'><title>1</title></titleInfo><titleInfo><title>2</title></titleInfo></mods>", false)
186
+ @mods_rec.title_info.sort_title.should == ['2']
187
+ @mods_rec.sort_title.should == '2'
188
+ end
189
+ it "should have a configurable delimiter between title and subtitle" do
190
+ m = Mods::Record.new(' : ')
191
+ m.from_str("<mods><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>", false)
192
+ m.title_info.sort_title.should == ["Jerk : A Tale of Tourettes"]
193
+ end
194
+ context "Mods::Record.sort_title convenience method" do
195
+ it "convenience method sort_title in Mods::Record should return a string" do
196
+ @mods_rec.from_str("<mods><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>", false)
197
+ @mods_rec.sort_title.should == "Jerk A Tale of Tourettes"
198
+ end
199
+ end
200
+ # note that Mods::Record.sort_title tests are in record_spec
104
201
  end
105
- it "should not get an alternative title if type attribute from titleInfo is not 'alternative'" do
106
- @mods_rec.from_str('<mods><titleInfo type="uniform"><title>ta da!</title></titleInfo></mods>')
107
- @mods_rec.alternative_titles.should == []
202
+
203
+ context "alternative_title" do
204
+ it "should get an alternative title, if it exists" do
205
+ @mods_rec.from_str("<mods><titleInfo type='alternative'><title>ta da!</title></titleInfo></mods>", false)
206
+ @mods_rec.title_info.alternative_title.should == ["ta da!"]
207
+ end
208
+ it "Mods::Record.alternative_titles convenience method for getting an Array of alternative titles when there are multiple elements" do
209
+ @mods_rec.from_str("<mods><titleInfo type='alternative'><title>1</title></titleInfo><titleInfo type='alternative'><title>2</title></titleInfo></mods>", false)
210
+ @mods_rec.alternative_titles.should == ['1', '2']
211
+ @mods_rec.from_str("<mods><titleInfo type='alternative'><title>1</title><title>2</title></titleInfo></mods>", false)
212
+ @mods_rec.alternative_titles.should == ['12']
213
+ end
214
+ it "should not get an alternative title if type attribute is absent from titleInfo" do
215
+ @mods_rec.from_str("<mods><titleInfo><title>ta da!</title></titleInfo></mods>", false)
216
+ @mods_rec.alternative_titles.should == []
217
+ end
218
+ it "should not get an alternative title if type attribute from titleInfo is not 'alternative'" do
219
+ @mods_rec.from_str("<mods><titleInfo type='uniform'><title>ta da!</title></titleInfo></mods>", false)
220
+ @mods_rec.alternative_titles.should == []
221
+ end
222
+ # note that Mods::Record.alternative_title tests are in record_spec
108
223
  end
109
- end
224
+ end # WITHOUT namespaces
110
225
 
111
226
  end
@@ -5,186 +5,365 @@ describe "Mods Top Level Elements that do not have Child Elements" do
5
5
  before(:all) do
6
6
  @mods_rec = Mods::Record.new
7
7
  end
8
-
9
- it "should get the text contents of any single simple (cannot have child elements) top level element" do
10
- Mods::TOP_LEVEL_ELEMENTS_SIMPLE.each { |elname|
11
- @mods_rec.from_str("<mods><#{elname}>hi</#{elname}></mods>")
12
- @mods_rec.send(elname.to_sym).map { |e| e.text }.should == ["hi"]
13
- }
14
- end
15
8
 
9
+ it "should deal with camelcase vs. ruby underscore convention" do
10
+ pending "need to implement ruby style version of (element/attribute) method names"
11
+ end
12
+
16
13
  it "should get the text contents of any single complex top level element instance with no child elements" do
17
14
  pending "to be implemented"
18
15
  Mods::TOP_LEVEL_ELEMENTS_COMPLEX.each { |elname|
19
- @mods_rec.from_str("<mods><#{elname}>hi</#{elname}></mods>")
16
+ @mods_rec.from_str("<mods><#{elname}>hi</#{elname}></mods>", false)
20
17
  @mods_rec.send(elname.to_sym).map { |e| e.text }.should == ["hi"]
21
18
  }
22
19
  end
23
-
24
- it "should return an array of strings when there are multiple occurrences of simple top level elements" do
25
- @mods_rec.from_str('<mods><note>hi</note><note>hello</note></mods>').note.map { |e| e.text }.should == ["hi", "hello"]
26
- end
27
-
28
- it "should deal with camelcase vs. ruby underscore convention" do
29
- pending "need to implement ruby style version of (element/attribute) method names"
30
- end
31
-
32
- context "<abstract> child element" do
33
- it ".abstract.displayLabel should be an accessor for displayLabel attribute on abstract element: <abstract displayLabel='foo'>" do
34
- @mods_rec.from_str('<mods><abstract displayLabel="Summary">blah blah blah</abstract></mods>')
35
- @mods_rec.abstract.displayLabel.should == ['Summary']
36
- end
37
- it ".abstract.type_at should be an accessor for type attribute on abstract element: <abstract type='foo'>" do
38
- @mods_rec.from_str('<mods><abstract type="Scope and Contents note">blah blah blah</abstract></mods>')
39
- @mods_rec.abstract.type_at.should == ['Scope and Contents note']
40
- end
41
- end
42
-
43
- context "<accessCondition> child element" do
44
- before(:all) do
45
- @acc_cond = @mods_rec.from_str('<mods><accessCondition displayLabel="meh" type="useAndReproduction">blah blah blah</accessCondition></mods>').accessCondition
46
- @acc_cond2 = @mods_rec.from_str('<mods><accessCondition type="useAndReproduction">All rights reserved.</accessCondition></mods>').accessCondition
47
- end
48
- it ".accessCondition.displayLabel should be an accessor for displayLabel attribute on accessCondition element: <accessCondition displayLabel='foo'>" do
49
- @acc_cond.displayLabel.should == ['meh']
50
- end
51
- it ".accessCondition.type_at should be an accessor for type attribute on accessCondition element: <accessCondition type='foo'>" do
52
- [@acc_cond, @acc_cond2].each { |ac| ac.type_at.should == ['useAndReproduction'] }
53
- end
54
- end
55
-
56
- context "<classification> child element" do
57
- before(:all) do
58
- @class1 = @mods_rec.from_str('<mods><classification authority="ddc" edition="11">683</classification></mods>').classification
59
- @class2 = @mods_rec.from_str('<mods><classification authority="lcc">JK609.M2</classification></mods>').classification
60
- end
61
- it ".classification.authority should be an accessor for authority attribute on classification element: <classification authority='foo'>" do
62
- @class1.authority.should == ['ddc']
63
- @class2.authority.should == ['lcc']
64
- end
65
- it ".classification.edition should be an accessor for edition attribute on classification element: <classification edition='foo'>" do
66
- @class1.edition.should == ['11']
67
- end
68
- it "should recognize all authority attributes" do
69
- Mods::AUTHORITY_ATTRIBS.each { |a|
70
- @mods_rec.from_str("<mods><classification #{a}='attr_val'>zzz</classification></mods>")
71
- @mods_rec.classification.send(a.to_sym).should == ['attr_val']
20
+
21
+ context "parsing without namespaces" do
22
+
23
+ it "should get the text contents of any single simple (cannot have child elements) top level element" do
24
+ Mods::TOP_LEVEL_ELEMENTS_SIMPLE.each { |elname|
25
+ @mods_rec.from_str("<mods><#{elname}>hi</#{elname}></mods>", false)
26
+ @mods_rec.send(elname.to_sym).map { |e| e.text }.should == ["hi"]
72
27
  }
73
28
  end
74
- end
75
-
76
- context "<extension> child element" do
77
- before(:all) do
78
- @ext = @mods_rec.from_str('<mods><extension xmlns:dcterms="http://purl.org/dc/terms/" >
79
- <dcterms:modified>2003-03-24</dcterms:modified>
80
- </extension></mods>').extension
81
- end
82
- it ".extension.displayLabel should be an accessor for displayLabel attribute on extension element: <extension displayLabel='foo'>" do
83
- @mods_rec.from_str('<mods><extension displayLabel="something">blah blah blah</extension></mods>')
84
- @mods_rec.extension.displayLabel.should == ['something']
85
- end
86
- end
87
29
 
88
- context "<genre> child element" do
89
- it ".genre.displayLabel should be an accessor for displayLabel attribute on genre element: <genre displayLabel='foo'>" do
90
- @mods_rec.from_str('<mods><genre displayLabel="something">blah blah blah</genre></mods>')
91
- @mods_rec.genre.displayLabel.should == ['something']
30
+ it "should return an array of strings when there are multiple occurrences of simple top level elements" do
31
+ @mods_rec.from_str('<mods><note>hi</note><note>hello</note></mods>', false).note.map { |e| e.text }.should == ["hi", "hello"]
32
+ end
33
+
34
+ context "<abstract> child element" do
35
+ it ".abstract.displayLabel should be an accessor for displayLabel attribute on abstract element: <abstract displayLabel='foo'>" do
36
+ @mods_rec.from_str('<mods><abstract displayLabel="Summary">blah blah blah</abstract></mods>', false)
37
+ @mods_rec.abstract.displayLabel.should == ['Summary']
38
+ end
39
+ it ".abstract.type_at should be an accessor for type attribute on abstract element: <abstract type='foo'>" do
40
+ @mods_rec.from_str('<mods><abstract type="Scope and Contents note">blah blah blah</abstract></mods>', false)
41
+ @mods_rec.abstract.type_at.should == ['Scope and Contents note']
42
+ end
92
43
  end
93
- it ".genre.type_at should be an accessor for type attribute on genre element: <genre type='foo'>" do
94
- @mods_rec.from_str('<mods><genre type="maybe">blah blah blah</genre></mods>')
95
- @mods_rec.genre.type_at.should == ['maybe']
44
+
45
+ context "<accessCondition> child element" do
46
+ before(:all) do
47
+ @acc_cond = @mods_rec.from_str('<mods><accessCondition displayLabel="meh" type="useAndReproduction">blah blah blah</accessCondition></mods>', false).accessCondition
48
+ @acc_cond2 = @mods_rec.from_str('<mods><accessCondition type="useAndReproduction">All rights reserved.</accessCondition></mods>', false).accessCondition
49
+ end
50
+ it ".accessCondition.displayLabel should be an accessor for displayLabel attribute on accessCondition element: <accessCondition displayLabel='foo'>" do
51
+ @acc_cond.displayLabel.should == ['meh']
52
+ end
53
+ it ".accessCondition.type_at should be an accessor for type attribute on accessCondition element: <accessCondition type='foo'>" do
54
+ [@acc_cond, @acc_cond2].each { |ac| ac.type_at.should == ['useAndReproduction'] }
55
+ end
96
56
  end
97
- it ".genre.usage should be an accessor for usage attribute on genre element: <genre usage='foo'>" do
98
- @mods_rec.from_str('<mods><genre usage="fer sure">blah blah blah</genre></mods>')
99
- @mods_rec.genre.usage.should == ['fer sure']
57
+
58
+ context "<classification> child element" do
59
+ before(:all) do
60
+ @class1 = @mods_rec.from_str('<mods><classification authority="ddc" edition="11">683</classification></mods>', false).classification
61
+ @class2 = @mods_rec.from_str('<mods><classification authority="lcc">JK609.M2</classification></mods>', false).classification
62
+ end
63
+ it ".classification.authority should be an accessor for authority attribute on classification element: <classification authority='foo'>" do
64
+ @class1.authority.should == ['ddc']
65
+ @class2.authority.should == ['lcc']
66
+ end
67
+ it ".classification.edition should be an accessor for edition attribute on classification element: <classification edition='foo'>" do
68
+ @class1.edition.should == ['11']
69
+ end
70
+ it "should recognize all authority attributes" do
71
+ Mods::AUTHORITY_ATTRIBS.each { |a|
72
+ @mods_rec.from_str("<mods><classification #{a}='attr_val'>zzz</classification></mods>", false)
73
+ @mods_rec.classification.send(a.to_sym).should == ['attr_val']
74
+ }
75
+ end
100
76
  end
101
- it "should recognize all authority attributes" do
102
- Mods::AUTHORITY_ATTRIBS.each { |a|
103
- @mods_rec.from_str("<mods><genre #{a}='attr_val'>zzz</genre></mods>")
104
- @mods_rec.genre.send(a.to_sym).should == ['attr_val']
105
- }
77
+
78
+ context "<extension> child element" do
79
+ before(:all) do
80
+ @ext = @mods_rec.from_str('<mods><extension xmlns:dcterms="http://purl.org/dc/terms/" >
81
+ <dcterms:modified>2003-03-24</dcterms:modified>
82
+ </extension></mods>', false).extension
83
+ end
84
+ it ".extension.displayLabel should be an accessor for displayLabel attribute on extension element: <extension displayLabel='foo'>" do
85
+ @mods_rec.from_str('<mods><extension displayLabel="something">blah blah blah</extension></mods>', false)
86
+ @mods_rec.extension.displayLabel.should == ['something']
87
+ end
106
88
  end
107
- end
108
89
 
109
- context "<identifier> child element" do
110
- before(:all) do
111
- @id = @mods_rec.from_str('<mods><identifier displayLabel="book_number" type="local">70</identifier></mods>').identifier
90
+ context "<genre> child element" do
91
+ it ".genre.displayLabel should be an accessor for displayLabel attribute on genre element: <genre displayLabel='foo'>" do
92
+ @mods_rec.from_str('<mods><genre displayLabel="something">blah blah blah</genre></mods>', false)
93
+ @mods_rec.genre.displayLabel.should == ['something']
94
+ end
95
+ it ".genre.type_at should be an accessor for type attribute on genre element: <genre type='foo'>" do
96
+ @mods_rec.from_str('<mods><genre type="maybe">blah blah blah</genre></mods>', false)
97
+ @mods_rec.genre.type_at.should == ['maybe']
98
+ end
99
+ it ".genre.usage should be an accessor for usage attribute on genre element: <genre usage='foo'>" do
100
+ @mods_rec.from_str('<mods><genre usage="fer sure">blah blah blah</genre></mods>', false)
101
+ @mods_rec.genre.usage.should == ['fer sure']
102
+ end
103
+ it "should recognize all authority attributes" do
104
+ Mods::AUTHORITY_ATTRIBS.each { |a|
105
+ @mods_rec.from_str("<mods><genre #{a}='attr_val'>zzz</genre></mods>", false)
106
+ @mods_rec.genre.send(a.to_sym).should == ['attr_val']
107
+ }
108
+ end
112
109
  end
113
- it ".identifier.displayLabel should be an accessor for displayLabel attribute on identifier element: <identifier displayLabel='foo'>" do
114
- @id.displayLabel.should == ['book_number']
110
+
111
+ context "<identifier> child element" do
112
+ before(:all) do
113
+ @id = @mods_rec.from_str('<mods><identifier displayLabel="book_number" type="local">70</identifier></mods>', false).identifier
114
+ end
115
+ it ".identifier.displayLabel should be an accessor for displayLabel attribute on identifier element: <identifier displayLabel='foo'>" do
116
+ @id.displayLabel.should == ['book_number']
117
+ end
118
+ it ".identifier.invalid should be an accessor for invalid attribute on identifier element: <identifier invalid='foo'>" do
119
+ @mods_rec.from_str('<mods> <identifier type="isbn" invalid="yes">0877780116</identifier></mods>', false)
120
+ @mods_rec.identifier.invalid.should == ['yes']
121
+ end
122
+ it ".identifier.type_at should be an accessor for type attribute on identifier element: <identifier type='foo'>" do
123
+ @id.type_at.should == ['local']
124
+ end
115
125
  end
116
- it ".identifier.invalid should be an accessor for invalid attribute on identifier element: <identifier invalid='foo'>" do
117
- @mods_rec.from_str('<mods> <identifier type="isbn" invalid="yes">0877780116</identifier></mods>')
118
- @mods_rec.identifier.invalid.should == ['yes']
126
+
127
+ context "<note> child element" do
128
+ it ".note.displayLabel should be an accessor for displayLabel attribute on note element: <note displayLabel='foo'>" do
129
+ @mods_rec.from_str('<mods><note displayLabel="state_note">blah</note></mods>', false)
130
+ @mods_rec.note.displayLabel.should == ['state_note']
131
+ end
132
+ it ".note.id_at should be an accessor for ID attribute on note element: <note ID='foo'>" do
133
+ @mods_rec.from_str('<mods><note ID="foo">blah blah blah</note></mods>', false)
134
+ @mods_rec.note.id_at.should == ['foo']
135
+ end
136
+ it ".note.type_at should be an accessor for type attribute on note element: <note type='foo'>" do
137
+ @mods_rec.from_str('<mods><note type="content">blah</note></mods>', false)
138
+ @mods_rec.note.type_at.should == ['content']
139
+ end
119
140
  end
120
- it ".identifier.type_at should be an accessor for type attribute on identifier element: <identifier type='foo'>" do
121
- @id.type_at.should == ['local']
141
+
142
+ context "<tableOfContents> child element" do
143
+ it ".tableOfContents.displayLabel should be an accessor for displayLabel attribute on tableOfContents element: <tableOfContents displayLabel='foo'>" do
144
+ @mods_rec.from_str('<mods><tableOfContents displayLabel="Chapters included in book">blah blah</tableOfContents></mods>', false)
145
+ @mods_rec.tableOfContents.displayLabel.should == ['Chapters included in book']
146
+ end
147
+ it ".tableOfContents.shareable should be an accessor for shareable attribute on tableOfContents element: <tableOfContents shareable='foo'>" do
148
+ @mods_rec.from_str('<mods><tableOfContents shareable="no">blah blah blah</tableOfContents></mods>', false)
149
+ @mods_rec.tableOfContents.shareable.should == ['no']
150
+ end
151
+ it ".tableOfContents.type_at should be an accessor for type attribute on tableOfContents element: <tableOfContents type='foo'>" do
152
+ @mods_rec.from_str('<mods><tableOfContents type="partial contents">blah blah</tableOfContents></mods>', false)
153
+ @mods_rec.tableOfContents.type_at.should == ['partial contents']
154
+ end
122
155
  end
123
- end
124
156
 
125
- context "<note> child element" do
126
- it ".note.displayLabel should be an accessor for displayLabel attribute on note element: <note displayLabel='foo'>" do
127
- @mods_rec.from_str('<mods><note displayLabel="state_note">blah</note></mods>')
128
- @mods_rec.note.displayLabel.should == ['state_note']
157
+ context "<targetAudience> child element" do
158
+ it ".targetAudience.displayLabel should be an accessor for displayLabel attribute on targetAudience element: <targetAudience displayLabel='foo'>" do
159
+ @mods_rec.from_str('<mods><targetAudience displayLabel="ta da">blah blah</targetAudience></mods>', false)
160
+ @mods_rec.targetAudience.displayLabel.should == ['ta da']
161
+ end
162
+ it "should recognize all authority attributes" do
163
+ Mods::AUTHORITY_ATTRIBS.each { |a|
164
+ @mods_rec.from_str("<mods><targetAudience #{a}='attr_val'>zzz</targetAudience></mods>", false)
165
+ @mods_rec.targetAudience.send(a.to_sym).should == ['attr_val']
166
+ }
167
+ end
129
168
  end
130
- it ".note.id_at should be an accessor for ID attribute on note element: <note ID='foo'>" do
131
- @mods_rec.from_str('<mods><note ID="foo">blah blah blah</note></mods>')
132
- @mods_rec.note.id_at.should == ['foo']
169
+
170
+ context "<typeOfResource> child element" do
171
+ before(:all) do
172
+ '<typeOfResource manuscript="yes">mixed material</typeOfResource>'
173
+ end
174
+ it ".typeOfResource.collection should be an accessor for collection attribute on typeOfResource element: <typeOfResource collection='foo'>" do
175
+ @mods_rec.from_str('<mods><typeOfResource collection="yes">blah blah blah</typeOfResource></mods>', false)
176
+ @mods_rec.typeOfResource.collection.should == ['yes']
177
+ end
178
+ it ".typeOfResource.displayLabel should be an accessor for displayLabel attribute on typeOfResource element: <typeOfResource displayLabel='foo'>" do
179
+ @mods_rec.from_str('<mods><typeOfResource displayLabel="Summary">blah blah blah</typeOfResource></mods>', false)
180
+ @mods_rec.typeOfResource.displayLabel.should == ['Summary']
181
+ end
182
+ it ".typeOfResource.manuscript should be an accessor for manuscript attribute on typeOfResource element: <typeOfResource manuscript='foo'>" do
183
+ @mods_rec.from_str('<mods><typeOfResource manuscript="yes">blah blah blah</typeOfResource></mods>', false)
184
+ @mods_rec.typeOfResource.manuscript.should == ['yes']
185
+ end
186
+ it ".typeOfResource.usage should be an accessor for usage attribute on typeOfResource element: <typeOfResource usage='foo'>" do
187
+ @mods_rec.from_str('<mods><typeOfResource usage="fer sure">blah blah blah</typeOfResource></mods>', false)
188
+ @mods_rec.typeOfResource.usage.should == ['fer sure']
189
+ end
190
+ end
191
+
192
+ end # context without namespaces
193
+
194
+ context "parsing with namespaces" do
195
+
196
+ before(:all) do
197
+ @mods_el_w_ns = '<mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">'
133
198
  end
134
- it ".note.type_at should be an accessor for type attribute on note element: <note type='foo'>" do
135
- @mods_rec.from_str('<mods><note type="content">blah</note></mods>')
136
- @mods_rec.note.type_at.should == ['content']
199
+
200
+ it "should get the text contents of any single simple (cannot have child elements) top level element" do
201
+ Mods::TOP_LEVEL_ELEMENTS_SIMPLE.each { |elname|
202
+ @mods_rec.from_str(@mods_el_w_ns + "<#{elname}>hi</#{elname}></mods>")
203
+ @mods_rec.send(elname.to_sym).map { |e| e.text }.should == ["hi"]
204
+ }
137
205
  end
138
- end
139
206
 
140
- context "<tableOfContents> child element" do
141
- it ".tableOfContents.displayLabel should be an accessor for displayLabel attribute on tableOfContents element: <tableOfContents displayLabel='foo'>" do
142
- @mods_rec.from_str('<mods><tableOfContents displayLabel="Chapters included in book">blah blah</tableOfContents></mods>')
143
- @mods_rec.tableOfContents.displayLabel.should == ['Chapters included in book']
207
+ it "should return an array of strings when there are multiple occurrences of simple top level elements" do
208
+ @mods_rec.from_str(@mods_el_w_ns + '<note>hi</note><note>hello</note></mods>').note.map { |e| e.text }.should == ["hi", "hello"]
144
209
  end
145
- it ".tableOfContents.shareable should be an accessor for shareable attribute on tableOfContents element: <tableOfContents shareable='foo'>" do
146
- @mods_rec.from_str('<mods><tableOfContents shareable="no">blah blah blah</tableOfContents></mods>')
147
- @mods_rec.tableOfContents.shareable.should == ['no']
210
+
211
+ context "<abstract> child element" do
212
+ it ".abstract.displayLabel should be an accessor for displayLabel attribute on abstract element: <abstract displayLabel='foo'>" do
213
+ @mods_rec.from_str(@mods_el_w_ns + '<abstract displayLabel="Summary">blah blah blah</abstract></mods>')
214
+ @mods_rec.abstract.displayLabel.should == ['Summary']
215
+ end
216
+ it ".abstract.type_at should be an accessor for type attribute on abstract element: <abstract type='foo'>" do
217
+ @mods_rec.from_str(@mods_el_w_ns + '<abstract type="Scope and Contents note">blah blah blah</abstract></mods>')
218
+ @mods_rec.abstract.type_at.should == ['Scope and Contents note']
219
+ end
148
220
  end
149
- it ".tableOfContents.type_at should be an accessor for type attribute on tableOfContents element: <tableOfContents type='foo'>" do
150
- @mods_rec.from_str('<mods><tableOfContents type="partial contents">blah blah</tableOfContents></mods>')
151
- @mods_rec.tableOfContents.type_at.should == ['partial contents']
221
+
222
+ context "<accessCondition> child element" do
223
+ before(:all) do
224
+ @acc_cond = @mods_rec.from_str(@mods_el_w_ns + '<accessCondition displayLabel="meh" type="useAndReproduction">blah blah blah</accessCondition></mods>').accessCondition
225
+ @acc_cond2 = @mods_rec.from_str(@mods_el_w_ns + '<accessCondition type="useAndReproduction">All rights reserved.</accessCondition></mods>').accessCondition
226
+ end
227
+ it ".accessCondition.displayLabel should be an accessor for displayLabel attribute on accessCondition element: <accessCondition displayLabel='foo'>" do
228
+ @acc_cond.displayLabel.should == ['meh']
229
+ end
230
+ it ".accessCondition.type_at should be an accessor for type attribute on accessCondition element: <accessCondition type='foo'>" do
231
+ [@acc_cond, @acc_cond2].each { |ac| ac.type_at.should == ['useAndReproduction'] }
232
+ end
152
233
  end
153
- end
154
234
 
155
- context "<targetAudience> child element" do
156
- it ".targetAudience.displayLabel should be an accessor for displayLabel attribute on targetAudience element: <targetAudience displayLabel='foo'>" do
157
- @mods_rec.from_str('<mods><targetAudience displayLabel="ta da">blah blah</targetAudience></mods>')
158
- @mods_rec.targetAudience.displayLabel.should == ['ta da']
235
+ context "<classification> child element" do
236
+ before(:all) do
237
+ @class1 = @mods_rec.from_str(@mods_el_w_ns + '<classification authority="ddc" edition="11">683</classification></mods>').classification
238
+ @class2 = @mods_rec.from_str(@mods_el_w_ns + '<classification authority="lcc">JK609.M2</classification></mods>').classification
239
+ end
240
+ it ".classification.authority should be an accessor for authority attribute on classification element: <classification authority='foo'>" do
241
+ @class1.authority.should == ['ddc']
242
+ @class2.authority.should == ['lcc']
243
+ end
244
+ it ".classification.edition should be an accessor for edition attribute on classification element: <classification edition='foo'>" do
245
+ @class1.edition.should == ['11']
246
+ end
247
+ it "should recognize all authority attributes" do
248
+ Mods::AUTHORITY_ATTRIBS.each { |a|
249
+ @mods_rec.from_str(@mods_el_w_ns + "<classification #{a}='attr_val'>zzz</classification></mods>")
250
+ @mods_rec.classification.send(a.to_sym).should == ['attr_val']
251
+ }
252
+ end
159
253
  end
160
- it "should recognize all authority attributes" do
161
- Mods::AUTHORITY_ATTRIBS.each { |a|
162
- @mods_rec.from_str("<mods><targetAudience #{a}='attr_val'>zzz</targetAudience></mods>")
163
- @mods_rec.targetAudience.send(a.to_sym).should == ['attr_val']
164
- }
254
+
255
+ context "<extension> child element" do
256
+ before(:all) do
257
+ @ext = @mods_rec.from_str(@mods_el_w_ns + '<extension xmlns:dcterms="http://purl.org/dc/terms/" >
258
+ <dcterms:modified>2003-03-24</dcterms:modified>
259
+ </extension></mods>').extension
260
+ end
261
+ it ".extension.displayLabel should be an accessor for displayLabel attribute on extension element: <extension displayLabel='foo'>" do
262
+ @mods_rec.from_str(@mods_el_w_ns + '<extension displayLabel="something">blah blah blah</extension></mods>')
263
+ @mods_rec.extension.displayLabel.should == ['something']
264
+ end
165
265
  end
166
- end
167
266
 
168
- context "<typeOfResource> child element" do
169
- before(:all) do
170
- '<typeOfResource manuscript="yes">mixed material</typeOfResource>'
267
+ context "<genre> child element" do
268
+ it ".genre.displayLabel should be an accessor for displayLabel attribute on genre element: <genre displayLabel='foo'>" do
269
+ @mods_rec.from_str(@mods_el_w_ns + '<genre displayLabel="something">blah blah blah</genre></mods>')
270
+ @mods_rec.genre.displayLabel.should == ['something']
271
+ end
272
+ it ".genre.type_at should be an accessor for type attribute on genre element: <genre type='foo'>" do
273
+ @mods_rec.from_str(@mods_el_w_ns + '<genre type="maybe">blah blah blah</genre></mods>')
274
+ @mods_rec.genre.type_at.should == ['maybe']
275
+ end
276
+ it ".genre.usage should be an accessor for usage attribute on genre element: <genre usage='foo'>" do
277
+ @mods_rec.from_str(@mods_el_w_ns + '<genre usage="fer sure">blah blah blah</genre></mods>')
278
+ @mods_rec.genre.usage.should == ['fer sure']
279
+ end
280
+ it "should recognize all authority attributes" do
281
+ Mods::AUTHORITY_ATTRIBS.each { |a|
282
+ @mods_rec.from_str(@mods_el_w_ns + "<genre #{a}='attr_val'>zzz</genre></mods>")
283
+ @mods_rec.genre.send(a.to_sym).should == ['attr_val']
284
+ }
285
+ end
171
286
  end
172
- it ".typeOfResource.collection should be an accessor for collection attribute on typeOfResource element: <typeOfResource collection='foo'>" do
173
- @mods_rec.from_str('<mods><typeOfResource collection="yes">blah blah blah</typeOfResource></mods>')
174
- @mods_rec.typeOfResource.collection.should == ['yes']
287
+
288
+ context "<identifier> child element" do
289
+ before(:all) do
290
+ @id = @mods_rec.from_str(@mods_el_w_ns + '<identifier displayLabel="book_number" type="local">70</identifier></mods>').identifier
291
+ end
292
+ it ".identifier.displayLabel should be an accessor for displayLabel attribute on identifier element: <identifier displayLabel='foo'>" do
293
+ @id.displayLabel.should == ['book_number']
294
+ end
295
+ it ".identifier.invalid should be an accessor for invalid attribute on identifier element: <identifier invalid='foo'>" do
296
+ @mods_rec.from_str(@mods_el_w_ns + '<identifier type="isbn" invalid="yes">0877780116</identifier></mods>')
297
+ @mods_rec.identifier.invalid.should == ['yes']
298
+ end
299
+ it ".identifier.type_at should be an accessor for type attribute on identifier element: <identifier type='foo'>" do
300
+ @id.type_at.should == ['local']
301
+ end
175
302
  end
176
- it ".typeOfResource.displayLabel should be an accessor for displayLabel attribute on typeOfResource element: <typeOfResource displayLabel='foo'>" do
177
- @mods_rec.from_str('<mods><typeOfResource displayLabel="Summary">blah blah blah</typeOfResource></mods>')
178
- @mods_rec.typeOfResource.displayLabel.should == ['Summary']
303
+
304
+ context "<note> child element" do
305
+ it ".note.displayLabel should be an accessor for displayLabel attribute on note element: <note displayLabel='foo'>" do
306
+ @mods_rec.from_str(@mods_el_w_ns + '<note displayLabel="state_note">blah</note></mods>')
307
+ @mods_rec.note.displayLabel.should == ['state_note']
308
+ end
309
+ it ".note.id_at should be an accessor for ID attribute on note element: <note ID='foo'>" do
310
+ @mods_rec.from_str(@mods_el_w_ns + '<note ID="foo">blah blah blah</note></mods>')
311
+ @mods_rec.note.id_at.should == ['foo']
312
+ end
313
+ it ".note.type_at should be an accessor for type attribute on note element: <note type='foo'>" do
314
+ @mods_rec.from_str(@mods_el_w_ns + '<note type="content">blah</note></mods>')
315
+ @mods_rec.note.type_at.should == ['content']
316
+ end
179
317
  end
180
- it ".typeOfResource.manuscript should be an accessor for manuscript attribute on typeOfResource element: <typeOfResource manuscript='foo'>" do
181
- @mods_rec.from_str('<mods><typeOfResource manuscript="yes">blah blah blah</typeOfResource></mods>')
182
- @mods_rec.typeOfResource.manuscript.should == ['yes']
318
+
319
+ context "<tableOfContents> child element" do
320
+ it ".tableOfContents.displayLabel should be an accessor for displayLabel attribute on tableOfContents element: <tableOfContents displayLabel='foo'>" do
321
+ @mods_rec.from_str(@mods_el_w_ns + '<tableOfContents displayLabel="Chapters included in book">blah blah</tableOfContents></mods>')
322
+ @mods_rec.tableOfContents.displayLabel.should == ['Chapters included in book']
323
+ end
324
+ it ".tableOfContents.shareable should be an accessor for shareable attribute on tableOfContents element: <tableOfContents shareable='foo'>" do
325
+ @mods_rec.from_str(@mods_el_w_ns + '<tableOfContents shareable="no">blah blah blah</tableOfContents></mods>')
326
+ @mods_rec.tableOfContents.shareable.should == ['no']
327
+ end
328
+ it ".tableOfContents.type_at should be an accessor for type attribute on tableOfContents element: <tableOfContents type='foo'>" do
329
+ @mods_rec.from_str(@mods_el_w_ns + '<tableOfContents type="partial contents">blah blah</tableOfContents></mods>')
330
+ @mods_rec.tableOfContents.type_at.should == ['partial contents']
331
+ end
183
332
  end
184
- it ".typeOfResource.usage should be an accessor for usage attribute on typeOfResource element: <typeOfResource usage='foo'>" do
185
- @mods_rec.from_str('<mods><typeOfResource usage="fer sure">blah blah blah</typeOfResource></mods>')
186
- @mods_rec.typeOfResource.usage.should == ['fer sure']
333
+
334
+ context "<targetAudience> child element" do
335
+ it ".targetAudience.displayLabel should be an accessor for displayLabel attribute on targetAudience element: <targetAudience displayLabel='foo'>" do
336
+ @mods_rec.from_str(@mods_el_w_ns + '<targetAudience displayLabel="ta da">blah blah</targetAudience></mods>')
337
+ @mods_rec.targetAudience.displayLabel.should == ['ta da']
338
+ end
339
+ it "should recognize all authority attributes" do
340
+ Mods::AUTHORITY_ATTRIBS.each { |a|
341
+ @mods_rec.from_str(@mods_el_w_ns + "<targetAudience #{a}='attr_val'>zzz</targetAudience></mods>")
342
+ @mods_rec.targetAudience.send(a.to_sym).should == ['attr_val']
343
+ }
344
+ end
187
345
  end
188
- end
346
+
347
+ context "<typeOfResource> child element" do
348
+ it ".typeOfResource.collection should be an accessor for collection attribute on typeOfResource element: <typeOfResource collection='foo'>" do
349
+ @mods_rec.from_str(@mods_el_w_ns + '<typeOfResource collection="yes">blah blah blah</typeOfResource></mods>')
350
+ @mods_rec.typeOfResource.collection.should == ['yes']
351
+ end
352
+ it ".typeOfResource.displayLabel should be an accessor for displayLabel attribute on typeOfResource element: <typeOfResource displayLabel='foo'>" do
353
+ @mods_rec.from_str(@mods_el_w_ns + '<typeOfResource displayLabel="Summary">blah blah blah</typeOfResource></mods>')
354
+ @mods_rec.typeOfResource.displayLabel.should == ['Summary']
355
+ end
356
+ it ".typeOfResource.manuscript should be an accessor for manuscript attribute on typeOfResource element: <typeOfResource manuscript='foo'>" do
357
+ @mods_rec.from_str(@mods_el_w_ns + '<typeOfResource manuscript="yes">blah blah blah</typeOfResource></mods>')
358
+ @mods_rec.typeOfResource.manuscript.should == ['yes']
359
+ end
360
+ it ".typeOfResource.usage should be an accessor for usage attribute on typeOfResource element: <typeOfResource usage='foo'>" do
361
+ @mods_rec.from_str(@mods_el_w_ns + '<typeOfResource usage="fer sure">blah blah blah</typeOfResource></mods>')
362
+ @mods_rec.typeOfResource.usage.should == ['fer sure']
363
+ end
364
+ end
365
+
366
+ end # parsing with namespaces
367
+
189
368
 
190
369
  end