mods 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mods/reader.rb CHANGED
@@ -19,7 +19,6 @@ module Mods
19
19
  def from_str(str)
20
20
  @mods_ng_xml = Nokogiri::XML(str, nil, str.encoding.to_s)
21
21
  normalize_mods
22
- @mods_ng_xml
23
22
  end
24
23
 
25
24
  # Read in the contents of a Mods file from a url.
@@ -31,7 +30,6 @@ module Mods
31
30
  require 'open-uri'
32
31
  @mods_ng_xml = Nokogiri::XML(open(url).read)
33
32
  normalize_mods
34
- @mods_ng_xml
35
33
  end
36
34
 
37
35
  # Read in the contents of a Mods record from a file.
@@ -44,7 +42,6 @@ module Mods
44
42
  @mods_ng_xml = Nokogiri::XML(file)
45
43
  file.close
46
44
  normalize_mods
47
- @mods_ng_xml
48
45
  end
49
46
 
50
47
  # @param node (Nokogiri::XML::Node) - Nokogiri::XML::Node that is the top level element of a mods record
@@ -52,10 +49,10 @@ module Mods
52
49
  def from_nk_node(node)
53
50
  @mods_ng_xml = Nokogiri::XML(node.to_s, nil, node.document.encoding)
54
51
  normalize_mods
55
- @mods_ng_xml
56
52
  end
57
53
 
58
54
  # Whatever we get, normalize it into a Nokogiri::XML::Document,
55
+ # @return mods_ng_xml (Nokogiri::XML::Document) normalized doc
59
56
  def normalize_mods
60
57
  if !@namespace_aware
61
58
  @mods_ng_xml.remove_namespaces!
@@ -68,6 +65,7 @@ module Mods
68
65
  # @mods_ng_xml = Nokogiri::XML(@mods_ng_xml.to_s, nil, @mods_ng_xml.encoding, Nokogiri::XML::ParseOptions::PEDANTIC)
69
66
  @mods_ng_xml = Nokogiri::XML(@mods_ng_xml.to_s, nil, @mods_ng_xml.encoding)
70
67
  end
68
+ @mods_ng_xml
71
69
  end
72
70
 
73
71
  end # class
data/lib/mods/record.rb CHANGED
@@ -24,6 +24,7 @@ module Mods
24
24
  # convenience method to call Mods::Reader.new.from_str and to nom
25
25
  # @param ns_aware true if the XML parsing should be strict about using namespaces. Default is true
26
26
  # @param str - a string containing mods xml
27
+ # @return Mods::Record
27
28
  def from_str(str, ns_aware = true)
28
29
  @mods_ng_xml = Mods::Reader.new(ns_aware).from_str(str)
29
30
  if ns_aware
@@ -31,6 +32,7 @@ module Mods
31
32
  else
32
33
  set_terminology_no_ns(@mods_ng_xml)
33
34
  end
35
+ return self
34
36
  end
35
37
 
36
38
  # Convenience method to call Mods::Reader.new.from_url and to nom.
@@ -68,8 +70,9 @@ module Mods
68
70
  end
69
71
 
70
72
  # convenience method to call Mods::Reader.new.from_nk_node and to nom
71
- # @param ns_aware true if the XML parsing should be strict about using namespaces. Default is true
72
73
  # @param node (Nokogiri::XML::Node) - Nokogiri::XML::Node that is the top level element of a mods record
74
+ # @param ns_aware true if the XML parsing should be strict about using namespaces. Default is true
75
+ # @return Mods::Record
73
76
  def from_nk_node(node, ns_aware = true)
74
77
  @mods_ng_xml = Mods::Reader.new(ns_aware).from_nk_node(node)
75
78
  if ns_aware
@@ -77,6 +80,7 @@ module Mods
77
80
  else
78
81
  set_terminology_no_ns(@mods_ng_xml)
79
82
  end
83
+ return self
80
84
  end
81
85
 
82
86
  # get the value for the terms, as a String. f there are multiple values, they will be joined with the separator.
data/lib/mods/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Mods
2
2
  # this is the Ruby Gem version
3
- VERSION = "2.0.1"
3
+ VERSION = "2.0.2"
4
4
  end
data/mods.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ["lib"]
18
18
 
19
19
  gem.add_dependency 'nokogiri'
20
- gem.add_dependency 'nom-xml'
20
+ gem.add_dependency 'nom-xml', '~> 0.5.2'
21
21
  gem.add_dependency 'iso-639'
22
22
 
23
23
  # Runtime dependencies
@@ -31,8 +31,8 @@ Gem::Specification.new do |gem|
31
31
  gem.add_development_dependency "rdoc"
32
32
  gem.add_development_dependency "yard"
33
33
  # tests
34
- gem.add_development_dependency 'rspec', '~> 3.0'
35
- # using coveralls with travis
36
- # gem.add_development_dependency 'ruby-debug19'
34
+ gem.add_development_dependency 'rspec', '~> 3.0'
35
+ # using coveralls with travis
36
+ # gem.add_development_dependency 'ruby-debug19'
37
37
  gem.add_development_dependency 'equivalent-xml'
38
38
  end
@@ -19,43 +19,43 @@ describe "Mods <language> Element" do
19
19
  @ex_array = [@iso639_2b_code_ln, @mult_code_terms, @mult_text_terms]
20
20
  end
21
21
  it "should be a NodeSet" do
22
- @ex_array.each { |t| t.should be_an_instance_of(Nokogiri::XML::NodeSet) }
22
+ @ex_array.each { |t| expect(t).to be_an_instance_of(Nokogiri::XML::NodeSet) }
23
23
  end
24
24
  it "should have as many members as there are <language> elements in the xml" do
25
- @ex_array.each { |t| t.size.should == 1 }
25
+ @ex_array.each { |t| expect(t.size).to eq(1) }
26
26
  end
27
27
 
28
28
  context "<languageTerm> child element" do
29
29
  it "should understand languageTerm.type_at attribute" do
30
- @iso639_2b_code_ln.languageTerm.type_at.should == ["code"]
30
+ expect(@iso639_2b_code_ln.languageTerm.type_at).to eq(["code"])
31
31
  end
32
32
  it "should understand languageTerm.authority attribute" do
33
- @iso639_2b_code_ln.languageTerm.authority.should == ["iso639-2b"]
33
+ expect(@iso639_2b_code_ln.languageTerm.authority).to eq(["iso639-2b"])
34
34
  end
35
35
  it "should understand languageTerm value" do
36
- @iso639_2b_code_ln.languageTerm.text.should == "fre"
37
- @iso639_2b_code_ln.languageTerm.size.should == 1
36
+ expect(@iso639_2b_code_ln.languageTerm.text).to eq("fre")
37
+ expect(@iso639_2b_code_ln.languageTerm.size).to eq(1)
38
38
  end
39
39
 
40
40
  it "should recognize all authority attributes" do
41
41
  Mods::AUTHORITY_ATTRIBS.each { |a|
42
42
  @mods_rec.from_str("<mods #{@ns_decl}><language><languageTerm #{a}='attr_val'>zzz</languageTerm></language></mods>")
43
- @mods_rec.language.languageTerm.send(a.to_sym).should == ['attr_val']
43
+ expect(@mods_rec.language.languageTerm.send(a.to_sym)).to eq(['attr_val'])
44
44
  }
45
45
  end
46
46
  end # <languageTerm>
47
47
 
48
48
  it "should get one language.code_term for each languageTerm element with a type attribute of 'code'" do
49
- @iso639_2b_code_ln.code_term.size.should == 1
50
- @iso639_2b_code_ln.code_term.text.should == "fre"
51
- @mult_code_terms.code_term.size.should == 2
52
- @mult_code_terms.code_term.first.text.should include("spa")
53
- @mult_code_terms.code_term[1].text.should == "dut"
49
+ expect(@iso639_2b_code_ln.code_term.size).to eq(1)
50
+ expect(@iso639_2b_code_ln.code_term.text).to eq("fre")
51
+ expect(@mult_code_terms.code_term.size).to eq(2)
52
+ expect(@mult_code_terms.code_term.first.text).to include("spa")
53
+ expect(@mult_code_terms.code_term[1].text).to eq("dut")
54
54
  end
55
55
  it "should get one language.text_term for each languageTerm element with a type attribute of 'text'" do
56
- @mult_text_terms.text_term.size.should == 2
57
- @mult_text_terms.text_term.first.text.should include("Chinese")
58
- @mult_text_terms.text_term[1].text.should == "Spanish"
56
+ expect(@mult_text_terms.text_term.size).to eq(2)
57
+ expect(@mult_text_terms.text_term.first.text).to include("Chinese")
58
+ expect(@mult_text_terms.text_term[1].text).to eq("Spanish")
59
59
  end
