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
@@ -75,14 +75,14 @@ describe "OM::XML::Document" do
75
75
  end
76
76
 
77
77
  it "should automatically include the necessary modules" do
78
- DocumentTest.included_modules.should include(OM::XML::Container)
79
- DocumentTest.included_modules.should include(OM::XML::TermValueOperators)
80
- DocumentTest.included_modules.should include(OM::XML::Validation)
78
+ expect(DocumentTest.included_modules).to include(OM::XML::Container)
79
+ expect(DocumentTest.included_modules).to include(OM::XML::TermValueOperators)
80
+ expect(DocumentTest.included_modules).to include(OM::XML::Validation)
81
81
  end
82
82
 
83
83
  describe ".ox_namespaces" do
84
84
  it "should merge terminology namespaces with document namespaces" do
85
- @fixturemods.ox_namespaces.should == {"oxns"=>"http://www.loc.gov/mods/v3", "xmlns:ns2"=>"http://www.w3.org/1999/xlink", "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", "xmlns:ns3"=>"http://www.loc.gov/mods/v3", "xmlns"=>"http://www.loc.gov/mods/v3"}
85
+ expect(@fixturemods.ox_namespaces).to eq({"oxns"=>"http://www.loc.gov/mods/v3", "xmlns:ns2"=>"http://www.w3.org/1999/xlink", "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", "xmlns:ns3"=>"http://www.loc.gov/mods/v3", "xmlns"=>"http://www.loc.gov/mods/v3"})
86
86
  end
87
87
  end
88
88
 
@@ -90,72 +90,72 @@ describe "OM::XML::Document" do
90
90
  describe ".find_by_terms_and_value" do
91
91
  it "should fail gracefully if you try to look up nodes for an undefined property" do
92
92
  skip "better to get an informative error?"
93
- @fixturemods.find_by_terms_and_value(:nobody_home).should == []
93
+ expect(@fixturemods.find_by_terms_and_value(:nobody_home)).to eq []
94
94
  end
95
95
  it "should use Nokogiri to retrieve a NodeSet corresponding to the term pointers" do
96
- @mods_article.find_by_terms_and_value( :person ).length.should == 2
96
+ expect(@mods_article.find_by_terms_and_value( :person ).length).to eq 2
97
97
  end
98
98
 
99
99
  it "should allow you to search by term pointer" do
100
- @fixturemods.ng_xml.should_receive(:xpath).with('//oxns:name[@type="personal"]', @fixturemods.ox_namespaces)
100
+ expect(@fixturemods.ng_xml).to receive(:xpath).with('//oxns:name[@type="personal"]', @fixturemods.ox_namespaces)
101
101
  @fixturemods.find_by_terms_and_value(:person)
102
102
  end
103
103
  it "should allow you to constrain your searches" do
104
- @fixturemods.ng_xml.should_receive(:xpath).with('//oxns:name[@type="personal" and contains(., "Beethoven, Ludwig van")]', @fixturemods.ox_namespaces)
104
+ expect(@fixturemods.ng_xml).to receive(:xpath).with('//oxns:name[@type="personal" and contains(., "Beethoven, Ludwig van")]', @fixturemods.ox_namespaces)
105
105
  @fixturemods.find_by_terms_and_value(:person, "Beethoven, Ludwig van")
106
106
  end
107
107
  it "should allow you to use complex constraints" do
108
- @fixturemods.ng_xml.should_receive(:xpath).with('//oxns:name[@type="personal"]/oxns:namePart[@type="date" and contains(., "2010")]', @fixturemods.ox_namespaces)
108
+ expect(@fixturemods.ng_xml).to receive(:xpath).with('//oxns:name[@type="personal"]/oxns:namePart[@type="date" and contains(., "2010")]', @fixturemods.ox_namespaces)
109
109
  @fixturemods.find_by_terms_and_value(:person, :date=>"2010")
110
110
 
