mods 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/lib/mods/nom_terminology.rb +248 -249
- data/lib/mods/reader.rb +2 -4
- data/lib/mods/record.rb +5 -1
- data/lib/mods/version.rb +1 -1
- data/mods.gemspec +4 -4
- data/spec/language_spec.rb +30 -30
- data/spec/location_spec.rb +44 -44
- data/spec/name_spec.rb +155 -155
- data/spec/origin_info_spec.rb +32 -32
- data/spec/part_spec.rb +122 -122
- data/spec/physical_description_spec.rb +18 -18
- data/spec/reader_spec.rb +41 -40
- data/spec/record_info_spec.rb +120 -120
- data/spec/record_spec.rb +63 -58
- data/spec/related_item_spec.rb +76 -76
- data/spec/subject_spec.rb +165 -165
- data/spec/title_spec.rb +44 -44
- data/spec/top_level_elmnts_simple_spec.rb +61 -61
- metadata +28 -27
@@ -12,7 +12,7 @@ describe "Mods <physicalDescription> Element" do
|
|
12
12
|
|
13
13
|
it "extent child element" do
|
14
14
|
@mods_rec.from_str("<mods #{@ns_decl}><physicalDescription><extent>extent</extent></physicalDescription></mods>")
|
15
|
-
@mods_rec.physical_description.extent.map { |n| n.text }.
|
15
|
+
expect(@mods_rec.physical_description.extent.map { |n| n.text }).to eq(["extent"])
|
16
16
|
end
|
17
17
|
|
18
18
|
context "note child element" do
|
@@ -26,10 +26,10 @@ describe "Mods <physicalDescription> Element" do
|
|
26
26
|
@mods_rec.from_str(forms_and_notes)
|
27
27
|
end
|
28
28
|
it "should understand note element" do
|
29
|
-
@mods_rec.physical_description.note.map { |n| n.text }.
|
29
|
+
expect(@mods_rec.physical_description.note.map { |n| n.text }).to eq(["dimension text", "condition text"])
|
30
30
|
end
|
31
31
|
it "should understand displayLabel attribute on note element" do
|
32
|
-
@mods_rec.physical_description.note.displayLabel.
|
32
|
+
expect(@mods_rec.physical_description.note.displayLabel).to eq(["Dimensions", "Condition"])
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -43,13 +43,13 @@ describe "Mods <physicalDescription> Element" do
|
|
43
43
|
@mods_rec.from_str(forms_and_extent)
|
44
44
|
end
|
45
45
|
it "should understand form element" do
|
46
|
-
@mods_rec.physical_description.form.map { |n| n.text }.
|
46
|
+
expect(@mods_rec.physical_description.form.map { |n| n.text }).to eq(["map", "foo"])
|
47
47
|
end
|
48
48
|
it "should understand authority attribute on form element" do
|
49
|
-
@mods_rec.physical_description.form.authority.
|
49
|
+
expect(@mods_rec.physical_description.form.authority).to eq(["smd"])
|
50
50
|
end
|
51
51
|
it "should understand type attribute on form element" do
|
52
|
-
@mods_rec.physical_description.form.type_at.
|
52
|
+
expect(@mods_rec.physical_description.form.type_at).to eq(["material"])
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -63,13 +63,13 @@ describe "Mods <physicalDescription> Element" do
|
|
63
63
|
@mods_rec.from_str(digital)
|
64
64
|
end
|
65
65
|
it "should understand reformattingQuality child element" do
|
66
|
-
@mods_rec.physical_description.reformattingQuality.map { |n| n.text }.
|
66
|
+
expect(@mods_rec.physical_description.reformattingQuality.map { |n| n.text }).to eq(["preservation"])
|
67
67
|
end
|
68
68
|
it "should understand digitalOrigin child element" do
|
69
|
-
@mods_rec.physical_description.digitalOrigin.map { |n| n.text }.
|
69
|
+
expect(@mods_rec.physical_description.digitalOrigin.map { |n| n.text }).to eq(["reformatted digital"])
|
70
70
|
end
|
71
71
|
it "should understand internetMediaType child element" do
|
72
|
-
@mods_rec.physical_description.internetMediaType.map { |n| n.text }.
|
72
|
+
expect(@mods_rec.physical_description.internetMediaType.map { |n| n.text }).to eq(["image/jp2"])
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end # WITH namespaces
|
@@ -77,7 +77,7 @@ describe "Mods <physicalDescription> Element" do
|
|
77
77
|
context "WITHOUT namespaces" do
|
78
78
|
it "extent child element" do
|
79
79
|
@mods_rec.from_str('<mods><physicalDescription><extent>extent</extent></physicalDescription></mods>', false)
|
80
|
-
@mods_rec.physical_description.extent.map { |n| n.text }.
|
80
|
+
expect(@mods_rec.physical_description.extent.map { |n| n.text }).to eq(["extent"])
|
81
81
|
end
|
82
82
|
|
83
83
|
context "note child element" do
|
@@ -91,10 +91,10 @@ describe "Mods <physicalDescription> Element" do
|
|
91
91
|
@mods_rec.from_str(forms_and_notes, false)
|
92
92
|
end
|
93
93
|
it "should understand note element" do
|
94
|
-
@mods_rec.physical_description.note.map { |n| n.text }.
|
94
|
+
expect(@mods_rec.physical_description.note.map { |n| n.text }).to eq(["dimension text", "condition text"])
|
95
95
|
end
|
96
96
|
it "should understand displayLabel attribute on note element" do
|
97
|
-
@mods_rec.physical_description.note.displayLabel.
|
97
|
+
expect(@mods_rec.physical_description.note.displayLabel).to eq(["Dimensions", "Condition"])
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -108,13 +108,13 @@ describe "Mods <physicalDescription> Element" do
|
|
108
108
|
@mods_rec.from_str(forms_and_extent, false)
|
109
109
|
end
|
110
110
|
it "should understand form element" do
|
111
|
-
@mods_rec.physical_description.form.map { |n| n.text }.
|
111
|
+
expect(@mods_rec.physical_description.form.map { |n| n.text }).to eq(["map", "foo"])
|
112
112
|
end
|
113
113
|
it "should understand authority attribute on form element" do
|
114
|
-
@mods_rec.physical_description.form.authority.
|
114
|
+
expect(@mods_rec.physical_description.form.authority).to eq(["smd"])
|
115
115
|
end
|
116
116
|
it "should understand type attribute on form element" do
|
117
|
-
@mods_rec.physical_description.form.type_at.
|
117
|
+
expect(@mods_rec.physical_description.form.type_at).to eq(["material"])
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -128,13 +128,13 @@ describe "Mods <physicalDescription> Element" do
|
|
128
128
|
@mods_rec.from_str(digital, false)
|
129
129
|
end
|
130
130
|
it "should understand reformattingQuality child element" do
|
131
|
-
@mods_rec.physical_description.reformattingQuality.map { |n| n.text }.
|
131
|
+
expect(@mods_rec.physical_description.reformattingQuality.map { |n| n.text }).to eq(["preservation"])
|
132
132
|
end
|
133
133
|
it "should understand digitalOrigin child element" do
|
134
|
-
@mods_rec.physical_description.digitalOrigin.map { |n| n.text }.
|
134
|
+
expect(@mods_rec.physical_description.digitalOrigin.map { |n| n.text }).to eq(["reformatted digital"])
|
135
135
|
end
|
136
136
|
it "should understand internetMediaType child element" do
|
137
|
-
@mods_rec.physical_description.internetMediaType.map { |n| n.text }.
|
137
|
+
expect(@mods_rec.physical_description.internetMediaType.map { |n| n.text }).to eq(["image/jp2"])
|
138
138
|
end
|
139
139
|
end
|
140
140
|
end # WITHOUT namespaces
|
data/spec/reader_spec.rb
CHANGED
@@ -8,21 +8,21 @@ describe "Mods::Reader" do
|
|
8
8
|
# url is for a namespaced document
|
9
9
|
@example_url = 'http://www.loc.gov/standards/mods/v3/mods99042030_linkedDataAdded.xml'
|
10
10
|
@example_default_ns_str = '<mods xmlns="http://www.loc.gov/mods/v3"><note>default ns</note></mods>'
|
11
|
-
@example_ns_str
|
12
|
-
@example_no_ns_str
|
13
|
-
@example_wrong_ns_str
|
11
|
+
@example_ns_str = '<mods:mods xmlns:mods="http://www.loc.gov/mods/v3"><mods:note>ns</mods:note></mods:mods>'
|
12
|
+
@example_no_ns_str = '<mods><note>no ns</note></mods>'
|
13
|
+
@example_wrong_ns_str = '<mods xmlns="wrong"><note>wrong ns</note></mods>'
|
14
14
|
@doc_from_str_default_ns = Mods::Reader.new.from_str(@example_ns_str)
|
15
|
-
@doc_from_str_ns
|
16
|
-
@doc_from_str_no_ns
|
17
|
-
@doc_from_str_wrong_ns
|
15
|
+
@doc_from_str_ns = Mods::Reader.new.from_str(@example_ns_str)
|
16
|
+
@doc_from_str_no_ns = Mods::Reader.new.from_str(@example_no_ns_str)
|
17
|
+
@doc_from_str_wrong_ns = Mods::Reader.new.from_str(@example_wrong_ns_str)
|
18
18
|
@from_url = Mods::Reader.new.from_url(@example_url)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "from_str should turn an xml string into a Nokogiri::XML::Document object" do
|
22
22
|
expect(@doc_from_str_default_ns).to be_instance_of(Nokogiri::XML::Document)
|
23
|
-
expect(@doc_from_str_ns).to be_instance_of(Nokogiri::XML::Document)
|
24
|
-
expect(@doc_from_str_no_ns).to be_instance_of(Nokogiri::XML::Document)
|
25
|
-
expect(@doc_from_str_wrong_ns).to be_instance_of(Nokogiri::XML::Document)
|
23
|
+
expect(@doc_from_str_ns ).to be_instance_of(Nokogiri::XML::Document)
|
24
|
+
expect(@doc_from_str_no_ns ).to be_instance_of(Nokogiri::XML::Document)
|
25
|
+
expect(@doc_from_str_wrong_ns ).to be_instance_of(Nokogiri::XML::Document)
|
26
26
|
end
|
27
27
|
|
28
28
|
context "from_url" do
|
@@ -48,32 +48,32 @@ describe "Mods::Reader" do
|
|
48
48
|
context "namespace awareness" do
|
49
49
|
it "should care about namespace by default" do
|
50
50
|
r = Mods::Reader.new
|
51
|
-
r.namespace_aware.
|
52
|
-
@doc_from_str_default_ns.root.namespace.href.
|
53
|
-
@doc_from_str_default_ns.xpath('/m:mods/m:note', @ns_hash).text.
|
54
|
-
@doc_from_str_default_ns.xpath('/mods/note').size.
|
55
|
-
@doc_from_str_ns.root.namespace.href.
|
56
|
-
@doc_from_str_ns.xpath('/m:mods/m:note', @ns_hash).text.
|
57
|
-
@doc_from_str_ns.xpath('/mods/note').size.
|
58
|
-
@doc_from_str_no_ns.xpath('/m:mods/m:note', @ns_hash).size.
|
59
|
-
@doc_from_str_no_ns.xpath('/mods/note').text.
|
60
|
-
@doc_from_str_wrong_ns.root.namespace.href.
|
61
|
-
@doc_from_str_wrong_ns.xpath('/m:mods/m:note', @ns_hash).size.
|
62
|
-
@doc_from_str_wrong_ns.xpath('/mods/note').size.
|
51
|
+
expect(r.namespace_aware).to be_truthy
|
52
|
+
expect(@doc_from_str_default_ns.root.namespace.href).to eq(Mods::MODS_NS)
|
53
|
+
expect(@doc_from_str_default_ns.xpath('/m:mods/m:note', @ns_hash).text).to eq("ns")
|
54
|
+
expect(@doc_from_str_default_ns.xpath('/mods/note').size).to eq(0)
|
55
|
+
expect(@doc_from_str_ns.root.namespace.href).to eq(Mods::MODS_NS)
|
56
|
+
expect(@doc_from_str_ns.xpath('/m:mods/m:note', @ns_hash).text).to eq("ns")
|
57
|
+
expect(@doc_from_str_ns.xpath('/mods/note').size).to eq(0)
|
58
|
+
expect(@doc_from_str_no_ns.xpath('/m:mods/m:note', @ns_hash).size).to eq(0)
|
59
|
+
expect(@doc_from_str_no_ns.xpath('/mods/note').text).to eq("no ns")
|
60
|
+
expect(@doc_from_str_wrong_ns.root.namespace.href).to eq("wrong")
|
61
|
+
expect(@doc_from_str_wrong_ns.xpath('/m:mods/m:note', @ns_hash).size).to eq(0)
|
62
|
+
expect(@doc_from_str_wrong_ns.xpath('/mods/note').size).to eq(0)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should be allowed not to care about namespaces" do
|
66
66
|
r = Mods::Reader.new(false)
|
67
|
-
r.namespace_aware.
|
67
|
+
expect(r.namespace_aware).to be_falsey
|
68
68
|
my_from_str_ns = r.from_str(@example_ns_str)
|
69
|
-
my_from_str_ns.xpath('/m:mods/m:note', @ns_hash).size.
|
70
|
-
my_from_str_ns.xpath('/mods/note').text.
|
69
|
+
expect(my_from_str_ns.xpath('/m:mods/m:note', @ns_hash).size).to eq(0)
|
70
|
+
expect(my_from_str_ns.xpath('/mods/note').text).to eq("ns")
|
71
71
|
my_from_str_no_ns = r.from_str(@example_no_ns_str)
|
72
|
-
my_from_str_no_ns.xpath('/m:mods/m:note', @ns_hash).size.
|
73
|
-
my_from_str_no_ns.xpath('/mods/note').text.
|
72
|
+
expect(my_from_str_no_ns.xpath('/m:mods/m:note', @ns_hash).size).to eq(0)
|
73
|
+
expect(my_from_str_no_ns.xpath('/mods/note').text).to eq("no ns")
|
74
74
|
my_from_str_wrong_ns = r.from_str(@example_wrong_ns_str)
|
75
|
-
my_from_str_wrong_ns.xpath('/m:mods/m:note', @ns_hash).size.
|
76
|
-
my_from_str_wrong_ns.xpath('/mods/note').text.
|
75
|
+
expect(my_from_str_wrong_ns.xpath('/m:mods/m:note', @ns_hash).size).to eq(0)
|
76
|
+
expect(my_from_str_wrong_ns.xpath('/mods/note').text).to eq("wrong ns")
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -92,20 +92,20 @@ describe "Mods::Reader" do
|
|
92
92
|
</mods:name>
|
93
93
|
</mods:mods>'
|
94
94
|
reader = Mods::Reader.new.from_str(utf_mods)
|
95
|
-
reader.encoding.
|
95
|
+
expect(reader.encoding).to eql("UTF-8")
|
96
96
|
end
|
97
97
|
it "should remove xsi:schemaLocation attribute from mods element if removing namespaces" do
|
98
98
|
str = '<ns3:mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://www.loc.gov/mods/v3" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
99
|
+
<ns3:note>be very frightened</ns3:note></ns3:mods>'
|
100
|
+
ng_xml = Nokogiri::XML(str)
|
101
|
+
# Nokogiri treats namespaced attributes differently in jruby than in ruby
|
102
|
+
expect(ng_xml.root.has_attribute?('schemaLocation') || ng_xml.root.has_attribute?('xsi:schemaLocation')).to be_truthy
|
103
|
+
r = Mods::Reader.new
|
104
104
|
r.namespace_aware = false
|
105
105
|
r.from_nk_node(ng_xml)
|
106
106
|
# the below are different depending on jruby or ruby ... oy
|
107
|
-
r.mods_ng_xml.root.attributes.keys.
|
108
|
-
r.mods_ng_xml.root.attributes.keys.
|
107
|
+
expect(r.mods_ng_xml.root.attributes.keys).not_to include('schemaLocation')
|
108
|
+
expect(r.mods_ng_xml.root.attributes.keys).not_to include('xsi:schemaLocation')
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -137,16 +137,17 @@ describe "Mods::Reader" do
|
|
137
137
|
@mods_ng_doc = @r.from_nk_node(@mods_node)
|
138
138
|
end
|
139
139
|
it "should turn the Nokogiri::XML::Node into a Nokogiri::XML::Document object" do
|
140
|
-
@mods_ng_doc.
|
140
|
+
expect(@mods_ng_doc).to be_kind_of(Nokogiri::XML::Document)
|
141
141
|
end
|
142
142
|
it "should care about namespace by default" do
|
143
|
-
@mods_ng_doc.xpath('/m:mods/m:titleInfo/m:title', @ns_hash).text.
|
143
|
+
expect(@mods_ng_doc.xpath('/m:mods/m:titleInfo/m:title', @ns_hash).text).to eq("boo")
|
144
144
|
end
|
145
145
|
it "should be able not to care about namespaces" do
|
146
146
|
@r.namespace_aware = false
|
147
147
|
mods_ng_doc = @r.from_nk_node(@mods_node)
|
148
|
-
mods_ng_doc.
|
149
|
-
mods_ng_doc.xpath('/mods/titleInfo/title').
|
148
|
+
expect(mods_ng_doc).to be_kind_of(Nokogiri::XML::Document)
|
149
|
+
expect(mods_ng_doc.xpath('/m:mods/m:titleInfo/m:title', @ns_hash).size).to eq(0)
|
150
|
+
expect(mods_ng_doc.xpath('/mods/titleInfo/title').text).to eq("boo")
|
150
151
|
@r.namespace_aware = true
|
151
152
|
end
|
152
153
|
end # context from_nk_node
|
data/spec/record_info_spec.rb
CHANGED
@@ -51,153 +51,153 @@ describe "Mods <recordInfo> Element" do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should be a NodeSet" do
|
54
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.
|
54
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
55
55
|
end
|
56
56
|
it "should have as many members as there are <recordInfo> elements in the xml" do
|
57
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.size.
|
57
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.size).to eq(1) }
|
58
58
|
end
|
59
59
|
it "should recognize language attributes on <recordInfo> element" do
|
60
60
|
skip "problem with xml:lang"
|
61
61
|
Mods::LANG_ATTRIBS.each { |a|
|
62
62
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo #{a}='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>")
|
63
|
-
@mods_rec.record_info.send(a.to_sym).
|
63
|
+
expect(@mods_rec.record_info.send(a.to_sym)).to eq(['val'])
|
64
64
|
}
|
65
65
|
end
|
66
66
|
it "should recognize displayLabel attribute on <recordInfo> element" do
|
67
67
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo displayLabel='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>")
|
68
|
-
@mods_rec.record_info.displayLabel.
|
68
|
+
expect(@mods_rec.record_info.displayLabel).to eq(['val'])
|
69
69
|
end
|
70
70
|
|
71
71
|
context "<recordContentSource> child element" do
|
72
72
|
it "should be a NodeSet" do
|
73
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordContentSource.
|
73
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordContentSource).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
74
74
|
end
|
75
75
|
it "recordContentSource NodeSet should have as many Nodes as there are <recordContentSource> elements in the xml" do
|
76
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordContentSource.size.
|
76
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordContentSource.size).to eq(1) }
|
77
77
|
end
|
78
78
|
it "text should get element value" do
|
79
|
-
@rec_info.recordContentSource.map { |n| n.text }.
|
80
|
-
@rec_info2.recordContentSource.map { |n| n.text }.
|
81
|
-
@bnf.recordContentSource.map { |n| n.text }.
|
82
|
-
@rlin.recordContentSource.map { |n| n.text }.
|
79
|
+
expect(@rec_info.recordContentSource.map { |n| n.text }).to eq(["RQE"])
|
80
|
+
expect(@rec_info2.recordContentSource.map { |n| n.text }).to eq(["AU@"])
|
81
|
+
expect(@bnf.recordContentSource.map { |n| n.text }).to eq(["TEI Description"])
|
82
|
+
expect(@rlin.recordContentSource.map { |n| n.text }).to eq(["CSt"])
|
83
83
|
end
|
84
84
|
it "should recognize authority attribute" do
|
85
|
-
[@rec_info, @rec_info2, @rlin].each { |ri| ri.recordContentSource.authority.
|
86
|
-
@bnf.recordContentSource.authority.size.
|
85
|
+
[@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordContentSource.authority).to eq(['marcorg']) }
|
86
|
+
expect(@bnf.recordContentSource.authority.size).to eq(0)
|
87
87
|
end
|
88
88
|
it "should recognize all authority attributes" do
|
89
89
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
90
90
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><recordContentSource #{a}='attr_val'>zzz</recordContentSource></recordInfo></mods>")
|
91
|
-
@mods_rec.record_info.recordContentSource.send(a.to_sym).
|
91
|
+
expect(@mods_rec.record_info.recordContentSource.send(a.to_sym)).to eq(['attr_val'])
|
92
92
|
}
|
93
93
|
end
|
94
94
|
end # <recordContentSource>
|
95
95
|
|
96
96
|
context "<recordCreationDate> child element" do
|
97
97
|
it "should be a NodeSet" do
|
98
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordCreationDate.
|
98
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordCreationDate).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
99
99
|
end
|
100
100
|
it "recordCreationDate NodeSet should have as many Nodes as there are <recordCreationDate> elements in the xml" do
|
101
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordCreationDate.size.
|
101
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordCreationDate.size).to eq(1) }
|
102
102
|
end
|
103
103
|
it "text should get element value" do
|
104
|
-
@rec_info.recordCreationDate.map { |n| n.text }.
|
105
|
-
@rec_info2.recordCreationDate.map { |n| n.text }.
|
106
|
-
@bnf.recordCreationDate.map { |n| n.text }.
|
107
|
-
@rlin.recordCreationDate.map { |n| n.text }.
|
104
|
+
expect(@rec_info.recordCreationDate.map { |n| n.text }).to eq(['890517'])
|
105
|
+
expect(@rec_info2.recordCreationDate.map { |n| n.text }).to eq(['050921'])
|
106
|
+
expect(@bnf.recordCreationDate.map { |n| n.text }).to eq(['2011-12-07'])
|
107
|
+
expect(@rlin.recordCreationDate.map { |n| n.text }).to eq(['850416'])
|
108
108
|
end
|
109
109
|
it "should recognize encoding attribute" do
|
110
|
-
[@rec_info, @rec_info2, @rlin].each { |ri| ri.recordCreationDate.encoding.
|
111
|
-
@bnf.recordCreationDate.encoding.
|
110
|
+
[@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordCreationDate.encoding).to eq(['marc']) }
|
111
|
+
expect(@bnf.recordCreationDate.encoding).to eq(['w3cdtf'])
|
112
112
|
end
|
113
113
|
it "should recognize all date attributes" do
|
114
114
|
Mods::DATE_ATTRIBS.each { |a|
|
115
115
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><recordCreationDate #{a}='attr_val'>zzz</recordCreationDate></recordInfo></mods>")
|
116
|
-
@mods_rec.record_info.recordCreationDate.send(a.to_sym).
|
116
|
+
expect(@mods_rec.record_info.recordCreationDate.send(a.to_sym)).to eq(['attr_val'])
|
117
117
|
}
|
118
118
|
end
|
119
119
|
end # <recordCreationDate>
|
120
120
|
|
121
121
|
context "<recordChangeDate> child element" do
|
122
122
|
it "should be a NodeSet" do
|
123
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordChangeDate.
|
123
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordChangeDate).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
124
124
|
end
|
125
125
|
it "recordChangeDate NodeSet should have as many Nodes as there are <recordChangeDate> elements in the xml" do
|
126
|
-
[@rec_info, @rec_info2, @bnf].each { |ri| ri.recordChangeDate.size.
|
127
|
-
@rlin.recordChangeDate.size.
|
126
|
+
[@rec_info, @rec_info2, @bnf].each { |ri| expect(ri.recordChangeDate.size).to eq(0) }
|
127
|
+
expect(@rlin.recordChangeDate.size).to eq(1)
|
128
128
|
end
|
129
129
|
it "text should get element value" do
|
130
|
-
@rlin.recordChangeDate.map { |n| n.text }.
|
130
|
+
expect(@rlin.recordChangeDate.map { |n| n.text }).to eq(['19991012150824.0'])
|
131
131
|
end
|
132
132
|
it "should recognize encoding attribute" do
|
133
|
-
@rlin.recordChangeDate.encoding.
|
133
|
+
expect(@rlin.recordChangeDate.encoding).to eq(['iso8601'])
|
134
134
|
end
|
135
135
|
it "should recognize all date attributes" do
|
136
136
|
Mods::DATE_ATTRIBS.each { |a|
|
137
137
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><recordChangeDate #{a}='attr_val'>zzz</recordChangeDate></recordInfo></mods>")
|
138
|
-
@mods_rec.record_info.recordChangeDate.send(a.to_sym).
|
138
|
+
expect(@mods_rec.record_info.recordChangeDate.send(a.to_sym)).to eq(['attr_val'])
|
139
139
|
}
|
140
140
|
end
|
141
141
|
end # <recordChangeDate>
|
142
142
|
|
143
143
|
context "<recordIdentifier> child element" do
|
144
144
|
it "should be a NodeSet" do
|
145
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordIdentifier.
|
145
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordIdentifier).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
146
146
|
end
|
147
147
|
it "recordIdentifier NodeSet should have as many Nodes as there are <recordIdentifier> elements in the xml" do
|
148
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordIdentifier.size.
|
148
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordIdentifier.size).to eq(1) }
|
149
149
|
end
|
150
150
|
it "text should get element value" do
|
151
|
-
@rec_info.recordIdentifier.map { |n| n.text }.
|
152
|
-
@rec_info2.recordIdentifier.map { |n| n.text }.
|
153
|
-
@bnf.recordIdentifier.map { |n| n.text }.
|
154
|
-
@rlin.recordIdentifier.map { |n| n.text }.
|
151
|
+
expect(@rec_info.recordIdentifier.map { |n| n.text }).to eq(['a9079953'])
|
152
|
+
expect(@rec_info2.recordIdentifier.map { |n| n.text }).to eq(['a8837534'])
|
153
|
+
expect(@bnf.recordIdentifier.map { |n| n.text }).to eq([''])
|
154
|
+
expect(@rlin.recordIdentifier.map { |n| n.text }).to eq(['a4083219'])
|
155
155
|
end
|
156
156
|
it "should recognize source attribute" do
|
157
|
-
[@rec_info, @rec_info2].each { |ri| ri.recordIdentifier.source.
|
158
|
-
@bnf.recordIdentifier.source.
|
159
|
-
@rlin.recordIdentifier.source.
|
157
|
+
[@rec_info, @rec_info2].each { |ri| expect(ri.recordIdentifier.source).to eq(['SIRSI']) }
|
158
|
+
expect(@bnf.recordIdentifier.source).to eq(['BNF 2166'])
|
159
|
+
expect(@rlin.recordIdentifier.source).to eq(['CStRLIN'])
|
160
160
|
end
|
161
161
|
it "should allow a source attribute without element content" do
|
162
|
-
@bnf.recordIdentifier.source.
|
163
|
-
@bnf.recordIdentifier.map { |n| n.text }.
|
162
|
+
expect(@bnf.recordIdentifier.source).to eq(['BNF 2166'])
|
163
|
+
expect(@bnf.recordIdentifier.map { |n| n.text }).to eq([''])
|
164
164
|
end
|
165
165
|
end # <recordIdentifier>
|
166
166
|
|
167
167
|
context "<recordOrigin> child element" do
|
168
168
|
it "should be a NodeSet" do
|
169
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordOrigin.
|
169
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordOrigin).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
170
170
|
end
|
171
171
|
it "recordOrigin NodeSet should have as many Nodes as there are <recordOrigin> elements in the xml" do
|
172
|
-
[@rec_info, @rec_info2, @rlin].each { |ri| ri.recordOrigin.size.
|
173
|
-
@bnf.recordOrigin.size.
|
172
|
+
[@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordOrigin.size).to eq(0) }
|
173
|
+
expect(@bnf.recordOrigin.size).to eq(1)
|
174
174
|
end
|
175
175
|
it "text should get element value" do
|
176
176
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><recordOrigin>human prepared</recordOrigin></recordInfo></mods>")
|
177
|
-
@mods_rec.record_info.recordOrigin.map {|n| n.text }.
|
178
|
-
@bnf.recordOrigin.map { |n| n.text }.
|
177
|
+
expect(@mods_rec.record_info.recordOrigin.map {|n| n.text }).to eq(['human prepared'])
|
178
|
+
expect(@bnf.recordOrigin.map { |n| n.text }).to eq([''])
|
179
179
|
end
|
180
180
|
end # <recordOrigin>
|
181
181
|
|
182
182
|
context "<languageOfCataloging> child element" do
|
183
183
|
it "should be a NodeSet" do
|
184
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.languageOfCataloging.
|
184
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.languageOfCataloging).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
185
185
|
end
|
186
186
|
it "languageOfCataloging NodeSet should have as many Nodes as there are <languageOfCataloging> elements in the xml" do
|
187
|
-
[@rec_info2, @bnf].each { |ri| ri.languageOfCataloging.size.
|
188
|
-
[@rec_info, @rlin].each { |ri| ri.languageOfCataloging.size.
|
187
|
+
[@rec_info2, @bnf].each { |ri| expect(ri.languageOfCataloging.size).to eq(1) }
|
188
|
+
[@rec_info, @rlin].each { |ri| expect(ri.languageOfCataloging.size).to eq(0) }
|
189
189
|
end
|
190
190
|
it "text should get element value" do
|
191
191
|
# this example is from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html
|
192
192
|
# though it doesn't match the doc at http://www.loc.gov/standards/mods/mods-outline.html#recordInfo
|
193
193
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><languageOfCataloging authority='iso639-2b'>fre</languageOfCataloging></recordInfo></mods>")
|
194
|
-
@mods_rec.record_info.languageOfCataloging.map { |n| n.text }.
|
194
|
+
expect(@mods_rec.record_info.languageOfCataloging.map { |n| n.text }).to eq(['fre'])
|
195
195
|
end
|
196
196
|
it "authority should get attribute value" do
|
197
197
|
# this example is from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html
|
198
198
|
# though it doesn't match the doc at http://www.loc.gov/standards/mods/mods-outline.html#recordInfo
|
199
199
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><languageOfCataloging authority='iso639-2b'>fre</languageOfCataloging></recordInfo></mods>")
|
200
|
-
@mods_rec.record_info.languageOfCataloging.authority.
|
200
|
+
expect(@mods_rec.record_info.languageOfCataloging.authority).to eq(['iso639-2b'])
|
201
201
|
end
|
202
202
|
|
203
203
|
# from http://www.loc.gov/standards/mods/userguide/recordinfo.html#languageofcataloging
|
@@ -208,17 +208,17 @@ describe "Mods <recordInfo> Element" do
|
|
208
208
|
|
209
209
|
context "<languageTerm> child element" do
|
210
210
|
it "text should get element value" do
|
211
|
-
@rec_info2.languageOfCataloging.languageTerm.map { |n| n.text }.
|
212
|
-
@bnf.languageOfCataloging.languageTerm.map { |n| n.text }.
|
211
|
+
expect(@rec_info2.languageOfCataloging.languageTerm.map { |n| n.text }).to eq(['eng'])
|
212
|
+
expect(@bnf.languageOfCataloging.languageTerm.map { |n| n.text }).to eq(['fra'])
|
213
213
|
end
|
214
214
|
it "should recognize all authority attributes" do
|
215
215
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
216
216
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><languageOfCataloging><languageTerm #{a}='attr_val'>zzz</languageTerm></languageOfCataloging></recordInfo></mods>")
|
217
|
-
@mods_rec.record_info.languageOfCataloging.languageTerm.send(a.to_sym).
|
217
|
+
expect(@mods_rec.record_info.languageOfCataloging.languageTerm.send(a.to_sym)).to eq(['attr_val'])
|
218
218
|
}
|
219
219
|
end
|
220
220
|
it "should recognize the type attribute with type_at term" do
|
221
|
-
@rec_info2.languageOfCataloging.languageTerm.type_at.
|
221
|
+
expect(@rec_info2.languageOfCataloging.languageTerm.type_at).to eq(['code'])
|
222
222
|
end
|
223
223
|
end # <languageTerm>
|
224
224
|
|
@@ -231,21 +231,21 @@ describe "Mods <recordInfo> Element" do
|
|
231
231
|
|
232
232
|
context "<descriptionStandard> child element" do
|
233
233
|
it "should be a NodeSet" do
|
234
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.descriptionStandard.
|
234
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.descriptionStandard).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
235
235
|
end
|
236
236
|
it "descriptionStandard NodeSet should have as many Nodes as there are <descriptionStandard> elements in the xml" do
|
237
|
-
[@rec_info, @bnf].each { |ri| ri.descriptionStandard.size.
|
238
|
-
[@rec_info2, @rlin].each { |ri| ri.descriptionStandard.size.
|
237
|
+
[@rec_info, @bnf].each { |ri| expect(ri.descriptionStandard.size).to eq(0) }
|
238
|
+
[@rec_info2, @rlin].each { |ri| expect(ri.descriptionStandard.size).to eq(1) }
|
239
239
|
end
|
240
240
|
it "text should get element value" do
|
241
|
-
@rec_info2.descriptionStandard.map { |n| n.text }.
|
242
|
-
@rlin.descriptionStandard.map { |n| n.text }.
|
243
|
-
@bnf.descriptionStandard.map { |n| n.text }.
|
241
|
+
expect(@rec_info2.descriptionStandard.map { |n| n.text }).to eq(['aacr2'])
|
242
|
+
expect(@rlin.descriptionStandard.map { |n| n.text }).to eq(['appm'])
|
243
|
+
expect(@bnf.descriptionStandard.map { |n| n.text }).to eq([])
|
244
244
|
end
|
245
245
|
it "should recognize all authority attributes" do
|
246
246
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
247
247
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><descriptionStandard #{a}='attr_val'>zzz</descriptionStandard></recordInfo></mods>")
|
248
|
-
@mods_rec.record_info.descriptionStandard.send(a.to_sym).
|
248
|
+
expect(@mods_rec.record_info.descriptionStandard.send(a.to_sym)).to eq(['attr_val'])
|
249
249
|
}
|
250
250
|
end
|
251
251
|
end # <descriptionStandard>
|
@@ -287,153 +287,153 @@ describe "Mods <recordInfo> Element" do
|
|
287
287
|
end
|
288
288
|
|
289
289
|
it "should be a NodeSet" do
|
290
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.
|
290
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
291
291
|
end
|
292
292
|
it "should have as many members as there are <recordInfo> elements in the xml" do
|
293
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.size.
|
293
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.size).to eq(1) }
|
294
294
|
end
|
295
295
|
it "should recognize language attributes on <recordInfo> element" do
|
296
296
|
skip "problem with xml:lang"
|
297
297
|
Mods::LANG_ATTRIBS.each { |a|
|
298
298
|
@mods_rec.from_str("<mods><recordInfo #{a}='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>", false)
|
299
|
-
@mods_rec.record_info.send(a.to_sym).
|
299
|
+
expect(@mods_rec.record_info.send(a.to_sym)).to eq(['val'])
|
300
300
|
}
|
301
301
|
end
|
302
302
|
it "should recognize displayLabel attribute on <recordInfo> element" do
|
303
303
|
@mods_rec.from_str("<mods><recordInfo displayLabel='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>", false)
|
304
|
-
@mods_rec.record_info.displayLabel.
|
304
|
+
expect(@mods_rec.record_info.displayLabel).to eq(['val'])
|
305
305
|
end
|
306
306
|
|
307
307
|
context "<recordContentSource> child element" do
|
308
308
|
it "should be a NodeSet" do
|
309
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordContentSource.
|
309
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordContentSource).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
310
310
|
end
|
311
311
|
it "recordContentSource NodeSet should have as many Nodes as there are <recordContentSource> elements in the xml" do
|
312
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordContentSource.size.
|
312
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordContentSource.size).to eq(1) }
|
313
313
|
end
|
314
314
|
it "text should get element value" do
|
315
|
-
@rec_info.recordContentSource.map { |n| n.text }.
|
316
|
-
@rec_info2.recordContentSource.map { |n| n.text }.
|
317
|
-
@bnf.recordContentSource.map { |n| n.text }.
|
318
|
-
@rlin.recordContentSource.map { |n| n.text }.
|
315
|
+
expect(@rec_info.recordContentSource.map { |n| n.text }).to eq(["RQE"])
|
316
|
+
expect(@rec_info2.recordContentSource.map { |n| n.text }).to eq(["AU@"])
|
317
|
+
expect(@bnf.recordContentSource.map { |n| n.text }).to eq(["TEI Description"])
|
318
|
+
expect(@rlin.recordContentSource.map { |n| n.text }).to eq(["CSt"])
|
319
319
|
end
|
320
320
|
it "should recognize authority attribute" do
|
321
|
-
[@rec_info, @rec_info2, @rlin].each { |ri| ri.recordContentSource.authority.
|
322
|
-
@bnf.recordContentSource.authority.size.
|
321
|
+
[@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordContentSource.authority).to eq(['marcorg']) }
|
322
|
+
expect(@bnf.recordContentSource.authority.size).to eq(0)
|
323
323
|
end
|
324
324
|
it "should recognize all authority attributes" do
|
325
325
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
326
326
|
@mods_rec.from_str("<mods><recordInfo><recordContentSource #{a}='attr_val'>zzz</recordContentSource></recordInfo></mods>", false)
|
327
|
-
@mods_rec.record_info.recordContentSource.send(a.to_sym).
|
327
|
+
expect(@mods_rec.record_info.recordContentSource.send(a.to_sym)).to eq(['attr_val'])
|
328
328
|
}
|
329
329
|
end
|
330
330
|
end # <recordContentSource>
|
331
331
|
|
332
332
|
context "<recordCreationDate> child element" do
|
333
333
|
it "should be a NodeSet" do
|
334
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordCreationDate.
|
334
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordCreationDate).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
335
335
|
end
|
336
336
|
it "recordCreationDate NodeSet should have as many Nodes as there are <recordCreationDate> elements in the xml" do
|
337
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordCreationDate.size.
|
337
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordCreationDate.size).to eq(1) }
|
338
338
|
end
|
339
339
|
it "text should get element value" do
|
340
|
-
@rec_info.recordCreationDate.map { |n| n.text }.
|
341
|
-
@rec_info2.recordCreationDate.map { |n| n.text }.
|
342
|
-
@bnf.recordCreationDate.map { |n| n.text }.
|
343
|
-
@rlin.recordCreationDate.map { |n| n.text }.
|
340
|
+
expect(@rec_info.recordCreationDate.map { |n| n.text }).to eq(['890517'])
|
341
|
+
expect(@rec_info2.recordCreationDate.map { |n| n.text }).to eq(['050921'])
|
342
|
+
expect(@bnf.recordCreationDate.map { |n| n.text }).to eq(['2011-12-07'])
|
343
|
+
expect(@rlin.recordCreationDate.map { |n| n.text }).to eq(['850416'])
|
344
344
|
end
|
345
345
|
it "should recognize encoding attribute" do
|
346
|
-
[@rec_info, @rec_info2, @rlin].each { |ri| ri.recordCreationDate.encoding.
|
347
|
-
@bnf.recordCreationDate.encoding.
|
346
|
+
[@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordCreationDate.encoding).to eq(['marc']) }
|
347
|
+
expect(@bnf.recordCreationDate.encoding).to eq(['w3cdtf'])
|
348
348
|
end
|
349
349
|
it "should recognize all date attributes" do
|
350
350
|
Mods::DATE_ATTRIBS.each { |a|
|
351
351
|
@mods_rec.from_str("<mods><recordInfo><recordCreationDate #{a}='attr_val'>zzz</recordCreationDate></recordInfo></mods>", false)
|
352
|
-
@mods_rec.record_info.recordCreationDate.send(a.to_sym).
|
352
|
+
expect(@mods_rec.record_info.recordCreationDate.send(a.to_sym)).to eq(['attr_val'])
|
353
353
|
}
|
354
354
|
end
|
355
355
|
end # <recordCreationDate>
|
356
356
|
|
357
357
|
context "<recordChangeDate> child element" do
|
358
358
|
it "should be a NodeSet" do
|
359
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordChangeDate.
|
359
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordChangeDate).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
360
360
|
end
|
361
361
|
it "recordChangeDate NodeSet should have as many Nodes as there are <recordChangeDate> elements in the xml" do
|
362
|
-
[@rec_info, @rec_info2, @bnf].each { |ri| ri.recordChangeDate.size.
|
363
|
-
@rlin.recordChangeDate.size.
|
362
|
+
[@rec_info, @rec_info2, @bnf].each { |ri| expect(ri.recordChangeDate.size).to eq(0) }
|
363
|
+
expect(@rlin.recordChangeDate.size).to eq(1)
|
364
364
|
end
|
365
365
|
it "text should get element value" do
|
366
|
-
@rlin.recordChangeDate.map { |n| n.text }.
|
366
|
+
expect(@rlin.recordChangeDate.map { |n| n.text }).to eq(['19991012150824.0'])
|
367
367
|
end
|
368
368
|
it "should recognize encoding attribute" do
|
369
|
-
@rlin.recordChangeDate.encoding.
|
369
|
+
expect(@rlin.recordChangeDate.encoding).to eq(['iso8601'])
|
370
370
|
end
|
371
371
|
it "should recognize all date attributes" do
|
372
372
|
Mods::DATE_ATTRIBS.each { |a|
|
373
373
|
@mods_rec.from_str("<mods><recordInfo><recordChangeDate #{a}='attr_val'>zzz</recordChangeDate></recordInfo></mods>", false)
|
374
|
-
@mods_rec.record_info.recordChangeDate.send(a.to_sym).
|
374
|
+
expect(@mods_rec.record_info.recordChangeDate.send(a.to_sym)).to eq(['attr_val'])
|
375
375
|
}
|
376
376
|
end
|
377
377
|
end # <recordChangeDate>
|
378
378
|
|
379
379
|
context "<recordIdentifier> child element" do
|
380
380
|
it "should be a NodeSet" do
|
381
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordIdentifier.
|
381
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordIdentifier).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
382
382
|
end
|
383
383
|
it "recordIdentifier NodeSet should have as many Nodes as there are <recordIdentifier> elements in the xml" do
|
384
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordIdentifier.size.
|
384
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordIdentifier.size).to eq(1) }
|
385
385
|
end
|
386
386
|
it "text should get element value" do
|
387
|
-
@rec_info.recordIdentifier.map { |n| n.text }.
|
388
|
-
@rec_info2.recordIdentifier.map { |n| n.text }.
|
389
|
-
@bnf.recordIdentifier.map { |n| n.text }.
|
390
|
-
@rlin.recordIdentifier.map { |n| n.text }.
|
387
|
+
expect(@rec_info.recordIdentifier.map { |n| n.text }).to eq(['a9079953'])
|
388
|
+
expect(@rec_info2.recordIdentifier.map { |n| n.text }).to eq(['a8837534'])
|
389
|
+
expect(@bnf.recordIdentifier.map { |n| n.text }).to eq([''])
|
390
|
+
expect(@rlin.recordIdentifier.map { |n| n.text }).to eq(['a4083219'])
|
391
391
|
end
|
392
392
|
it "should recognize source attribute" do
|
393
|
-
[@rec_info, @rec_info2].each { |ri| ri.recordIdentifier.source.
|
394
|
-
@bnf.recordIdentifier.source.
|
395
|
-
@rlin.recordIdentifier.source.
|
393
|
+
[@rec_info, @rec_info2].each { |ri| expect(ri.recordIdentifier.source).to eq(['SIRSI']) }
|
394
|
+
expect(@bnf.recordIdentifier.source).to eq(['BNF 2166'])
|
395
|
+
expect(@rlin.recordIdentifier.source).to eq(['CStRLIN'])
|
396
396
|
end
|
397
397
|
it "should allow a source attribute without element content" do
|
398
|
-
@bnf.recordIdentifier.source.
|
399
|
-
@bnf.recordIdentifier.map { |n| n.text }.
|
398
|
+
expect(@bnf.recordIdentifier.source).to eq(['BNF 2166'])
|
399
|
+
expect(@bnf.recordIdentifier.map { |n| n.text }).to eq([''])
|
400
400
|
end
|
401
401
|
end # <recordIdentifier>
|
402
402
|
|
403
403
|
context "<recordOrigin> child element" do
|
404
404
|
it "should be a NodeSet" do
|
405
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.recordOrigin.
|
405
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.recordOrigin).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
406
406
|
end
|
407
407
|
it "recordOrigin NodeSet should have as many Nodes as there are <recordOrigin> elements in the xml" do
|
408
|
-
[@rec_info, @rec_info2, @rlin].each { |ri| ri.recordOrigin.size.
|
409
|
-
@bnf.recordOrigin.size.
|
408
|
+
[@rec_info, @rec_info2, @rlin].each { |ri| expect(ri.recordOrigin.size).to eq(0) }
|
409
|
+
expect(@bnf.recordOrigin.size).to eq(1)
|
410
410
|
end
|
411
411
|
it "text should get element value" do
|
412
412
|
@mods_rec.from_str("<mods><recordInfo><recordOrigin>human prepared</recordOrigin></recordInfo></mods>", false)
|
413
|
-
@mods_rec.record_info.recordOrigin.map {|n| n.text }.
|
414
|
-
@bnf.recordOrigin.map { |n| n.text }.
|
413
|
+
expect(@mods_rec.record_info.recordOrigin.map {|n| n.text }).to eq(['human prepared'])
|
414
|
+
expect(@bnf.recordOrigin.map { |n| n.text }).to eq([''])
|
415
415
|
end
|
416
416
|
end # <recordOrigin>
|
417
417
|
|
418
418
|
context "<languageOfCataloging> child element" do
|
419
419
|
it "should be a NodeSet" do
|
420
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.languageOfCataloging.
|
420
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.languageOfCataloging).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
421
421
|
end
|
422
422
|
it "languageOfCataloging NodeSet should have as many Nodes as there are <languageOfCataloging> elements in the xml" do
|
423
|
-
[@rec_info2, @bnf].each { |ri| ri.languageOfCataloging.size.
|
424
|
-
[@rec_info, @rlin].each { |ri| ri.languageOfCataloging.size.
|
423
|
+
[@rec_info2, @bnf].each { |ri| expect(ri.languageOfCataloging.size).to eq(1) }
|
424
|
+
[@rec_info, @rlin].each { |ri| expect(ri.languageOfCataloging.size).to eq(0) }
|
425
425
|
end
|
426
426
|
it "text should get element value" do
|
427
427
|
# this example is from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html
|
428
428
|
# though it doesn't match the doc at http://www.loc.gov/standards/mods/mods-outline.html#recordInfo
|
429
429
|
@mods_rec.from_str("<mods><recordInfo><languageOfCataloging authority='iso639-2b'>fre</languageOfCataloging></recordInfo></mods>", false)
|
430
|
-
@mods_rec.record_info.languageOfCataloging.map { |n| n.text }.
|
430
|
+
expect(@mods_rec.record_info.languageOfCataloging.map { |n| n.text }).to eq(['fre'])
|
431
431
|
end
|
432
432
|
it "authority should get attribute value" do
|
433
433
|
# this example is from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html
|
434
434
|
# though it doesn't match the doc at http://www.loc.gov/standards/mods/mods-outline.html#recordInfo
|
435
435
|
@mods_rec.from_str("<mods><recordInfo><languageOfCataloging authority='iso639-2b'>fre</languageOfCataloging></recordInfo></mods>", false)
|
436
|
-
@mods_rec.record_info.languageOfCataloging.authority.
|
436
|
+
expect(@mods_rec.record_info.languageOfCataloging.authority).to eq(['iso639-2b'])
|
437
437
|
end
|
438
438
|
|
439
439
|
# from http://www.loc.gov/standards/mods/userguide/recordinfo.html#languageofcataloging
|
@@ -444,17 +444,17 @@ describe "Mods <recordInfo> Element" do
|
|
444
444
|
|
445
445
|
context "<languageTerm> child element" do
|
446
446
|
it "text should get element value" do
|
447
|
-
@rec_info2.languageOfCataloging.languageTerm.map { |n| n.text }.
|
448
|
-
@bnf.languageOfCataloging.languageTerm.map { |n| n.text }.
|
447
|
+
expect(@rec_info2.languageOfCataloging.languageTerm.map { |n| n.text }).to eq(['eng'])
|
448
|
+
expect(@bnf.languageOfCataloging.languageTerm.map { |n| n.text }).to eq(['fra'])
|
449
449
|
end
|
450
450
|
it "should recognize all authority attributes" do
|
451
451
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
452
452
|
@mods_rec.from_str("<mods><recordInfo><languageOfCataloging><languageTerm #{a}='attr_val'>zzz</languageTerm></languageOfCataloging></recordInfo></mods>", false)
|
453
|
-
@mods_rec.record_info.languageOfCataloging.languageTerm.send(a.to_sym).
|
453
|
+
expect(@mods_rec.record_info.languageOfCataloging.languageTerm.send(a.to_sym)).to eq(['attr_val'])
|
454
454
|
}
|
455
455
|
end
|
456
456
|
it "should recognize the type attribute with type_at term" do
|
457
|
-
@rec_info2.languageOfCataloging.languageTerm.type_at.
|
457
|
+
expect(@rec_info2.languageOfCataloging.languageTerm.type_at).to eq(['code'])
|
458
458
|
end
|
459
459
|
end # <languageTerm>
|
460
460
|
|
@@ -467,21 +467,21 @@ describe "Mods <recordInfo> Element" do
|
|
467
467
|
|
468
468
|
context "<descriptionStandard> child element" do
|
469
469
|
it "should be a NodeSet" do
|
470
|
-
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.descriptionStandard.
|
470
|
+
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| expect(ri.descriptionStandard).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
471
471
|
end
|
472
472
|
it "descriptionStandard NodeSet should have as many Nodes as there are <descriptionStandard> elements in the xml" do
|
473
|
-
[@rec_info, @bnf].each { |ri| ri.descriptionStandard.size.
|
474
|
-
[@rec_info2, @rlin].each { |ri| ri.descriptionStandard.size.
|
473
|
+
[@rec_info, @bnf].each { |ri| expect(ri.descriptionStandard.size).to eq(0) }
|
474
|
+
[@rec_info2, @rlin].each { |ri| expect(ri.descriptionStandard.size).to eq(1) }
|
475
475
|
end
|
476
476
|
it "text should get element value" do
|
477
|
-
@rec_info2.descriptionStandard.map { |n| n.text }.
|
478
|
-
@rlin.descriptionStandard.map { |n| n.text }.
|
479
|
-
@bnf.descriptionStandard.map { |n| n.text }.
|
477
|
+
expect(@rec_info2.descriptionStandard.map { |n| n.text }).to eq(['aacr2'])
|
478
|
+
expect(@rlin.descriptionStandard.map { |n| n.text }).to eq(['appm'])
|
479
|
+
expect(@bnf.descriptionStandard.map { |n| n.text }).to eq([])
|
480
480
|
end
|
481
481
|
it "should recognize all authority attributes" do
|
482
482
|
Mods::AUTHORITY_ATTRIBS.each { |a|
|
483
483
|
@mods_rec.from_str("<mods><recordInfo><descriptionStandard #{a}='attr_val'>zzz</descriptionStandard></recordInfo></mods>", false)
|
484
|
-
@mods_rec.record_info.descriptionStandard.send(a.to_sym).
|
484
|
+
expect(@mods_rec.record_info.descriptionStandard.send(a.to_sym)).to eq(['attr_val'])
|
485
485
|
}
|
486
486
|
end
|
487
487
|
end # <descriptionStandard>
|