60
60
  end # namespace_aware
61
61
 
@@ -71,43 +71,43 @@ describe "Mods <language> Element" do
71
71
  @ex_array = [@iso639_2b_code_ln, @mult_code_terms, @mult_text_terms]
72
72
  end
73
73
  it "should be a NodeSet" do
74
- @ex_array.each { |t| t.should be_an_instance_of(Nokogiri::XML::NodeSet) }
74
+ @ex_array.each { |t| expect(t).to be_an_instance_of(Nokogiri::XML::NodeSet) }
75
75
  end
76
76
  it "should have as many members as there are <language> elements in the xml" do
77
- @ex_array.each { |t| t.size.should == 1 }
77
+ @ex_array.each { |t| expect(t.size).to eq(1) }
78
78
  end
79
79
 
80
80
  context "<languageTerm> child element" do
81
81
  it "should understand languageTerm.type_at attribute" do
82
- @iso639_2b_code_ln.languageTerm.type_at.should == ["code"]
82
+ expect(@iso639_2b_code_ln.languageTerm.type_at).to eq(["code"])
83
83
  end
84
84
  it "should understand languageTerm.authority attribute" do
85
- @iso639_2b_code_ln.languageTerm.authority.should == ["iso639-2b"]
85
+ expect(@iso639_2b_code_ln.languageTerm.authority).to eq(["iso639-2b"])
86
86
  end
87
87
  it "should understand languageTerm value" do
88
- @iso639_2b_code_ln.languageTerm.text.should == "fre"
89
- @iso639_2b_code_ln.languageTerm.size.should == 1
88
+ expect(@iso639_2b_code_ln.languageTerm.text).to eq("fre")
89
+ expect(@iso639_2b_code_ln.languageTerm.size).to eq(1)
90
90
  end
91
91
 
92
92
  it "should recognize all authority attributes" do
93
93
  Mods::AUTHORITY_ATTRIBS.each { |a|
94
94
  @mods_rec.from_str("<mods><language><languageTerm #{a}='attr_val'>zzz</languageTerm></language></mods>", false)
95
- @mods_rec.language.languageTerm.send(a.to_sym).should == ['attr_val']
95
+ expect(@mods_rec.language.languageTerm.send(a.to_sym)).to eq(['attr_val'])
96
96
  }
97
97
  end
98
98
  end # <languageTerm>
99
99
 
100
100
  it "should get one language.code_term for each languageTerm element with a type attribute of 'code'" do
101
- @iso639_2b_code_ln.code_term.size.should == 1
102
- @iso639_2b_code_ln.code_term.text.should == "fre"
103
- @mult_code_terms.code_term.size.should == 2
104
- @mult_code_terms.code_term.first.text.should include("spa")
105
- @mult_code_terms.code_term[1].text.should == "dut"
101
+ expect(@iso639_2b_code_ln.code_term.size).to eq(1)
102
+ expect(@iso639_2b_code_ln.code_term.text).to eq("fre")
103
+ expect(@mult_code_terms.code_term.size).to eq(2)
104
+ expect(@mult_code_terms.code_term.first.text).to include("spa")
105
+ expect(@mult_code_terms.code_term[1].text).to eq("dut")
106
106
  end
107
107
  it "should get one language.text_term for each languageTerm element with a type attribute of 'text'" do
108
- @mult_text_terms.text_term.size.should == 2
109
- @mult_text_terms.text_term.first.text.should include("Chinese")
110
- @mult_text_terms.text_term[1].text.should == "Spanish"
108
+ expect(@mult_text_terms.text_term.size).to eq(2)
109
+ expect(@mult_text_terms.text_term.first.text).to include("Chinese")
110
+ expect(@mult_text_terms.text_term[1].text).to eq("Spanish")
111
111
  end
112
112
  end # NOT namespace_aware
113
113
 
@@ -31,17 +31,17 @@ describe "Mods <location> Element" do
31
31
  end
32
32
  it "should have access to text value of element" do
33
33
  @mods_rec.from_str(@phys_loc_only)
34
- @mods_rec.location.physicalLocation.text.should == "here"
34
+ expect(@mods_rec.location.physicalLocation.text).to eq("here")
35
35
  @mods_rec.from_str(@phys_loc_authority)
36
- @mods_rec.location.physicalLocation.map { |n| n.text }.should == ["MnRM"]
36
+ expect(@mods_rec.location.physicalLocation.map { |n| n.text }).to eq(["MnRM"])
37
37
  end
38
38
  it "should recognize authority attribute" do
39
39
  @mods_rec.from_str(@phys_loc_authority)
40
- @mods_rec.location.physicalLocation.authority.should == ["marcorg"]
40
+ expect(@mods_rec.location.physicalLocation.authority).to eq(["marcorg"])
41
41
  end
42
42
  it "should recognize displayLabel attribute" do
43
43
  @mods_rec.from_str("<mods #{@ns_decl}><location><physicalLocation displayLabel='Correspondence'>some address</physicalLocation></location></mods>")
44
- @mods_rec.location.physicalLocation.displayLabel.should == ["Correspondence"]
44
+ expect(@mods_rec.location.physicalLocation.displayLabel).to eq(["Correspondence"])
45
45
  end
46
46
  end
47
47
 
@@ -51,7 +51,7 @@ describe "Mods <location> Element" do
51
51
  <shelfLocator>DAG no. 1410</shelfLocator>
52
52
  </location></mods>"
53
53
  @mods_rec.from_str(shelf_loc)
54
- @mods_rec.location.shelfLocator.map { |n| n.text }.should == ["DAG no. 1410"]
54
+ expect(@mods_rec.location.shelfLocator.map { |n| n.text }).to eq(["DAG no. 1410"])
55
55
  end
56
56
 
57
57
  context "url child element" do
@@ -65,10 +65,10 @@ describe "Mods <location> Element" do
65
65
  end
66
66
  it "should have access to text value of element" do
67
67
  urls = @mods_rec.from_str(@mult_flavor_loc_urls).location.url.map { |e| e.text }
68
- urls.size.should == 3
69
- urls.should include("http://preview.org")
70
- urls.should include("http://context.org")
71
- urls.should include("http://object.org")
68
+ expect(urls.size).to eq(3)
69
+ expect(urls).to include("http://preview.org")
70
+ expect(urls).to include("http://context.org")
71
+ expect(urls).to include("http://object.org")
72
72
  end
73
73
  context "attributes" do
74
74
  before(:all) do
@@ -77,29 +77,29 @@ describe "Mods <location> Element" do
77
77
  </location></mods>"
78
78
  end
79
79
  it "should recognize displayLabel attribute" do
80
- @mods_rec.from_str(@url_attribs).location.url.displayLabel.should == ["Digital collection of 46 images available online"]
80
+ expect(@mods_rec.from_str(@url_attribs).location.url.displayLabel).to eq(["Digital collection of 46 images available online"])
81
81
  end
82
82
  it "should recognize access attribute" do
83
83
  vals = @mods_rec.from_str(@mult_flavor_loc_urls).location.url.access
84
- vals.size.should == 3
85
- vals.should include("preview")
86
- vals.should include("object in context")
87
- vals.should include("raw object")
84
+ expect(vals.size).to eq(3)
85
+ expect(vals).to include("preview")
86
+ expect(vals).to include("object in context")
87
+ expect(vals).to include("raw object")
88
88
  end
89
89
  it "should recognize usage attribute" do
90
- @mods_rec.from_str(@url_attribs).location.url.usage.should == ["primary display"]
90
+ expect(@mods_rec.from_str(@url_attribs).location.url.usage).to eq(["primary display"])
91
91
  end
92
92
  it "should recognize note attribute" do
93
93
  @mods_rec.from_str("<mods #{@ns_decl}><location><url note='something'>http://somewhere.org</url></location></mods>")
94
- @mods_rec.location.url.note.should == ["something"]
94
+ expect(@mods_rec.location.url.note).to eq(["something"])
95
95
  end
96
96
  it "should recognize dateLastAccessed attribute" do
97
97
  @mods_rec.from_str("<mods #{@ns_decl}><location><url dateLastAccessed='something'>http://somewhere.org</url></location></mods>")
98
- @mods_rec.location.url.dateLastAccessed.should == ["something"]
98
+ expect(@mods_rec.location.url.dateLastAccessed).to eq(["something"])
99
99
  end
100
100
  end # attributes
101
101
  it "should have array with empty string for single empty url element" do
102
- @mods_rec.from_str(@empty_loc_url).location.url.map { |n| n.text }.should == [""]
102
+ expect(@mods_rec.from_str(@empty_loc_url).location.url.map { |n| n.text }).to eq([""])
103
103
  end