111
- @fixturemods.ng_xml.should_receive(:xpath).with('//oxns:name[@type="personal"]/oxns:role[contains(., "donor")]', @fixturemods.ox_namespaces)
111
+ expect(@fixturemods.ng_xml).to receive(:xpath).with('//oxns:name[@type="personal"]/oxns:role[contains(., "donor")]', @fixturemods.ox_namespaces)
112
112
  @fixturemods.find_by_terms_and_value(:person, :role=>"donor")
113
113
  end
114
114
  end
115
115
  describe ".find_by_terms" do
116
116
  it "should use Nokogiri to retrieve a NodeSet corresponding to the combination of term pointers and array/nodeset indexes" do
117
- @mods_article.find_by_terms( :person ).length.should == 2
118
- @mods_article.find_by_terms( {:person=>1} ).first.should == @mods_article.ng_xml.xpath('//oxns:name[@type="personal"][2]', "oxns"=>"http://www.loc.gov/mods/v3").first
119
- @mods_article.find_by_terms( {:person=>1}, :first_name ).class.should == Nokogiri::XML::NodeSet
120
- @mods_article.find_by_terms( {:person=>1}, :first_name ).first.text.should == "Siddartha"
117
+ expect(@mods_article.find_by_terms( :person ).length).to eq 2
118
+ expect(@mods_article.find_by_terms( {:person=>1} ).first).to eq @mods_article.ng_xml.xpath('//oxns:name[@type="personal"][2]', "oxns"=>"http://www.loc.gov/mods/v3").first
119
+ expect(@mods_article.find_by_terms( {:person=>1}, :first_name ).class).to eq Nokogiri::XML::NodeSet
120
+ expect(@mods_article.find_by_terms( {:person=>1}, :first_name ).first.text).to eq "Siddartha"
121
121
  end
122
122
  it "should find a NodeSet where a terminology attribute has been set to :none" do
123
- @mods_article.find_by_terms( {:person=>1}, :person_id).first.text.should == "123987"
123
+ expect(@mods_article.find_by_terms( {:person=>1}, :person_id).first.text).to eq "123987"
124
124
  end
125
125
  it "should support accessors whose relative_xpath is a lookup array instead of an xpath string" do
126
126
  # skip "this only impacts scenarios where we want to display & edit"
127
- DocumentTest.terminology.retrieve_term(:title_info, :language).path.should == {:attribute=>"lang"}
127
+ expect(DocumentTest.terminology.retrieve_term(:title_info, :language).path).to eq({:attribute=>"lang"})
128
128
  # @sample.retrieve( :title, 1 ).first.text.should == "Artikkelin otsikko Hydrangea artiklan 1"
129
- @mods_article.find_by_terms( {:title_info=>1}, :language ).first.text.should == "finnish"
129
+ expect(@mods_article.find_by_terms( {:title_info=>1}, :language ).first.text).to eq "finnish"
130
130
  end
131
131
 
132
132
  it "should support xpath queries as the pointer" do
133
- @mods_article.find_by_terms('//oxns:name[@type="personal"][1]/oxns:namePart[1]').first.text.should == "FAMILY NAME"
133
+ expect(@mods_article.find_by_terms('//oxns:name[@type="personal"][1]/oxns:namePart[1]').first.text).to eq "FAMILY NAME"
134
134
  end
135
135
 
136
136
  it "should return nil if the xpath fails to generate" do
137
137
  skip "Can't decide if it's better to return nil or raise an error. Choosing informative errors for now."
138
- @mods_article.find_by_terms( {:foo=>20}, :bar ).should == nil
138
+ expect(@mods_article.find_by_terms( {:foo=>20}, :bar )).to eq nil
139
139
  end
140
140
 
141
141
  it "should support terms that point to attributes instead of nodes" do
142
- @mods_article.find_by_terms( {:title_info=>1}, :language ).first.text.should == "finnish"
142
+ expect(@mods_article.find_by_terms( {:title_info=>1}, :language ).first.text).to eq "finnish"
143
143
  end
144
144
 
145
145
  it "should support xpath queries as the pointer" do
