om 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/{COMMON_OM_PATTERNS.textile → COMMON_OM_PATTERNS.md} +136 -126
  3. data/CONTRIBUTING.md +2 -2
  4. data/GETTING_FANCY.md +153 -0
  5. data/GETTING_STARTED.md +329 -0
  6. data/Gemfile +1 -1
  7. data/History.md +164 -0
  8. data/LICENSE +15 -20
  9. data/QUERYING_DOCUMENTS.md +162 -0
  10. data/README.md +2 -2
  11. data/UPDATING_DOCUMENTS.md +6 -0
  12. data/gemfiles/gemfile.rails3 +1 -1
  13. data/gemfiles/gemfile.rails4 +1 -1
  14. data/lib/om/version.rb +1 -1
  15. data/lib/om/xml/dynamic_node.rb +42 -51
  16. data/lib/tasks/om.rake +1 -1
  17. data/om.gemspec +1 -2
  18. data/spec/integration/differentiated_elements_spec.rb +2 -2
  19. data/spec/integration/element_value_spec.rb +13 -13
  20. data/spec/integration/proxies_and_ref_spec.rb +10 -10
  21. data/spec/integration/querying_documents_spec.rb +20 -27
  22. data/spec/integration/rights_metadata_integration_example_spec.rb +4 -4
  23. data/spec/integration/selective_querying_spec.rb +1 -1
  24. data/spec/integration/serialization_spec.rb +15 -15
  25. data/spec/integration/set_reentrant_terminology_spec.rb +6 -6
  26. data/spec/integration/subclass_terminology_spec.rb +8 -8
  27. data/spec/integration/xpathy_stuff_spec.rb +10 -10
  28. data/spec/unit/container_spec.rb +27 -27
  29. data/spec/unit/document_spec.rb +24 -24
  30. data/spec/unit/dynamic_node_spec.rb +60 -49
  31. data/spec/unit/named_term_proxy_spec.rb +12 -7
  32. data/spec/unit/node_generator_spec.rb +4 -4
  33. data/spec/unit/nokogiri_sanity_spec.rb +17 -18
  34. data/spec/unit/om_spec.rb +2 -2
  35. data/spec/unit/template_registry_spec.rb +51 -51
  36. data/spec/unit/term_builder_spec.rb +45 -44
  37. data/spec/unit/term_spec.rb +55 -55
  38. data/spec/unit/term_value_operators_spec.rb +205 -205
  39. data/spec/unit/term_xpath_generator_spec.rb +33 -36
  40. data/spec/unit/terminology_builder_spec.rb +50 -47
  41. data/spec/unit/terminology_spec.rb +92 -92
  42. data/spec/unit/validation_spec.rb +12 -12
  43. data/spec/unit/xml_serialization_spec.rb +20 -20
  44. data/spec/unit/xml_spec.rb +3 -3
  45. data/spec/unit/xml_terminology_based_solrizer_spec.rb +18 -18
  46. metadata +11 -38
  47. data/GETTING_FANCY.textile +0 -145
  48. data/GETTING_STARTED.textile +0 -254
  49. data/History.textile +0 -186
  50. data/QUERYING_DOCUMENTS.textile +0 -139
  51. data/UPDATING_DOCUMENTS.textile +0 -3
@@ -4,8 +4,8 @@ describe "OM" do
4
4
 
5
5
  describe "#{}destringify" do
6
6
  it "should recursively change any strings beginning with : to symbols and any number strings to integers" do
7
- OM.destringify( [{":person"=>"0"}, ":last_name"] ).should == [{:person=>0}, :last_name]
8
- OM.destringify( [{"person"=>"3"}, "last_name"] ).should == [{:person=>3}, :last_name]
7
+ expect(OM.destringify( [{":person"=>"0"}, ":last_name"] )).to eq([{:person=>0}, :last_name])
8
+ expect(OM.destringify( [{"person"=>"3"}, "last_name"] )).to eq([{:person=>3}, :last_name])
9
9
  end
10
10
  end
11
11
 
@@ -38,189 +38,189 @@ describe "OM::XML::TemplateRegistry" do
38
38
 
39
39
  describe "template definitions" do
40
40
  it "should contain predefined templates" do
41
- RegistryTest.template_registry.node_types.should include(:person)
42
- RegistryTest.template_registry.node_types.should_not include(:zombie)
41
+ expect(RegistryTest.template_registry.node_types).to include(:person)
42
+ expect(RegistryTest.template_registry.node_types).not_to include(:zombie)
43
43
  end