104
104
  end # url child element
105
105
 
@@ -113,8 +113,8 @@ describe "Mods <location> Element" do
113
113
  <enumerationAndChronology unitType='1'> v.1-v.8 1970-1976</enumerationAndChronology>
114
114
  </copyInformation>
115
115
  </holdingSimple></location></mods>"
116
- @mods_rec.from_str(xml).location.holdingSimple.should be_an_instance_of(Nokogiri::XML::NodeSet)
117
- @mods_rec.from_str(xml).location.holdingSimple.first.should be_an_instance_of(Nokogiri::XML::Element)
116
+ expect(@mods_rec.from_str(xml).location.holdingSimple).to be_an_instance_of(Nokogiri::XML::NodeSet)
117
+ expect(@mods_rec.from_str(xml).location.holdingSimple.first).to be_an_instance_of(Nokogiri::XML::Element)
118
118
  end
119
119
  it "holdingComplex child element" do
120
120
  xml = "<mods #{@ns_decl}>
@@ -143,8 +143,8 @@ describe "Mods <location> Element" do
143
143
  </holding>
144
144
  </holdingExternal>
145
145
  </mods>"
146
- @mods_rec.from_str(xml).location.holdingExternal.should be_an_instance_of(Nokogiri::XML::NodeSet)
147
- @mods_rec.from_str(xml).location.holdingExternal.first.should be_an_instance_of(Nokogiri::XML::Element)
146
+ expect(@mods_rec.from_str(xml).location.holdingExternal).to be_an_instance_of(Nokogiri::XML::NodeSet)
147
+ expect(@mods_rec.from_str(xml).location.holdingExternal.first).to be_an_instance_of(Nokogiri::XML::Element)
148
148
  end
149
149
 
150
150
  end # WITH namespaces
@@ -172,17 +172,17 @@ describe "Mods <location> Element" do
172
172
  end
173
173
  it "should have access to text value of element" do
174
174
  @mods_rec.from_str(@phys_loc_only, false)
175
- @mods_rec.location.physicalLocation.text.should == "here"
175
+ expect(@mods_rec.location.physicalLocation.text).to eq("here")
176
176
  @mods_rec.from_str(@phys_loc_authority, false)
177
- @mods_rec.location.physicalLocation.map { |n| n.text }.should == ["MnRM"]
177
+ expect(@mods_rec.location.physicalLocation.map { |n| n.text }).to eq(["MnRM"])
178
178
  end
179
179
  it "should recognize authority attribute" do
180
180
  @mods_rec.from_str(@phys_loc_authority, false)
181
- @mods_rec.location.physicalLocation.authority.should == ["marcorg"]
181
+ expect(@mods_rec.location.physicalLocation.authority).to eq(["marcorg"])
182
182
  end
183
183
  it "should recognize displayLabel attribute" do
184
184
  @mods_rec.from_str('<mods><location><physicalLocation displayLabel="Correspondence">some address</physicalLocation></location></mods>', false)
185
- @mods_rec.location.physicalLocation.displayLabel.should == ["Correspondence"]
185
+ expect(@mods_rec.location.physicalLocation.displayLabel).to eq(["Correspondence"])
186
186
  end
187
187
  end
188
188
 
@@ -192,7 +192,7 @@ describe "Mods <location> Element" do
192
192
  <shelfLocator>DAG no. 1410</shelfLocator>
193
193
  </location></mods>'
194
194
  @mods_rec.from_str(shelf_loc, false)
195
- @mods_rec.location.shelfLocator.map { |n| n.text }.should == ["DAG no. 1410"]
195
+ expect(@mods_rec.location.shelfLocator.map { |n| n.text }).to eq(["DAG no. 1410"])
196
196
  end
197
197
 
198
198
  context "url child element" do
@@ -206,10 +206,10 @@ describe "Mods <location> Element" do
206
206
  end
207
207
  it "should have access to text value of element" do
208
208
  urls = @mods_rec.from_str(@mult_flavor_loc_urls, false).location.url.map { |e| e.text }
209
- urls.size.should == 3
210
- urls.should include("http://preview.org")
211
- urls.should include("http://context.org")
212
- urls.should include("http://object.org")
209
+ expect(urls.size).to eq(3)
210
+ expect(urls).to include("http://preview.org")
211
+ expect(urls).to include("http://context.org")
212
+ expect(urls).to include("http://object.org")
213
213
  end
214
214
  context "attributes" do
215
215
  before(:all) do
@@ -218,29 +218,29 @@ describe "Mods <location> Element" do
218
218
  </location></mods>'
219
219
  end
220
220
  it "should recognize displayLabel attribute" do
221
- @mods_rec.from_str(@url_attribs, false).location.url.displayLabel.should == ["Digital collection of 46 images available online"]
221
+ expect(@mods_rec.from_str(@url_attribs, false).location.url.displayLabel).to eq(["Digital collection of 46 images available online"])
222
222
  end
223
223
  it "should recognize access attribute" do
224
224
  vals = @mods_rec.from_str(@mult_flavor_loc_urls, false).location.url.access
225
- vals.size.should == 3
226
- vals.should include("preview")
227
- vals.should include("object in context")
228
- vals.should include("raw object")
225
+ expect(vals.size).to eq(3)
226
+ expect(vals).to include("preview")
227
+ expect(vals).to include("object in context")
228
+ expect(vals).to include("raw object")
229
229
  end
230
230
  it "should recognize usage attribute" do
231
- @mods_rec.from_str(@url_attribs, false).location.url.usage.should == ["primary display"]
231
+ expect(@mods_rec.from_str(@url_attribs, false).location.url.usage).to eq(["primary display"])
232
232
  end
233
233
  it "should recognize note attribute" do
234
234
  @mods_rec.from_str('<mods><location><url note="something">http://somewhere.org</url></location></mods>', false)
235
- @mods_rec.location.url.note.should == ["something"]
235
+ expect(@mods_rec.location.url.note).to eq(["something"])
236
236
  end
237
237
  it "should recognize dateLastAccessed attribute" do
238
238
  @mods_rec.from_str('<mods><location><url dateLastAccessed="something">http://somewhere.org</url></location></mods>', false)
239
- @mods_rec.location.url.dateLastAccessed.should == ["something"]
239
+ expect(@mods_rec.location.url.dateLastAccessed).to eq(["something"])
240
240
  end
241
241
  end # attributes
242
242
  it "should have array with empty string for single empty url element" do
243
- @mods_rec.from_str(@empty_loc_url, false).location.url.map { |n| n.text }.should == [""]
243
+ expect(@mods_rec.from_str(@empty_loc_url, false).location.url.map { |n| n.text }).to eq([""])
244
244
  end
245
245
  end # url child element
246
246
 
@@ -254,8 +254,8 @@ describe "Mods <location> Element" do
254
254
  <enumerationAndChronology unitType="1"> v.1-v.8 1970-1976</enumerationAndChronology>
255
255
  </copyInformation>
256
256
  </holdingSimple></location></mods>'
257
- @mods_rec.from_str(xml, false).location.holdingSimple.should be_an_instance_of(Nokogiri::XML::NodeSet)
258
- @mods_rec.from_str(xml, false).location.holdingSimple.first.should be_an_instance_of(Nokogiri::XML::Element)
257
+ expect(@mods_rec.from_str(xml, false).location.holdingSimple).to be_an_instance_of(Nokogiri::XML::NodeSet)
258
+ expect(@mods_rec.from_str(xml, false).location.holdingSimple.first).to be_an_instance_of(Nokogiri::XML::Element)
259
259
  end
260
260
  it "holdingComplex child element" do
261
261
  xml = '<mods>
@@ -284,8 +284,8 @@ describe "Mods <location> Element" do
284
284
  </holding>
285
285
  </holdingExternal>
286
286
  </mods>'
287
- @mods_rec.from_str(xml, false).location.holdingExternal.should be_an_instance_of(Nokogiri::XML::NodeSet)
288
- @mods_rec.from_str(xml, false).location.holdingExternal.first.should be_an_instance_of(Nokogiri::XML::Element)
287
+ expect(@mods_rec.from_str(xml, false).location.holdingExternal).to be_an_instance_of(Nokogiri::XML::NodeSet)
288
+ expect(@mods_rec.from_str(xml, false).location.holdingExternal.first).to be_an_instance_of(Nokogiri::XML::Element)
289
289
  end
290
290
 
291
291
  end # WITHOUT namespaces
data/spec/name_spec.rb CHANGED
@@ -48,37 +48,37 @@ describe "Mods <name> Element" do
48
48
  Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role"}.each { |e|
49
49
  @mods_rec.from_str("<mods #{@ns_decl}><name type='personal'><#{e}>oofda</#{e}></name></mods>")