146
- @mods_article.find_by_terms('//oxns:name[@type="personal"][1]/oxns:namePart[1]').first.text.should == "FAMILY NAME"
146
+ expect(@mods_article.find_by_terms('//oxns:name[@type="personal"][1]/oxns:namePart[1]').first.text).to eq "FAMILY NAME"
147
147
  end
148
148
  end
149
149
 
150
150
  describe "node_exists?" do
151
151
  it "should return true if any nodes are found" do
152
- @mods_article.node_exists?( {:person=>1}, :first_name).should be true
152
+ expect(@mods_article.node_exists?( {:person=>1}, :first_name)).to be true
153
153
  end
154
154
  it "should return false if no nodes are found" do
155
- @mods_article.node_exists?( {:person=>8}, :first_name ).should be false
155
+ expect(@mods_article.node_exists?( {:person=>8}, :first_name )).to be false
156
156
  end
157
157
  it "should support xpath queries" do
158
- @mods_article.node_exists?('//oxns:name[@type="personal"][1]/oxns:namePart[1]').should be true
158
+ expect(@mods_article.node_exists?('//oxns:name[@type="personal"][1]/oxns:namePart[1]')).to be true
159
159
  end
160
160
  end
161
161
 
@@ -26,26 +26,26 @@ describe "OM::XML::DynamicNode" do
26
26
 
27
27
  it "should create templates for dynamic nodes" do
28
28
  @sample.creator = "Foo"
29
- @sample.creator.should == ['Foo']
29
+ expect(@sample.creator).to eq ['Foo']
30
30
  end
31
31
  it "should create templates for dynamic nodes with multiple values" do
32
32
  @sample.creator = ["Foo", "Bar"]
33
- @sample.creator.should == ['Foo', 'Bar']
33
+ expect(@sample.creator).to eq ['Foo', 'Bar']
34
34
  end
35
35
 
36
36
  it "should create templates for dynamic nodes with empty string values" do
37
37
  @sample.creator = ['']
38
- @sample.creator.should == ['']
38
+ expect(@sample.creator).to eq ['']
39
39
  end
40
40
 
41
41
  it "should create templates for plain nodes" do
42
42
  @sample.foo = ['in a galaxy far far away']
43
- @sample.foo.should == ['in a galaxy far far away']
43
+ expect(@sample.foo).to eq ['in a galaxy far far away']
44
44
  end
45
45
 
46
46
  it "should create templates for dynamic nodes with a period in the element name" do
47
47
  @sample.date_created = ['A long time ago']
48
- @sample.date_created.should == ['A long time ago']
48
+ expect(@sample.date_created).to eq ['A long time ago']
49
49
  end
50
50
 
51
51
  it "checks inequality" do
@@ -53,36 +53,36 @@ describe "OM::XML::DynamicNode" do
53
53
  expect(@sample.foo != ['nearby']).to be true
54
54
  end
55
55
  end
56
-
57
-
56
+
57
+
58
58
  describe "with a template" do
59
59
  before(:each) do
60
60
  @sample = OM::Samples::ModsArticle.from_xml( fixture( File.join("test_dummy_mods.xml") ) )
61
61
  @article = OM::Samples::ModsArticle.from_xml( fixture( File.join("mods_articles","hydrangea_article1.xml") ) )
62
62
  end
63
-
63
+
64
64
  describe "dynamically created nodes" do
65
65
 
66
66
  it "should return build an array of values from the nodeset corresponding to the given term" do
67
67
  expected_values = ["Berners-Lee", "Jobs", "Wozniak", "Klimt"]
68
68
  result = @sample.person.last_name
69
- result.length.should == expected_values.length
70
- expected_values.each {|v| result.should include(v)}
69
+ expect(result.length).to eq expected_values.length
70
+ expected_values.each {|v| expect(result).to include(v)}
71
71
  end
72
72
 
73
73
  it "should be able to set first level elements" do
74
74
  @article.abstract = "My Abstract"