44
44
 
45
45
  it "should define new templates" do
46
- RegistryTest.template_registry.node_types.should_not include(:zombie)
46
+ expect(RegistryTest.template_registry.node_types).not_to include(:zombie)
47
47
  RegistryTest.define_template :zombie do |xml,name|
48
48
  xml.monster(:wants => 'braaaaainz') do
49
49
  xml.text(name)
50
50
  end
51
51
  end
52
- RegistryTest.template_registry.node_types.should include(:zombie)
52
+ expect(RegistryTest.template_registry.node_types).to include(:zombie)
53
53
  end
54
54
 
55
55
  it "should instantiate a detached node from a template" do
56
56
  node = RegistryTest.template_registry.instantiate(:zombie, 'Zeke')
57
57
  expectation = Nokogiri::XML('<monster wants="braaaaainz">Zeke</monster>').root
58
- node.should be_equivalent_to(expectation)
58
+ expect(node).to be_equivalent_to(expectation)
59
59
  end
60
60
 
61
61
  it "should raise an error when trying to instantiate an unknown node_type" do
62
- lambda { RegistryTest.template_registry.instantiate(:demigod, 'Hercules') }.should raise_error(NameError)
62
+ expect { RegistryTest.template_registry.instantiate(:demigod, 'Hercules') }.to raise_error(NameError)
63
63
  end
64
64
 
65
65
  it "should raise an exception if a missing method name doesn't match a node_type" do
66
- lambda { RegistryTest.template_registry.demigod('Hercules') }.should raise_error(NameError)
66
+ expect { RegistryTest.template_registry.demigod('Hercules') }.to raise_error(NameError)
67
67
  end
68
68
 
69
69
  it "should undefine existing templates" do
70
- RegistryTest.template_registry.node_types.should include(:zombie)
70
+ expect(RegistryTest.template_registry.node_types).to include(:zombie)
71
71
  RegistryTest.template_registry.undefine :zombie
72
- RegistryTest.template_registry.node_types.should_not include(:zombie)
72
+ expect(RegistryTest.template_registry.node_types).not_to include(:zombie)
73
73
  end
74
74
 
75
75
  it "should complain if the template name isn't a symbol" do
76
- lambda { RegistryTest.template_registry.define("die!") { |xml| xml.this_never_happened } }.should raise_error(TypeError)
76
+ expect(lambda { RegistryTest.template_registry.define("die!") { |xml| xml.this_never_happened } }).to raise_error(TypeError)
77
77
  end
78
78
 
79
79
  it "should report on whether a given template is defined" do
80
- RegistryTest.template_registry.has_node_type?(:person).should == true
81
- RegistryTest.template_registry.has_node_type?(:zombie).should == false
80
+ expect(RegistryTest.template_registry.has_node_type?(:person)).to eq true
81
+ expect(RegistryTest.template_registry.has_node_type?(:zombie)).to eq false
82
82
  end
83
83
 
84
84
  it "should include defined node_types as method names for introspection" do
85
- RegistryTest.template_registry.methods.should include('person')
85
+ expect(RegistryTest.template_registry.methods).to include('person')
86
86
  end
87
87
  end
88
88
 
89
89
  describe "template-based document manipulations" do
90
90
  it "should accept a Nokogiri::XML::Node as target" do
91
91
  @test_document.template_registry.after(@test_document.ng_xml.root.elements.first, :person, 'Bob', 'Builder')
92
- @test_document.ng_xml.root.elements.length.should == 2
92
+ expect(@test_document.ng_xml.root.elements.length).to eq 2
93
93
  end
94
94
 
95
95
  it "should accept a Nokogiri::XML::NodeSet as target" do
96
96
  @test_document.template_registry.after(@test_document.find_by_terms(:person => 0), :person, 'Bob', 'Builder')
97
- @test_document.ng_xml.root.elements.length.should == 2
97
+ expect(@test_document.ng_xml.root.elements.length).to eq 2
98
98
  end
99
99
 
100
100
  it "should instantiate a detached node from a template using the template name as a method" do
101
101
  node = RegistryTest.template_registry.person('Odin', 'All-Father')
102
102
  expectation = Nokogiri::XML('<person title="All-Father">Odin</person>').root