50
50
  if e == 'description'
51
- @mods_rec.personal_name.description_el.text.should == 'oofda'
51
+ expect(@mods_rec.personal_name.description_el.text).to eq('oofda')
52
52
  else
53
- @mods_rec.personal_name.send(e).text.should == 'oofda'
53
+ expect(@mods_rec.personal_name.send(e).text).to eq('oofda')
54
54
  end
55
55
  }
56
56
  end
57
57
  it "should include name elements with type attr = personal" do
58
58
  @mods_rec.from_str(@mods_w_pers_name_ns)
59
- @mods_rec.personal_name.namePart.text.should == @pers_name
60
- @mods_rec.from_str(@mods_w_both_ns).personal_name.namePart.text.should == @pers_name
59
+ expect(@mods_rec.personal_name.namePart.text).to eq(@pers_name)
60
+ expect(@mods_rec.from_str(@mods_w_both_ns).personal_name.namePart.text).to eq(@pers_name)
61
61
  end
62
62
  it "should not include name elements with type attr != personal" do
63
63
  @mods_rec.from_str(@mods_w_corp_name_ns)
64
- @mods_rec.personal_name.namePart.text.should == ""
65
- @mods_rec.from_str(@mods_w_both_ns).personal_name.namePart.text.should_not match(@corp_name)
64
+ expect(@mods_rec.personal_name.namePart.text).to eq("")
65
+ expect(@mods_rec.from_str(@mods_w_both_ns).personal_name.namePart.text).not_to match(@corp_name)
66
66
  end
67
67
 
68
68
  context "roles" do
69
69
  it "should be possible to access a personal_name role easily" do
70
70
  @mods_rec.from_str(@mods_w_pers_name_role_ns)
71
- @mods_rec.personal_name.role.roleTerm.text.should include(@pers_role)
71
+ expect(@mods_rec.personal_name.role.roleTerm.text).to include(@pers_role)
72
72
  end
73
73
  it "should get role type" do
74
74
  @mods_rec.from_str(@mods_w_pers_name_role_ns)
75
- @mods_rec.personal_name.role.roleTerm.type_at.should == ["text"]
75
+ expect(@mods_rec.personal_name.role.roleTerm.type_at).to eq(["text"])
76
76
  @mods_rec.from_str(@mods_w_pers_name_role_code_ns)
77
- @mods_rec.personal_name.role.roleTerm.type_at.should == ["code"]
77
+ expect(@mods_rec.personal_name.role.roleTerm.type_at).to eq(["code"])
78
78
  end
79
79
  it "should get role authority" do
80
80
  @mods_rec.from_str(@mods_w_pers_name_role_ns)
81
- @mods_rec.personal_name.role.roleTerm.authority.should == ["marcrelator"]
81
+ expect(@mods_rec.personal_name.role.roleTerm.authority).to eq(["marcrelator"])
82
82
  end
83
83
  end # roles
84
84
  end # WITH namespaces (personal name)
@@ -88,37 +88,37 @@ describe "Mods <name> Element" do
88
88
  Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role"}.each { |e|
89
89
  @mods_rec.from_str("<mods><name type='personal'><#{e}>oofda</#{e}></name></mods>", false)
90
90
  if e == 'description'
91
- @mods_rec.personal_name.description_el.text.should == 'oofda'
91
+ expect(@mods_rec.personal_name.description_el.text).to eq('oofda')
92
92
  else
93
- @mods_rec.personal_name.send(e).text.should == 'oofda'
93
+ expect(@mods_rec.personal_name.send(e).text).to eq('oofda')
94
94
  end
95
95
  }
96
96
  end
97
97
  it "should include name elements with type attr = personal" do
98
98
  @mods_rec.from_str(@mods_w_pers_name, false)
99
- @mods_rec.personal_name.namePart.text.should == @pers_name
100
- @mods_rec.from_str(@mods_w_both, false).personal_name.namePart.text.should == @pers_name
99
+ expect(@mods_rec.personal_name.namePart.text).to eq(@pers_name)
100
+ expect(@mods_rec.from_str(@mods_w_both, false).personal_name.namePart.text).to eq(@pers_name)
101
101
  end
102
102
  it "should not include name elements with type attr != personal" do
103
103
  @mods_rec.from_str(@mods_w_corp_name, false)
104
- @mods_rec.personal_name.namePart.text.should == ""
105
- @mods_rec.from_str(@mods_w_both, false).personal_name.namePart.text.should_not match(@corp_name)
104
+ expect(@mods_rec.personal_name.namePart.text).to eq("")
105
+ expect(@mods_rec.from_str(@mods_w_both, false).personal_name.namePart.text).not_to match(@corp_name)
106
106
  end
107
107
 
108
108
  context "roles" do
109
109
  it "should be possible to access a personal_name role easily" do
110
110
  @mods_rec.from_str(@mods_w_pers_name_role, false)
111
- @mods_rec.personal_name.role.text.should include(@pers_role)
111
+ expect(@mods_rec.personal_name.role.text).to include(@pers_role)
112
112
  end
113
113
  it "should get role type" do
114
114
  @mods_rec.from_str(@mods_w_pers_name_role, false)
115
- @mods_rec.personal_name.role.roleTerm.type_at.should == ["text"]
115
+ expect(@mods_rec.personal_name.role.roleTerm.type_at).to eq(["text"])
116
116
  @mods_rec.from_str(@mods_w_pers_name_role_code, false)
117
- @mods_rec.personal_name.role.roleTerm.type_at.should == ["code"]
117
+ expect(@mods_rec.personal_name.role.roleTerm.type_at).to eq(["code"])
118
118
  end
119
119
  it "should get role authority" do
120
120
  @mods_rec.from_str(@mods_w_pers_name_role, false)
121
- @mods_rec.personal_name.role.roleTerm.authority.should == ["marcrelator"]
121
+ expect(@mods_rec.personal_name.role.roleTerm.authority).to eq(["marcrelator"])
122
122
  end
123
123
  end # roles
124
124
  end # WITHOUT namespaces
@@ -133,21 +133,21 @@ describe "Mods <name> Element" do
133
133
  Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role" }.each { |e|
134
134
  @mods_rec.from_str("<mods #{@ns_decl}><name type='corporate'><#{e}>oofda</#{e}></name></mods>")
135
135
  if e == 'description'
136
- @mods_rec.corporate_name.description_el.text.should == 'oofda'
136
+ expect(@mods_rec.corporate_name.description_el.text).to eq('oofda')
137
137
  else
138
- @mods_rec.corporate_name.send(e).text.should == 'oofda'
138
+ expect(@mods_rec.corporate_name.send(e).text).to eq('oofda')
139
139
  end
140
140
  }
141
141
  end
142
142
  it "should include name elements with type attr = corporate" do
143
143
  @mods_rec.from_str(@mods_w_corp_name_ns)
144
- @mods_rec.corporate_name.namePart.text.should == @corp_name
145
- @mods_rec.from_str(@mods_w_both_ns).corporate_name.namePart.text.should == @corp_name
144
+ expect(@mods_rec.corporate_name.namePart.text).to eq(@corp_name)
145
+ expect(@mods_rec.from_str(@mods_w_both_ns).corporate_name.namePart.text).to eq(@corp_name)
146
146
  end
147
147
  it "should not include name elements with type attr != corporate" do
148
148
  @mods_rec.from_str(@mods_w_pers_name_ns)
149
- @mods_rec.corporate_name.namePart.text.should == ""
150
- @mods_rec.from_str(@mods_w_both_ns).corporate_name.namePart.text.should_not match(@pers_name)
149
+ expect(@mods_rec.corporate_name.namePart.text).to eq("")
150
+ expect(@mods_rec.from_str(@mods_w_both_ns).corporate_name.namePart.text).not_to match(@pers_name)
151
151
  end
152
152
  end # WITH namespaces
153
153
  context "WITHOUT namespaces" do
@@ -155,21 +155,21 @@ describe "Mods <name> Element" do
155
155
  Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role" }.each { |e|
156
156
  @mods_rec.from_str("<mods><name type='corporate'><#{e}>oofda</#{e}></name></mods>", false)
157
157
  if e == 'description'
158
- @mods_rec.corporate_name.description_el.text.should == 'oofda'
158
+ expect(@mods_rec.corporate_name.description_el.text).to eq('oofda')
159
159
  else
160
- @mods_rec.corporate_name.send(e).text.should == 'oofda'
160
+ expect(@mods_rec.corporate_name.send(e).text).to eq('oofda')
161
161
  end
162
162
  }
163
163
  end
164
164
  it "should include name elements with type attr = corporate" do
165
165
  @mods_rec.from_str(@mods_w_corp_name, false)