75
- @article.abstract.should == ["My Abstract"]
75
+ expect(@article.abstract).to eq ["My Abstract"]
76
76
  end
77
77
 
78
78
  it "should be able to set first level elements that are arrays" do
79
79
  @article.abstract = ["My Abstract", "two"]
80
- @article.abstract.should == ["My Abstract", 'two']
80
+ expect(@article.abstract).to eq ["My Abstract", 'two']
81
81
  end
82
82
 
83
83
  it "should delegate all methods (i.e. to_s, first, etc.) to the found array" do
84
- @article.person.last_name.to_s.should == ["FAMILY NAME", "Gautama"].to_s
85
- @article.person.last_name.first.should == "FAMILY NAME"
84
+ expect(@article.person.last_name.to_s).to eq ["FAMILY NAME", "Gautama"].to_s
85
+ expect(@article.person.last_name.first).to eq "FAMILY NAME"
86
86
  end
87
87
 
88
88
  it "should respond_to? things an array can do" do
@@ -92,98 +92,109 @@ describe "OM::XML::DynamicNode" do
92
92
  it "should delegate with blocks to the found array" do
93
93
  arr = []
94
94
  @article.person.last_name.each{|x| arr << x}
95
- arr.should == ["FAMILY NAME", "Gautama"]
95
+ expect(arr).to eq ["FAMILY NAME", "Gautama"]
96
96
  end
97
97
 
98
-
99
98
  describe "setting attributes" do
100
99
  it "when they exist" do
101
100
  @article.title_info(0).main_title.main_title_lang = "ger"
102
- @article.title_info(0).main_title.main_title_lang.should == ["ger"]
101
+ expect(@article.title_info(0).main_title.main_title_lang).to eq ["ger"]
103
102
  end
104
103
  it "when they don't exist" do
105
104
  title = @article.title_info(0)
106
105
  title.language = "rus"
107
- @article.title_info(0).language.should == ["rus"]
106
+ expect(@article.title_info(0).language).to eq ["rus"]
108
107
  end
109
-
110
108
  end
111
109
 
112
110
  it "should find elements two deep" do
113
- #TODO reimplement so that method_missing with name is only called once. Create a new method for name.
114
- @article.name.name_content.val.should == ["Describes a person"]
115
- @article.name.name_content.should == ["Describes a person"]
116
- @article.name.name_content(0).should == ["Describes a person"]
111
+ # TODO reimplement so that method_missing with name is only called once. Create a new method for name.
112
+ expect(@article.name.name_content.val).to eq(["Describes a person"])
113
+ expect(@article.name.name_content ).to eq(["Describes a person"])
114
+ expect(@article.name.name_content(0) ).to eq(["Describes a person"])
117
115
  end
118
116
 
119
- it "should not find elements that don't exist" do
120
- lambda {@article.name.hedgehog}.should raise_exception NoMethodError
117
+ it 'should offer some awareness for respond_to?' do
118
+ expect(@article.name.name_content.include?('Describes a person')).to be_truthy
119
+ expect(@article.name.name_content.respond_to?(:include?)).to be_truthy
120
+ expect(@article.name.name_content).to include('Describes a person')
121
+ end
122
+
123
+ it "should not find elements that don't exist" do
124
+ expect{@article.name.hedgehog }.to raise_exception NoMethodError, /hedgehog/
125
+ expect{@article.name.hedgehog = 5 }.to raise_exception NoMethodError, /hedgehog/
126
+ expect{@article.name.hedgehog(5) }.to raise_exception NoMethodError, /hedgehog/
127
+ expect{@article.name.hedgehog(5,1)}.to raise_exception NoMethodError, /hedgehog/
128
+ expect{@article.name.name_content.hedgehog }.to raise_exception NoMethodError, /hedgehog/
129
+ expect{@article.name.name_content.hedgehog = 'foo' }.to raise_exception NoMethodError, /hedgehog/
130
+ expect{@article.name.name_content.hedgehog(1) }.to raise_exception NoMethodError, /hedgehog/
131
+ expect{@article.name.name_content.hedgehog(1,'foo')}.to raise_exception NoMethodError, /hedgehog/
121
132
  end
