stanford-mods 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stanford-mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-04 00:00:00.000000000 Z
12
+ date: 2014-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods
@@ -121,7 +121,6 @@ extra_rdoc_files:
121
121
  - README.rdoc
122
122
  files:
123
123
  - .gitignore
124
- - .rvmrc
125
124
  - .travis.yml
126
125
  - .yardopts
127
126
  - Gemfile
@@ -130,14 +129,14 @@ files:
130
129
  - Rakefile
131
130
  - config/mappings_hash.rb
132
131
  - lib/stanford-mods.rb
133
- - lib/stanford-mods/kolb.rb
134
132
  - lib/stanford-mods/searchworks.rb
135
133
  - lib/stanford-mods/searchworks_languages.rb
136
134
  - lib/stanford-mods/version.rb
137
- - spec/kolb_spec.rb
138
135
  - spec/name_spec.rb
139
- - spec/searchworks_gdor_spec.rb
136
+ - spec/searchworks_format_spec.rb
137
+ - spec/searchworks_pub_dates_spec.rb
140
138
  - spec/searchworks_spec.rb
139
+ - spec/searchworks_subject_raw_spec.rb
141
140
  - spec/searchworks_subject_spec.rb
142
141
  - spec/spec_helper.rb
143
142
  - stanford-mods.gemspec
@@ -160,15 +159,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
159
  version: '0'
161
160
  requirements: []
162
161
  rubyforge_project:
163
- rubygems_version: 2.0.7
162
+ rubygems_version: 2.2.0
164
163
  signing_key:
165
164
  specification_version: 4
166
165
  summary: Stanford specific wrangling of MODS metadata
167
166
  test_files:
168
- - spec/kolb_spec.rb
169
167
  - spec/name_spec.rb
170
- - spec/searchworks_gdor_spec.rb
168
+ - spec/searchworks_format_spec.rb
169
+ - spec/searchworks_pub_dates_spec.rb
171
170
  - spec/searchworks_spec.rb
171
+ - spec/searchworks_subject_raw_spec.rb
172
172
  - spec/searchworks_subject_spec.rb
173
173
  - spec/spec_helper.rb