166
- @mods_rec.corporate_name.namePart.text.should == @corp_name
167
- @mods_rec.from_str(@mods_w_both, false).corporate_name.namePart.text.should == @corp_name
166
+ expect(@mods_rec.corporate_name.namePart.text).to eq(@corp_name)
167
+ expect(@mods_rec.from_str(@mods_w_both, false).corporate_name.namePart.text).to eq(@corp_name)
168
168
  end
169
169
  it "should not include name elements with type attr != corporate" do
170
170
  @mods_rec.from_str(@mods_w_pers_name, false)
171
- @mods_rec.corporate_name.namePart.text.should == ""
172
- @mods_rec.from_str(@mods_w_both, false).corporate_name.namePart.text.should_not match(@pers_name)
171
+ expect(@mods_rec.corporate_name.namePart.text).to eq("")
172
+ expect(@mods_rec.from_str(@mods_w_both, false).corporate_name.namePart.text).not_to match(@pers_name)
173
173
  end
174
174
  end # WITHOUT namespaces
175
175
 
@@ -185,9 +185,9 @@ describe "Mods <name> Element" do
185
185
  Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role"}.each { |e|
186
186
  @mods_rec.from_str("<mods #{@ns_decl}><name><#{e}>oofda</#{e}></name></mods>")
187
187
  if e == 'description'
188
- @mods_rec.plain_name.description_el.text.should == 'oofda'
188
+ expect(@mods_rec.plain_name.description_el.text).to eq('oofda')
189
189
  else
190
- @mods_rec.plain_name.send(e).text.should == 'oofda'
190
+ expect(@mods_rec.plain_name.send(e).text).to eq('oofda')
191
191
  end
192
192
  }
193
193
  end
@@ -195,9 +195,9 @@ describe "Mods <name> Element" do
195
195
  Mods::Name::ATTRIBUTES.each { |attrb|
196
196
  @mods_rec.from_str("<mods #{@ns_decl}><name #{attrb}='hello'><displayForm>q</displayForm></name></mods>")
197
197
  if attrb != 'type'
198
- @mods_rec.plain_name.send(attrb).should == ['hello']
198
+ expect(@mods_rec.plain_name.send(attrb)).to eq(['hello'])
199
199
  else
200
- @mods_rec.plain_name.type_at.should == ['hello']
200
+ expect(@mods_rec.plain_name.type_at).to eq(['hello'])
201
201
  end
202
202
  }
203
203
  end
@@ -205,20 +205,20 @@ describe "Mods <name> Element" do
205
205
  it "should recognize type attribute on namePart element" do
206
206
  Mods::Name::NAME_PART_TYPES.each { |t|
207
207
  @mods_rec.from_str("<mods #{@ns_decl}><name><namePart type='#{t}'>hi</namePart></name></mods>")
208
- @mods_rec.plain_name.namePart.type_at.should == [t]
208
+ expect(@mods_rec.plain_name.namePart.type_at).to eq([t])
209
209
  }
210
210
  end
211
211
  end
212
212
  context "role child element" do
213
213
  it "should get role type" do
214
214
  @mods_rec.from_str(@mods_w_pers_name_role_ns)
215
- @mods_rec.plain_name.role.roleTerm.type_at.should == ["text"]
215
+ expect(@mods_rec.plain_name.role.roleTerm.type_at).to eq(["text"])
216
216
  @mods_rec.from_str(@mods_w_pers_name_role_code_ns)
217
- @mods_rec.plain_name.role.roleTerm.type_at.should == ["code"]
217
+ expect(@mods_rec.plain_name.role.roleTerm.type_at).to eq(["code"])
218
218
  end
219
219
  it "should get role authority" do
220
220
  @mods_rec.from_str(@mods_w_pers_name_role_ns)
221
- @mods_rec.plain_name.role.roleTerm.authority.should == ["marcrelator"]
221
+ expect(@mods_rec.plain_name.role.roleTerm.authority).to eq(["marcrelator"])
222
222
  end
223
223
  end
224
224
 
@@ -229,9 +229,9 @@ describe "Mods <name> Element" do
229
229
  Mods::Name::CHILD_ELEMENTS.reject{|e| e == "role"}.each { |e|
230
230
  @mods_rec.from_str("<mods><name><#{e}>oofda</#{e}></name></mods>", false)
231
231
  if e == 'description'
232
- @mods_rec.plain_name.description_el.text.should == 'oofda'
232
+ expect(@mods_rec.plain_name.description_el.text).to eq('oofda')
233
233
  else
234
- @mods_rec.plain_name.send(e).text.should == 'oofda'
234
+ expect(@mods_rec.plain_name.send(e).text).to eq('oofda')
235
235
  end
236
236
  }
237
237
  end
@@ -239,9 +239,9 @@ describe "Mods <name> Element" do
239
239
  Mods::Name::ATTRIBUTES.each { |attrb|
240
240
  @mods_rec.from_str("<mods><name #{attrb}='hello'><displayForm>q</displayForm></name></mods>", false)
241
241
  if attrb != 'type'
242
- @mods_rec.plain_name.send(attrb).should == ['hello']
242
+ expect(@mods_rec.plain_name.send(attrb)).to eq(['hello'])
243
243
  else
244
- @mods_rec.plain_name.type_at.should == ['hello']
244
+ expect(@mods_rec.plain_name.type_at).to eq(['hello'])
245
245
  end
246
246
  }
247
247
  end
@@ -249,20 +249,20 @@ describe "Mods <name> Element" do
249
249
  it "should recognize type attribute on namePart element" do
250
250
  Mods::Name::NAME_PART_TYPES.each { |t|
251
251
  @mods_rec.from_str("<mods><name><namePart type='#{t}'>hi</namePart></name></mods>", false)
252
- @mods_rec.plain_name.namePart.type_at.should == [t]
252
+ expect(@mods_rec.plain_name.namePart.type_at).to eq([t])
253
253
  }
254
254
  end
255
255
  end
256
256
  context "role child element" do
257
257
  it "should get role type" do
258
258
  @mods_rec.from_str(@mods_w_pers_name_role, false)
259
- @mods_rec.plain_name.role.roleTerm.type_at.should == ["text"]
259
+ expect(@mods_rec.plain_name.role.roleTerm.type_at).to eq(["text"])
260
260
  @mods_rec.from_str(@mods_w_pers_name_role_code, false)
261
- @mods_rec.plain_name.role.roleTerm.type_at.should == ["code"]
261
+ expect(@mods_rec.plain_name.role.roleTerm.type_at).to eq(["code"])
262
262
  end
263
263
  it "should get role authority" do
264
264
  @mods_rec.from_str(@mods_w_pers_name_role, false)
265
- @mods_rec.plain_name.role.roleTerm.authority.should == ["marcrelator"]
265
+ expect(@mods_rec.plain_name.role.roleTerm.authority).to eq(["marcrelator"])
266
266
  end
267
267
  end
268
268
  end # context WITHOUT namespaces
@@ -270,7 +270,7 @@ describe "Mods <name> Element" do
270
270
  end # plain name
271
271
 
272
272
  it "should be able to translate the marc relator code into text" do
273
- MARC_RELATOR['drt'].should == "Director"
273
+ expect(MARC_RELATOR['drt']).to eq("Director")
274
274
  end
275
275
 
276
276
  context "display_value and display_value_w_date" do
@@ -306,47 +306,47 @@ describe "Mods <name> Element" do
306
306
  @mods_namepart_date = Mods::Record.new.from_str(@namepart_xml)
307
307
  end
308
308
  it "should be a string value for each name, not an Array" do
309
- @mods_name.plain_name.first.display_value.should be_an_instance_of(String)
310
- @mods_name.plain_name.first.display_value_w_date.should be_an_instance_of(String)
309
+ expect(@mods_name.plain_name.first.display_value).to be_an_instance_of(String)
310
+ expect(@mods_name.plain_name.first.display_value_w_date).to be_an_instance_of(String)
311
311
  end
312
312
  it "should return nil when there is no display_value" do
313
313
  x = "<mods #{@ns_decl}><name>
314
314
  <namePart></namePart>
315
315
  </name></mods>"
316
316
  r = Mods::Record.new.from_str(x)
317
- r.plain_name.first.display_value.should == nil
317
+ expect(r.plain_name.first.display_value).to eq(nil)
318
318
  end
319
319
  it "should be applicable to all name term flavors (plain_name, personal_name, corporate_name ...)" do