122
133
 
123
134
  it "should allow you to call methods on the return value" do
124
- @article.name.name_content.first.should == "Describes a person"
135
+ expect(@article.name.name_content.first).to eq "Describes a person"
125
136
  end
126
137
 
127
138
  it "Should work with proxies" do
128
- @article.title.should == ["ARTICLE TITLE HYDRANGEA ARTICLE 1", "Artikkelin otsikko Hydrangea artiklan 1", "TITLE OF HOST JOURNAL"]
129
- @article.title.main_title_lang.should == ['eng']
139
+ expect(@article.title).to eq(["ARTICLE TITLE HYDRANGEA ARTICLE 1", "Artikkelin otsikko Hydrangea artiklan 1", "TITLE OF HOST JOURNAL"])
140
+ expect(@article.title.main_title_lang).to eq ['eng']
130
141
 
131
- @article.title(1).to_pointer.should == [{:title => 1}]
142
+ expect(@article.title(1).to_pointer).to eq [{:title => 1}]
132
143
 
133
- @article.journal_title.xpath.should == "//oxns:relatedItem[@type=\"host\"]/oxns:titleInfo/oxns:title"
134
- @article.journal_title.should == ["TITLE OF HOST JOURNAL"]
144
+ expect(@article.journal_title.xpath).to eq "//oxns:relatedItem[@type=\"host\"]/oxns:titleInfo/oxns:title"
145
+ expect(@article.journal_title).to eq ["TITLE OF HOST JOURNAL"]
135
146
  end
136
147
 
137
148
  it "Should be addressable to a specific node" do
138
149
  @article.update_values( {[{:journal=>0}, {:issue=>3}, :pages, :start]=>"434"})
139
150
 
140
151
  @article.subject.topic(1).to_pointer == [:subject, {:topic => 1}]
141
- @article.journal(0).issue.length.should == 2
142
- @article.journal(0).issue(1).pages.to_pointer == [{:journal=>0}, {:issue=>1}, :pages]
143
- @article.journal(0).issue(1).pages.length.should == 1
144
- @article.journal(0).issue(1).pages.start.length.should == 1
145
- @article.journal(0).issue(1).pages.start.first.should == "434"
152
+ expect(@article.journal(0).issue.length).to eq 2
153
+ expect(@article.journal(0).issue(1).pages.to_pointer).to eq [{:journal=>0}, {:issue=>1}, :pages]
154
+ expect(@article.journal(0).issue(1).pages.length).to eq 1
155
+ expect(@article.journal(0).issue(1).pages.start.length).to eq 1
156
+ expect(@article.journal(0).issue(1).pages.start.first).to eq "434"
146
157
 
147
- @article.subject.topic(1).should == ["TOPIC 2"]
148
- @article.subject.topic(1).xpath.should == "//oxns:subject/oxns:topic[2]"
158
+ expect(@article.subject.topic(1)).to eq ["TOPIC 2"]
159
+ expect(@article.subject.topic(1).xpath).to eq "//oxns:subject/oxns:topic[2]"
149
160
  end
150
-
161
+
151
162
  describe ".nodeset" do
152
163
  it "should return a Nokogiri NodeSet" do
153
164
  @article.update_values( {[{:journal=>0}, {:issue=>3}, :pages, :start]=>"434" })
154
165
  nodeset = @article.journal(0).issue(1).pages.start.nodeset
155
- nodeset.should be_kind_of Nokogiri::XML::NodeSet
156
- nodeset.length.should == @article.journal(0).issue(1).pages.start.length
157
- nodeset.first.text.should == @article.journal(0).issue(1).pages.start.first
166
+ expect(nodeset).to be_kind_of Nokogiri::XML::NodeSet
167
+ expect(nodeset.length).to eq @article.journal(0).issue(1).pages.start.length
168
+ expect(nodeset.first.text).to eq @article.journal(0).issue(1).pages.start.first
158
169
  end