103
- node.should be_equivalent_to(expectation)
103
+ expect(node).to be_equivalent_to(expectation)
104
104
  end
105
105
 
106
106
  it "should add_child" do
107
107
  return_value = @test_document.template_registry.add_child(@test_document.ng_xml.root, :person, 'Bob', 'Builder')
108
- return_value.should == @test_document.find_by_terms(:person => 1).first
109
- @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
108
+ expect(return_value).to eq @test_document.find_by_terms(:person => 1).first
109
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:after]).respecting_element_order
110
110
  end
111
111
 
112
112
  it "should add_next_sibling" do
113
113
  return_value = @test_document.template_registry.add_next_sibling(@test_document.find_by_terms(:person => 0), :person, 'Bob', 'Builder')
114
- return_value.should == @test_document.find_by_terms(:person => 1).first
115
- @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
114
+ expect(return_value).to eq @test_document.find_by_terms(:person => 1).first
115
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:after]).respecting_element_order
116
116
  end
117
117
 
118
118
  it "should add_previous_sibling" do
119
119
  return_value = @test_document.template_registry.add_previous_sibling(@test_document.find_by_terms(:person => 0), :person, 'Bob', 'Builder')
120
- return_value.should == @test_document.find_by_terms(:person => 0).first
121
- @test_document.ng_xml.should be_equivalent_to(@expectations[:before]).respecting_element_order
120
+ expect(return_value).to eq(@test_document.find_by_terms(:person => 0).first)
121
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:before]).respecting_element_order
122
122
  end
123
123
 
124
124
  it "should after" do
125
125
  return_value = @test_document.template_registry.after(@test_document.find_by_terms(:person => 0), :person, 'Bob', 'Builder')
126
- return_value.should == @test_document.find_by_terms(:person => 0).first
127
- @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
126
+ expect(return_value).to eq(@test_document.find_by_terms(:person => 0).first)
127
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:after]).respecting_element_order
128
128
  end
129
129
 
130
130
  it "should before" do
131
131
  return_value = @test_document.template_registry.before(@test_document.find_by_terms(:person => 0), :person, 'Bob', 'Builder')
132
- return_value.should == @test_document.find_by_terms(:person => 1).first
133
- @test_document.ng_xml.should be_equivalent_to(@expectations[:before]).respecting_element_order
132
+ expect(return_value).to eq(@test_document.find_by_terms(:person => 1).first)
133
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:before]).respecting_element_order
134
134
  end
135
135
 
136
136
  it "should replace" do
137
137
  target_node = @test_document.find_by_terms(:person => 0).first
138
138
  return_value = @test_document.template_registry.replace(target_node, :person, 'Bob', 'Builder')
139
- return_value.should == @test_document.find_by_terms(:person => 0).first
140
- @test_document.ng_xml.should be_equivalent_to(@expectations[:instead]).respecting_element_order
139
+ expect(return_value).to eq(@test_document.find_by_terms(:person => 0).first)
140
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:instead]).respecting_element_order
141
141
  end
142
142
 
143
143
  it "should swap" do
144
144
  target_node = @test_document.find_by_terms(:person => 0).first
145
145
  return_value = @test_document.template_registry.swap(target_node, :person, 'Bob', 'Builder')
146
- return_value.should == target_node
147
- @test_document.ng_xml.should be_equivalent_to(@expectations[:instead]).respecting_element_order
146
+ expect(return_value).to eq target_node
147
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:instead]).respecting_element_order
148
148
  end
149
149
 
150
150
  it "should yield the result if a block is given" do
151
151
  target_node = @test_document.find_by_terms(:person => 0).first
152
152
  expectation = Nokogiri::XML('<person xmlns="urn:registry-test" title="Actor">Alice</person>').root
153
- @test_document.template_registry.swap(target_node, :person, 'Bob', 'Builder') { |old_node|
154
- old_node.should be_equivalent_to(expectation)
153
+ expect(@test_document.template_registry.swap(target_node, :person, 'Bob', 'Builder') { |old_node|
154
+ expect(old_node).to be_equivalent_to(expectation)
155
155
  old_node
156
- }.should be_equivalent_to(expectation)
156
+ }).to be_equivalent_to(expectation)
157
157
  end
158
158
  end
159
159
 
160
160
  describe "document-based document manipulations" do
161
161
  it "should accept a Nokogiri::XML::Node as target" do
