om 1.8.1 → 1.9.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/container_spec.rb +14 -14
- data/lib/om.rb +12 -9
- data/lib/om/samples/mods_article.rb +9 -9
- data/lib/om/tree_node.rb +6 -6
- data/lib/om/version.rb +1 -1
- data/lib/om/xml.rb +33 -31
- data/lib/om/xml/container.rb +12 -12
- data/lib/om/xml/document.rb +19 -18
- data/lib/om/xml/dynamic_node.rb +50 -45
- data/lib/om/xml/named_term_proxy.rb +13 -13
- data/lib/om/xml/node_generator.rb +3 -3
- data/lib/om/xml/template_registry.rb +26 -18
- data/lib/om/xml/term.rb +46 -30
- data/lib/om/xml/term_value_operators.rb +56 -52
- data/lib/om/xml/term_xpath_generator.rb +57 -51
- data/lib/om/xml/terminology.rb +10 -8
- data/lib/om/xml/terminology_based_solrizer.rb +90 -0
- data/lib/om/xml/validation.rb +19 -19
- data/lib/om/xml/vocabulary.rb +4 -4
- data/lib/tasks/om.rake +6 -4
- data/om.gemspec +2 -1
- data/spec/fixtures/mods_article.rb +90 -0
- data/spec/fixtures/mods_articles/hydrangea_article1.xml +2 -2
- data/spec/integration/differentiated_elements_spec.rb +2 -2
- data/spec/integration/element_value_spec.rb +13 -13
- data/spec/integration/proxies_and_ref_spec.rb +15 -15
- data/spec/integration/querying_documents_spec.rb +18 -24
- data/spec/integration/rights_metadata_integration_example_spec.rb +18 -18
- data/spec/integration/selective_querying_spec.rb +1 -1
- data/spec/integration/serialization_spec.rb +13 -13
- data/spec/integration/set_reentrant_terminology_spec.rb +10 -10
- data/spec/integration/xpathy_stuff_spec.rb +16 -16
- data/spec/spec_helper.rb +2 -2
- data/spec/unit/container_spec.rb +29 -28
- data/spec/unit/document_spec.rb +50 -49
- data/spec/unit/dynamic_node_spec.rb +45 -57
- data/spec/unit/named_term_proxy_spec.rb +16 -16
- data/spec/unit/node_generator_spec.rb +7 -7
- data/spec/unit/nokogiri_sanity_spec.rb +30 -30
- data/spec/unit/om_spec.rb +5 -5
- data/spec/unit/template_registry_spec.rb +69 -69
- data/spec/unit/term_builder_spec.rb +77 -77
- data/spec/unit/term_spec.rb +73 -79
- data/spec/unit/term_value_operators_spec.rb +191 -186
- data/spec/unit/term_xpath_generator_spec.rb +43 -37
- data/spec/unit/terminology_builder_spec.rb +85 -85
- data/spec/unit/terminology_spec.rb +98 -98
- data/spec/unit/validation_spec.rb +22 -22
- data/spec/unit/xml_serialization_spec.rb +22 -21
- data/spec/unit/xml_spec.rb +7 -7
- data/spec/unit/xml_terminology_based_solrizer_spec.rb +109 -0
- metadata +57 -17
- checksums.yaml +0 -7
- data/.rspec +0 -1
- data/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +0 -382
- data/.travis.yml +0 -10
- data/gemfiles/gemfile.rails3 +0 -11
- data/gemfiles/gemfile.rails4 +0 -10
@@ -18,71 +18,73 @@ describe "OM::XML::TermXpathGeneratorSpec" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
before(:each) do
|
21
|
-
@test_term
|
21
|
+
@test_term = OM::XML::Term.new(:terms_of_address, :path=>"namePart", :attributes=>{:type=>"termsOfAddress"})
|
22
22
|
@test_term_with_default_path = OM::XML::Term.new(:volume, :path=>"detail", :attributes=>{:type=>"volume"}, :default_content_path=>"number")
|
23
|
-
@test_role_text
|
24
|
-
@test_lang_attribute
|
25
|
-
@test_none_attribute_value
|
23
|
+
@test_role_text = OM::XML::Term.new(:role_text, :path=>"roleTerm", :attributes=>{:type=>"text"})
|
24
|
+
@test_lang_attribute = OM::XML::Term.new(:language, :path=>{:attribute=>"lang"})
|
25
|
+
@test_none_attribute_value = OM::XML::Term.new(:person_id, :path=>"namePart", :attributes=>{:type=>:none})
|
26
|
+
|
26
27
|
end
|
27
28
|
|
28
29
|
it "should support terms that are pointers to attribute values" do
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
OM::XML::TermXpathGenerator.generate_xpath(@test_lang_attribute, :absolute).should == "//@lang"
|
31
|
+
OM::XML::TermXpathGenerator.generate_xpath(@test_lang_attribute, :relative).should == "@lang"
|
32
|
+
OM::XML::TermXpathGenerator.generate_xpath(@test_lang_attribute, :constrained).should == '//@lang[contains(., "#{constraint_value}")]'.gsub('"', '\"')
|
32
33
|
end
|
33
34
|
|
34
35
|
describe "generate_xpath" do
|
35
36
|
it "should generate an xpath based on the given mapper and options" do
|
36
|
-
|
37
|
+
OM::XML::TermXpathGenerator.should_receive(:generate_absolute_xpath).with(@test_term)
|
37
38
|
OM::XML::TermXpathGenerator.generate_xpath(@test_term, :absolute)
|
38
39
|
|
39
|
-
|
40
|
+
OM::XML::TermXpathGenerator.should_receive(:generate_relative_xpath).with(@test_term)
|
40
41
|
OM::XML::TermXpathGenerator.generate_xpath(@test_term, :relative)
|
41
42
|
|
42
|
-
|
43
|
+
OM::XML::TermXpathGenerator.should_receive(:generate_constrained_xpath).with(@test_term)
|
43
44
|
OM::XML::TermXpathGenerator.generate_xpath(@test_term, :constrained)
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
48
|
describe "generate_relative_xpath" do
|
48
49
|
it "should generate a relative xpath based on the given mapper" do
|
49
|
-
|
50
|
+
OM::XML::TermXpathGenerator.generate_relative_xpath(@test_term).should == 'namePart[@type="termsOfAddress"]'
|
50
51
|
end
|
51
52
|
it "should support mappers without namespaces" do
|
52
53
|
@test_term.namespace_prefix = nil
|
53
|
-
|
54
|
+
OM::XML::TermXpathGenerator.generate_relative_xpath(@test_term).should == 'namePart[@type="termsOfAddress"]'
|
54
55
|
end
|
55
56
|
it "should not use a namespace for a path set to text() and should include normalize-space to ignore white space" do
|
56
57
|
text_term = OM::XML::Term.new(:title_content, :path=>"text()")
|
57
|
-
|
58
|
+
OM::XML::TermXpathGenerator.generate_relative_xpath(text_term).should == 'text()[normalize-space(.)]'
|
58
59
|
end
|
59
60
|
it "should set a 'not' predicate if the attribute value is :none" do
|
60
|
-
|
61
|
+
OM::XML::TermXpathGenerator.generate_relative_xpath(@test_none_attribute_value).should == 'namePart[not(@type)]'
|
61
62
|
end
|
63
|
+
|
62
64
|
end
|
63
65
|
|
64
66
|
describe "generate_absolute_xpath" do
|
65
67
|
it "should generate an absolute xpath based on the given mapper" do
|
66
|
-
|
68
|
+
OM::XML::TermXpathGenerator.generate_absolute_xpath(@test_term).should == '//namePart[@type="termsOfAddress"]'
|
67
69
|
end
|
68
70
|
it "should prepend the xpath for any parent nodes" do
|
69
|
-
mock_parent_mapper =
|
70
|
-
|
71
|
-
|
71
|
+
mock_parent_mapper = mock("Term", :xpath_absolute=>'//name[@type="conference"]/role')
|
72
|
+
@test_role_text.stub(:parent => mock_parent_mapper)
|
73
|
+
OM::XML::TermXpathGenerator.generate_absolute_xpath(@test_role_text).should == '//name[@type="conference"]/role/roleTerm[@type="text"]'
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
75
77
|
describe "generate_constrained_xpath" do
|
76
78
|
it "should generate a constrained xpath based on the given mapper" do
|
77
|
-
|
79
|
+
OM::XML::TermXpathGenerator.generate_constrained_xpath(@test_term).should == '//namePart[@type="termsOfAddress" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
81
83
|
it "should support mappers without namespaces" do
|
82
84
|
@test_term.namespace_prefix = nil
|
83
|
-
|
84
|
-
|
85
|
-
|
85
|
+
OM::XML::TermXpathGenerator.generate_relative_xpath(@test_term).should == 'namePart[@type="termsOfAddress"]'
|
86
|
+
OM::XML::TermXpathGenerator.generate_absolute_xpath(@test_term).should == '//namePart[@type="termsOfAddress"]'
|
87
|
+
OM::XML::TermXpathGenerator.generate_constrained_xpath(@test_term).should == '//namePart[@type="termsOfAddress" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
|
86
88
|
end
|
87
89
|
|
88
90
|
describe "generate_xpath_with_indexes" do
|
@@ -90,40 +92,44 @@ describe "OM::XML::TermXpathGeneratorSpec" do
|
|
90
92
|
generated_xpath = OM::XML::TermXpathGenerator.generate_xpath_with_indexes( @sample_terminology, :person, {:first_name=>"Tim", :family_name=>"Berners-Lee"} )
|
91
93
|
# 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")]'
|
92
94
|
# can't use string comparison because the contains functions can arrive in any order
|
93
|
-
|
94
|
-
|
95
|
+
generated_xpath.should match( /\/\/oxns:name\[@type=\"personal\".*and contains\(oxns:namePart\[@type=\"given\"\], \"Tim\"\).*\]/ )
|
96
|
+
generated_xpath.should match( /\/\/oxns:name\[@type=\"personal\".*and contains\(oxns:namePart\[@type=\"family\"\], \"Berners-Lee\"\).*\]/ )
|
95
97
|
end
|
96
98
|
it "should support xpath queries as argument" do
|
97
|
-
|
99
|
+
OM::XML::TermXpathGenerator.generate_xpath_with_indexes(@sample_terminology, '//oxns:name[@type="personal"][1]/oxns:namePart').should == '//oxns:name[@type="personal"][1]/oxns:namePart'
|
98
100
|
end
|
99
101
|
it "should return the xpath of the terminology's root node if term pointer is nil" do
|
100
|
-
|
102
|
+
OM::XML::TermXpathGenerator.generate_xpath_with_indexes( @sample_terminology, nil ).should == @sample_terminology.root_terms.first.xpath
|
101
103
|
end
|
102
104
|
it "should return / if term pointer is nil and the terminology does not have a root term defined" do
|
103
|
-
|
105
|
+
OM::XML::TermXpathGenerator.generate_xpath_with_indexes( @rootless_terminology, nil ).should == "/"
|
104
106
|
end
|
105
107
|
it "should destringify term pointers before using them" do
|
106
|
-
generated_xpath =
|
108
|
+
generated_xpath = OM::XML::TermXpathGenerator.generate_xpath_with_indexes( @sample_terminology, {"person"=>"1"}, "first_name" ).should == '//oxns:name[@type="personal"][2]/oxns:namePart[@type="given"]'
|
107
109
|
### Last argument is a filter, we are passing no filters
|
108
|
-
|
110
|
+
@sample_terminology.xpath_with_indexes(:name, {:family_name=>1},{}).should == '//oxns:name/oxns:namePart[@type="family"][2]'
|
109
111
|
end
|
110
112
|
it "should warn about indexes on a proxy" do
|
111
|
-
|
112
|
-
|
113
|
+
Logger.any_instance.should_receive(:warn).with("You attempted to call an index value of 1 on the term \":family_name\". However \":family_name\" is a proxy so we are ignoring the index. See https://jira.duraspace.org/browse/HYDRA-643")
|
114
|
+
@sample_terminology.xpath_with_indexes({:family_name=>1}).should == "//oxns:name/oxns:namePart[@type=\"family\"]"
|
113
115
|
end
|
114
116
|
end
|
115
117
|
|
116
118
|
it "should support mappers with default_content_path" do
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
119
|
+
pending "need to implement mapper_set first"
|
120
|
+
#@test_term_with_default_path = OM::XML::Term.new(:volume, :path=>"detail", :attributes=>{:type=>"volume"}, :default_content_path=>"number")
|
121
|
+
|
122
|
+
OM::XML::TermXpathGenerator.generate_relative_xpath(@test_term_with_default_path).should == 'oxns:detail[@type="volume"]'
|
123
|
+
OM::XML::TermXpathGenerator.generate_absolute_xpath(@test_term_with_default_path).should == '//oxns:detail[@type="volume"]'
|
124
|
+
OM::XML::TermXpathGenerator.generate_constrained_xpath(@test_term_with_default_path).should == '//oxns:detail[contains(oxns:number[@type="volume"], "#{constraint_value}")]'.gsub('"', '\"')
|
122
125
|
end
|
123
126
|
|
124
127
|
it "should default to using an inherited namspace prefix" do
|
128
|
+
|
125
129
|
term = @sample_terminology.retrieve_term(:person, :first_name)
|
126
|
-
|
130
|
+
OM::XML::TermXpathGenerator.generate_absolute_xpath(term).should == "//oxns:name[@type=\"personal\"]/oxns:namePart[@type=\"given\"]"
|
131
|
+
|
132
|
+
|
127
133
|
end
|
128
134
|
|
129
135
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "OM::XML::Terminology::Builder" do
|
4
|
-
|
4
|
+
|
5
5
|
before(:each) do
|
6
6
|
@test_builder = OM::XML::Terminology::Builder.new
|
7
|
-
|
7
|
+
|
8
8
|
@builder_with_block = OM::XML::Terminology::Builder.new do |t|
|
9
9
|
t.root(:path=>"mods", :xmlns=>"http://www.loc.gov/mods/v3", :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
|
10
10
|
|
11
11
|
t.title_info(:path=>"titleInfo") {
|
12
12
|
t.main_title(:path=>"title", :label=>"title")
|
13
13
|
t.language(:path=>{:attribute=>"lang"})
|
14
|
-
}
|
14
|
+
}
|
15
15
|
# t.title(:path=>"titleInfo", :default_content_path=>"title") {
|
16
16
|
# t.@language(:path=>{:attribute=>"lang"})
|
17
|
-
# }
|
17
|
+
# }
|
18
18
|
# This is a mods:name. The underscore is purely to avoid namespace conflicts.
|
19
19
|
t.name_ {
|
20
20
|
# this is a namepart
|
@@ -29,7 +29,7 @@ describe "OM::XML::Terminology::Builder" do
|
|
29
29
|
t.given_name(:path=>"namePart", :attributes=>{:type=>"given"}, :label=>"first name")
|
30
30
|
t.terms_of_address(:path=>"namePart", :attributes=>{:type=>"termsOfAddress"})
|
31
31
|
}
|
32
|
-
# lookup :person, :first_name
|
32
|
+
# lookup :person, :first_name
|
33
33
|
t.person(:ref=>:name, :attributes=>{:type=>"personal"})
|
34
34
|
|
35
35
|
t.role {
|
@@ -61,144 +61,144 @@ describe "OM::XML::Terminology::Builder" do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
# @test_full_terminology = @builder_with_block.build
|
64
|
-
|
64
|
+
|
65
65
|
end
|
66
|
-
|
67
|
-
it "supports proxy terms at the root of the Terminology" do
|
68
|
-
t_builder = OM::XML::Terminology::Builder.new do |t|
|
69
|
-
t.root(:path=>"mods", :xmlns=>"http://www.loc.gov/mods/v3", :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
|
70
|
-
t.title_info(:path=>"titleInfo") {
|
71
|
-
t.main_title(:path=>"title", :label=>"title")
|
72
|
-
t.language(:path=>{:attribute=>"lang"})
|
73
|
-
}
|
74
|
-
t.title(:proxy=>[:title_info, :main_title], :index_as =>[:facetable, :not_searchable])
|
75
|
-
end
|
76
|
-
|
77
|
-
terminology = t_builder.build
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
66
|
+
|
67
|
+
it "supports proxy terms at the root of the Terminology" do
|
68
|
+
t_builder = OM::XML::Terminology::Builder.new do |t|
|
69
|
+
t.root(:path=>"mods", :xmlns=>"http://www.loc.gov/mods/v3", :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
|
70
|
+
t.title_info(:path=>"titleInfo") {
|
71
|
+
t.main_title(:path=>"title", :label=>"title")
|
72
|
+
t.language(:path=>{:attribute=>"lang"})
|
73
|
+
}
|
74
|
+
t.title(:proxy=>[:title_info, :main_title], :index_as =>[:facetable, :not_searchable])
|
75
|
+
end
|
76
|
+
|
77
|
+
terminology = t_builder.build
|
78
|
+
terminology.retrieve_term(:title).should be_kind_of OM::XML::NamedTermProxy
|
79
|
+
terminology.retrieve_term(:title).index_as.should == [:facetable, :not_searchable]
|
80
|
+
terminology.retrieve_term(:title_info, :main_title).index_as.should == []
|
81
|
+
terminology.xpath_for(:title).should == '//oxns:titleInfo/oxns:title'
|
82
|
+
terminology.xpath_with_indexes({:title=>0}).should == "//oxns:titleInfo/oxns:title"
|
83
83
|
# @builder_with_block.build.xpath_for_pointer(:issue).should == '//oxns:part'
|
84
84
|
# terminology.xpath_for_pointer(:title).should == '//oxns:titleInfo/oxns:title'
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
describe '#new' do
|
88
88
|
it "should return an instance of OM::XML::Terminology::Builder" do
|
89
|
-
|
89
|
+
OM::XML::Terminology::Builder.new.should be_instance_of OM::XML::Terminology::Builder
|
90
90
|
end
|
91
91
|
it "should process the input block, creating a new Term Builder for each entry and its children" do
|
92
92
|
expected_root_terms = [:mods, :title_info, :issue, :person, :name, :journal, :role]
|
93
93
|
expected_root_terms.each do |name|
|
94
|
-
|
94
|
+
@builder_with_block.term_builders.should have_key(name)
|
95
95
|
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
96
|
+
@builder_with_block.term_builders.length.should == expected_root_terms.length
|
97
|
+
|
98
|
+
@builder_with_block.term_builders[:journal].should be_instance_of OM::XML::Term::Builder
|
99
|
+
@builder_with_block.term_builders[:journal].settings[:path].should == "relatedItem"
|
100
|
+
@builder_with_block.term_builders[:journal].settings[:attributes].should == {:type=>"host"}
|
101
|
+
|
102
|
+
@builder_with_block.term_builders[:journal].children[:issn].should be_instance_of OM::XML::Term::Builder
|
103
|
+
@builder_with_block.term_builders[:journal].children[:issn].settings[:path].should == "identifier"
|
104
|
+
@builder_with_block.term_builders[:journal].children[:issn].settings[:attributes].should == {:type=>"issn"}
|
105
105
|
end
|
106
106
|
it "should clip the underscore off the end of any Term names" do
|
107
|
-
|
108
|
-
|
107
|
+
@builder_with_block.term_builders[:name].should be_instance_of OM::XML::Term::Builder
|
108
|
+
@builder_with_block.term_builders[:name].name.should == :name
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
110
|
+
@builder_with_block.term_builders[:name].children[:date].should be_instance_of OM::XML::Term::Builder
|
111
|
+
@builder_with_block.term_builders[:name].children[:date].settings[:path].should == "namePart"
|
112
|
+
@builder_with_block.term_builders[:name].children[:date].settings[:attributes].should == {:type=>"date"}
|
113
113
|
end
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
describe '#from_xml' do
|
117
117
|
it "should let you load mappings from an xml file" do
|
118
|
-
|
118
|
+
pending
|
119
119
|
vocab = OM::XML::Terminology.from_xml( fixture("sample_mappings.xml") )
|
120
|
-
|
121
|
-
|
120
|
+
vocab.should be_instance_of OM::XML::Terminology
|
121
|
+
vocab.mappers.should == {}
|
122
122
|
end
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
describe ".retrieve_term_builder" do
|
126
126
|
it "should support looking up Term Builders by pointer" do
|
127
127
|
expected = @builder_with_block.term_builders[:name].children[:date]
|
128
|
-
|
128
|
+
@builder_with_block.retrieve_term_builder(:name, :date).should == expected
|
129
129
|
end
|
130
130
|
end
|
131
|
-
|
131
|
+
|
132
132
|
describe "build" do
|
133
133
|
it "should generate the new Terminology, calling .build on its Term builders"
|
134
134
|
it "should resolve :refs" do
|
135
|
-
|
136
|
-
|
137
|
-
|
135
|
+
@builder_with_block.retrieve_term_builder(:name, :role).settings[:ref].should == [:role]
|
136
|
+
@builder_with_block.retrieve_term_builder(:role).children[:text].should be_instance_of OM::XML::Term::Builder
|
137
|
+
|
138
138
|
built_terminology = @builder_with_block.build
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
|
140
|
+
built_terminology.retrieve_term(:name, :role, :text).should be_instance_of OM::XML::Term
|
141
|
+
built_terminology.retrieve_term(:name, :role, :text).path.should == "roleTerm"
|
142
|
+
built_terminology.retrieve_term(:name, :role, :text).attributes.should == {:type=>"text"}
|
143
143
|
end
|
144
144
|
it "should put copies of the entire terminology under any root terms" do
|
145
|
-
|
146
|
-
|
145
|
+
@builder_with_block.root_term_builders.should include(@builder_with_block.retrieve_term_builder(:mods))
|
146
|
+
|
147
147
|
built_terminology = @builder_with_block.build
|
148
148
|
expected_keys = [:title_info, :issue, :person, :name, :journal, :role]
|
149
|
-
|
150
|
-
|
149
|
+
|
150
|
+
built_terminology.retrieve_term(:mods).children.length.should == expected_keys.length
|
151
151
|
expected_keys.each do |key|
|
152
|
-
|
152
|
+
built_terminology.retrieve_term(:mods).children.keys.should include(key)
|
153
153
|
end
|
154
|
-
|
155
|
-
|
154
|
+
built_terminology.retrieve_term(:mods, :name, :role, :text).should be_instance_of OM::XML::Term
|
155
|
+
built_terminology.retrieve_term(:mods, :person, :role, :text).should be_instance_of OM::XML::Term
|
156
156
|
|
157
157
|
end
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
describe '.insert_term' do
|
161
161
|
it "should create a new OM::XML::Term::Builder and insert it into the class mappings hash" do
|
162
|
-
|
163
|
-
|
164
|
-
result = @test_builder.insert_mapper(:name_, :namePart).index_as([:facetable, :searchable, :sortable, :displayable]).required(true).type(:text)
|
165
|
-
|
166
|
-
|
162
|
+
pending
|
163
|
+
|
164
|
+
result = @test_builder.insert_mapper(:name_, :namePart).index_as([:facetable, :searchable, :sortable, :displayable]).required(true).type(:text)
|
165
|
+
@test_builder.mapper_builders(:name_, :namePart).should == result
|
166
|
+
result.should be_instance_of OM::XML::Mapper::Builder
|
167
167
|
end
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
describe ".root" do
|
171
171
|
it "should accept options for the root node, such as namespace(s) and schema and those values should impact the resulting Terminology" do
|
172
172
|
root_term_builder = @test_builder.root(:path=>"mods", :xmlns => 'one:two', 'xmlns:foo' => 'bar', :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
173
|
+
root_term_builder.settings[:is_root_term].should == true
|
174
|
+
|
175
|
+
@test_builder.schema.should == "http://www.loc.gov/standards/mods/v3/mods-3-2.xsd"
|
176
|
+
@test_builder.namespaces.should == { "oxns"=>"one:two", 'xmlns' => 'one:two', 'xmlns:foo' => 'bar' }
|
177
|
+
@test_builder.term_builders[:mods].should == root_term_builder
|
178
|
+
|
179
179
|
terminology = @test_builder.build
|
180
|
-
|
181
|
-
|
180
|
+
terminology.schema.should == "http://www.loc.gov/standards/mods/v3/mods-3-2.xsd"
|
181
|
+
terminology.namespaces.should == { "oxns"=>"one:two", 'xmlns' => 'one:two', 'xmlns:foo' => 'bar' }
|
182
182
|
end
|
183
183
|
it "should create an explicit term correspoinding to the root node and pass any additional settings into that term" do
|
184
184
|
@test_builder.root(:path=>"fwoop", :xmlns => 'one:two', 'xmlns:foo' => 'bar', :index_as=>[:not_searchable], :namespace_prefix=>"foox")
|
185
185
|
terminology = @test_builder.build
|
186
186
|
term = terminology.retrieve_term(:fwoop)
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
187
|
+
term.should be_instance_of OM::XML::Term
|
188
|
+
term.is_root_term?.should == true
|
189
|
+
term.index_as.should == [:not_searchable]
|
190
|
+
term.namespace_prefix.should == "foox"
|
191
191
|
end
|
192
192
|
it "should work within a builder block" do
|
193
|
-
|
193
|
+
@builder_with_block.term_builders[:mods].settings[:is_root_term].should == true
|
194
194
|
end
|
195
195
|
end
|
196
|
-
|
196
|
+
|
197
197
|
describe ".root_term_builders" do
|
198
198
|
it "should return the terms that have been marked root" do
|
199
|
-
|
200
|
-
|
199
|
+
@builder_with_block.root_term_builders.length.should == 1
|
200
|
+
@builder_with_block.root_term_builders.first.should == @builder_with_block.term_builders[:mods]
|
201
201
|
end
|
202
202
|
end
|
203
|
-
|
203
|
+
|
204
204
|
end
|
@@ -89,162 +89,162 @@ describe "OM::XML::Terminology" do
|
|
89
89
|
|
90
90
|
describe "namespaceless terminologies" do
|
91
91
|
it "should generate xpath queries without namespaces" do
|
92
|
-
|
93
|
-
|
92
|
+
@namespaceless_terminology.xpath_for(:to).should == "//to"
|
93
|
+
@namespaceless_terminology.xpath_for(:note, :from).should == "//note/from"
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should work with xml documents that have no namespaces" do
|
97
|
-
|
98
|
-
|
97
|
+
@namespaceless_doc.from.first.should == "Jani"
|
98
|
+
@namespaceless_doc.to.should == ["Tove"]
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
describe "basics" do
|
103
103
|
|
104
104
|
it "constructs xpath queries for finding properties" do
|
105
|
-
|
106
|
-
|
105
|
+
@test_full_terminology.retrieve_term(:name).xpath.should == '//oxns:name'
|
106
|
+
@test_full_terminology.retrieve_term(:name).xpath_relative.should == 'oxns:name'
|
107
107
|
|
108
|
-
|
109
|
-
|
110
|
-
|
108
|
+
@test_full_terminology.retrieve_term(:person).xpath.should == '//oxns:name[@type="personal"]'
|
109
|
+
@test_full_terminology.retrieve_term(:person).xpath_relative.should == 'oxns:name[@type="personal"]'
|
110
|
+
@test_full_terminology.retrieve_term(:person, :person_id).xpath_relative.should == 'oxns:namePart[not(@type)]'
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should expand proxy and get sub terms" do
|
114
|
-
|
114
|
+
@test_full_terminology.retrieve_node(:title, :main_title_lang).xpath.should == '//oxns:titleInfo/oxns:title/@xml:lang'
|
115
115
|
### retrieve_term() will not cross proxies
|
116
|
-
|
116
|
+
@test_full_terminology.retrieve_term(:title_info, :main_title, :main_title_lang).xpath.should == '//oxns:titleInfo/oxns:title/@xml:lang'
|
117
117
|
end
|
118
118
|
|
119
119
|
it "constructs templates for value-driven searches" do
|
120
|
-
|
121
|
-
|
120
|
+
@test_full_terminology.retrieve_term(:name).xpath_constrained.should == '//oxns:name[contains(., "#{constraint_value}")]'.gsub('"', '\"')
|
121
|
+
@test_full_terminology.retrieve_term(:person).xpath_constrained.should == '//oxns:name[@type="personal" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
|
122
122
|
|
123
123
|
# Example of how you could use these templates:
|
124
124
|
constraint_value = "SAMPLE CONSTRAINT VALUE"
|
125
125
|
constrained_query = eval( '"' + @test_full_terminology.retrieve_term(:person).xpath_constrained + '"' )
|
126
|
-
|
126
|
+
constrained_query.should == '//oxns:name[@type="personal" and contains(., "SAMPLE CONSTRAINT VALUE")]'
|
127
127
|
end
|
128
128
|
|
129
129
|
it "constructs xpath queries & templates for nested terms" do
|
130
130
|
name_date_term = @test_full_terminology.retrieve_term(:name, :date)
|
131
|
-
|
132
|
-
|
133
|
-
|
131
|
+
name_date_term.xpath.should == '//oxns:name/oxns:namePart[@type="date"]'
|
132
|
+
name_date_term.xpath_relative.should == 'oxns:namePart[@type="date"]'
|
133
|
+
name_date_term.xpath_constrained.should == '//oxns:name/oxns:namePart[@type="date" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
|
134
134
|
# name_date_term.xpath_constrained.should == '//oxns:name[contains(oxns:namePart[@type="date"], "#{constraint_value}")]'.gsub('"', '\"')
|
135
135
|
|
136
136
|
person_date_term = @test_full_terminology.retrieve_term(:person, :date)
|
137
|
-
|
138
|
-
|
139
|
-
|
137
|
+
person_date_term.xpath.should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date"]'
|
138
|
+
person_date_term.xpath_relative.should == 'oxns:namePart[@type="date"]'
|
139
|
+
person_date_term.xpath_constrained.should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date" and contains(., "#{constraint_value}")]'.gsub('"', '\"')
|
140
140
|
# person_date_term.xpath_constrained.should == '//oxns:name[@type="personal" and contains(oxns:namePart[@type="date"], "#{constraint_value}")]'.gsub('"', '\"')
|
141
141
|
end
|
142
142
|
|
143
143
|
it "supports subelements that are specified using a :ref" do
|
144
144
|
role_term = @test_full_terminology.retrieve_term(:name, :role)
|
145
|
-
|
146
|
-
|
147
|
-
|
145
|
+
role_term.xpath.should == '//oxns:name/oxns:role'
|
146
|
+
role_term.xpath_relative.should == 'oxns:role'
|
147
|
+
role_term.xpath_constrained.should == '//oxns:name/oxns:role[contains(., "#{constraint_value}")]'.gsub('"', '\"')
|
148
148
|
# role_term.xpath_constrained.should == '//oxns:name[contains(oxns:role/oxns:roleTerm, "#{constraint_value}")]'.gsub('"', '\"')
|
149
149
|
end
|
150
150
|
|
151
151
|
describe "treating attributes as properties" do
|
152
|
-
it "should build correct xpath" do
|
152
|
+
it "should build correct xpath" do
|
153
153
|
language_term = @test_full_terminology.retrieve_term(:title_info, :language)
|
154
|
-
|
155
|
-
|
156
|
-
|
154
|
+
language_term.xpath.should == '//oxns:titleInfo/@lang'
|
155
|
+
language_term.xpath_relative.should == '@lang'
|
156
|
+
language_term.xpath_constrained.should == '//oxns:titleInfo/@lang[contains(., "#{constraint_value}")]'.gsub('"', '\"')
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should support deep nesting of properties" do
|
161
161
|
volume_term = @test_full_terminology.retrieve_term(:journal, :issue, :volume)
|
162
|
-
|
163
|
-
|
162
|
+
volume_term.xpath.should == "//oxns:relatedItem[@type=\"host\"]/oxns:part/oxns:detail[@type=\"volume\"]"
|
163
|
+
volume_term.xpath_relative.should == "oxns:detail[@type=\"volume\"]"
|
164
164
|
# volume_term.xpath_constrained.should == "//oxns:part[contains(oxns:detail[@type=\\\"volume\\\"], \\\"\#{constraint_value}\\\")]"
|
165
|
-
|
165
|
+
volume_term.xpath_constrained.should == '//oxns:relatedItem[@type="host"]/oxns:part/oxns:detail[@type="volume" and contains(oxns:number, "#{constraint_value}")]'.gsub('"', '\"')
|
166
166
|
end
|
167
167
|
|
168
168
|
it "should not overwrite default property info when adding a variant property" do
|
169
169
|
name_term = @test_full_terminology.retrieve_term(:name)
|
170
170
|
person_term = @test_full_terminology.retrieve_term(:person)
|
171
171
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
172
|
+
name_term.should_not equal(person_term)
|
173
|
+
name_term.xpath.should_not equal(person_term.xpath)
|
174
|
+
name_term.children.should_not equal(person_term.children)
|
175
|
+
name_term.children[:date].xpath_constrained.should_not equal(person_term.children[:date].xpath_constrained)
|
176
176
|
end
|
177
177
|
|
178
178
|
end
|
179
179
|
|
180
180
|
describe '#from_xml' do
|
181
181
|
it "should let you load mappings from an xml file" do
|
182
|
-
|
182
|
+
pending
|
183
183
|
vocab = OM::XML::Terminology.from_xml( fixture("sample_mappings.xml") )
|
184
|
-
|
185
|
-
|
184
|
+
vocab.should be_instance_of OM::XML::Terminology
|
185
|
+
vocab.mappers.should == {}
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
189
189
|
describe '#to_xml' do
|
190
190
|
it "should let you serialize mappings to an xml document" do
|
191
|
-
|
192
|
-
|
191
|
+
pending
|
192
|
+
TerminologyTest.to_xml.should == ""
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
196
196
|
describe ".has_term?" do
|
197
197
|
it "should return true if the specified term does exist in the terminology" do
|
198
|
-
|
198
|
+
@test_full_terminology.has_term?(:journal,:issue,:end_page).should be_true
|
199
199
|
end
|
200
200
|
it "should support term_pointers with array indexes in them (ignoring the indexes)" do
|
201
|
-
|
202
|
-
|
201
|
+
@test_full_terminology.has_term?(:title_info, :main_title).should be_true
|
202
|
+
@test_full_terminology.has_term?({:title_info=>"0"}, :main_title).should be_true
|
203
203
|
end
|
204
204
|
it "should return false if the specified term does not exist in the terminology" do
|
205
|
-
|
205
|
+
@test_full_terminology.has_term?(:name, :date, :nonexistentTerm, :anotherTermName).should be_false
|
206
206
|
end
|
207
207
|
end
|
208
208
|
|
209
209
|
describe ".retrieve_term" do
|
210
210
|
it "should return the mapper identified by the given pointer" do
|
211
211
|
term = @test_terminology.retrieve_term(:name, :namePart)
|
212
|
-
|
213
|
-
|
212
|
+
term.should == @test_terminology.terms[:name].children[:namePart]
|
213
|
+
term.should == @test_child_term
|
214
214
|
end
|
215
215
|
it "should build complete terminologies" do
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
216
|
+
@test_full_terminology.retrieve_term(:name, :date).should be_instance_of OM::XML::Term
|
217
|
+
@test_full_terminology.retrieve_term(:name, :date).path.should == 'namePart'
|
218
|
+
@test_full_terminology.retrieve_term(:name, :date).attributes.should == {:type=>"date"}
|
219
|
+
@test_full_terminology.retrieve_term(:name, :affiliation).path.should == 'affiliation'
|
220
|
+
@test_full_terminology.retrieve_term(:name, :date).xpath.should == '//oxns:name/oxns:namePart[@type="date"]'
|
221
221
|
end
|
222
222
|
it "should support looking up variant Terms" do
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
223
|
+
@test_full_terminology.retrieve_term(:person).path.should == 'name'
|
224
|
+
@test_full_terminology.retrieve_term(:person).attributes.should == {:type=>"personal"}
|
225
|
+
@test_full_terminology.retrieve_term(:person, :affiliation).path.should == 'affiliation'
|
226
|
+
@test_full_terminology.retrieve_term(:person, :date).xpath.should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date"]'
|
227
227
|
end
|
228
228
|
it "should support including root terms in pointer" do
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
229
|
+
@test_full_terminology.retrieve_term(:mods).should be_instance_of OM::XML::Term
|
230
|
+
@test_full_terminology.retrieve_term(:mods, :name, :date).should be_instance_of OM::XML::Term
|
231
|
+
@test_full_terminology.retrieve_term(:mods, :name, :date).path.should == 'namePart'
|
232
|
+
@test_full_terminology.retrieve_term(:mods, :name, :date).attributes.should == {:type=>"date"}
|
233
|
+
@test_full_terminology.retrieve_term(:mods, :name, :date).xpath.should == '//oxns:mods/oxns:name/oxns:namePart[@type="date"]'
|
234
234
|
end
|
235
235
|
|
236
236
|
it "should raise an informative error if the desired Term doesn't exist" do
|
237
|
-
|
237
|
+
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
238
|
end
|
239
239
|
end
|
240
240
|
|
241
241
|
describe ".term_xpath" do
|
242
242
|
it "should insert calls to xpath array lookup into parent xpaths if parents argument is provided" do
|
243
|
-
|
243
|
+
pending
|
244
244
|
# conference_mapper = TerminologyTest.retrieve_mapper(:conference)
|
245
245
|
# role_mapper = TerminologyTest.retrieve_mapper(:conference, :role)
|
246
246
|
# text_mapper = TerminologyTest.retrieve_mapper(:conference, :role, :text)
|
247
|
-
|
247
|
+
TerminologyTest.term_xpath({:conference=>0}, {:role=>1}, :text ).should == '//oxns:name[@type="conference"][1]/oxns:role[2]/oxns:roleTerm[@type="text"]'
|
248
248
|
# OM::XML::TermXpathGenerator.expects(:generate_absolute_xpath).with({conference_mapper=>0}, {role_mapper=>1}, text_mapper)
|
249
249
|
end
|
250
250
|
end
|
@@ -252,72 +252,72 @@ describe "OM::XML::Terminology" do
|
|
252
252
|
describe ".xpath_for" do
|
253
253
|
|
254
254
|
it "should retrieve the generated xpath query to match your desires" do
|
255
|
-
|
255
|
+
@test_full_terminology.xpath_for(:person).should == '//oxns:name[@type="personal"]'
|
256
256
|
|
257
|
-
|
257
|
+
@test_full_terminology.xpath_for(:person, "Beethoven, Ludwig van").should == '//oxns:name[@type="personal" and contains(., "Beethoven, Ludwig van")]'
|
258
258
|
|
259
|
-
|
259
|
+
@test_full_terminology.xpath_for(:person, :date).should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date"]'
|
260
260
|
|
261
|
-
|
261
|
+
@test_full_terminology.xpath_for(:person, :date, "2010").should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date" and contains(., "2010")]'
|
262
262
|
|
263
|
-
|
263
|
+
@test_full_terminology.xpath_for(:person, :person_id).should == '//oxns:name[@type="personal"]/oxns:namePart[not(@type)]'
|
264
264
|
|
265
265
|
end
|
266
266
|
|
267
267
|
it "should support including root terms in term pointer" do
|
268
|
-
|
269
|
-
|
268
|
+
@test_full_terminology.xpath_for(:mods, :person).should == '//oxns:mods/oxns:name[@type="personal"]'
|
269
|
+
@test_full_terminology.xpath_for(:mods, :person, "Beethoven, Ludwig van").should == '//oxns:mods/oxns:name[@type="personal" and contains(., "Beethoven, Ludwig van")]'
|
270
270
|
end
|
271
271
|
|
272
272
|
it "should support queries with complex constraints" do
|
273
|
-
|
274
|
-
|
273
|
+
pending
|
274
|
+
@test_full_terminology.xpath_for(:person, {:date=>"2010"}).should == '//oxns:name[@type="personal" and contains(oxns:namePart[@type="date"], "2010")]'
|
275
275
|
end
|
276
276
|
|
277
277
|
it "should support queries with multiple complex constraints" do
|
278
|
-
|
279
|
-
|
278
|
+
pending
|
279
|
+
@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")]'
|
280
280
|
end
|
281
281
|
|
282
282
|
it "should parrot any strings back to you (in case you already have an xpath query)" do
|
283
|
-
|
283
|
+
@test_full_terminology.xpath_for('//oxns:name[@type="personal"]/oxns:namePart[@type="date"]').should == '//oxns:name[@type="personal"]/oxns:namePart[@type="date"]'
|
284
284
|
end
|
285
285
|
|
286
286
|
it "should traverse named term proxies transparently" do
|
287
287
|
proxied_xpath = @test_full_terminology.xpath_for(:journal, :issue, :pages, :start)
|
288
|
-
|
288
|
+
@test_full_terminology.xpath_for( :journal, :issue, :start_page ).should == proxied_xpath
|
289
289
|
end
|
290
290
|
|
291
291
|
end
|
292
292
|
|
293
293
|
describe ".xpath_with_indexes" do
|
294
294
|
it "should return the xpath given in the call to #accessor" do
|
295
|
-
|
295
|
+
@test_full_terminology.xpath_with_indexes( :title_info ).should == '//oxns:titleInfo'
|
296
296
|
end
|
297
297
|
it "should support xpath queries as argument" do
|
298
|
-
|
298
|
+
@test_full_terminology.xpath_with_indexes('//oxns:name[@type="personal"][1]/oxns:namePart').should == '//oxns:name[@type="personal"][1]/oxns:namePart'
|
299
299
|
end
|
300
300
|
# Note: Ruby array indexes begin from 0. In xpath queries (which start from 1 instead of 0), this will be translated accordingly.
|
301
301
|
it "should prepend the xpath for any parent nodes, inserting calls to xpath array lookup where necessary" do
|
302
|
-
|
302
|
+
@test_full_terminology.xpath_with_indexes( {:conference=>0}, {:role=>1}, :text ).should == '//oxns:name[@type="conference"][1]/oxns:role[2]/oxns:roleTerm[@type="text"]'
|
303
303
|
end
|
304
304
|
it "should be idempotent" do
|
305
|
-
|
306
|
-
|
307
|
-
|
305
|
+
@test_full_terminology.xpath_with_indexes( *[{:title_info=>2}, :main_title] ).should == "//oxns:titleInfo[3]/oxns:title"
|
306
|
+
@test_full_terminology.xpath_with_indexes( *[{:title_info=>2}, :main_title] ).should == "//oxns:titleInfo[3]/oxns:title"
|
307
|
+
@test_full_terminology.xpath_with_indexes( *[{:title_info=>2}, :main_title] ).should == "//oxns:titleInfo[3]/oxns:title"
|
308
308
|
end
|
309
309
|
it "should traverse named term proxies transparently" do
|
310
310
|
proxied_xpath = @test_full_terminology.xpath_with_indexes(:journal, :issue, :pages, :start)
|
311
|
-
|
311
|
+
@test_full_terminology.xpath_with_indexes( :journal, :issue, :start_page ).should == proxied_xpath
|
312
312
|
end
|
313
313
|
end
|
314
314
|
|
315
315
|
describe "#xml_builder_template" do
|
316
316
|
|
317
317
|
it "should generate a template call for passing into the builder block (assumes 'xml' as the argument for the block)" do
|
318
|
-
|
319
|
-
|
320
|
-
|
318
|
+
@test_full_terminology.xml_builder_template(:person,:date).should == 'xml.namePart( \'#{builder_new_value}\', \'type\'=>\'date\' )'
|
319
|
+
@test_full_terminology.xml_builder_template(:person,:person_id).should == 'xml.namePart( \'#{builder_new_value}\' )'
|
320
|
+
@test_full_terminology.xml_builder_template(:name,:affiliation).should == 'xml.affiliation( \'#{builder_new_value}\' )'
|
321
321
|
end
|
322
322
|
|
323
323
|
it "should accept extra options" do
|
@@ -326,44 +326,44 @@ describe "OM::XML::Terminology" do
|
|
326
326
|
e1 = %q{xml.roleTerm( '#{builder_new_value}', 'type'=>'code', 'authority'=>'marcrelator' )}
|
327
327
|
e2 = %q{xml.roleTerm( '#{builder_new_value}', 'authority'=>'marcrelator', 'type'=>'code' )}
|
328
328
|
got = @test_full_terminology.xml_builder_template(:role, :code, {:attributes=>{"authority"=>"marcrelator"}} )
|
329
|
-
|
329
|
+
[e1, e2].should include(got)
|
330
330
|
got = @test_full_terminology.xml_builder_template(:person, :role, :code, {:attributes=>{"authority"=>"marcrelator"}} )
|
331
|
-
|
331
|
+
[e1, e2].should include(got)
|
332
332
|
end
|
333
333
|
|
334
334
|
it "should work with deeply nested properties" do
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
335
|
+
@test_full_terminology.xml_builder_template(:issue, :volume).should == "xml.detail( \'type\'=>'volume' ) { xml.number( '\#{builder_new_value}' ) }"
|
336
|
+
@test_full_terminology.xml_builder_template(:journal, :issue, :level).should == "xml.detail( \'type\'=>'number' ) { xml.number( '\#{builder_new_value}' ) }"
|
337
|
+
@test_full_terminology.xml_builder_template(:journal, :issue, :volume).should == "xml.detail( \'type\'=>'volume' ) { xml.number( '\#{builder_new_value}' ) }"
|
338
|
+
@test_full_terminology.xml_builder_template(:journal, :issue, :pages, :start).should == "xml.start( '\#{builder_new_value}' )"
|
339
339
|
end
|
340
340
|
|
341
341
|
end
|
342
342
|
|
343
343
|
describe "#term_generic_name" do
|
344
344
|
it "should generate a generic accessor name based on an array of pointers" do
|
345
|
-
|
346
|
-
|
345
|
+
OM::XML::Terminology.term_generic_name( {:conference=>0}, {:role=>1}, :text ).should == "conference_role_text"
|
346
|
+
OM::XML::Terminology.term_generic_name( *[{:conference=>0}, {:role=>1}, :text] ).should == "conference_role_text"
|
347
347
|
end
|
348
348
|
end
|
349
349
|
|
350
350
|
describe "#term_hierarchical_name" do
|
351
351
|
it "should generate a specific accessor name based on an array of pointers and indexes" do
|
352
|
-
|
353
|
-
|
352
|
+
OM::XML::Terminology.term_hierarchical_name( {:conference=>0}, {:role=>1}, :text ).should == "conference_0_role_1_text"
|
353
|
+
OM::XML::Terminology.term_hierarchical_name( *[{:conference=>0}, {:role=>1}, :text] ).should == "conference_0_role_1_text"
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
357
357
|
describe ".term_builders" do
|
358
358
|
it "should return a hash terms that have been added to the root of the terminology, indexed by term name" do
|
359
|
-
|
359
|
+
@test_terminology.terms[:name].should == @test_name
|
360
360
|
end
|
361
361
|
end
|
362
362
|
|
363
363
|
describe ".root_terms" do
|
364
364
|
it "should return the terms that have been marked root" do
|
365
|
-
|
366
|
-
|
365
|
+
@test_full_terminology.root_terms.length.should == 1
|
366
|
+
@test_full_terminology.root_terms.first.should == @test_full_terminology.terms[:mods]
|
367
367
|
end
|
368
368
|
end
|
369
369
|
|