159
170
  end
160
171
 
161
172
  it "should append nodes at the specified index if possible" do
162
173
  @article.journal.title_info = ["all", "for", "the"]
163
174
  @article.journal.title_info(3, 'glory')
164
- @article.term_values(:journal, :title_info).should == ["all", "for", "the", "glory"]
165
- @article.should be_changed
175
+ expect(@article.term_values(:journal, :title_info)).to eq ["all", "for", "the", "glory"]
176
+ expect(@article).to be_changed
166
177
  end
167
-
178
+
168
179
  it "should remove extra nodes if fewer are given than currently exist" do
169
180
  @article.journal.title_info = %W(one two three four five)
170
181
  @article.journal.title_info = %W(six seven)
171
- @article.journal.title_info.should == ["six", "seven"]
182
+ expect(@article.journal.title_info).to eq ["six", "seven"]
172
183
  end
173
184
 
174
185
  describe '==' do
175
186
  it "returns true when values of dynamic nodes are equal." do
176
187
  @article.name(0).last_name = "Steven"
177
188
  @article.name(0).first_name = "Steven"
178
- (@article.name(0).last_name == @article.name(0).first_name).should == true
189
+ expect(@article.name(0).last_name).to eq @article.name(0).first_name
179
190
  end
180
191
 
181
192
  it 'returns false when values of dynamic nodes are not equal.' do
182
193
  @article.name(0).first_name = "Horatio"
183
194
  @article.name(0).last_name = "Hogginobble"
184
- (@article.name(0).last_name == @article.name(0).first_name).should == false
195
+ expect(@article.name(0).last_name == @article.name(0).first_name).to be false
185
196
  end
186
- end
197
+ end
187
198
  end
188
199
  end
189
200
  end
@@ -31,25 +31,30 @@ describe "OM::XML::NamedTermProxy" do
31
31
 
32
32
  it "should proxy all extra methods to the proxied object" do
33
33
  [:xpath, :xpath_relative, :xml_builder_template].each do |method|
34
- @proxied_term.should_receive(method)
34
+ expect(@proxied_term).to receive(method)
35
35
  @test_proxy.send(method)
36
36
  end
37
37
  end
38
+
38
39
  it "should proxy the term specified by the builder" do
39
- @test_proxy.proxied_term.should == @test_terminology.retrieve_term(:parent, :foo, :bar)
40
- @test_proxy.xpath.should == "//oxns:parent/oxns:foo/oxns:bar"
40
+ expect(@test_proxy.proxied_term).to eq(@test_terminology.retrieve_term(:parent, :foo, :bar))
41
+ expect(@test_proxy.xpath).to eq "//oxns:parent/oxns:foo/oxns:bar"
41
42
  end
43
+
42
44
  it "should search relative to the parent term when finding the term to proxy" do
43
45
  proxy2 = @test_terminology.retrieve_term(:adoptive_parent, :my_proxy)
44
- proxy2.proxied_term.should == @test_terminology.retrieve_term(:adoptive_parent, :foo, :bar)
45
- proxy2.xpath.should == '//oxns:parent[@type="adoptive"]/oxns:foo/oxns:bar'
46
+ expect(proxy2.proxied_term).to eq @test_terminology.retrieve_term(:adoptive_parent, :foo, :bar)
47
+ expect(proxy2.xpath).to eq '//oxns:parent[@type="adoptive"]/oxns:foo/oxns:bar'
46
48
  end
49
+
47
50
  it "should support NamedTermProxies that point to root terms" do
48
- @test_terminology.xpath_for(:parentfoobarproxy).should == "//oxns:parent/oxns:foo/oxns:bar"
51
+ expect(@test_terminology.xpath_for(:parentfoobarproxy)).to eq("//oxns:parent/oxns:foo/oxns:bar")
49
52
  end
53
+
50
54
  it "should be usable in update_values" do
51
55
  document = NamedProxyTestDocument.from_xml(NamedProxyTestDocument.xml_template)