162
162
  @test_document.after_node(@test_document.ng_xml.root.elements.first, :person, 'Bob', 'Builder')
163
- @test_document.ng_xml.root.elements.length.should == 2
163
+ expect(@test_document.ng_xml.root.elements.length).to eq 2
164
164
  end
165
165
 
166
166
  it "should accept a Nokogiri::XML::NodeSet as target" do
167
167
  @test_document.after_node(@test_document.find_by_terms(:person => 0), :person, 'Bob', 'Builder')
168
- @test_document.ng_xml.root.elements.length.should == 2
168
+ expect(@test_document.ng_xml.root.elements.length).to eq 2
169
169
  end
170
170
 
171
171
  it "should accept a term-pointer array as target" do
172
172
  @test_document.after_node([:person => 0], :person, 'Bob', 'Builder')
173
- @test_document.ng_xml.root.elements.length.should == 2
173
+ expect(@test_document.ng_xml.root.elements.length).to eq 2
174
174
  end
175
175
 
176
176
  it "should instantiate a detached node from a template" do
177
177
  node = @test_document.template(:person, 'Odin', 'All-Father')
178
178
  expectation = Nokogiri::XML('<person title="All-Father">Odin</person>').root
179
- node.should be_equivalent_to(expectation)
179
+ expect(node).to be_equivalent_to(expectation)
180
180
  end
181
181
 
182
182
  it "should add_child_node" do
183
183
  return_value = @test_document.add_child_node(@test_document.ng_xml.root, :person, 'Bob', 'Builder')
184
- return_value.should == @test_document.find_by_terms(:person => 1).first
185
- @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
184
+ expect(return_value).to eq @test_document.find_by_terms(:person => 1).first
185
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:after]).respecting_element_order
186
186
  end
187
187
 
188
188
  it "should add_next_sibling_node" do
189
189
  return_value = @test_document.add_next_sibling_node([:person => 0], :person, 'Bob', 'Builder')
190
- return_value.should == @test_document.find_by_terms(:person => 1).first
191
- @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
190
+ expect(return_value).to eq @test_document.find_by_terms(:person => 1).first
191
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:after]).respecting_element_order
192
192
  end
193
193
 
194
194
  it "should add_previous_sibling_node" do
195
195
  return_value = @test_document.add_previous_sibling_node([:person => 0], :person, 'Bob', 'Builder')
196
- return_value.should == @test_document.find_by_terms(:person => 0).first
197
- @test_document.ng_xml.should be_equivalent_to(@expectations[:before]).respecting_element_order
196
+ expect(return_value).to eq @test_document.find_by_terms(:person => 0).first
197
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:before]).respecting_element_order
198
198
  end
199
199
 
200
200
  it "should after_node" do
201
201
  return_value = @test_document.after_node([:person => 0], :person, 'Bob', 'Builder')
202
- return_value.should == @test_document.find_by_terms(:person => 0).first
203
- @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
202
+ expect(return_value).to eq @test_document.find_by_terms(:person => 0).first
203
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:after]).respecting_element_order
204
204
  end
205
205
 
206
206
  it "should before_node" do
207
207
  return_value = @test_document.before_node([:person => 0], :person, 'Bob', 'Builder')
208
- return_value.should == @test_document.find_by_terms(:person => 1).first
209
- @test_document.ng_xml.should be_equivalent_to(@expectations[:before]).respecting_element_order
208
+ expect(return_value).to eq @test_document.find_by_terms(:person => 1).first
209
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:before]).respecting_element_order
210
210
  end
211
211
 
212
212
  it "should replace_node" do
213
213
  target_node = @test_document.find_by_terms(:person => 0).first
214
214
  return_value = @test_document.replace_node(target_node, :person, 'Bob', 'Builder')
215
- return_value.should == @test_document.find_by_terms(:person => 0).first
216
- @test_document.ng_xml.should be_equivalent_to(@expectations[:instead]).respecting_element_order
215
+ expect(return_value).to eq @test_document.find_by_terms(:person => 0).first
216
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:instead]).respecting_element_order
217
217
  end
218
218
 
219
219
  it "should swap_node" do
220
220
  target_node = @test_document.find_by_terms(:person => 0).first
221
221
  return_value = @test_document.swap_node(target_node, :person, 'Bob', 'Builder')