174
174
  has_rdoc:
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use ruby-1.9.3@stanford-mods --create
@@ -1,14 +0,0 @@
1
- # Kolb Collection specific wranglings of MODS metadata as an extension of the Mods::Record object
2
- module Stanford
3
- module Mods
4
-
5
- class KolbRecord < Record
6
-
7
- # NAOMI_MUST_COMMENT_THIS_METHOD
8
- def publish_date
9
-
10
- end
11
-
12
- end
13
- end
14
- end
data/spec/kolb_spec.rb DELETED
@@ -1,234 +0,0 @@
1
- require 'spec_helper'
2
- require 'stanford-mods/kolb'
3
-
4
- describe "Kolb Collection Mods Record" do
5
- before(:all) do
6
- @krec = Stanford::Mods::KolbRecord.new
7
- @krec.from_str('<?xml version="1.0"?>
8
- <ns3:mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://www.loc.gov/mods/v3" xmlns:ns2="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
9
- <ns3:titleInfo>
10
- <ns3:title>Edward VI, king of England,</ns3:title>
11
- </ns3:titleInfo>
12
- <ns3:language>
13
- <ns3:languageTerm type="code" authority="iso639-2b">eng</ns3:languageTerm>
14
- <ns3:languageTerm type="text">English</ns3:languageTerm>
15
- </ns3:language>
16
- <ns3:typeOfResource>still image</ns3:typeOfResource>
17
- <ns3:originInfo>
18
- <ns3:dateCreated>1537-1553.</ns3:dateCreated>
19
- <ns3:dateCreated point="start">1537</ns3:dateCreated>
20
- <ns3:dateCreated point="end">1553</ns3:dateCreated>
21
- </ns3:originInfo>
22
- <ns3:subject>
23
- <ns3:name type="personal" authority="ingest">
24
- <ns3:namePart type="family">Edward VI , king of England, </ns3:namePart>
25
- <ns3:displayForm>Edward VI , king of England, 1537-1553</ns3:displayForm>
26
- </ns3:name>
27
- </ns3:subject>
28
- <ns3:name type="personal" authority="ingest">
29
- <ns3:role>
30
- <ns3:roleTerm type="text" authority="marcrelator">creator</ns3:roleTerm>
31
- <ns3:roleTerm type="code" authority="marcrelator">cre</ns3:roleTerm>
32
- </ns3:role>
33
- <ns3:namePart type="family">Holbein, Han, 1497-1543</ns3:namePart>
34
- <ns3:displayForm>Holbein, Han, 1497-1543</ns3:displayForm>
35
- </ns3:name>
36
- <ns3:name type="personal" authority="ingest">
37
- <ns3:role>
38
- <ns3:roleTerm type="text" authority="marcrelator">creator</ns3:roleTerm>
39
- <ns3:roleTerm type="code" authority="marcrelator">cre</ns3:roleTerm>
40
- </ns3:role>
41
- <ns3:namePart type="family">Sheppard, Robert, 1732-1737</ns3:namePart>
42
- <ns3:displayForm>Sheppard, Robert, 1732-1737</ns3:displayForm>
43
- </ns3:name>
44
- <ns3:subject authority="ingest">
45
- <ns3:topic>Ruler, English.Ruler, English.</ns3:topic>
46
- </ns3:subject>
47
- <ns3:abstract displayLabel="Scope and Contents note"/>
48
- <ns3:physicalDescription>
49
- <ns3:note displayLabel="Material Specific Details note">0395</ns3:note>
50
- </ns3:physicalDescription>
51
- </ns3:mods>')
52
- end
53
-
54
- context "for SearchWorks Solr" do
55
- # from https://consul.stanford.edu/display/NGDE/Required+and+Recommended+Solr+Fields+for+SearchWorks+documents
56
-
57
- context "required values" do
58
-
59
- it "catch all text field" do
60
- pending "to be implemented"
61
- end
62
-
63
- it "format" do
64
- # sometimes from contentMetadata, o.w. see mods_mapper.is_a_map/image?
65
- pending "to be implemented"
66
-
67
- #<ns3:typeOfResource>still image</ns3:typeOfResource>
68
- end
69
-
70
- # FIXME: update per gryphDOR code / searcworks code / new schema
71
-
72
- it "collection" do
73
- pending "to be implemented"
74
- # from solr_mapper.rb
75
- # # Special treatment for collection objects
76
- #if is_a_collection?
77
- # solr_doc[:display_type] = "Collection"
78
- # solr_doc[:collection_type] = "Digital Collection"
79
- #else
80
- # solr_doc[:display_type] = display_type
81
- #end
82
-
83
- #if collections # An array of the druids of any collections this object is part of
84
- # solr_doc[:collection] = collections
85
- # solr_doc[:collection_with_title] = collections_with_titles
86
- #end
87
-
88
-
89
- end
90
-
91
- it "display_type" do
92
- pending "to be implemented"
93
- end
94
- end
95
-
96
- context "strongly recommended" do
97
- # access_facet has nothing to do with mods
98
- context "title" do
99
- context "for display and searching" do
100
- it "short title" do
101
- @krec.short_titles.should == ['Edward VI, king of England,']
102
- end
103
- it "full title" do
104
- @krec.full_titles.should == ['Edward VI, king of England,']
105
- end
106
- it "alternative titles" do
107
- @krec.alternative_titles.size.should == 0
108
- end
109
- end
110
- it "sortable title" do
111
- @krec.sort_title.should == 'Edward VI, king of England,'
112
- end
113
- end
114
- end
115
-
116
- context "recommended" do
117
- context "publication date" do
118
- it "for searching and facet" do
119
- pending "to be implemented"
120
- @krec.pub_date.should include('1537')
121
- @krec.pub_date.should include('1545')
122
- @krec.pub_date.should include('1553')
123
- @krec.pub_date.should_not include('1554')
124
- @krec.pub_date.should_not include('1536')
125
- end
126
- it "for sorting should be dateCreated start date" do
127
- pending "to be implemented"
128
- @krec.pub_date_sort.should == '1537'
129
- end
130
- it "for pub date grouping (hierarchical / date slider?)" do
131
- pending "to be implemented"
132
- @krec.pub_date_group_facet.should == 'More than 50 years ago'
133
- end
134
- end
135
- context "language" do
136
- it "facet should have a text value" do
137
- @krec.sw_language_facet.should == ['English']
138
- end
139
- end
140
- context "authors" do
141
- it "personal_names" do
142
- @krec.personal_names.size.should == 2
143
- @krec.personal_names.should include('Holbein, Han, 1497-1543')
144
- @krec.personal_names.should include('Sheppard, Robert, 1732-1737')
145
- end
146
- it "name object showing creator role" do
147
- pending "to be implemented"
148
- end
149
- it "author sort" do
150
- pending "to be implemented"
151
- end
152
- end
153
- end
154
-
155
- end # for SearchWorks Solr
156
-
157
- context "abstract" do
158
- # FIXME: move to stanford_mods, not kolb specific
159
- it "should not include empty elements" do
160
- pending "to be implemented"
161
- # <ns3:abstract displayLabel="Scope and Contents note"/>
162
- @krec.abstract.size.should == 0
163
- @krec.scope_and_contents_note.size.should == 0
164
- end
165
- end
166
-
167
- context "physicalDescription" do
168
- # <ns3:physicalDescription>
169
- # <ns3:note displayLabel="Material Specific Details note">0395</ns3:note>
170
- # </ns3:physicalDescription>
171
- it "should be included in catch all text" do
172
- pending "to be implemented"
173
- end
174
- end
175
-
176
- context "subject" do
177
- it "topic" do
178
- @krec.subject.topic.map { |e| e.text }.should == ['Ruler, English.Ruler, English.']
179
- end
180
- it "name" do
181
- pending "to be implemented"
182
- @krec.subject.name.map { |e| e.text }.should == ['Edward VI , king of England, 1537-1553']
183
- end
184
- end
185
-
186
- context "kolb record title issue" do
187
- before(:all) do
188
- @krec.from_str('<?xml version="1.0" encoding="UTF-8"?>
189
- <ns3:mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://www.loc.gov/mods/v3" xmlns:ns2="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
190
- <ns3:titleInfo>
191
- <ns3:title>Elizabeth I, queen of England,</ns3:title>
192
- </ns3:titleInfo>
193
- <ns3:language>
194
- <ns3:languageTerm type="code" authority="iso639-2b">eng</ns3:languageTerm>
195
- <ns3:languageTerm type="text">English</ns3:languageTerm>
196
- </ns3:language>
197
- <ns3:typeOfResource>still image</ns3:typeOfResource>
198
- <ns3:originInfo>
199
- <ns3:dateCreated>1533-1603.</ns3:dateCreated>
200
- <ns3:dateCreated point="start">1533</ns3:dateCreated>
201
- <ns3:dateCreated point="end">1603</ns3:dateCreated>
202
- </ns3:originInfo>
203
- <ns3:subject>
204
- <ns3:name type="personal" authority="ingest">
205
- <ns3:namePart type="family">Elizabeth I, Queen of England</ns3:namePart>
206
- <ns3:displayForm>Elizabeth I, Queen of England, 1533-1603</ns3:displayForm>
207
- </ns3:name>
208
- </ns3:subject>
209
- <ns3:name type="personal" authority="ingest">
210
- <ns3:role>
211
- <ns3:roleTerm type="text" authority="marcrelator">creator</ns3:roleTerm>
212
- <ns3:roleTerm type="code" authority="marcrelator">cre</ns3:roleTerm>
213
- </ns3:role>
214
- <ns3:namePart type="family">Houston, Richard, 1721?-1775</ns3:namePart>
215
- <ns3:displayForm>Houston, Richard, 1721?-1775</ns3:displayForm>
216
- </ns3:name>
217
- <ns3:subject authority="ingest">
218
- <ns3:topic>Ruler, English. W</ns3:topic>
219
- </ns3:subject>
220
- <ns3:abstract displayLabel="Scope and Contents note">Elisabetha D.G./Angliae,Franciae &amp; Hiberniae,
221
- Regina,./Printed for E.Bakewell &amp; H.Parker; opposite Birchin Lane
222
- in Cornhill.</ns3:abstract>
223
- <ns3:physicalDescription>
224
- <ns3:note displayLabel="Material Specific Details note">0411</ns3:note>
225
- </ns3:physicalDescription>
226
- </ns3:mods>')
227
- end
228
- it "should get full title" do
229
- @krec.title_info.full_title.should == ['Elizabeth I, queen of England,']
230
- @krec.full_titles.should == ['Elizabeth I, queen of England,']
231
- end
232
- end
233
-
234
- end
@@ -1,771 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
-
4
- describe "Searchworks mixin for Stanford::Mods::Record" do
5
-
6
- before(:all) do
7
- @smods_rec = Stanford::Mods::Record.new
8
- @ns_decl = "xmlns='#{Mods::MODS_NS}'"
9
- end
10
- before :each do
11
- @genre = 'genre top level'
12
- @cart_coord = '6 00 S, 71 30 E'
13
- @s_genre = 'genre in subject'
14
- @geo = 'Somewhere'
15
- @geo_code = 'us'
16
- @hier_geo_country = 'France'
17
- @s_name = 'name in subject'
18
- @occupation = 'worker bee'
19
- @temporal = 'temporal'
20
- @s_title = 'title in subject'
21
- @topic = 'topic'
22
- m = "<mods #{@ns_decl}>
23
- <genre>#{@genre}</genre>
24
- <subject><cartographics><coordinates>#{@cart_coord}</coordinates></cartographics></subject>
25
- <subject><genre>#{@s_genre}</genre></subject>
26
- <subject><geographic>#{@geo}</geographic></subject>
27
- <subject><geographicCode authority='iso3166'>#{@geo_code}</geographicCode></subject>
28
- <subject><hierarchicalGeographic><country>#{@hier_geo_country}</country></hierarchicalGeographic></subject>
29
- <subject><name><namePart>#{@s_name}</namePart></name></subject>
30
- <subject><occupation>#{@occupation}</occupation></subject>
31
- <subject><temporal>#{@temporal}</temporal></subject>
32
- <subject><titleInfo><title>#{@s_title}</title></titleInfo></subject>
33
- <subject><topic>#{@topic}</topic></subject>
34
- </mods>"
35
- @smods_rec = Stanford::Mods::Record.new
36
- @smods_rec.from_str(m)
37
- @ng_mods = Nokogiri::XML(m)
38
- m_no_subject = "<mods #{@ns_decl}><note>notit</note></mods>"
39
- @ng_mods_no_subject = Nokogiri::XML(m_no_subject)
40
- end
41
-
42
- context "sw author methods" do
43
- before(:all) do
44
- m = "<mods #{@ns_decl}>
45
-
46
- </mods>"
47
- @smods_rec = Stanford::Mods::Record.new
48
- @smods_rec.from_str(m)
49
- end
50
- it 'should choose a date ending with CE if there are multiple dates' do
51
- m = "<mods #{@ns_decl}><originInfo><dateIssued>7192 AM (li-Adam) / 1684 CE</dateIssued><issuance>monographic</issuance></originInfo>"
52
- @smods_rec = Stanford::Mods::Record.new
53
- @smods_rec.from_str(m)
54
- @smods_rec.pub_date.should == '1684'
55
- end
56
-
57
- end
58
-
59
- context "search fields" do
60
-
61
- context "topic_search" do
62
- before :each do
63
- @genre = 'genre top level'
64
- @cart_coord = '6 00 S, 71 30 E'
65
- @s_genre = 'genre in subject'
66
- @geo = 'Somewhere'
67
- @geo_code = 'us'
68
- @hier_geo_country = 'France'
69
- @s_name = 'name in subject'
70
- @occupation = 'worker bee'
71
- @temporal = 'temporal'
72
- @s_title = 'title in subject'
73
- @topic = 'topic'
74
- m = "<mods #{@ns_decl}>
75
- <genre>#{@genre}</genre>
76
- <subject><cartographics><coordinates>#{@cart_coord}</coordinates></cartographics></subject>
77
- <subject><genre>#{@s_genre}</genre></subject>
78
- <subject><geographic>#{@geo}</geographic></subject>
79
- <subject><geographicCode authority='iso3166'>#{@geo_code}</geographicCode></subject>
80
- <subject><hierarchicalGeographic><country>#{@hier_geo_country}</country></hierarchicalGeographic></subject>
81
- <subject><name><namePart>#{@s_name}</namePart></name></subject>
82
- <subject><occupation>#{@occupation}</occupation></subject>
83
- <subject><temporal>#{@temporal}</temporal></subject>
84
- <subject><titleInfo><title>#{@s_title}</title></titleInfo></subject>
85
- <subject><topic>#{@topic}</topic></subject>
86
- </mods>"
87
- @smods_rec = Stanford::Mods::Record.new
88
- @smods_rec.from_str(m)
89
- @ng_mods = Nokogiri::XML(m)
90
- m_no_subject = "<mods #{@ns_decl}><note>notit</note></mods>"
91
- @ng_mods_no_subject = Nokogiri::XML(m_no_subject)
92
- end
93
- it "should be nil if there are no values in the MODS" do
94
- m = "<mods #{@ns_decl}></mods>"
95
- @smods_rec = Stanford::Mods::Record.new
96
- @smods_rec.from_str(m)
97
- @smods_rec.topic_search.should == nil
98
- end
99
- it "should contain subject <topic> subelement data" do
100
- @smods_rec.topic_search.should include(@topic)
101
- end
102
- it "should contain top level <genre> element data" do
103
- @smods_rec.topic_search.should include(@genre)
104
- end
105
- it "should not contain other subject element data" do
106
- @smods_rec.topic_search.should_not include(@cart_coord)
107
- @smods_rec.topic_search.should_not include(@s_genre)
108
- @smods_rec.topic_search.should_not include(@geo)
109
- @smods_rec.topic_search.should_not include(@geo_code)
110
- @smods_rec.topic_search.should_not include(@hier_geo_country)
111
- @smods_rec.topic_search.should_not include(@s_name)
112
- @smods_rec.topic_search.should_not include(@occupation)
113
- @smods_rec.topic_search.should_not include(@temporal)
114
- @smods_rec.topic_search.should_not include(@s_title)
115
- end
116
- it "should not be nil if there are only subject/topic elements (no <genre>)" do
117
- m = "<mods #{@ns_decl}><subject><topic>#{@topic}</topic></subject></mods>"
118
- @smods_rec = Stanford::Mods::Record.new
119
- @smods_rec.from_str(m)
120
- @smods_rec.topic_search.should == [@topic]
121
- end
122
- it "should not be nil if there are only <genre> elements (no subject/topic elements)" do
123
- m = "<mods #{@ns_decl}><genre>#{@genre}</genre></mods>"
124
- @smods_rec = Stanford::Mods::Record.new
125
- @smods_rec.from_str(m)
126
- @smods_rec.topic_search.should == [@genre]
127
- end
128
- context "topic subelement" do
129
- it "should have a separate value for each topic element" do
130
- m = "<mods #{@ns_decl}>
131
- <subject>
132
- <topic>first</topic>
133
- <topic>second</topic>
134
- </subject>
135
- <subject><topic>third</topic></subject>
136
- </mods>"
137
- @smods_rec = Stanford::Mods::Record.new
138
- @smods_rec.from_str(m)
139
- @smods_rec.topic_search.should == ['first', 'second', 'third']
140
- end
141
- it "should be nil if there are only empty values in the MODS" do
142
- m = "<mods #{@ns_decl}><subject><topic/></subject><note>notit</note></mods>"
143
- @smods_rec = Stanford::Mods::Record.new
144
- @smods_rec.from_str(m)
145
- @smods_rec.topic_search.should == nil
146
- end
147
- end
148
- end # topic_search
149
-
150
- context "geographic_search" do
151
- it "should call sw_geographic_search (from stanford-mods gem)" do
152
- m = "<mods #{@ns_decl}><subject><geographic>#{@geo}</geographic></subject></mods>"
153
- @smods_rec = Stanford::Mods::Record.new
154
- @smods_rec.from_str(m)
155
- @smods_rec.should_receive(:sw_geographic_search)
156
- @smods_rec.geographic_search
157
- end
158
- it "should log an info message when it encounters a geographicCode encoding it doesn't translate" do
159
- m = "<mods #{@ns_decl}><subject><geographicCode authority='iso3166'>ca</geographicCode></subject></mods>"
160
- @smods_rec = Stanford::Mods::Record.new
161
- @smods_rec.from_str(m)
162
- @smods_rec.sw_logger.should_receive(:info).with(/#{@fake_druid} has subject geographicCode element with untranslated encoding \(iso3166\): <geographicCode authority=.*>ca<\/geographicCode>/)
163
- @smods_rec.geographic_search
164
- end
165
- end # geographic_search
166
-
167
- context "subject_other_search" do
168
-
169
- it "should call sw_subject_names (from stanford-mods gem)" do
170
- @smods_rec.should_receive(:sw_subject_names)
171
- @smods_rec.subject_other_search
172
- end
173
- it "should call sw_subject_titles (from stanford-mods gem)" do
174
- @smods_rec.should_receive(:sw_subject_titles)
175
- @smods_rec.subject_other_search
176
- end
177
- it "should be nil if there are no values in the MODS" do
178
- m = "<mods #{@ns_decl}></mods>"
179
- @smods_rec = Stanford::Mods::Record.new
180
- @smods_rec.from_str(m)
181
- @smods_rec.subject_other_search.should == nil
182
- end
183
- it "should contain subject <name> SUBelement data" do
184
- @smods_rec.subject_other_search.should include(@s_name)
185
- end
186
- it "should contain subject <occupation> subelement data" do
187
- @smods_rec.subject_other_search.should include(@occupation)
188
- end
189
- it "should contain subject <titleInfo> SUBelement data" do
190
- @smods_rec.subject_other_search.should include(@s_title)
191
- end
192
- it "should not contain other subject element data" do
193
- @smods_rec.subject_other_search.should_not include(@genre)
194
- @smods_rec.subject_other_search.should_not include(@cart_coord)
195
- @smods_rec.subject_other_search.should_not include(@s_genre)
196
- @smods_rec.subject_other_search.should_not include(@geo)
197
- @smods_rec.subject_other_search.should_not include(@geo_code)
198
- @smods_rec.subject_other_search.should_not include(@hier_geo_country)
199
- @smods_rec.subject_other_search.should_not include(@temporal)
200
- @smods_rec.subject_other_search.should_not include(@topic)
201
- end
202
- it "should not be nil if there are only subject/name elements" do
203
- m = "<mods #{@ns_decl}><subject><name><namePart>#{@s_name}</namePart></name></subject></mods>"
204
- @smods_rec = Stanford::Mods::Record.new
205
- @smods_rec.from_str(m)
206
- @smods_rec.subject_other_search.should == [@s_name]
207
- end
208
- it "should not be nil if there are only subject/occupation elements" do
209
- m = "<mods #{@ns_decl}><subject><occupation>#{@occupation}</occupation></subject></mods>"
210
- @smods_rec = Stanford::Mods::Record.new
211
- @smods_rec.from_str(m)
212
-
213
-
214
- @smods_rec. subject_other_search.should == [@occupation]
215
- end
216
- it "should not be nil if there are only subject/titleInfo elements" do
217
- m = "<mods #{@ns_decl}><subject><titleInfo><title>#{@s_title}</title></titleInfo></subject></mods>"
218
- @smods_rec = Stanford::Mods::Record.new
219
- @smods_rec.from_str(m)
220
-
221
-
222
- @smods_rec. subject_other_search.should == [@s_title]
223
- end
224
- context "occupation subelement" do
225
- it "should have a separate value for each occupation element" do
226
- m = "<mods #{@ns_decl}>
227
- <subject>
228
- <occupation>first</occupation>
229
- <occupation>second</occupation>
230
- </subject>
231
- <subject><occupation>third</occupation></subject>
232
- </mods>"
233
- @smods_rec = Stanford::Mods::Record.new
234
- @smods_rec.from_str(m)
235
-
236
- @smods_rec.subject_other_search.should == ['first', 'second', 'third']
237
- end
238
- it "should be nil if there are only empty values in the MODS" do
239
- m = "<mods #{@ns_decl}><subject><occupation/></subject><note>notit</note></mods>"
240
- @smods_rec = Stanford::Mods::Record.new
241
- @smods_rec.from_str(m)
242
-
243
- @smods_rec. subject_other_search.should == nil
244
- end
245
- end
246
- end # subject_other_search
247
-
248
- context "subject_other_subvy_search" do
249
- it "should be nil if there are no values in the MODS" do
250
- @smods_rec = Stanford::Mods::Record.new
251
- @smods_rec.from_str(@ng_mods_no_subject.to_s)
252
-
253
- @smods_rec. subject_other_subvy_search.should == nil
254
- end
255
- it "should contain subject <temporal> subelement data" do
256
- @smods_rec.subject_other_subvy_search.should include(@temporal)
257
- end
258
- it "should contain subject <genre> SUBelement data" do
259
- @smods_rec.subject_other_subvy_search.should include(@s_genre)
260
- end
261
- it "should not contain other subject element data" do
262
- @smods_rec.subject_other_subvy_search.should_not include(@genre)
263
- @smods_rec.subject_other_subvy_search.should_not include(@cart_coord)
264
- @smods_rec.subject_other_subvy_search.should_not include(@geo)
265
- @smods_rec.subject_other_subvy_search.should_not include(@geo_code)
266
- @smods_rec.subject_other_subvy_search.should_not include(@hier_geo_country)
267
- @smods_rec.subject_other_subvy_search.should_not include(@s_name)
268
- @smods_rec.subject_other_subvy_search.should_not include(@occupation)
269
- @smods_rec.subject_other_subvy_search.should_not include(@topic)
270
- @smods_rec.subject_other_subvy_search.should_not include(@s_title)
271
- end
272
- it "should not be nil if there are only subject/temporal elements (no subject/genre)" do
273
- m = "<mods #{@ns_decl}><subject><temporal>#{@temporal}</temporal></subject></mods>"
274
- @smods_rec = Stanford::Mods::Record.new
275
- @smods_rec.from_str(m)
276
-
277
-
278
- @smods_rec. subject_other_subvy_search.should == [@temporal]
279
- end
280
- it "should not be nil if there are only subject/genre elements (no subject/temporal)" do
281
- m = "<mods #{@ns_decl}><subject><genre>#{@s_genre}</genre></subject></mods>"
282
- @smods_rec = Stanford::Mods::Record.new
283
- @smods_rec.from_str(m)
284
-
285
-
286
- @smods_rec. subject_other_subvy_search.should == [@s_genre]
287
- end
288
- context "temporal subelement" do
289
- it "should have a separate value for each temporal element" do
290
- m = "<mods #{@ns_decl}>
291
- <subject>
292
- <temporal>1890-1910</temporal>
293
- <temporal>20th century</temporal>
294
- </subject>
295
- <subject><temporal>another</temporal></subject>
296
- </mods>"
297
- @smods_rec = Stanford::Mods::Record.new
298
- @smods_rec.from_str(m)
299
-
300
- @smods_rec. subject_other_subvy_search.should == ['1890-1910', '20th century', 'another']
301
- end
302
- it "should log an info message when it encounters an encoding it doesn't translate" do
303
- m = "<mods #{@ns_decl}><subject><temporal encoding='iso8601'>197505</temporal></subject></mods>"
304
- @smods_rec = Stanford::Mods::Record.new
305
- @smods_rec.from_str(m)
306
-
307
- @smods_rec.sw_logger.should_receive(:info).with(/#{@fake_druid} has subject temporal element with untranslated encoding: <temporal encoding=.*>197505<\/temporal>/)
308
- @smods_rec.subject_other_subvy_search
309
- end
310
- it "should be nil if there are only empty values in the MODS" do
311
- m = "<mods #{@ns_decl}><subject><temporal/></subject><note>notit</note></mods>"
312
- @smods_rec = Stanford::Mods::Record.new
313
- @smods_rec.from_str(m)
314
-
315
- @smods_rec. subject_other_subvy_search.should == nil
316
- end
317
- end
318
- context "genre subelement" do
319
- it "should have a separate value for each genre element" do
320
- m = "<mods #{@ns_decl}>
321
- <subject>
322
- <genre>first</genre>
323
- <genre>second</genre>
324
- </subject>
325
- <subject><genre>third</genre></subject>
326
- </mods>"
327
- @smods_rec = Stanford::Mods::Record.new
328
- @smods_rec.from_str(m)
329
-
330
- @smods_rec. subject_other_subvy_search.should == ['first', 'second', 'third']
331
- end
332
- it "should be nil if there are only empty values in the MODS" do
333
- m = "<mods #{@ns_decl}><subject><genre/></subject><note>notit</note></mods>"
334
- @smods_rec = Stanford::Mods::Record.new
335
- @smods_rec.from_str(m)
336
-
337
- @smods_rec. subject_other_subvy_search.should == nil
338
- end
339
- end
340
- end # subject_other_subvy_search
341
-
342
- context "subject_all_search" do
343
- it "should be nil if there are no values in the MODS" do
344
- @smods_rec = Stanford::Mods::Record.new
345
- @smods_rec.from_str(@ng_mods_no_subject.to_s)
346
-
347
- @smods_rec. subject_all_search.should == nil
348
- end
349
- it "should contain top level <genre> element data" do
350
- @smods_rec.subject_all_search.should include(@genre)
351
- end
352
- it "should not contain cartographic sub element" do
353
- @smods_rec.subject_all_search.should_not include(@cart_coord)
354
- end
355
- it "should not include codes from hierarchicalGeographic sub element" do
356
- @smods_rec.subject_all_search.should_not include(@geo_code)
357
- end
358
- it "should contain all other subject subelement data" do
359
- @smods_rec.subject_all_search.should include(@s_genre)
360
- @smods_rec.subject_all_search.should include(@geo)
361
- @smods_rec.subject_all_search.should include(@hier_geo_country)
362
- @smods_rec.subject_all_search.should include(@s_name)
363
- @smods_rec.subject_all_search.should include(@occupation)
364
- @smods_rec.subject_all_search.should include(@temporal)
365
- @smods_rec.subject_all_search.should include(@s_title)
366
- @smods_rec.subject_all_search.should include(@topic)
367
- end
368
- end # subject_all_search
369
- end # subject search fields
370
-
371
- context "facet fields" do
372
- context "topic_facet" do
373
- it "should include topic subelement" do
374
- @smods_rec.topic_facet.should include(@topic)
375
- end
376
- it "should include sw_subject_names" do
377
- @smods_rec.topic_facet.should include(@s_name)
378
- end
379
- it "should include sw_subject_titles" do
380
- @smods_rec.topic_facet.should include(@s_title)
381
- end
382
- it "should include occupation subelement" do
383
- @smods_rec.topic_facet.should include(@occupation)
384
- end
385
- it "should have the trailing punctuation removed" do
386
- m = "<mods #{@ns_decl}><subject>
387
- <topic>comma,</topic>
388
- <occupation>semicolon;</occupation>
389
- <titleInfo><title>backslash \\</title></titleInfo>
390
- <name><namePart>internal, punct;uation</namePart></name>
391
- </subject></mods>"
392
- @smods_rec = Stanford::Mods::Record.new
393
- @smods_rec.from_str(m)
394
-
395
-
396
- @smods_rec. topic_facet.should include('comma')
397
- @smods_rec. topic_facet.should include('semicolon')
398
- @smods_rec. topic_facet.should include('backslash')
399
- @smods_rec. topic_facet.should include('internal, punct;uation')
400
- end
401
- it "should be nil if there are no values" do
402
- @smods_rec = Stanford::Mods::Record.new
403
- @smods_rec.from_str(@ng_mods_no_subject.to_s)
404
- @smods_rec. topic_facet.should == nil
405
- end
406
- end
407
- context "geographic_facet" do
408
- it "should call geographic_search" do
409
- @smods_rec.should_receive(:geographic_search)
410
- @smods_rec.geographic_facet
411
- end
412
- it "should be like geographic_search with the trailing punctuation (and preceding spaces) removed" do
413
- m = "<mods #{@ns_decl}><subject>
414
- <geographic>comma,</geographic>
415
- <geographic>semicolon;</geographic>
416
- <geographic>backslash \\</geographic>
417
- <geographic>internal, punct;uation</geographic>
418
- </subject></mods>"
419
- @smods_rec = Stanford::Mods::Record.new
420
- @smods_rec.from_str(m)
421
-
422
-
423
- @smods_rec. geographic_facet.should include('comma')
424
- @smods_rec. geographic_facet.should include('semicolon')
425
- @smods_rec. geographic_facet.should include('backslash')
426
- @smods_rec. geographic_facet.should include('internal, punct;uation')
427
- end
428
- it "should be nil if there are no values" do
429
- @smods_rec = Stanford::Mods::Record.new
430
- @smods_rec.from_str(@ng_mods_no_subject.to_s)
431
- @smods_rec. geographic_facet.should == nil
432
- end
433
- end
434
- context "era_facet" do
435
- it "should be temporal subelement with the trailing punctuation removed" do
436
- m = "<mods #{@ns_decl}><subject>
437
- <temporal>comma,</temporal>
438
- <temporal>semicolon;</temporal>
439
- <temporal>backslash \\</temporal>
440
- <temporal>internal, punct;uation</temporal>
441
- </subject></mods>"
442
- @smods_rec = Stanford::Mods::Record.new
443
- @smods_rec.from_str(m)
444
-
445
-
446
- @smods_rec. era_facet.should include('comma')
447
- @smods_rec. era_facet.should include('semicolon')
448
- @smods_rec. era_facet.should include('backslash')
449
- @smods_rec. era_facet.should include('internal, punct;uation')
450
- end
451
- it "should be nil if there are no values" do
452
- @smods_rec = Stanford::Mods::Record.new
453
- @smods_rec.from_str(@ng_mods_no_subject.to_s)
454
- @smods_rec. era_facet.should == nil
455
- end
456
-
457
- end # subject facet fields
458
- context "pub_dates" do
459
- it "should choose the first date" do
460
- m = "<mods #{@ns_decl}><originInfo>
461
- <dateCreated>1904</dateCreated>
462
- <dateCreated>1904</dateCreated>
463
- <dateIssued>1906</dateIssued>
464
-
465
- </originInfo></mods>"
466
- @smods_rec = Stanford::Mods::Record.new
467
- @smods_rec.from_str(m)
468
- @smods_rec.pub_dates.should == ['1906','1904','1904']
469
- end
470
- end
471
- end # context sw subject methods
472
- context "pub_date" do
473
- it "should choose the first date" do
474
- m = "<mods #{@ns_decl}><originInfo>
475
- <dateCreated>1904</dateCreated>
476
- </originInfo></mods>"
477
- @smods_rec = Stanford::Mods::Record.new
478
- @smods_rec.from_str(m)
479
- @smods_rec.pub_date.should == '1904'
480
- end
481
- it "should parse a date" do
482
- m = "<mods #{@ns_decl}><originInfo>
483
- <dateCreated>Aug. 3rd, 1886</dateCreated>
484
- </originInfo></mods>"
485
- @smods_rec = Stanford::Mods::Record.new
486
- @smods_rec.from_str(m)
487
- @smods_rec.pub_date.should == '1886'
488
- end
489
- it "should remove question marks and brackets" do
490
- m = "<mods #{@ns_decl}><originInfo>
491
- <dateCreated>Aug. 3rd, [18]86?</dateCreated>
492
- </originInfo></mods>"
493
- @smods_rec = Stanford::Mods::Record.new
494
- @smods_rec.from_str(m)
495
- @smods_rec.pub_date.should == '1886'
496
- end
497
- it 'should handle an s after the decade' do
498
- m = "<mods #{@ns_decl}><originInfo>
499
- <dateCreated>early 1890s</dateCreated>
500
- </originInfo></mods>"
501
- @smods_rec = Stanford::Mods::Record.new
502
- @smods_rec.from_str(m)
503
- @smods_rec.pub_date.should == '1890'
504
- end
505
- it 'should choose a date ending with CE if there are multiple dates' do
506
- m = "<mods #{@ns_decl}><originInfo><dateIssued>7192 AM (li-Adam) / 1684 CE</dateIssued><issuance>monographic</issuance></originInfo>"
507
- @smods_rec = Stanford::Mods::Record.new
508
- @smods_rec.from_str(m)
509
- @smods_rec.pub_date.should == '1684'
510
- end
511
- it 'should handle hyphenated range dates' do
512
- m = "<mods #{@ns_decl}><originInfo><dateIssued>1282 AH / 1865-6 CE</dateIssued><issuance>monographic</issuance></originInfo>"
513
- @smods_rec = Stanford::Mods::Record.new
514
- @smods_rec.from_str(m)
515
- @smods_rec.pub_date.should == '1865'
516
- end
517
- it 'should work with multiple 4 digit dates' do
518
- m = "<mods #{@ns_decl}><originInfo><dateCreated>Text dated June 4, 1594; miniatures added by 1596</dateCreated></originInfo>"
519
- @smods_rec = Stanford::Mods::Record.new
520
- @smods_rec.from_str(m)
521
- @smods_rec.pub_date.should == '1594'
522
- end
523
- it 'should work on 3 digit BC dates' do
524
- m = "<mods #{@ns_decl}><originInfo><dateCreated>300 B.C.</dateCreated></originInfo>"
525
- @smods_rec = Stanford::Mods::Record.new
526
- @smods_rec.from_str(m)
527
- @smods_rec.pub_year.should == '-700'
528
- @smods_rec.pub_date.should == '-700'
529
- @smods_rec.pub_date_sort.should =='-700'
530
- @smods_rec.pub_date_facet.should == '300 B.C.'
531
- end
532
- it 'should handle century based dates' do
533
- m = "<mods #{@ns_decl}><originInfo><dateIssued>13th century AH / 19th CE</dateIssued><issuance>monographic</issuance></originInfo>"
534
- @smods_rec = Stanford::Mods::Record.new
535
- @smods_rec.from_str(m)
536
- @smods_rec.pub_date_facet.should == '19th century'
537
- @smods_rec.pub_date_sort.should =='1800'
538
- @smods_rec.pub_date.should == '18--'
539
- end
540
- it 'should handle multiple CE dates' do
541
- m = "<mods #{@ns_decl}><originInfo><dateIssued>6 Dhu al-Hijjah 923 AH / 1517 CE -- 7 Rabi I 924 AH / 1518 CE</dateIssued><issuance>monographic</issuance></originInfo>"
542
- @smods_rec = Stanford::Mods::Record.new
543
- @smods_rec.from_str(m)
544
- @smods_rec.pub_date.should == '1517'
545
- @smods_rec.pub_date_sort.should =='1517'
546
- @smods_rec.pub_date_facet.should == '1517'
547
- end
548
- it 'should handle this case from walters' do
549
- m = "<mods #{@ns_decl}><originInfo><dateIssued>Late 14th or early 15th century CE</dateIssued><issuance>monographic</issuance></originInfo>"
550
- @smods_rec = Stanford::Mods::Record.new
551
- @smods_rec.from_str(m)
552
- @smods_rec.pub_date.should == '14--'
553
- @smods_rec.pub_date_sort.should =='1400'
554
- @smods_rec.pub_date_facet.should == '15th century'
555
- end
556
- it 'should work on 3 digit dates' do
557
- m = "<mods #{@ns_decl}><originInfo><dateIssued>966 CE</dateIssued><issuance>monographic</issuance></originInfo>"
558
- @smods_rec = Stanford::Mods::Record.new
559
- @smods_rec.from_str(m)
560
- @smods_rec.pub_date.should == '966'
561
- @smods_rec.pub_date_sort.should =='0966'
562
- @smods_rec.pub_date_facet.should == '966'
563
- end
564
- it 'should work on 3 digit dates' do
565
- m = "<mods #{@ns_decl}><originInfo><dateIssued>3rd century AH / 9th CE</dateIssued><issuance>monographic</issuance></originInfo>"
566
- @smods_rec = Stanford::Mods::Record.new
567
- @smods_rec.from_str(m)
568
-
569
- @smods_rec.pub_date.should == '8--'
570
- @smods_rec.pub_date_sort.should =='0800'
571
- @smods_rec.pub_date_facet.should == '9th century'
572
- end
573
-
574
- context "dates with u notation (e.g., 198u)" do
575
- context "single digit u notation (e.g., 198u)" do
576
- before(:each) do
577
- m = "<mods #{@ns_decl}>
578
- <originInfo>
579
- <dateIssued encoding=\"marc\" point=\"start\" keyDate=\"yes\">198u</dateIssued>
580
- <dateIssued encoding=\"marc\" point=\"end\">9999</dateIssued>
581
- </originInfo></mods>"
582
- @smods_rec = Stanford::Mods::Record.new
583
- @smods_rec.from_str(m)
584
- end
585
- it "recognizes single digit u notation" do
586
- dates = ["198u", "9999"]
587
- uDate = @smods_rec.get_u_year dates
588
- uDate.should eql("1980")
589
- end
590
- it 'pub_date: 198u = 1980' do
591
- @smods_rec.pub_date.should == '1980'
592
- end
593
- it "pub_date_sort: 198u = 1980" do
594
- @smods_rec.pub_date_sort.should =='1980'
595
- end
596
- it "pub_date_facet: 198u = 1980" do
597
- @smods_rec.pub_date_facet.should == '1980'
598
- end
599
- end
600
- context "double digit u notation (e.g., 19uu)" do
601
- before(:each) do
602
- m = "<mods #{@ns_decl}>
603
- <originInfo>
604
- <dateIssued encoding=\"marc\" point=\"start\" keyDate=\"yes\">19uu</dateIssued>
605
- <dateIssued encoding=\"marc\" point=\"end\">9999</dateIssued>
606
- </originInfo></mods>"
607
- @smods_rec = Stanford::Mods::Record.new
608
- @smods_rec.from_str(m)
609
- end
610
- it "recognizes double digit u notation" do
611
- dates = ["19uu", "9999"]
612
- uDate = @smods_rec.get_u_year dates
613
- uDate.should eql("19--")
614
- end
615
- it 'pub_date: 19uu = 19--' do
616
- @smods_rec.pub_date.should == '19--'
617
- end
618
- it "pub_date_sort: 19uu = 1900" do
619
- @smods_rec.pub_date_sort.should =='1900'
620
- end
621
- it "pub_date_facet: 19uu = 20th century" do
622
- @smods_rec.pub_date_facet.should == '20th century'
623
- end
624
- end
625
- end
626
-
627
-
628
-
629
-
630
-
631
- end #context pub_dates
632
- context 'pub_date_sort' do
633
- before :each do
634
- m = "<mods #{@ns_decl}><originInfo>
635
- <dateCreated>Aug. 3rd, 1886</dateCreated>
636
- </originInfo></mods>"
637
- @smods_rec = Stanford::Mods::Record.new
638
- @smods_rec.from_str(m)
639
-
640
- end
641
- it 'should work on normal dates' do
642
- @smods_rec.stub(:pub_date).and_return('1945')
643
- @smods_rec.pub_date_sort.should == '1945'
644
- end
645
- it 'should work on 3 digit dates' do
646
- @smods_rec.stub(:pub_date).and_return('945')
647
- @smods_rec.pub_date_sort.should == '0945'
648
- end
649
- it 'should work on century dates' do
650
- @smods_rec.stub(:pub_date).and_return('16--')
651
- @smods_rec.pub_date_sort.should == '1600'
652
- end
653
- it 'should work on 3 digit century dates' do
654
- @smods_rec.stub(:pub_date).and_return('9--')
655
- @smods_rec.pub_date_sort.should == '0900'
656
- end
657
- end
658
-
659
- context "format" do
660
- it "should check genre as part of deciding format" do
661
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResouce><genre>thesis</genre></mods>"
662
- @smods_rec = Stanford::Mods::Record.new
663
- @smods_rec.from_str(m)
664
- @smods_rec.format.should == ['Thesis']
665
- end
666
- it 'should work for datasets' do
667
- m = "<mods #{@ns_decl}><typeOfResource>software, multimedia</typeOfResouce></mods>"
668
- @smods_rec = Stanford::Mods::Record.new
669
- @smods_rec.from_str(m)
670
- @smods_rec.format.should == ['Computer File']
671
- end
672
- it 'should work for books' do
673
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResouce><originInfo><issuance>monographic</issueance></originInfo></mods>"
674
- @smods_rec = Stanford::Mods::Record.new
675
- @smods_rec.from_str(m)
676
- @smods_rec.format.should == ['Book']
677
- end
678
- it "should work for a hydrus journal article" do
679
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResouce><genre>article</genre></mods>"
680
- @smods_rec = Stanford::Mods::Record.new
681
- @smods_rec.from_str(m)
682
- @smods_rec.format.should == ['Journal/Periodical']
683
- end
684
- it "should choose the format" do
685
- m = "<mods #{@ns_decl}><typeOfResource>still image</typeOfResouce></mods>"
686
- @smods_rec = Stanford::Mods::Record.new
687
- @smods_rec.from_str(m)
688
- @smods_rec.format.should == ['Image']
689
- end
690
- # Student Project Reports: spec via email from Vitus, August 16, 2013
691
- it "should give a format of Other for <genre>student project report</genre> and <typeOfResource>text</typeOfResouce>" do
692
- m = "<mods #{@ns_decl}><genre>student project report</genre><typeOfResource>text</typeOfResouce></mods>"
693
- @smods_rec = Stanford::Mods::Record.new
694
- @smods_rec.from_str(m)
695
- @smods_rec.format.should == ['Other']
696
- end
697
- # Hydrus mappings per GRYPHONDOR-207
698
- it "should give a format of Computer File for <genre>game</genre> and <typeOfResource>software, multimedia</typeOfResouce>" do
699
- m = "<mods #{@ns_decl}><genre>game</genre><typeOfResource>software, multimedia</typeOfResouce></mods>"
700
- @smods_rec = Stanford::Mods::Record.new
701
- @smods_rec.from_str(m)
702
- @smods_rec.format.should == ['Computer File']
703
- end
704
- it "should give a format of Video for <genre>motion picture</genre> and <typeOfResource>moving image</typeOfResouce>" do
705
- m = "<mods #{@ns_decl}><genre>motion picture</genre><typeOfResource>moving image</typeOfResouce></mods>"
706
- @smods_rec = Stanford::Mods::Record.new
707
- @smods_rec.from_str(m)
708
- @smods_rec.format.should == ['Video']
709
- end
710
- it "should give a format of Sound Recording for <genre>sound</genre> and <typeOfResource>sound recording-nonmusical</typeOfResouce>" do
711
- m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording-nonmusical</typeOfResouce></mods>"
712
- @smods_rec = Stanford::Mods::Record.new
713
- @smods_rec.from_str(m)
714
- @smods_rec.format.should == ['Sound Recording']
715
- end
716
- it "should give a format of Conference Proceedings for <genre>conference publication</genre> and <typeOfResource>text</typeOfResouce>" do
717
- m = "<mods #{@ns_decl}><genre>conference publication</genre><typeOfResource>text</typeOfResouce></mods>"
718
- @smods_rec = Stanford::Mods::Record.new
719
- @smods_rec.from_str(m)
720
- @smods_rec.format.should == ['Conference Proceedings']
721
- end
722
- it "should give a format of Book for <genre>technical report</genre> and <typeOfResource>text</typeOfResouce>" do
723
- m = "<mods #{@ns_decl}><genre>technical report</genre><typeOfResource>text</typeOfResouce></mods>"
724
- @smods_rec = Stanford::Mods::Record.new
725
- @smods_rec.from_str(m)
726
- @smods_rec.format.should == ['Book']
727
- end
728
- # end Hydrus mappings
729
- it "should give a format of Music - Score for <typeOfResource>notated music</typeOfResouce>" do
730
- m = "<mods #{@ns_decl}><typeOfResource>notated music</typeOfResouce></mods>"
731
- @smods_rec = Stanford::Mods::Record.new
732
- @smods_rec.from_str(m)
733
- @smods_rec.format.should == ['Music - Score']
734
- end
735
- it "should return nothing if there is no format info" do
736
- m = "<mods #{@ns_decl}><originInfo>
737
- <dateCreated>1904</dateCreated>
738
- </originInfo></mods>"
739
- @smods_rec = Stanford::Mods::Record.new
740
- @smods_rec.from_str(m)
741
- @smods_rec.format.should == []
742
- end
743
- end#context format
744
- context "pub_date_groups" do
745
- it 'should generate the groups' do
746
- m = "<mods #{@ns_decl}><originInfo>
747
- <dateCreated>1904</dateCreated>
748
- </originInfo></mods>"
749
- @smods_rec = Stanford::Mods::Record.new
750
- @smods_rec.from_str(m)
751
-
752
- @smods_rec.pub_date_groups(1904).should == ['More than 50 years ago']
753
- end
754
- it 'should work for a modern date too' do
755
- m = "<mods #{@ns_decl}><originInfo>
756
- <dateCreated>1904</dateCreated>
757
- </originInfo></mods>"
758
- @smods_rec = Stanford::Mods::Record.new
759
- @smods_rec.from_str(m)
760
- @smods_rec.pub_date_groups(2013).should == ["This year"]
761
- end
762
- it 'should work ok given a nil date' do
763
- m = "<mods #{@ns_decl}><originInfo>
764
- <dateCreated>1904</dateCreated>
765
- </originInfo></mods>"
766
- @smods_rec = Stanford::Mods::Record.new
767
- @smods_rec.from_str(m)
768
- @smods_rec.pub_date_groups(nil).should == nil
769
- end
770
- end#context pub date groups
771
- end