52
56
  document.update_values([:parentfoobarproxy] => "FOObar!")
53
- document.term_values(:parentfoobarproxy).should == ["FOObar!"]
57
+ expect(document.term_values(:parentfoobarproxy)).to eq ["FOObar!"]
54
58
  end
59
+
55
60
  end
@@ -10,17 +10,17 @@ describe "OM::XML::NodeGenerator" do
10
10
 
11
11
  describe '#generate' do
12
12
  it "should use the corresponding builder template(s) to generate the node" do
13
- OM::XML::NodeGenerator.generate(@test_mods_term, "foo").root.to_xml.should == "<mods>foo</mods>"
13
+ expect(OM::XML::NodeGenerator.generate(@test_mods_term, "foo").root.to_xml).to eq "<mods>foo</mods>"
14
14
  generated_node = OM::XML::NodeGenerator.generate(@test_volume_term, "108", {:attributes=>{"extraAttr"=>"my value"}})
15
- generated_node.xpath('./detail[@type="volume"][@extraAttr="my value"]').xpath("./number").text.should == "108"
15
+ expect(generated_node.xpath('./detail[@type="volume"][@extraAttr="my value"]').xpath("./number").text).to eq "108"
16
16
  # Would be great if we wrote a have_node custom rspec matcher...
17
17
  # generated_node.should have_node 'role[@authority="marcrelator"][@type="code"]' do
18
18
  # with_node "roleTerm", "creator"
19
19
  # end
20
20
  end
21
+
21
22
  it "should return Nokogiri Documents" do
22
- OM::XML::NodeGenerator.generate(@test_mods_term, "foo").class.should == Nokogiri::XML::Document
23
+ expect(OM::XML::NodeGenerator.generate(@test_mods_term, "foo").class).to eq Nokogiri::XML::Document
23
24
  end
24
25
  end
25
-
26
26
  end
@@ -8,7 +8,7 @@ describe "OM::XML::TermValueOperators" do
8
8
  end
9
9
 
10
10
  it "should do" do
11
- @article.find_by_terms({:journal=>0}).length.should == 1
11
+ expect(@article.find_by_terms({:journal=>0}).length).to eq 1
12
12
  end
13
13
  end
14
14
 
@@ -20,56 +20,55 @@ describe "OM::XML::TermValueOperators" do
20
20
  it "should respond with a hash of updated values and their indexes" do
21
21
  test_args = {[{"person"=>"0"},"description"]=>["mork", "york"]}
22
22
  result = @article.update_values(test_args)
23
- result.should == {"person_0_description"=>["mork", "york"]}
23
+ expect(result).to eq({"person_0_description"=>["mork", "york"]})
24
24
  end
25
25
 
26
26
  it "should update the xml in the specified datastream and know that changes have been made" do
27
- @article.term_values({:person=>0}, :first_name).should == ["GIVEN NAMES"]
27
+ expect(@article.term_values({:person=>0}, :first_name)).to eq ["GIVEN NAMES"]
28
28
  test_args = {[{:person=>0}, :first_name]=>"Replacement FirstName"}
29
29
  @article.update_values(test_args)
30
- @article.term_values({:person=>0}, :first_name).should == ["Replacement FirstName"]
31
- @article.should be_changed
30
+ expect(@article.term_values({:person=>0}, :first_name)).to eq ["Replacement FirstName"]
31
+ expect(@article).to be_changed
32
32
  end
33
33
 
34
34
  it "should update the xml according to the find_by_terms_and_values in the given hash" do
35
35
  terms_attributes = {[{":person"=>"0"}, "affiliation"]=>["affiliation1", "affiliation2", "affiliation3"]}
36
36
  result = @article.update_values(terms_attributes)
37
- result.should == {"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"]}
37
+ expect(result).to eq({"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"]})
38
38
 
39
39
  # Trying again with a more complex update hash