222
- return_value.should == target_node
223
- @test_document.ng_xml.should be_equivalent_to(@expectations[:instead]).respecting_element_order
222
+ expect(return_value).to eq target_node
223
+ expect(@test_document.ng_xml).to be_equivalent_to(@expectations[:instead]).respecting_element_order
224
224
  end
225
225
  end
226
226
 
@@ -34,7 +34,7 @@ describe "OM::XML::Term::Builder" do
34
34
  describe '#new' do
35
35
  it "should set terminology_builder attribute if provided" do
36
36
  mock_terminology_builder = double("TerminologyBuilder")
37
- OM::XML::Term::Builder.new("term1", mock_terminology_builder).terminology_builder.should == mock_terminology_builder
37
+ expect(OM::XML::Term::Builder.new("term1", mock_terminology_builder).terminology_builder).to eq mock_terminology_builder
38
38
  end
39
39
  end
40
40
 
@@ -42,7 +42,7 @@ describe "OM::XML::Term::Builder" do
42
42
  it "should set the corresponding .settings value return the mapping object" do
43
43
  [:path, :index_as, :required, :type, :variant_of, :path, :attributes, :default_content_path].each do |method_name|
44
44
  @test_builder.send("#{method_name}=".to_sym, "#{method_name.to_s}foo")
45
- @test_builder.settings[method_name].should == "#{method_name.to_s}foo"
45
+ expect(@test_builder.settings[method_name]).to eq "#{method_name.to_s}foo"
46
46
  end
47
47
  end
48
48
  # it "should be chainable" do
@@ -59,11 +59,11 @@ describe "OM::XML::Term::Builder" do
59
59
  describe "settings" do
60
60
  describe "defaults" do
61
61
  it "should be set" do
62
- @test_builder.settings[:required].should == false
63
- @test_builder.settings[:type].should == :string
64
- @test_builder.settings[:variant_of].should be_nil
65
- @test_builder.settings[:attributes].should be_nil
66
- @test_builder.settings[:default_content_path].should be_nil
62
+ expect(@test_builder.settings[:required]).to eq false
63
+ expect(@test_builder.settings[:type]).to eq :string
64
+ expect(@test_builder.settings[:variant_of]).to be_nil
65
+ expect(@test_builder.settings[:attributes]).to be_nil
66
+ expect(@test_builder.settings[:default_content_path]).to be_nil
67
67
  end
68
68
  end
69
69
  end
@@ -71,19 +71,19 @@ describe "OM::XML::Term::Builder" do
71
71
  describe ".add_child" do
72
72
  it "should insert the given Term Builder into the current Term Builder's children" do
73
73
  @test_builder.add_child(@test_builder_2)
74
- @test_builder.children[@test_builder_2.name].should == @test_builder_2
74
+ expect(@test_builder.children[@test_builder_2.name]).to eq @test_builder_2
75
75
  end
76
76
  end
77
77
  describe ".retrieve_child" do
78
78
  it "should fetch the child identified by the given name" do
79
79
  @test_builder.add_child(@test_builder_2)
80
- @test_builder.retrieve_child(@test_builder_2.name).should == @test_builder.children[@test_builder_2.name]
80
+ expect(@test_builder.retrieve_child(@test_builder_2.name)).to eq @test_builder.children[@test_builder_2.name]
81
81
  end
82
82
  end
83
83
  describe ".children" do
84
84
  it "should return a hash of Term Builders that are the children of the current object, indexed by name" do
85
85
  @test_builder.add_child(@test_builder_2)
86
- @test_builder.children[@test_builder_2.name].should == @test_builder_2
86
+ expect(@test_builder.children[@test_builder_2.name]).to eq @test_builder_2
87
87
  end
88
88
  end
89
89
 
@@ -95,70 +95,71 @@ describe "OM::XML::Term::Builder" do
95
95
  t.type = :text
96
96
  end
97
97
  result = test_builder.build
98
- result.should be_instance_of OM::XML::Term
99
- result.index_as.should == [:facetable, :searchable, :sortable, :displayable]
100
- result.required.should == true
101
- result.type.should == :text
98
+ expect(result).to be_instance_of OM::XML::Term
99
+ expect(result.index_as).to eq [:facetable, :searchable, :sortable, :displayable]
100
+ expect(result.required).to eq true
101
+ expect(result.type).to eq :text
102
102
 
