om 1.4.4 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,50 +5,50 @@ describe "OM::XML::TermXpathGeneratorSpec" do
5
5
 
6
6
  before(:all) do
7
7
  builder = OM::XML::Terminology::Builder.new do |t|
8
- t.root(:path=>"mods")
8
+ t.root(:path=>"mods", :xmlns=>"http://www.loc.gov/mods/v3", :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
9
9
  t.name_ {
10
10
  t.family_name(:path=>"namePart", :attributes=>{:type=>"family"})
11
11
  t.first_name(:path=>"namePart", :attributes=>{:type=>"given"}, :label=>"first name")
12
12
  }
13
- # lookup :person, :first_name
13
+ # lookup :person, :first_name
14
14
  t.person(:ref=>:name, :attributes=>{:type=>"personal"})
15
15
  t.family_name(:proxy=>[:name, :family_name])
16
16
  end
17
- @sample_terminology = builder.build
18
- @rootless_terminology = OM::XML::Terminology.new
17
+ @sample_terminology = builder.build
18
+ @rootless_terminology = OM::XML::Terminology.new
19
19
  end
20
-
20
+
21
21
  before(:each) do
22
22
  @test_term = OM::XML::Term.new(:terms_of_address, :path=>"namePart", :attributes=>{:type=>"termsOfAddress"})
23
23
  @test_term_with_default_path = OM::XML::Term.new(:volume, :path=>"detail", :attributes=>{:type=>"volume"}, :default_content_path=>"number")
24
24
  @test_role_text = OM::XML::Term.new(:role_text, :path=>"roleTerm", :attributes=>{:type=>"text"})
25
25
  @test_lang_attribute = OM::XML::Term.new(:language, :path=>{:attribute=>"lang"})
26
26
  @test_none_attribute_value = OM::XML::Term.new(:person_id, :path=>"namePart", :attributes=>{:type=>:none})
27
-
27
+
28
28
  end
29
-
29
+
30
30
  it "should support terms that are pointers to attribute values" do
31
31
  OM::XML::TermXpathGenerator.generate_xpath(@test_lang_attribute, :absolute).should == "//@lang"
32
32
  OM::XML::TermXpathGenerator.generate_xpath(@test_lang_attribute, :relative).should == "@lang"
33
- OM::XML::TermXpathGenerator.generate_xpath(@test_lang_attribute, :constrained).should == '//@lang[contains(., "#{constraint_value}")]'.gsub('"', '\"')
33
+ OM::XML::TermXpathGenerator.generate_xpath(@test_lang_attribute, :constrained).should == '//@lang[contains(., "#{constraint_value}")]'.gsub('"', '\"')
34
34
  end
35
-
35
+
36
36
  describe "generate_xpath" do
37
37
  it "should generate an xpath based on the given mapper and options" do
38
38
  OM::XML::TermXpathGenerator.expects(:generate_absolute_xpath).with(@test_term)
39
39
  OM::XML::TermXpathGenerator.generate_xpath(@test_term, :absolute)
40
-
40
+
41
41
  OM::XML::TermXpathGenerator.expects(:generate_relative_xpath).with(@test_term)
42
42
  OM::XML::TermXpathGenerator.generate_xpath(@test_term, :relative)
43
-
43
+
44
44
  OM::XML::TermXpathGenerator.expects(:generate_constrained_xpath).with(@test_term)
45
45
  OM::XML::TermXpathGenerator.generate_xpath(@test_term, :constrained)
46
46
  end
47
47
  end
48
-
48
+
49
49
  describe "generate_relative_xpath" do
50
50
  it "should generate a relative xpath based on the given mapper" do
51
- OM::XML::TermXpathGenerator.generate_relative_xpath(@test_term).should == 'oxns:namePart[@type="termsOfAddress"]'
51
+ OM::XML::TermXpathGenerator.generate_relative_xpath(@test_term).should == 'namePart[@type="termsOfAddress"]'
52
52
  end
53
53
  it "should support mappers without namespaces" do
54
54
  @test_term.namespace_prefix = nil
@@ -59,42 +59,42 @@ describe "OM::XML::TermXpathGeneratorSpec" do
59
59
  OM::XML::TermXpathGenerator.generate_relative_xpath(text_term).should == 'text()[normalize-space(.)]'
60
60
  end
61
61
  it "should set a 'not' predicate if the attribute value is :none" do
62
- OM::XML::TermXpathGenerator.generate_relative_xpath(@test_none_attribute_value).should == 'oxns:namePart[not(@type)]'
62
+ OM::XML::TermXpathGenerator.generate_relative_xpath(@test_none_attribute_value).should == 'namePart[not(@type)]'
63
63
  end
64
64
 
65
65
  end
66
-
66
+
67
67
  describe "generate_absolute_xpath" do
68
68
  it "should generate an absolute xpath based on the given mapper" do
69
- OM::XML::TermXpathGenerator.generate_absolute_xpath(@test_term).should == '//oxns:namePart[@type="termsOfAddress"]'
69
+ OM::XML::TermXpathGenerator.generate_absolute_xpath(@test_term).should == '//namePart[@type="termsOfAddress"]'
70
70
  end
71
- it "should prepend the xpath for any parent nodes" do
72
- mock_parent_mapper = mock("Term", :xpath_absolute=>'//oxns:name[@type="conference"]/oxns:role')
71
+ it "should prepend the xpath for any parent nodes" do
72
+ mock_parent_mapper = mock("Term", :xpath_absolute=>'//name[@type="conference"]/role')
73
73
  @test_role_text.stubs(:parent).returns(mock_parent_mapper)
74
- OM::XML::TermXpathGenerator.generate_absolute_xpath(@test_role_text).should == '//oxns:name[@type="conference"]/oxns:role/oxns:roleTerm[@type="text"]'
74
+ OM::XML::TermXpathGenerator.generate_absolute_xpath(@test_role_text).should == '//name[@type="conference"]/role/roleTerm[@type="text"]'
75
75
  end
76
76
  end
77
77
 
78
78
  describe "generate_constrained_xpath" do
79
79
  it "should generate a constrained xpath based on the given mapper" do
80
- OM::XML::TermXpathGenerator.generate_constrained_xpath(@test_term).should == '//oxns:namePart[@type="termsOfAddress" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
80
+ OM::XML::TermXpathGenerator.generate_constrained_xpath(@test_term).should == '//namePart[@type="termsOfAddress" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
81
81
  end
82
82
  end
83
-
83
+
84
84
  it "should support mappers without namespaces" do
85
85
  @test_term.namespace_prefix = nil
86
86
  OM::XML::TermXpathGenerator.generate_relative_xpath(@test_term).should == 'namePart[@type="termsOfAddress"]'
87
87
  OM::XML::TermXpathGenerator.generate_absolute_xpath(@test_term).should == '//namePart[@type="termsOfAddress"]'
88
- OM::XML::TermXpathGenerator.generate_constrained_xpath(@test_term).should == '//namePart[@type="termsOfAddress" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
88
+ OM::XML::TermXpathGenerator.generate_constrained_xpath(@test_term).should == '//namePart[@type="termsOfAddress" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
89
89
  end
90
-
90
+
91
91
  describe "generate_xpath_with_indexes" do
92
92
  it "should accept multiple constraints" do
93
93
  generated_xpath = OM::XML::TermXpathGenerator.generate_xpath_with_indexes( @sample_terminology, :person, {:first_name=>"Tim", :family_name=>"Berners-Lee"} )
94
94
  # expect an xpath that looks like this: '//oxns:name[@type="personal" and contains(oxns:namePart[@type="family"], "Berners-Lee") and contains(oxns:namePart[@type="given"], "Tim")]'
95
95
  # can't use string comparison because the contains functions can arrive in any order
96
- generated_xpath.should match( /\/\/oxns:name\[@type=\"personal\".*and contains\(oxns:namePart\[@type=\"given\"\], \"Tim\"\).*\]/ )
97
- generated_xpath.should match( /\/\/oxns:name\[@type=\"personal\".*and contains\(oxns:namePart\[@type=\"family\"\], \"Berners-Lee\"\).*\]/ )
96
+ generated_xpath.should match( /\/\/oxns:name\[@type=\"personal\".*and contains\(oxns:namePart\[@type=\"given\"\], \"Tim\"\).*\]/ )
97
+ generated_xpath.should match( /\/\/oxns:name\[@type=\"personal\".*and contains\(oxns:namePart\[@type=\"family\"\], \"Berners-Lee\"\).*\]/ )
98
98
  end
99
99
  it "should support xpath queries as argument" do
100
100
  OM::XML::TermXpathGenerator.generate_xpath_with_indexes(@sample_terminology, '//oxns:name[@type="personal"][1]/oxns:namePart').should == '//oxns:name[@type="personal"][1]/oxns:namePart'
@@ -115,14 +115,22 @@ describe "OM::XML::TermXpathGeneratorSpec" do
115
115
  @sample_terminology.xpath_with_indexes({:family_name=>1}).should == "//oxns:name/oxns:namePart[@type=\"family\"]"
116
116
  end
117
117
  end
118
-
118
+
119
119
  it "should support mappers with default_content_path" do
120
120
  pending "need to implement mapper_set first"
121
121
  #@test_term_with_default_path = OM::XML::Term.new(:volume, :path=>"detail", :attributes=>{:type=>"volume"}, :default_content_path=>"number")
122
-
122
+
123
123
  OM::XML::TermXpathGenerator.generate_relative_xpath(@test_term_with_default_path).should == 'oxns:detail[@type="volume"]'
124
124
  OM::XML::TermXpathGenerator.generate_absolute_xpath(@test_term_with_default_path).should == '//oxns:detail[@type="volume"]'
125
- OM::XML::TermXpathGenerator.generate_constrained_xpath(@test_term_with_default_path).should == '//oxns:detail[contains(oxns:number[@type="volume"], "#{constraint_value}")]'.gsub('"', '\"')
125
+ OM::XML::TermXpathGenerator.generate_constrained_xpath(@test_term_with_default_path).should == '//oxns:detail[contains(oxns:number[@type="volume"], "#{constraint_value}")]'.gsub('"', '\"')
126
126
  end
127
-
127
+
128
+ it "should default to using an inherited namspace prefix" do
129
+
130
+ term = @sample_terminology.retrieve_term(:person, :first_name)
131
+ OM::XML::TermXpathGenerator.generate_absolute_xpath(term).should == "//oxns:name[@type=\"personal\"]/oxns:namePart[@type=\"given\"]"
132
+
133
+
134
+ end
135
+
128
136
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
  require "om"
3
3
 
4
4
  describe "OM::XML::Terminology" do
5
-
5
+
6
6
  before(:each) do
7
7
  @test_terminology = OM::XML::Terminology.new
8
8
 
@@ -21,10 +21,10 @@ describe "OM::XML::Terminology" do
21
21
  t.main_title_lang(:path=>{:attribute=> "xml:lang"})
22
22
  }
23
23
  t.language(:path=>{:attribute=>"lang"})
24
- }
24
+ }
25
25
  # t.title(:path=>"titleInfo", :default_content_path=>"title") {
26
26
  # t.@language(:path=>{:attribute=>"lang"})
27
- # }
27
+ # }
28
28
  # This is a mods:name. The underscore is purely to avoid namespace conflicts.
29
29
  t.name_ {
30
30
  # this is a namepart
@@ -40,10 +40,10 @@ describe "OM::XML::Terminology" do
40
40
  t.terms_of_address(:path=>"namePart", :attributes=>{:type=>"termsOfAddress"})
41
41
  t.person_id(:path=>"namePart", :attributes=>{:type=>:none})
42
42
  }
43
- # lookup :person, :first_name
43
+ # lookup :person, :first_name
44
44
  t.person(:ref=>:name, :attributes=>{:type=>"personal"})
45
45
  t.conference(:ref=>:name, :attributes=>{:type=>"conference"})
46
-
46
+
47
47
  t.role {
48
48
  t.text(:path=>"roleTerm",:attributes=>{:type=>"text"})
49
49
  t.code(:path=>"roleTerm",:attributes=>{:type=>"code"})
@@ -72,14 +72,40 @@ describe "OM::XML::Terminology" do
72
72
 
73
73
  @test_full_terminology = @builder_with_block.build
74
74
 
75
+ @namespaceless_terminology = OM::XML::Terminology::Builder.new do |t|
76
+ t.root(:path=>"note", :xmlns=> nil )
77
+ t.to
78
+ t.from
79
+ t.heading
80
+ t.body
81
+ end
82
+ @namespaceless_terminology = @namespaceless_terminology.build
83
+
84
+ class NamespacelessTest
85
+ include OM::XML::Document
86
+ end
87
+ NamespacelessTest.terminology = @namespaceless_terminology
88
+ @namespaceless_doc = NamespacelessTest.from_xml(fixture("no_namespace.xml") )
89
+ end
90
+
91
+ describe "namespaceless terminologies" do
92
+ it "should generate xpath queries without namespaces" do
93
+ @namespaceless_terminology.xpath_for(:to).should == "//to"
94
+ @namespaceless_terminology.xpath_for(:note, :from).should == "//note/from"
95
+ end
96
+
97
+ it "should work with xml documents that have no namespaces" do
98
+ @namespaceless_doc.from.first.should == "Jani"
99
+ @namespaceless_doc.to.should == ["Tove"]
100
+ end
75
101
  end
76
-
102
+
77
103
  describe "basics" do
78
104
 
79
105
  it "constructs xpath queries for finding properties" do
80
- @test_full_terminology.retrieve_term(:name).xpath.should == '//oxns:name'
81
- @test_full_terminology.retrieve_term(:name).xpath_relative.should == 'oxns:name'
82
-
106
+ @test_full_terminology.retrieve_term(:name).xpath.should == '//oxns:name'
107
+ @test_full_terminology.retrieve_term(:name).xpath_relative.should == 'oxns:name'
108
+
83
109
  @test_full_terminology.retrieve_term(:person).xpath.should == '//oxns:name[@type="personal"]'
84
110
  @test_full_terminology.retrieve_term(:person).xpath_relative.should == 'oxns:name[@type="personal"]'
85
111
  @test_full_terminology.retrieve_term(:person, :person_id).xpath_relative.should == 'oxns:namePart[not(@type)]'
@@ -92,9 +118,9 @@ describe "OM::XML::Terminology" do
92
118
  end
93
119
 
94
120
  it "constructs templates for value-driven searches" do
95
- @test_full_terminology.retrieve_term(:name).xpath_constrained.should == '//oxns:name[contains(., "#{constraint_value}")]'.gsub('"', '\"')
121
+ @test_full_terminology.retrieve_term(:name).xpath_constrained.should == '//oxns:name[contains(., "#{constraint_value}")]'.gsub('"', '\"')
96
122
  @test_full_terminology.retrieve_term(:person).xpath_constrained.should == '//oxns:name[@type="personal" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
97
-
123
+
98
124
  # Example of how you could use these templates:
99
125
  constraint_value = "SAMPLE CONSTRAINT VALUE"
100
126
  constrained_query = eval( '"' + @test_full_terminology.retrieve_term(:person).xpath_constrained + '"' )
@@ -105,9 +131,9 @@ describe "OM::XML::Terminology" do
105
131
  name_date_term = @test_full_terminology.retrieve_term(:name, :date)
106
132
  name_date_term.xpath.should == '//oxns:name/oxns:namePart[@type="date"]'
107
133
  name_date_term.xpath_relative.should == 'oxns:namePart[@type="date"]'
108
- name_date_term.xpath_constrained.should == '//oxns:name/oxns:namePart[@type="date" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
109
- # name_date_term.xpath_constrained.should == '//oxns:name[contains(oxns:namePart[@type="date"], "#{constraint_value}")]'.gsub('"', '\"')
110
-
134
+ name_date_term.xpath_constrained.should == '//oxns:name/oxns:namePart[@type="date" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
135
+ # name_date_term.xpath_constrained.should == '//oxns:name[contains(oxns:namePart[@type="date"], "#{constraint_value}")]'.gsub('"', '\"')
136
+
111
137
  person_date_term = @test_full_terminology.retrieve_term(:person, :date)
112
138
  person_date_term.xpath.should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date"]'
113
139
  person_date_term.xpath_relative.should == 'oxns:namePart[@type="date"]'
@@ -115,7 +141,7 @@ describe "OM::XML::Terminology" do
115
141
  # person_date_term.xpath_constrained.should == '//oxns:name[@type="personal" and contains(oxns:namePart[@type="date"], "#{constraint_value}")]'.gsub('"', '\"')
116
142
  end
117
143
 
118
- it "supports subelements that are specified using a :ref" do
144
+ it "supports subelements that are specified using a :ref" do
119
145
  role_term = @test_full_terminology.retrieve_term(:name, :role)
120
146
  role_term.xpath.should == '//oxns:name/oxns:role'
121
147
  role_term.xpath_relative.should == 'oxns:role'
@@ -140,10 +166,10 @@ describe "OM::XML::Terminology" do
140
166
  volume_term.xpath_constrained.should == '//oxns:relatedItem[@type="host"]/oxns:part/oxns:detail[@type="volume" and contains(oxns:number, "#{constraint_value}")]'.gsub('"', '\"')
141
167
  end
142
168
 
143
- it "should not overwrite default property info when adding a variant property" do
169
+ it "should not overwrite default property info when adding a variant property" do
144
170
  name_term = @test_full_terminology.retrieve_term(:name)
145
171
  person_term = @test_full_terminology.retrieve_term(:person)
146
-
172
+
147
173
  name_term.should_not equal(person_term)
148
174
  name_term.xpath.should_not equal(person_term.xpath)
149
175
  name_term.children.should_not equal(person_term.children)
@@ -151,7 +177,7 @@ describe "OM::XML::Terminology" do
151
177
  end
152
178
 
153
179
  end
154
-
180
+
155
181
  describe '#from_xml' do
156
182
  it "should let you load mappings from an xml file" do
157
183
  pending
@@ -160,14 +186,14 @@ describe "OM::XML::Terminology" do
160
186
  vocab.mappers.should == {}
161
187
  end
162
188
  end
163
-
189
+
164
190
  describe '#to_xml' do
165
191
  it "should let you serialize mappings to an xml document" do
166
192
  pending
167
193
  TerminologyTest.to_xml.should == ""
168
194
  end
169
195
  end
170
-
196
+
171
197
  describe ".has_term?" do
172
198
  it "should return true if the specified term does exist in the terminology" do
173
199
  @test_full_terminology.has_term?(:journal,:issue,:end_page).should be_true
@@ -180,7 +206,7 @@ describe "OM::XML::Terminology" do
180
206
  @test_full_terminology.has_term?(:name, :date, :nonexistentTerm, :anotherTermName).should be_false
181
207
  end
182
208
  end
183
-
209
+
184
210
  describe ".retrieve_term" do
185
211
  it "should return the mapper identified by the given pointer" do
186
212
  term = @test_terminology.retrieve_term(:name, :namePart)
@@ -192,29 +218,29 @@ describe "OM::XML::Terminology" do
192
218
  @test_full_terminology.retrieve_term(:name, :date).path.should == 'namePart'
193
219
  @test_full_terminology.retrieve_term(:name, :date).attributes.should == {:type=>"date"}
194
220
  @test_full_terminology.retrieve_term(:name, :affiliation).path.should == 'affiliation'
195
- @test_full_terminology.retrieve_term(:name, :date).xpath.should == '//oxns:name/oxns:namePart[@type="date"]'
221
+ @test_full_terminology.retrieve_term(:name, :date).xpath.should == '//oxns:name/oxns:namePart[@type="date"]'
196
222
  end
197
223
  it "should support looking up variant Terms" do
198
- @test_full_terminology.retrieve_term(:person).path.should == 'name'
199
- @test_full_terminology.retrieve_term(:person).attributes.should == {:type=>"personal"}
224
+ @test_full_terminology.retrieve_term(:person).path.should == 'name'
225
+ @test_full_terminology.retrieve_term(:person).attributes.should == {:type=>"personal"}
200
226
  @test_full_terminology.retrieve_term(:person, :affiliation).path.should == 'affiliation'
201
- @test_full_terminology.retrieve_term(:person, :date).xpath.should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date"]'
227
+ @test_full_terminology.retrieve_term(:person, :date).xpath.should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date"]'
202
228
  end
203
229
  it "should support including root terms in pointer" do
204
230
  @test_full_terminology.retrieve_term(:mods).should be_instance_of OM::XML::Term
205
231
  @test_full_terminology.retrieve_term(:mods, :name, :date).should be_instance_of OM::XML::Term
206
232
  @test_full_terminology.retrieve_term(:mods, :name, :date).path.should == 'namePart'
207
233
  @test_full_terminology.retrieve_term(:mods, :name, :date).attributes.should == {:type=>"date"}
208
- @test_full_terminology.retrieve_term(:mods, :name, :date).xpath.should == '//oxns:mods/oxns:name/oxns:namePart[@type="date"]'
234
+ @test_full_terminology.retrieve_term(:mods, :name, :date).xpath.should == '//oxns:mods/oxns:name/oxns:namePart[@type="date"]'
209
235
  end
210
-
236
+
211
237
  it "should raise an informative error if the desired Term doesn't exist" do
212
- lambda { @test_full_terminology.retrieve_term(:name, :date, :nonexistentTerm, :anotherTermName) }.should raise_error(OM::XML::Terminology::BadPointerError, "You attempted to retrieve a Term using this pointer: [:name, :date, :nonexistentTerm, :anotherTermName] but no Term exists at that location. Everything is fine until \":nonexistentTerm\", which doesn't exist.")
238
+ lambda { @test_full_terminology.retrieve_term(:name, :date, :nonexistentTerm, :anotherTermName) }.should raise_error(OM::XML::Terminology::BadPointerError, "You attempted to retrieve a Term using this pointer: [:name, :date, :nonexistentTerm, :anotherTermName] but no Term exists at that location. Everything is fine until \":nonexistentTerm\", which doesn't exist.")
213
239
  end
214
240
  end
215
-
241
+
216
242
  describe ".term_xpath" do
217
- it "should insert calls to xpath array lookup into parent xpaths if parents argument is provided" do
243
+ it "should insert calls to xpath array lookup into parent xpaths if parents argument is provided" do
218
244
  pending
219
245
  # conference_mapper = TerminologyTest.retrieve_mapper(:conference)
220
246
  # role_mapper = TerminologyTest.retrieve_mapper(:conference, :role)
@@ -223,10 +249,10 @@ describe "OM::XML::Terminology" do
223
249
  # OM::XML::TermXpathGenerator.expects(:generate_absolute_xpath).with({conference_mapper=>0}, {role_mapper=>1}, text_mapper)
224
250
  end
225
251
  end
226
-
252
+
227
253
  describe ".xpath_for" do
228
254
 
229
- it "should retrieve the generated xpath query to match your desires" do
255
+ it "should retrieve the generated xpath query to match your desires" do
230
256
  @test_full_terminology.xpath_for(:person).should == '//oxns:name[@type="personal"]'
231
257
 
232
258
  @test_full_terminology.xpath_for(:person, "Beethoven, Ludwig van").should == '//oxns:name[@type="personal" and contains(., "Beethoven, Ludwig van")]'
@@ -234,21 +260,21 @@ describe "OM::XML::Terminology" do
234
260
  @test_full_terminology.xpath_for(:person, :date).should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date"]'
235
261
 
236
262
  @test_full_terminology.xpath_for(:person, :date, "2010").should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date" and contains(., "2010")]'
237
-
263
+
238
264
  @test_full_terminology.xpath_for(:person, :person_id).should == '//oxns:name[@type="personal"]/oxns:namePart[not(@type)]'
239
-
265
+
240
266
  end
241
-
267
+
242
268
  it "should support including root terms in term pointer" do
243
269
  @test_full_terminology.xpath_for(:mods, :person).should == '//oxns:mods/oxns:name[@type="personal"]'
244
270
  @test_full_terminology.xpath_for(:mods, :person, "Beethoven, Ludwig van").should == '//oxns:mods/oxns:name[@type="personal" and contains(., "Beethoven, Ludwig van")]'
245
271
  end
246
-
272
+
247
273
  it "should support queries with complex constraints" do
248
274
  pending
249
275
  @test_full_terminology.xpath_for(:person, {:date=>"2010"}).should == '//oxns:name[@type="personal" and contains(oxns:namePart[@type="date"], "2010")]'
250
276
  end
251
-
277
+
252
278
  it "should support queries with multiple complex constraints" do
253
279
  pending
254
280
  @test_full_terminology.xpath_for(:person, {:role=>"donor", :last_name=>"Rockefeller"}).should == '//oxns:name[@type="personal" and contains(oxns:role/oxns:roleTerm, "donor") and contains(oxns:namePart[@type="family"], "Rockefeller")]'
@@ -257,18 +283,18 @@ describe "OM::XML::Terminology" do
257
283
  it "should parrot any strings back to you (in case you already have an xpath query)" do
258
284
  @test_full_terminology.xpath_for('//oxns:name[@type="personal"]/oxns:namePart[@type="date"]').should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date"]'
259
285
  end
260
-
286
+
261
287
  it "should traverse named term proxies transparently" do
262
288
  proxied_xpath = @test_full_terminology.xpath_for(:journal, :issue, :pages, :start)
263
289
  @test_full_terminology.xpath_for( :journal, :issue, :start_page ).should == proxied_xpath
264
290
  end
265
-
291
+
266
292
  end
267
-
293
+
268
294
  describe ".xpath_with_indexes" do
269
295
  it "should return the xpath given in the call to #accessor" do
270
296
  @test_full_terminology.xpath_with_indexes( :title_info ).should == '//oxns:titleInfo'
271
- end
297
+ end
272
298
  it "should support xpath queries as argument" do
273
299
  @test_full_terminology.xpath_with_indexes('//oxns:name[@type="personal"][1]/oxns:namePart').should == '//oxns:name[@type="personal"][1]/oxns:namePart'
274
300
  end
@@ -286,32 +312,32 @@ describe "OM::XML::Terminology" do
286
312
  @test_full_terminology.xpath_with_indexes( :journal, :issue, :start_page ).should == proxied_xpath
287
313
  end
288
314
  end
289
-
315
+
290
316
  describe "#xml_builder_template" do
291
-
317
+
292
318
  it "should generate a template call for passing into the builder block (assumes 'xml' as the argument for the block)" do
293
319
  @test_full_terminology.xml_builder_template(:person,:date).should == 'xml.namePart( \'#{builder_new_value}\', \'type\'=>\'date\' )'
294
320
  @test_full_terminology.xml_builder_template(:name,:affiliation).should == 'xml.affiliation( \'#{builder_new_value}\' )'
295
321
  end
296
322
  it "should accept extra options" do
297
- marcrelator_role_xml_builder_template = 'xml.roleTerm( \'#{builder_new_value}\', \'type\'=>\'code\', \'authority\'=>\'marcrelator\' )'
323
+ marcrelator_role_xml_builder_template = 'xml.roleTerm( \'#{builder_new_value}\', \'type\'=>\'code\', \'authority\'=>\'marcrelator\' )'
298
324
  @test_full_terminology.xml_builder_template(:role, :code, {:attributes=>{"authority"=>"marcrelator"}} ).should == marcrelator_role_xml_builder_template
299
- @test_full_terminology.xml_builder_template(:person, :role, :code, {:attributes=>{"authority"=>"marcrelator"}} ).should == marcrelator_role_xml_builder_template
325
+ @test_full_terminology.xml_builder_template(:person, :role, :code, {:attributes=>{"authority"=>"marcrelator"}} ).should == marcrelator_role_xml_builder_template
300
326
  end
301
-
302
- it "should work with deeply nested properties" do
327
+
328
+ it "should work with deeply nested properties" do
303
329
  @test_full_terminology.xml_builder_template(:issue, :volume).should == "xml.detail( \'type\'=>'volume' ) { xml.number( '\#{builder_new_value}' ) }"
304
330
  @test_full_terminology.xml_builder_template(:journal, :issue, :level).should == "xml.detail( \'type\'=>'number' ) { xml.number( '\#{builder_new_value}' ) }"
305
331
  @test_full_terminology.xml_builder_template(:journal, :issue, :volume).should == "xml.detail( \'type\'=>'volume' ) { xml.number( '\#{builder_new_value}' ) }"
306
332
  @test_full_terminology.xml_builder_template(:journal, :issue, :pages, :start).should == "xml.start( '\#{builder_new_value}' )"
307
333
  end
308
-
334
+
309
335
  end
310
336
 
311
337
  describe "#term_generic_name" do
312
338
  it "should generate a generic accessor name based on an array of pointers" do
313
339
  OM::XML::Terminology.term_generic_name( {:conference=>0}, {:role=>1}, :text ).should == "conference_role_text"
314
- OM::XML::Terminology.term_generic_name( *[{:conference=>0}, {:role=>1}, :text] ).should == "conference_role_text"
340
+ OM::XML::Terminology.term_generic_name( *[{:conference=>0}, {:role=>1}, :text] ).should == "conference_role_text"
315
341
  end
316
342
  end
317
343
 
@@ -321,18 +347,18 @@ describe "OM::XML::Terminology" do
321
347
  OM::XML::Terminology.term_hierarchical_name( *[{:conference=>0}, {:role=>1}, :text] ).should == "conference_0_role_1_text"
322
348
  end
323
349
  end
324
-
350
+
325
351
  describe ".term_builders" do
326
352
  it "should return a hash terms that have been added to the root of the terminology, indexed by term name" do
327
353
  @test_terminology.terms[:name].should == @test_name
328
- end
354
+ end
329
355
  end
330
-
356
+
331
357
  describe ".root_terms" do
332
358
  it "should return the terms that have been marked root" do
333
359
  @test_full_terminology.root_terms.length.should == 1
334
360
  @test_full_terminology.root_terms.first.should == @test_full_terminology.terms[:mods]
335
361
  end
336
362
  end
337
-
363
+
338
364
  end