40
40
  terms_attributes = {[{":person"=>"0"}, "affiliation"]=>["affiliation1", "affiliation2", "affiliation3"], [{:person=>1}, :last_name]=>"Andronicus", [{"person"=>"1"},:first_name]=>["Titus"],[{:person=>1},:role]=>["otherrole1","otherrole2"] }
41
41
  result = @article.update_values(terms_attributes)
42
- result.should == {"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"], "person_1_last_name"=>["Andronicus"],"person_1_first_name"=>["Titus"], "person_1_role"=>["otherrole1","otherrole2"]}
43
- @article.should be_changed
42
+ expect(result).to eq({"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"], "person_1_last_name"=>["Andronicus"],"person_1_first_name"=>["Titus"], "person_1_role"=>["otherrole1","otherrole2"]})
43
+ expect(@article).to be_changed
44
44
  end
45
45
 
46
46
  it "should work when you re-run the command" do
47
47
  terms_attributes = {[{":person"=>"0"}, "affiliation"]=>["affiliation1", "affiliation2", "affiliation3"]}
48
48
  result = @article.update_values(terms_attributes)
49
- @article.term_values( {":person"=>"0"}, "affiliation" ).should == ["affiliation1", "affiliation2", "affiliation3"]
50
- result.should == {"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"]}
49
+
50
+ expect(@article.term_values( {":person"=>"0"}, "affiliation" )).to eq ["affiliation1", "affiliation2", "affiliation3"]
51
+ expect(result).to eq({"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"]})
51
52
 
52
53
  terms_attributes = {[{":person"=>"0"}, "affiliation"]=>["affiliation1", "affiliation2", "affiliation3"]}
53
54
  @article = OM::Samples::ModsArticle.from_xml( fixture( File.join("mods_articles","hydrangea_article1.xml") ) )
54
55
  result = @article.update_values(terms_attributes)
55
- @article.term_values( {":person"=>"0"}, "affiliation" ).should == ["affiliation1", "affiliation2", "affiliation3"]
56
- result.should == {"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"]}
56
+ expect(@article.term_values( {":person"=>"0"}, "affiliation" )).to eq ["affiliation1", "affiliation2", "affiliation3"]
57
+ expect(result).to eq({"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"]})
57
58
  result = @article.update_values(terms_attributes)
58
59
 
59
60
  terms_attributes = {[{":person"=>"0"}, "affiliation"]=>["affiliation1", "affiliation2", "affiliation3"]}
60
61
  @article = OM::Samples::ModsArticle.from_xml( fixture( File.join("mods_articles","hydrangea_article1.xml") ) )
61
62
  result = @article.update_values(terms_attributes)
62
- @article.term_values( {":person"=>"0"}, "affiliation" ).should == ["affiliation1", "affiliation2", "affiliation3"]
63
- result.should == {"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"]}
63
+ expect(@article.term_values( {":person"=>"0"}, "affiliation" )).to eq ["affiliation1", "affiliation2", "affiliation3"]
64
+ expect(result).to eq({"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"]})
64
65
 
65
66
  # Trying again with a more complex update hash
66
67
  terms_attributes = {[{":person"=>"0"}, "affiliation"]=>["affiliation1", "affiliation2", "affiliation3"], [{:person=>1}, :last_name]=>"Andronicus", [{"person"=>"1"},:first_name]=>["Titus"],[{:person=>1},:role]=>["otherrole1","otherrole2"] }
67
68
  result = @article.update_values(terms_attributes)
68
- result.should == {"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"], "person_1_last_name"=>["Andronicus"],"person_1_first_name"=>["Titus"], "person_1_role"=>["otherrole1", "otherrole2"]}
69
- @article.should be_changed
69
+ expect(result).to eq({"person_0_affiliation"=>["affiliation1", "affiliation2", "affiliation3"], "person_1_last_name"=>["Andronicus"],"person_1_first_name"=>["Titus"], "person_1_role"=>["otherrole1", "otherrole2"]})
70
+ expect(@article).to be_changed
70
71
  end
71
72
  end
72
-
73
73
 
74
-
75
74
  end