103
- result.xpath.should == OM::XML::TermXpathGenerator.generate_absolute_xpath(result)
104
- result.xpath_constrained.should == OM::XML::TermXpathGenerator.generate_constrained_xpath(result)
105
- result.xpath_relative.should == OM::XML::TermXpathGenerator.generate_relative_xpath(result)
103
+ expect(result.xpath).to eq OM::XML::TermXpathGenerator.generate_absolute_xpath(result)
104
+ expect(result.xpath_constrained).to eq OM::XML::TermXpathGenerator.generate_constrained_xpath(result)
105
+ expect(result.xpath_relative).to eq OM::XML::TermXpathGenerator.generate_relative_xpath(result)
106
106
  end
107
107
  it "should create proxy terms if :proxy is set" do
108
108
  test_builder = OM::XML::Term::Builder.new("my_proxy").tap do |t|
109
109
  t.proxy = [:foo, :bar]
110
110
  end
111
111
  result = test_builder.build
112
- result.should be_kind_of OM::XML::NamedTermProxy
112
+ expect(result).to be_kind_of OM::XML::NamedTermProxy
113
113
  end
114
114
  it "should set path to match name if it is empty" do
115
- @test_builder.settings[:path].should be_nil
116
- @test_builder.build.path.should == @test_builder.name.to_s
115
+ expect(@test_builder.settings[:path]).to be_nil
116
+ expect(@test_builder.build.path).to eq @test_builder.name.to_s
117
117
  end
118
118
  it "should work recursively, calling .build on any of its children" do
119
- OM::XML::Term.any_instance.stub(:generate_xpath_queries!)
119
+ allow_any_instance_of(OM::XML::Term).to receive(:generate_xpath_queries!)
120
120
  built_child1 = OM::XML::Term.new("child1")
121
121
  built_child2 = OM::XML::Term.new("child2")
122
122
 
123
123
  mock1 = double("Builder1", :build => built_child1 )
124
124
  mock2 = double("Builder2", :build => built_child2 )
125
- mock1.stub(:name).and_return("child1")
126
- mock2.stub(:name).and_return("child2")
125
+ allow(mock1).to receive(:name).and_return("child1")
126
+ allow(mock2).to receive(:name).and_return("child2")
127
127
 
128
128
  @test_builder.children = {:mock1=>mock1, :mock2=>mock2}
129
129
  result = @test_builder.build
130
- result.children[:child1].should == built_child1
131
- result.children[:child2].should == built_child2
132
- result.children.length.should == 2
130
+ expect(result.children[:child1]).to eq built_child1
131
+ expect(result.children[:child2]).to eq built_child2
132
+ expect(result.children.length).to eq 2
133
133
  end
134
134
  end
135
135
 
136
136
  describe ".lookup_refs" do
137
137
  it "should return an empty array if no refs are declared" do
138
- @test_builder.lookup_refs.should == []
138
+ expect(@test_builder.lookup_refs).to eq []
139
139
  end
140
140
  it "should should look up the referenced TermBuilder from the terminology_builder" do
141
- @peach.lookup_refs.should == [@stone_fruit]
141
+ expect(@peach.lookup_refs).to eq [@stone_fruit]
142
142
  end
143
143
  it "should support recursive refs" do
144
- @almond.lookup_refs.should == [@peach, @stone_fruit]
144
+ expect(@almond.lookup_refs).to eq [@peach, @stone_fruit]
145
145
  end
146
146
  it "should raise an error if the TermBuilder does not have a reference to a terminology builder" do
147
- lambda {
147
+ expect(lambda {
148
148
  OM::XML::Term::Builder.new("referrer").tap do |t|
149
149
  t.ref="bongos"
150
150
  t.lookup_refs
151
151
  end
152
- }.should raise_error(StandardError,"Cannot perform lookup_ref for the referrer builder. It doesn't have a reference to any terminology builder")
152
+ }).to raise_error(StandardError,"Cannot perform lookup_ref for the referrer builder. It doesn't have a reference to any terminology builder")
153
153
  end
154
+
154
155
  it "should raise an error if the referece points to a nonexistent term builder" do
155
156
  tb = OM::XML::Term::Builder.new("mork",@test_terminology_builder).tap do |t|
156
157
  t.ref = [:characters, :aliens]
157
158
  end