320
- @mods_name.plain_name.first.display_value.should_not == nil
321
- @mods_name.plain_name.first.display_value_w_date.should_not == nil
322
- @mods_pname1.personal_name.first.display_value.should_not == nil
323
- @mods_pname1.personal_name.first.display_value_w_date.should_not == nil
324
- @mods_cname.corporate_name.first.display_value.should_not == nil
325
- @mods_cname.corporate_name.first.display_value_w_date.should_not == nil
320
+ expect(@mods_name.plain_name.first.display_value).not_to eq(nil)
321
+ expect(@mods_name.plain_name.first.display_value_w_date).not_to eq(nil)
322
+ expect(@mods_pname1.personal_name.first.display_value).not_to eq(nil)
323
+ expect(@mods_pname1.personal_name.first.display_value_w_date).not_to eq(nil)
324
+ expect(@mods_cname.corporate_name.first.display_value).not_to eq(nil)
325
+ expect(@mods_cname.corporate_name.first.display_value_w_date).not_to eq(nil)
326
326
  end
327
327
  it "should not include <affiliation> text" do
328
- @mods_name.plain_name.first.display_value.should_not =~ Regexp.new(@affl)
328
+ expect(@mods_name.plain_name.first.display_value).not_to match(Regexp.new(@affl))
329
329
  end
330
330
  it "should not include <description> text" do
331
- @mods_name.plain_name.first.display_value.should_not =~ Regexp.new(@desc)
331
+ expect(@mods_name.plain_name.first.display_value).not_to match(Regexp.new(@desc))
332
332
  end
333
333
  it "should not include <role> info" do
334
- @mods_name.plain_name.first.display_value.should_not =~ Regexp.new(@role)
334
+ expect(@mods_name.plain_name.first.display_value).not_to match(Regexp.new(@role))
335
335
  end
336
336
  it "should be the value of the <displayForm> subelement if it exists" do
337
- @mods_pname1.plain_name.first.display_value.should == @disp_form
337
+ expect(@mods_pname1.plain_name.first.display_value).to eq(@disp_form)
338
338
  x = "<mods #{@ns_decl}><name type='personal'>
339
339
  <namePart>Alterman, Eric</namePart>
340
340
  <displayForm>Eric Alterman</displayForm>
341
341
  </name><mods>"
342
342
  r = Mods::Record.new.from_str(x)
343
- r.plain_name.first.display_value.should == 'Eric Alterman'
343
+ expect(r.plain_name.first.display_value).to eq('Eric Alterman')
344
344
  end
345
345
  it "display_value should not include <namePart type='date'>" do
346
- @mods_namepart_date.plain_name.first.display_value.should == 'Suzy'
346
+ expect(@mods_namepart_date.plain_name.first.display_value).to eq('Suzy')
347
347
  end
348
348
  it "date text should be added to display_value_w_date when it is available" do
349
- @mods_namepart_date.plain_name.first.display_value_w_date.should == 'Suzy, 1920-'
349
+ expect(@mods_namepart_date.plain_name.first.display_value_w_date).to eq('Suzy, 1920-')
350
350
  end
351
351
  it "date text should not be added to display_value_w_dates if dates are already included" do
352
352
  x = "<mods #{@ns_decl}><name>
@@ -355,7 +355,7 @@ describe "Mods <name> Element" do
355
355
  <displayForm>Woolf, Virginia, 1882-1941</namePart>
356
356
  </name></mods>"
357
357
  r = Mods::Record.new.from_str(x)
358
- r.plain_name.first.display_value_w_date.should == 'Woolf, Virginia, 1882-1941'
358
+ expect(r.plain_name.first.display_value_w_date).to eq('Woolf, Virginia, 1882-1941')
359
359
  end
360
360
  context "personal names" do
361
361
  before(:all) do
@@ -384,20 +384,20 @@ describe "Mods <name> Element" do
384
384
  <namePart type='family'>Huston</namePart>
385
385
  </name></mods>"
386
386
  r = Mods::Record.new.from_str(x)
387
- r.personal_name.first.display_value.should == 'Huston, John'
388
- @pope.personal_name.first.display_value.should == 'John Paul II, Pope'
387
+ expect(r.personal_name.first.display_value).to eq('Huston, John')
388
+ expect(@pope.personal_name.first.display_value).to eq('John Paul II, Pope')
389
389
  end
390
390
  it "should be concatenation of untyped <namePart> elements if there is no family or given name" do
391
- @pname2.personal_name.first.display_value.should == 'Crusty The Clown'
391
+ expect(@pname2.personal_name.first.display_value).to eq('Crusty The Clown')
392
392
  end
393
393
  it "should include <termOfAddress> elements, in order, comma separated" do
394
- @pope.personal_name.first.display_value.should == 'John Paul II, Pope'
394
+ expect(@pope.personal_name.first.display_value).to eq('John Paul II, Pope')
395
395
  end
396
396
  it "display_value should not include date" do
397
- @pope.personal_name.first.display_value.should_not =~ Regexp.new(@d)
397
+ expect(@pope.personal_name.first.display_value).not_to match(Regexp.new(@d))
398
398
  end
399
399
  it "date should be included in display_value_w_date" do
400
- @pope.personal_name.first.display_value_w_date.should == "John Paul II, Pope, #{@d}"
400
+ expect(@pope.personal_name.first.display_value_w_date).to eq("John Paul II, Pope, #{@d}")
401
401
  end
402
402
  end
403
403
  context "not personal name (e.g. corporate)" do
@@ -407,7 +407,7 @@ describe "Mods <name> Element" do
407
407
  <namePart>Court of Appeals (2nd Circuit)</namePart>
408
408
  </name></mods>"
409
409
  r = Mods::Record.new.from_str(x)
410
- r.corporate_name.first.display_value.should == 'United States Court of Appeals (2nd Circuit)'
410
+ expect(r.corporate_name.first.display_value).to eq('United States Court of Appeals (2nd Circuit)')
411
411
  end
412
412
  end
413
413
  end # WITH namespaces
@@ -420,47 +420,47 @@ describe "Mods <name> Element" do
420
420
  @mods_namepart_date = Mods::Record.new.from_str(@namepart_xml.sub(" #{@ns_decl}", ''), false)
421
421
  end
422
422
  it "should be a string value for each name, not an Array" do
423
- @mods_name.plain_name.first.display_value.should be_an_instance_of(String)
424
- @mods_name.plain_name.first.display_value_w_date.should be_an_instance_of(String)
423
+ expect(@mods_name.plain_name.first.display_value).to be_an_instance_of(String)
424
+ expect(@mods_name.plain_name.first.display_value_w_date).to be_an_instance_of(String)
425
425
  end
426
426
  it "should return nil when there is no display_value" do
427
427
  x = "<mods><name>
428
428
  <namePart></namePart>
429
429
  </name></mods>"
430
430
  r = Mods::Record.new.from_str(x, false)
431
- r.plain_name.first.display_value.should == nil
431
+ expect(r.plain_name.first.display_value).to eq(nil)
432
432
  end
433
433
  it "should be applicable to all name term flavors (plain_name, personal_name, corporate_name ...)" do
434
- @mods_name.plain_name.first.display_value.should_not == nil
435
- @mods_name.plain_name.first.display_value_w_date.should_not == nil
436
- @mods_pname1.personal_name.first.display_value.should_not == nil
437
- @mods_pname1.personal_name.first.display_value_w_date.should_not == nil
438
- @mods_cname.corporate_name.first.display_value.should_not == nil
439
- @mods_cname.corporate_name.first.display_value_w_date.should_not == nil
434
+ expect(@mods_name.plain_name.first.display_value).not_to eq(nil)
435
+ expect(@mods_name.plain_name.first.display_value_w_date).not_to eq(nil)
436
+ expect(@mods_pname1.personal_name.first.display_value).not_to eq(nil)
437
+ expect(@mods_pname1.personal_name.first.display_value_w_date).not_to eq(nil)
438
+ expect(@mods_cname.corporate_name.first.display_value).not_to eq(nil)
439
+ expect(@mods_cname.corporate_name.first.display_value_w_date).not_to eq(nil)
440
440
  end
441
441
  it "should not include <affiliation> text" do
442
- @mods_name.plain_name.first.display_value.should_not =~ Regexp.new(@affl)
442
+ expect(@mods_name.plain_name.first.display_value).not_to match(Regexp.new(@affl))
443
443
  end
444
444
  it "should not include <description> text" do
445
- @mods_name.plain_name.first.display_value.should_not =~ Regexp.new(@desc)
445
+ expect(@mods_name.plain_name.first.display_value).not_to match(Regexp.new(@desc))
446
446
  end
447
447
  it "should not include <role> info" do
448
- @mods_name.plain_name.first.display_value.should_not =~ Regexp.new(@role)
448
+ expect(@mods_name.plain_name.first.display_value).not_to match(Regexp.new(@role))
449
449
  end