158
- lambda { tb.lookup_refs }.should raise_error(OM::XML::Terminology::BadPointerError,"This TerminologyBuilder does not have a root TermBuilder defined that corresponds to \":characters\"")
159
+ expect { tb.lookup_refs }.to raise_error(OM::XML::Terminology::BadPointerError,"This TerminologyBuilder does not have a root TermBuilder defined that corresponds to \":characters\"")
159
160
  end
160
161
  it "should raise an error with informative error when given circular references" do
161
- lambda { @pineapple.lookup_refs }.should raise_error(OM::XML::Terminology::CircularReferenceError,"Circular reference in Terminology: :pineapple => :banana => :coconut => :pineapple")
162
+ expect { @pineapple.lookup_refs }.to raise_error(OM::XML::Terminology::CircularReferenceError,"Circular reference in Terminology: :pineapple => :banana => :coconut => :pineapple")
162
163
  end
163
164
  end
164
165
 
@@ -168,8 +169,8 @@ describe "OM::XML::Term::Builder" do
168
169
  children_pre = @test_builder.children
169
170
 
170
171
  @test_builder.resolve_refs!
171
- @test_builder.settings.should == settings_pre
172
- @test_builder.children.should == children_pre
172
+ expect(@test_builder.settings).to eq settings_pre
173
+ expect(@test_builder.children).to eq children_pre
173
174
  end
174
175
  it "should should look up the referenced TermBuilder, use its settings and duplicate its children without changing the name" do
175
176
  term_builder = OM::XML::Term::Builder.new("orange",@test_terminology_builder).tap do |b|
@@ -177,24 +178,24 @@ describe "OM::XML::Term::Builder" do
177
178
  end
178
179
  term_builder.resolve_refs!
179
180
  # Make sure children and settings were copied
180
- term_builder.settings.should == @citrus.settings.merge(:path=>"citrus")
181
- term_builder.children.should == @citrus.children
181
+ expect(term_builder.settings).to eq @citrus.settings.merge(:path=>"citrus")
182
+ expect(term_builder.children).to eq @citrus.children
182
183
 
183
184
  # Make sure name and parent of both the term_builder and its target were left alone
184
- term_builder.name.should == :orange
185
- @citrus.name.should == :citrus
185
+ expect(term_builder.name).to eq :orange
186
+ expect(@citrus.name).to eq :citrus
186
187
  end
187
188
  it "should set path based on the ref's path if set" do
188
189
  [@peach,@almond].each { |x| x.resolve_refs! }
189
- @peach.settings[:path].should == "prunus"
190
- @almond.settings[:path].should == "prunus"
190
+ expect(@peach.settings[:path]).to eq "prunus"
191
+ expect(@almond.settings[:path]).to eq "prunus"
191
192
  end
192
193
  it "should set path based on the first ref's name if no path is set" do
193
194
  orange_builder = OM::XML::Term::Builder.new("orange",@test_terminology_builder).tap do |b|
194
195
  b.ref= [:fruit_trees, :citrus]
195
196
  end
196
197
  orange_builder.resolve_refs!
197
- orange_builder.settings[:path].should == "citrus"
198
+ expect(orange_builder.settings[:path]).to eq "citrus"
198
199
  end
199
200
  # It should not be a problem if multiple TermBuilders refer to the same child TermBuilder since the parent-child relationship is set up after calling TermBuilder.build
200
201
  it "should result in clean trees of Terms after building"
@@ -206,11 +207,11 @@ describe "OM::XML::Term::Builder" do
206
207
  b.required =true
207
208
  end
208
209
  tb.resolve_refs!
209
- tb.settings.should == {:path=>"citrus", :attributes=>{"citric_acid"=>"true", :color=>"orange"}, :required=>true, :type=>:string, :index_as=>[:facetable]}
210
+ expect(tb.settings).to eq({:path=>"citrus", :attributes=>{"citric_acid"=>"true", :color=>"orange"}, :required=>true, :type=>:string, :index_as=>[:facetable]})
210
211
  end
211
212
  it "should aggregate all settings from refs, combining them with a cascading approach" do
212
213
  @almond.resolve_refs!
213
- @almond.settings[:attributes].should == {:genus=>"Prunus",:subgenus=>"Amygdalus", :species=>"Prunus dulcis"}
214
+ expect(@almond.settings[:attributes]).to eq({:genus=>"Prunus",:subgenus=>"Amygdalus", :species=>"Prunus dulcis"})
214
215
  end
215
216
  end
216
217
  end