450
450
  it "should be the value of the <displayForm> subelement if it exists" do
451
- @mods_pname1.plain_name.first.display_value.should == @disp_form
451
+ expect(@mods_pname1.plain_name.first.display_value).to eq(@disp_form)
452
452
  x = "<mods><name type='personal'>
453
453
  <namePart>Alterman, Eric</namePart>
454
454
  <displayForm>Eric Alterman</displayForm>
455
455
  </name><mods>"
456
456
  r = Mods::Record.new.from_str(x, false)
457
- r.plain_name.first.display_value.should == 'Eric Alterman'
457
+ expect(r.plain_name.first.display_value).to eq('Eric Alterman')
458
458
  end
459
459
  it "display_value should not include <namePart type='date'>" do
460
- @mods_namepart_date.plain_name.first.display_value.should == 'Suzy'
460
+ expect(@mods_namepart_date.plain_name.first.display_value).to eq('Suzy')
461
461
  end
462
462
  it "date text should be added to display_value_w_date when it is available" do
463
- @mods_namepart_date.plain_name.first.display_value_w_date.should == 'Suzy, 1920-'
463
+ expect(@mods_namepart_date.plain_name.first.display_value_w_date).to eq('Suzy, 1920-')
464
464
  end
465
465
  it "date text should not be added to display_value_w_dates if dates are already included" do
466
466
  x = "<mods><name>
@@ -469,7 +469,7 @@ describe "Mods <name> Element" do
469
469
  <displayForm>Woolf, Virginia, 1882-1941</namePart>
470
470
  </name></mods>"
471
471
  r = Mods::Record.new.from_str(x, false)
472
- r.plain_name.first.display_value_w_date.should == 'Woolf, Virginia, 1882-1941'
472
+ expect(r.plain_name.first.display_value_w_date).to eq('Woolf, Virginia, 1882-1941')
473
473
  end
474
474
  context "personal names" do
475
475
  before(:all) do
@@ -498,20 +498,20 @@ describe "Mods <name> Element" do
498
498
  <namePart type='family'>Huston</namePart>
499
499
  </name></mods>"
500
500
  r = Mods::Record.new.from_str(x, false)
501
- r.personal_name.first.display_value.should == 'Huston, John'
502
- @pope.personal_name.first.display_value.should == 'John Paul II, Pope'
501
+ expect(r.personal_name.first.display_value).to eq('Huston, John')
502
+ expect(@pope.personal_name.first.display_value).to eq('John Paul II, Pope')
503
503
  end
504
504
  it "should be concatenation of untyped <namePart> elements if there is no family or given name" do
505
- @pname2.personal_name.first.display_value.should == 'Crusty The Clown'
505
+ expect(@pname2.personal_name.first.display_value).to eq('Crusty The Clown')
506
506
  end
507
507
  it "should include <termOfAddress> elements, in order, comma separated" do
508
- @pope.personal_name.first.display_value.should == 'John Paul II, Pope'
508
+ expect(@pope.personal_name.first.display_value).to eq('John Paul II, Pope')
509
509
  end
510
510
  it "display_value should not include date" do
511
- @pope.personal_name.first.display_value.should_not =~ Regexp.new(@d)
511
+ expect(@pope.personal_name.first.display_value).not_to match(Regexp.new(@d))
512
512
  end
513
513
  it "date should be included in display_value_w_date" do
514
- @pope.personal_name.first.display_value_w_date.should == "John Paul II, Pope, #{@d}"
514
+ expect(@pope.personal_name.first.display_value_w_date).to eq("John Paul II, Pope, #{@d}")
515
515
  end
516
516
  end
517
517
  context "not personal name (e.g. corporate)" do
@@ -521,7 +521,7 @@ describe "Mods <name> Element" do
521
521
  <namePart>Court of Appeals (2nd Circuit)</namePart>
522
522
  </name></mods>"
523
523
  r = Mods::Record.new.from_str(x, false)
524
- r.corporate_name.first.display_value.should == 'United States Court of Appeals (2nd Circuit)'
524
+ expect(r.corporate_name.first.display_value).to eq('United States Court of Appeals (2nd Circuit)')
525
525
  end
526
526
  end
527
527
  end # WITHOUT namespaces
@@ -561,36 +561,36 @@ describe "Mods <name> Element" do
561
561
  end
562
562
  context "value" do
563
563
  it "should be the value of a text roleTerm" do
564
- @mods_w_text.plain_name.role.value.should == ["Actor"]
564
+ expect(@mods_w_text.plain_name.role.value).to eq(["Actor"])
565
565
  end
566
566
  it "should be the translation of the code if it is a marcrelator code and there is no text roleTerm" do
567
- @mods_w_code.plain_name.role.value.should == ["Director"]
567
+ expect(@mods_w_code.plain_name.role.value).to eq(["Director"])
568
568
  end
569
569
  it "should be the value of the text roleTerm if there are both a code and a text roleTerm" do
570
- @mods_w_both.plain_name.role.value.should == ["CreatorFake"]
570
+ expect(@mods_w_both.plain_name.role.value).to eq(["CreatorFake"])
571
571
  end
572
572
  it "should have 2 values if there are 2 role elements" do
573
- @mods_mult_roles.plain_name.role.value.should == ['Creator', 'Performer']
573
+ expect(@mods_mult_roles.plain_name.role.value).to eq(['Creator', 'Performer'])
574
574
  end
575
575
  end
576
576
  context "authority" do
577
577
  it "should be empty if it is missing from xml" do
578
- @mods_wo_authority.plain_name.role.authority.size.should == 0
578
+ expect(@mods_wo_authority.plain_name.role.authority.size).to eq(0)
579
579
  end
580
580
  it "should be the value of the authority attribute on the roleTerm element" do
581
- @mods_w_code.plain_name.role.authority.should == ["marcrelator"]
582
- @mods_w_text.plain_name.role.authority.should == ["marcrelator"]
583
- @mods_w_both.plain_name.role.authority.should == ["marcrelator"]
581
+ expect(@mods_w_code.plain_name.role.authority).to eq(["marcrelator"])
582
+ expect(@mods_w_text.plain_name.role.authority).to eq(["marcrelator"])
583
+ expect(@mods_w_both.plain_name.role.authority).to eq(["marcrelator"])
584
584
  end
585
585
  end
586
586
  context "code" do
587
587
  it "should be empty if the roleTerm is not of type code" do
588
- @mods_w_text.plain_name.role.code.size.should == 0
589
- @mods_wo_authority.plain_name.role.code.size.should == 0
588
+ expect(@mods_w_text.plain_name.role.code.size).to eq(0)
589
+ expect(@mods_wo_authority.plain_name.role.code.size).to eq(0)
590
590
  end
591
591
  it "should be the value of the roleTerm element if element's type attribute is 'code'" do
592
- @mods_w_code.plain_name.role.code.should == ["drt"]
593
- @mods_w_both.plain_name.role.code.should == ["cre"]
592
+ expect(@mods_w_code.plain_name.role.code).to eq(["drt"])
593
+ expect(@mods_w_both.plain_name.role.code).to eq(["cre"])
594
594
  end
595
595
  end
596
596
  context "pertaining to a specific name" do
@@ -620,34 +620,34 @@ describe "Mods <name> Element" do
620
620
  end
621
621
  it "roles should be empty array when there is no role element" do
622
622
  @mods_rec.from_str(@mods_w_pers_name_ns)
623
- @mods_rec.personal_name.first.role.size.should == 0
623
+ expect(@mods_rec.personal_name.first.role.size).to eq(0)
624
624
  end
625
625
  it "object should have same number of roles as it has role nodes in xml" do
626
- @mods_complex.plain_name[0].role.size.should == 1
627
- @mods_complex.plain_name[1].role.size.should == 2
628
- @mods_complex.plain_name[2].role.size.should == 1
626
+ expect(@mods_complex.plain_name[0].role.size).to eq(1)
627
+ expect(@mods_complex.plain_name[1].role.size).to eq(2)
628
+ expect(@mods_complex.plain_name[2].role.size).to eq(1)
629
629
  end
630
630
  context "name's roles should be correctly populated" do
631
631
  it "text attribute" do
632
- @mods_complex.plain_name[0].role.value.should == ['Director']
633
- @mods_complex.plain_name[1].role.value.should == ['CreatorFake', 'Actor']
634
- @mods_complex.plain_name[2].role.value.should == ['Actor']
632
+ expect(@mods_complex.plain_name[0].role.value).to eq(['Director'])
633
+ expect(@mods_complex.plain_name[1].role.value).to eq(['CreatorFake', 'Actor'])
634
+ expect(@mods_complex.plain_name[2].role.value).to eq(['Actor'])
635
635
  end
636
636
  it "code attribute" do
637
- @mods_complex.plain_name[0].role.code.should == ['drt']
638
- @mods_complex.plain_name[1].role.code.should == ['cre']
639
- @mods_complex.plain_name[2].role.code.should == ['cre']
637
+ expect(@mods_complex.plain_name[0].role.code).to eq(['drt'])
638
+ expect(@mods_complex.plain_name[1].role.code).to eq(['cre'])
639
+ expect(@mods_complex.plain_name[2].role.code).to eq(['cre'])
640
640
  end
641
641
  it "authority attribute" do
642
- @mods_complex.plain_name[0].role.authority.should == ['marcrelator']
643
- @mods_complex.plain_name[1].role.authority.should == ['marcrelator', 'marcrelator']
644
- @mods_complex.plain_name[2].role.authority.should == ['marcrelator']
642
+ expect(@mods_complex.plain_name[0].role.authority).to eq(['marcrelator'])
643
+ expect(@mods_complex.plain_name[1].role.authority).to eq(['marcrelator', 'marcrelator'])
644
+ expect(@mods_complex.plain_name[2].role.authority).to eq(['marcrelator'])
645
645
  end
646
646
  it "multiple roles" do
647
- @mods_mult_roles.plain_name.first.role.value.should == ['Creator', 'Performer']
648
- @mods_mult_roles.plain_name.first.role.code.should == ['cre']
649
- @mods_mult_roles.plain_name.role.first.roleTerm.authority.first.should == 'marcrelator'
650
- @mods_mult_roles.plain_name.role.last.roleTerm.authority.size.should == 0
647
+ expect(@mods_mult_roles.plain_name.first.role.value).to eq(['Creator', 'Performer'])
648
+ expect(@mods_mult_roles.plain_name.first.role.code).to eq(['cre'])
649
+ expect(@mods_mult_roles.plain_name.role.first.roleTerm.authority.first).to eq('marcrelator')
650
+ expect(@mods_mult_roles.plain_name.role.last.roleTerm.authority.size).to eq(0)
651
651
  end
652
652
  end
653
653
  end # pertaining to a specific name
@@ -663,36 +663,36 @@ describe "Mods <name> Element" do
663
663
  end
664
664
  context "value" do
665
665
  it "should be the value of a text roleTerm" do
666
- @mods_w_text.plain_name.role.value.should == ["Actor"]
666
+ expect(@mods_w_text.plain_name.role.value).to eq(["Actor"])
667
667
  end
668
668
  it "should be the translation of the code if it is a marcrelator code and there is no text roleTerm" do
669
- @mods_w_code.plain_name.role.value.should == ["Director"]
669
+ expect(@mods_w_code.plain_name.role.value).to eq(["Director"])
670
670
  end
671
671
  it "should be the value of the text roleTerm if there are both a code and a text roleTerm" do
672
- @mods_w_both.plain_name.role.value.should == ["CreatorFake"]
672
+ expect(@mods_w_both.plain_name.role.value).to eq(["CreatorFake"])
673
673
  end
674
674
  it "should have 2 values if there are 2 role elements" do
675
- @mods_mult_roles.plain_name.role.value.should == ['Creator', 'Performer']
675
+ expect(@mods_mult_roles.plain_name.role.value).to eq(['Creator', 'Performer'])
676
676
  end
677
677
  end
678
678
  context "authority" do
679
679
  it "should be empty if it is missing from xml" do
680
- @mods_wo_authority.plain_name.role.authority.size.should == 0
680
+ expect(@mods_wo_authority.plain_name.role.authority.size).to eq(0)
681
681
  end
682
682
  it "should be the value of the authority attribute on the roleTerm element" do
683
- @mods_w_code.plain_name.role.authority.should == ["marcrelator"]
684
- @mods_w_text.plain_name.role.authority.should == ["marcrelator"]
685
- @mods_w_both.plain_name.role.authority.should == ["marcrelator"]
683
+ expect(@mods_w_code.plain_name.role.authority).to eq(["marcrelator"])
684
+ expect(@mods_w_text.plain_name.role.authority).to eq(["marcrelator"])
685
+ expect(@mods_w_both.plain_name.role.authority).to eq(["marcrelator"])
686
686
  end
687
687
  end
688
688
  context "code" do
689
689
  it "should be empty if the roleTerm is not of type code" do
690
- @mods_w_text.plain_name.role.code.size.should == 0
691
- @mods_wo_authority.plain_name.role.code.size.should == 0
690
+ expect(@mods_w_text.plain_name.role.code.size).to eq(0)
691
+ expect(@mods_wo_authority.plain_name.role.code.size).to eq(0)
692
692
  end
693
693
  it "should be the value of the roleTerm element if element's type attribute is 'code'" do
694
- @mods_w_code.plain_name.role.code.should == ["drt"]
695
- @mods_w_both.plain_name.role.code.should == ["cre"]
694
+ expect(@mods_w_code.plain_name.role.code).to eq(["drt"])
695
+ expect(@mods_w_both.plain_name.role.code).to eq(["cre"])
696
696
  end
697
697
  end
698
698
  context "pertaining to a specific name" do
@@ -722,34 +722,34 @@ describe "Mods <name> Element" do
722
722
  end
723
723
  it "roles should be empty array when there is no role element" do
724
724
  @mods_rec.from_str(@mods_w_pers_name_ns)
725
- @mods_rec.personal_name.first.role.size.should == 0
725
+ expect(@mods_rec.personal_name.first.role.size).to eq(0)
726
726
  end
727
727
  it "object should have same number of roles as it has role nodes in xml" do
728
- @mods_complex.plain_name[0].role.size.should == 1
729
- @mods_complex.plain_name[1].role.size.should == 2
730
- @mods_complex.plain_name[2].role.size.should == 1
728
+ expect(@mods_complex.plain_name[0].role.size).to eq(1)
729
+ expect(@mods_complex.plain_name[1].role.size).to eq(2)
730
+ expect(@mods_complex.plain_name[2].role.size).to eq(1)
731
731
  end
732
732
  context "name's roles should be correctly populated" do
733
733
  it "text attribute" do
734
- @mods_complex.plain_name[0].role.value.should == ['Director']
735
- @mods_complex.plain_name[1].role.value.should == ['CreatorFake', 'Actor']
736
- @mods_complex.plain_name[2].role.value.should == ['Actor']
734
+ expect(@mods_complex.plain_name[0].role.value).to eq(['Director'])
735
+ expect(@mods_complex.plain_name[1].role.value).to eq(['CreatorFake', 'Actor'])
736
+ expect(@mods_complex.plain_name[2].role.value).to eq(['Actor'])
737
737
  end
738
738
  it "code attribute" do
739
- @mods_complex.plain_name[0].role.code.should == ['drt']
740
- @mods_complex.plain_name[1].role.code.should == ['cre']
741
- @mods_complex.plain_name[2].role.code.should == ['cre']
739
+ expect(@mods_complex.plain_name[0].role.code).to eq(['drt'])
740
+ expect(@mods_complex.plain_name[1].role.code).to eq(['cre'])
741
+ expect(@mods_complex.plain_name[2].role.code).to eq(['cre'])
742
742
  end
743
743
  it "authority attribute" do
744
- @mods_complex.plain_name[0].role.authority.should == ['marcrelator']
745
- @mods_complex.plain_name[1].role.authority.should == ['marcrelator', 'marcrelator']
746
- @mods_complex.plain_name[2].role.authority.should == ['marcrelator']
744
+ expect(@mods_complex.plain_name[0].role.authority).to eq(['marcrelator'])
745
+ expect(@mods_complex.plain_name[1].role.authority).to eq(['marcrelator', 'marcrelator'])
746
+ expect(@mods_complex.plain_name[2].role.authority).to eq(['marcrelator'])
747
747
  end
748
748
  it "multiple roles" do
749
- @mods_mult_roles.plain_name.first.role.value.should == ['Creator', 'Performer']
750
- @mods_mult_roles.plain_name.first.role.code.should == ['cre']
751
- @mods_mult_roles.plain_name.role.first.roleTerm.authority.first.should == 'marcrelator'
752
- @mods_mult_roles.plain_name.role.last.roleTerm.authority.size.should == 0
749
+ expect(@mods_mult_roles.plain_name.first.role.value).to eq(['Creator', 'Performer'])
750
+ expect(@mods_mult_roles.plain_name.first.role.code).to eq(['cre'])
751
+ expect(@mods_mult_roles.plain_name.role.first.roleTerm.authority.first).to eq('marcrelator')
752
+ expect(@mods_mult_roles.plain_name.role.last.roleTerm.authority.size).to eq(0)
753
753
  end
754
754
  end
755
755
  end # pertaining to a specific name