om 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.rspec +1 -0
 - data/.rubocop.yml +1 -0
 - data/.rubocop_todo.yml +382 -0
 - data/.travis.yml +10 -0
 - data/Rakefile +1 -1
 - data/container_spec.rb +14 -14
 - data/gemfiles/gemfile.rails3 +11 -0
 - data/gemfiles/gemfile.rails4 +10 -0
 - data/lib/om.rb +9 -12
 - 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 +18 -20
 - data/lib/om/xml/container.rb +12 -12
 - data/lib/om/xml/document.rb +3 -7
 - data/lib/om/xml/dynamic_node.rb +45 -50
 - 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 +18 -26
 - data/lib/om/xml/term.rb +30 -46
 - data/lib/om/xml/term_value_operators.rb +52 -56
 - data/lib/om/xml/term_xpath_generator.rb +51 -57
 - data/lib/om/xml/terminology.rb +8 -10
 - data/lib/om/xml/validation.rb +19 -19
 - data/lib/om/xml/vocabulary.rb +4 -4
 - data/lib/tasks/om.rake +4 -6
 - data/om.gemspec +1 -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 +24 -18
 - 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 +7 -7
 - data/spec/integration/xpathy_stuff_spec.rb +16 -16
 - data/spec/spec_helper.rb +2 -3
 - data/spec/unit/container_spec.rb +28 -29
 - data/spec/unit/document_spec.rb +49 -50
 - data/spec/unit/dynamic_node_spec.rb +55 -47
 - 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 +78 -72
 - data/spec/unit/term_value_operators_spec.rb +186 -191
 - data/spec/unit/term_xpath_generator_spec.rb +37 -43
 - 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 +21 -22
 - data/spec/unit/xml_spec.rb +7 -7
 - metadata +143 -147
 
| 
         @@ -1,55 +1,55 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe "OM::XML::TermValueOperators" do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       5 
5 
     | 
    
         
             
              before(:each) do
         
     | 
| 
       6 
     | 
    
         
            -
                @sample 
     | 
| 
       7 
     | 
    
         
            -
                @article 
     | 
| 
       8 
     | 
    
         
            -
                @empty_sample = OM::Samples::ModsArticle.from_xml( 
     | 
| 
      
 6 
     | 
    
         
            +
                @sample       = OM::Samples::ModsArticle.from_xml( fixture( File.join("test_dummy_mods.xml") ) )
         
     | 
| 
      
 7 
     | 
    
         
            +
                @article      = OM::Samples::ModsArticle.from_xml( fixture( File.join("mods_articles","hydrangea_article1.xml") ) )
         
     | 
| 
      
 8 
     | 
    
         
            +
                @empty_sample = OM::Samples::ModsArticle.from_xml('')
         
     | 
| 
       9 
9 
     | 
    
         
             
              end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       11 
11 
     | 
    
         
             
              describe ".term_values" do
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                it "should return build an array of values from the nodeset corresponding to the given term" do
         
     | 
| 
       14 
14 
     | 
    
         
             
                  expected_values = ["Berners-Lee", "Jobs", "Wozniak", "Klimt"]
         
     | 
| 
       15 
15 
     | 
    
         
             
                  result = @sample.term_values(:person, :last_name)
         
     | 
| 
       16 
     | 
    
         
            -
                  result.length. 
     | 
| 
       17 
     | 
    
         
            -
                  expected_values.each {|v| result. 
     | 
| 
      
 16 
     | 
    
         
            +
                  expect(result.length).to eq(expected_values.length)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  expected_values.each {|v| expect(result).to include(v)}
         
     | 
| 
       18 
18 
     | 
    
         
             
                end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                it "should ignore whitespace elements for a term pointing to a text() node for an element that contains children" do
         
     | 
| 
       21 
     | 
    
         
            -
                  @article.term_values(:name, :name_content). 
     | 
| 
      
 21 
     | 
    
         
            +
                  expect(@article.term_values(:name, :name_content)).to eq(["Describes a person"])
         
     | 
| 
       22 
22 
     | 
    
         
             
                end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       24 
24 
     | 
    
         
             
              end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       27 
27 
     | 
    
         
             
              describe ".update_values" do
         
     | 
| 
       28 
28 
     | 
    
         
             
                it "should update the xml according to the find_by_terms_and_values in the given hash" do
         
     | 
| 
       29 
29 
     | 
    
         
             
                  terms_update_hash = {[{":person"=>"0"}, "affiliation"]=>{"0"=>"affiliation1", "1"=>"affiliation2".freeze, "2"=>"affiliation3"}, [{:person=>1}, :last_name]=>"Andronicus", [{"person"=>"1"},:first_name]=>["Titus"],[{:person=>1},:role]=>["otherrole1","otherrole2"] }
         
     | 
| 
       30 
30 
     | 
    
         
             
                  result = @article.update_values(terms_update_hash)
         
     | 
| 
       31 
     | 
    
         
            -
                  result. 
     | 
| 
      
 31 
     | 
    
         
            +
                  expect(result).to eq({"person_0_affiliation"=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}, "person_1_last_name"=>{"0"=>"Andronicus"},"person_1_first_name"=>{"0"=>"Titus"}, "person_1_role"=>{"0"=>"otherrole1","1"=>"otherrole2"}})
         
     | 
| 
       32 
32 
     | 
    
         
             
                  person_0_affiliation = @article.find_by_terms({:person=>0}, :affiliation)
         
     | 
| 
       33 
     | 
    
         
            -
                  person_0_affiliation[0].text. 
     | 
| 
       34 
     | 
    
         
            -
                  person_0_affiliation[1].text. 
     | 
| 
       35 
     | 
    
         
            -
                  person_0_affiliation[2].text. 
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
      
 33 
     | 
    
         
            +
                  expect(person_0_affiliation[0].text).to eq("affiliation1")
         
     | 
| 
      
 34 
     | 
    
         
            +
                  expect(person_0_affiliation[1].text).to eq("affiliation2")
         
     | 
| 
      
 35 
     | 
    
         
            +
                  expect(person_0_affiliation[2].text).to eq("affiliation3")
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
       37 
37 
     | 
    
         
             
                  person_1_last_names = @article.find_by_terms({:person=>1}, :last_name)
         
     | 
| 
       38 
     | 
    
         
            -
                  person_1_last_names.length. 
     | 
| 
       39 
     | 
    
         
            -
                  person_1_last_names.first.text. 
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
                  expect(person_1_last_names.length).to eq(1)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  expect(person_1_last_names.first.text).to eq("Andronicus")
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
       41 
41 
     | 
    
         
             
                  person_1_first_names = @article.find_by_terms({:person=>1}, :first_name)
         
     | 
| 
       42 
     | 
    
         
            -
                  person_1_first_names.first.text. 
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
                  expect(person_1_first_names.first.text).to eq("Titus")
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       44 
44 
     | 
    
         
             
                  person_1_roles = @article.find_by_terms({:person=>1}, :role)
         
     | 
| 
       45 
     | 
    
         
            -
                  person_1_roles[0].text. 
     | 
| 
       46 
     | 
    
         
            -
                  person_1_roles[1].text. 
     | 
| 
      
 45 
     | 
    
         
            +
                  expect(person_1_roles[0].text).to eq("otherrole1")
         
     | 
| 
      
 46 
     | 
    
         
            +
                  expect(person_1_roles[1].text).to eq("otherrole2")
         
     | 
| 
       47 
47 
     | 
    
         
             
                end
         
     | 
| 
       48 
48 
     | 
    
         
             
                it "should call term_value_update if the corresponding node already exists" do
         
     | 
| 
       49 
     | 
    
         
            -
                  @article. 
     | 
| 
      
 49 
     | 
    
         
            +
                  expect(@article).to receive(:term_value_update).with('//oxns:titleInfo/oxns:title', 0, "My New Title")
         
     | 
| 
       50 
50 
     | 
    
         
             
                  @article.update_values( {[:title_info, :main_title] => "My New Title"} )
         
     | 
| 
       51 
51 
     | 
    
         
             
                end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
       53 
53 
     | 
    
         
             
                it "should call term_values_append if the corresponding node does not already exist or if the requested index is -1" do
         
     | 
| 
       54 
54 
     | 
    
         
             
                  expected_args = {
         
     | 
| 
       55 
55 
     | 
    
         
             
                    # :parent_select => OM::Samples::ModsArticle.terminology.xpath_with_indexes(*[{:person=>0}]) ,
         
     | 
| 
         @@ -58,204 +58,200 @@ describe "OM::XML::TermValueOperators" do 
     | 
|
| 
       58 
58 
     | 
    
         
             
                    :template => [:person, :role],
         
     | 
| 
       59 
59 
     | 
    
         
             
                    :values => "My New Role"
         
     | 
| 
       60 
60 
     | 
    
         
             
                  }
         
     | 
| 
       61 
     | 
    
         
            -
                  @article. 
     | 
| 
      
 61 
     | 
    
         
            +
                  expect(@article).to receive(:term_values_append).with(expected_args).exactly(2).times
         
     | 
| 
       62 
62 
     | 
    
         
             
                  @article.update_values( {[{:person=>0}, :role] => {"6"=>"My New Role"}} )
         
     | 
| 
       63 
63 
     | 
    
         
             
                  @article.update_values( {[{:person=>0}, :role] => {"-1"=>"My New Role"}} )
         
     | 
| 
       64 
64 
     | 
    
         
             
                end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
       66 
66 
     | 
    
         
             
                it "should support updating attribute values" do
         
     | 
| 
       67 
67 
     | 
    
         
             
                  pointer = [:title_info, :language]
         
     | 
| 
       68 
68 
     | 
    
         
             
                  test_val = "language value"
         
     | 
| 
       69 
69 
     | 
    
         
             
                  @article.update_values( {pointer=>{"0"=>test_val}} )
         
     | 
| 
       70 
     | 
    
         
            -
                  @article.term_values(*pointer).first. 
     | 
| 
      
 70 
     | 
    
         
            +
                  expect(@article.term_values(*pointer).first).to eq(test_val)
         
     | 
| 
       71 
71 
     | 
    
         
             
                end
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
       73 
73 
     | 
    
         
             
                it "should not get tripped up on root nodes" do
         
     | 
| 
       74 
74 
     | 
    
         
             
                  @article.update_values([:title_info]=>{"0"=>"york", "1"=>"mangle","2"=>"mork"})
         
     | 
| 
       75 
     | 
    
         
            -
                  @article.term_values(*[:title_info]). 
     | 
| 
      
 75 
     | 
    
         
            +
                  expect(@article.term_values(*[:title_info])).to eq(["york", "mangle", "mork"])
         
     | 
| 
       76 
76 
     | 
    
         
             
                end
         
     | 
| 
       77 
77 
     | 
    
         | 
| 
       78 
78 
     | 
    
         
             
                it "should destringify the field key/find_by_terms_and_value pointer" do
         
     | 
| 
       79 
     | 
    
         
            -
                  OM::Samples::ModsArticle.terminology. 
     | 
| 
       80 
     | 
    
         
            -
                  OM::Samples::ModsArticle.terminology. 
     | 
| 
      
 79 
     | 
    
         
            +
                  expect(OM::Samples::ModsArticle.terminology).to receive(:xpath_with_indexes).with( *[{:person=>0}, :role]).and_return("//oxns:name[@type=\"personal\"][1]/oxns:role").exactly(10).times
         
     | 
| 
      
 80 
     | 
    
         
            +
                  allow(OM::Samples::ModsArticle.terminology).to receive(:xpath_with_indexes).with( *[{:person=>0}]).and_return("//oxns:name[@type=\"personal\"][1]")
         
     | 
| 
       81 
81 
     | 
    
         
             
                  @article.update_values( { [{":person"=>"0"}, "role"]=>"the role" } )
         
     | 
| 
       82 
82 
     | 
    
         
             
                  @article.update_values( { [{"person"=>"0"}, "role"]=>"the role" } )
         
     | 
| 
       83 
83 
     | 
    
         
             
                  @article.update_values( { [{:person=>0}, :role]=>"the role" } )
         
     | 
| 
       84 
84 
     | 
    
         
             
                end
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
       86 
86 
     | 
    
         
             
                it "should traverse named term proxies transparently" do
         
     | 
| 
       87 
     | 
    
         
            -
                  @article.term_values( :journal, :issue, :start_page). 
     | 
| 
      
 87 
     | 
    
         
            +
                  expect(@article.term_values( :journal, :issue, :start_page)).not_to eq(["108"])
         
     | 
| 
       88 
88 
     | 
    
         
             
                  @article.update_values( { ["journal", "issue", "start_page"]=>"108" } )
         
     | 
| 
       89 
     | 
    
         
            -
                  @article.term_values( :journal, :issue, :start_page). 
     | 
| 
       90 
     | 
    
         
            -
                  @article.term_values( :journal, :issue, :pages, :start). 
     | 
| 
      
 89 
     | 
    
         
            +
                  expect(@article.term_values( :journal, :issue, :start_page)).to eq(["108"])
         
     | 
| 
      
 90 
     | 
    
         
            +
                  expect(@article.term_values( :journal, :issue, :pages, :start)).to eq(["108"])
         
     | 
| 
       91 
91 
     | 
    
         
             
                end
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
       93 
93 
     | 
    
         
             
                it "should create the necessary ancestor nodes when necessary" do
         
     | 
| 
       94 
     | 
    
         
            -
              	  @sample.find_by_terms(:person).length. 
     | 
| 
      
 94 
     | 
    
         
            +
              	  expect(@sample.find_by_terms(:person).length).to eq(4)
         
     | 
| 
       95 
95 
     | 
    
         
             
              	  @sample.update_values([{:person=>8}, :role, :text]=>"my role")
         
     | 
| 
       96 
96 
     | 
    
         
             
                  person_entries = @sample.find_by_terms(:person)
         
     | 
| 
       97 
     | 
    
         
            -
                  person_entries.length. 
     | 
| 
       98 
     | 
    
         
            -
                  person_entries[4].search("./ns3:role").first.text. 
     | 
| 
      
 97 
     | 
    
         
            +
                  expect(person_entries.length).to eq(5)
         
     | 
| 
      
 98 
     | 
    
         
            +
                  expect(person_entries[4].search("./ns3:role").first.text).to eq("my role")
         
     | 
| 
       99 
99 
     | 
    
         
             
            	  end
         
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
       101 
101 
     | 
    
         
             
                it "should create deep trees of ancestor nodes" do
         
     | 
| 
       102 
102 
     | 
    
         
             
                  result = @article.update_values( {[{:journal=>0}, {:issue=>3}, :pages, :start]=>{"0"=>"434"} })
         
     | 
| 
       103 
     | 
    
         
            -
                  @article.find_by_terms({:journal=>0}, :issue).length. 
     | 
| 
       104 
     | 
    
         
            -
                  @article.find_by_terms({:journal=>0}, {:issue=>1}, :pages).length. 
     | 
| 
       105 
     | 
    
         
            -
                  @article.find_by_terms({:journal=>0}, {:issue=>1}, :pages, :start).length. 
     | 
| 
       106 
     | 
    
         
            -
                  @article.find_by_terms({:journal=>0}, {:issue=>1}, :pages, :start).first.text. 
     | 
| 
       107 
     | 
    
         
            -
                  #Last argument is a filter, we must explicitly pass no filter
         
     | 
| 
       108 
     | 
    
         
            -
                  @article.class.terminology.xpath_with_indexes(:subject, {:topic=>1}, {}). 
     | 
| 
       109 
     | 
    
         
            -
                  @article.find_by_terms(:subject, {:topic => 1}, {}).text. 
     | 
| 
      
 103 
     | 
    
         
            +
                  expect(@article.find_by_terms({:journal=>0}, :issue).length).to eq(2)
         
     | 
| 
      
 104 
     | 
    
         
            +
                  expect(@article.find_by_terms({:journal=>0}, {:issue=>1}, :pages).length).to eq(1)
         
     | 
| 
      
 105 
     | 
    
         
            +
                  expect(@article.find_by_terms({:journal=>0}, {:issue=>1}, :pages, :start).length).to eq(1)
         
     | 
| 
      
 106 
     | 
    
         
            +
                  expect(@article.find_by_terms({:journal=>0}, {:issue=>1}, :pages, :start).first.text).to eq("434")
         
     | 
| 
      
 107 
     | 
    
         
            +
                  # Last argument is a filter, we must explicitly pass no filter
         
     | 
| 
      
 108 
     | 
    
         
            +
                  expect(@article.class.terminology.xpath_with_indexes(:subject, {:topic=>1}, {})).to eq('//oxns:subject/oxns:topic[2]')
         
     | 
| 
      
 109 
     | 
    
         
            +
                  expect(@article.find_by_terms(:subject, {:topic => 1}, {}).text).to eq("TOPIC 2")
         
     | 
| 
       110 
110 
     | 
    
         
             
            	  end
         
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
       112 
112 
     | 
    
         
             
            	  it "should accommodate appending term values with apostrophes in them"  do
         
     | 
| 
       113 
     | 
    
         
            -
            	    @article.find_by_terms(:person, :description). 
     | 
| 
      
 113 
     | 
    
         
            +
            	    expect(@article.find_by_terms(:person, :description)).to be_empty  # making sure that there's no description node -- forces a value_append
         
     | 
| 
       114 
114 
     | 
    
         
             
                  terms_update_hash =  {[:person, :description]=>" 'phrul gyi lde mig"}
         
     | 
| 
       115 
115 
     | 
    
         
             
                  result = @article.update_values(terms_update_hash)
         
     | 
| 
       116 
     | 
    
         
            -
                  @article.term_values(:person, :description). 
     | 
| 
      
 116 
     | 
    
         
            +
                  expect(@article.term_values(:person, :description)).to include(" 'phrul gyi lde mig")
         
     | 
| 
       117 
117 
     | 
    
         
             
                end
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
       119 
119 
     | 
    
         
             
                it "should support inserting nodes with namespaced attributes" do
         
     | 
| 
       120 
120 
     | 
    
         
             
                  @sample.update_values({['title_info', 'french_title']=>'Le Titre'})
         
     | 
| 
       121 
     | 
    
         
            -
                  @sample.term_values('title_info', 'french_title'). 
     | 
| 
      
 121 
     | 
    
         
            +
                  expect(@sample.term_values('title_info', 'french_title')).to eq(['Le Titre'])
         
     | 
| 
       122 
122 
     | 
    
         
             
                end
         
     | 
| 
       123 
123 
     | 
    
         | 
| 
       124 
124 
     | 
    
         
             
                it "should support inserting attributes" do
         
     | 
| 
       125 
     | 
    
         
            -
                   
     | 
| 
      
 125 
     | 
    
         
            +
                  skip "HYDRA-415"
         
     | 
| 
       126 
126 
     | 
    
         
             
                  @sample.update_values({['title_info', 'language']=>'Le Titre'})
         
     | 
| 
       127 
     | 
    
         
            -
                  @sample.term_values('title_info', 'french_title'). 
     | 
| 
      
 127 
     | 
    
         
            +
                  expect(@sample.term_values('title_info', 'french_title')).to eq(['Le Titre'])
         
     | 
| 
       128 
128 
     | 
    
         
             
                end
         
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
       130 
130 
     | 
    
         
             
                it "should support inserting namespaced attributes" do
         
     | 
| 
       131 
     | 
    
         
            -
                   
     | 
| 
      
 131 
     | 
    
         
            +
                  skip "HYDRA-415"
         
     | 
| 
       132 
132 
     | 
    
         
             
                  @sample.update_values({['title_info', 'main_title', 'main_title_lang']=>'eng'})
         
     | 
| 
       133 
     | 
    
         
            -
                  @sample.term_values('title_info', 'main_title', 'main_title_lang'). 
     | 
| 
      
 133 
     | 
    
         
            +
                  expect(@sample.term_values('title_info', 'main_title', 'main_title_lang')).to eq(['eng'])
         
     | 
| 
       134 
134 
     | 
    
         
             
                  ## After a proxy
         
     | 
| 
       135 
     | 
    
         
            -
                  @article.term_values(:title,:main_title_lang). 
     | 
| 
      
 135 
     | 
    
         
            +
                  expect(@article.term_values(:title,:main_title_lang)).to eq(['eng'])
         
     | 
| 
       136 
136 
     | 
    
         
             
                end
         
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
       138 
138 
     | 
    
         
             
                ### Examples copied over form nokogiri_datastream_spec
         
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
       140 
140 
     | 
    
         
             
                it "should apply submitted hash to corresponding datastream field values" do
         
     | 
| 
       141 
141 
     | 
    
         
             
                  result = @article.update_values( {[{":person"=>"0"}, "first_name"]=>{"0"=>"Billy", "1"=>"Bob", "2"=>"Joe"} })
         
     | 
| 
       142 
     | 
    
         
            -
                  result. 
     | 
| 
      
 142 
     | 
    
         
            +
                  expect(result).to eq({"person_0_first_name"=>{"0"=>"Billy", "1"=>"Bob", "2"=>"Joe"}})
         
     | 
| 
       143 
143 
     | 
    
         
             
                  # xpath = ds.class.xpath_with_indexes(*field_key)
         
     | 
| 
       144 
144 
     | 
    
         
             
                  # result = ds.term_values(xpath)
         
     | 
| 
       145 
     | 
    
         
            -
                  @article.term_values({:person=>0}, :first_name). 
     | 
| 
       146 
     | 
    
         
            -
                  @article.term_values('//oxns:name[@type="personal"][1]/oxns:namePart[@type="given"]'). 
     | 
| 
      
 145 
     | 
    
         
            +
                  expect(@article.term_values({:person=>0}, :first_name)).to eq(["Billy","Bob","Joe"])
         
     | 
| 
      
 146 
     | 
    
         
            +
                  expect(@article.term_values('//oxns:name[@type="personal"][1]/oxns:namePart[@type="given"]')).to eq(["Billy","Bob","Joe"])
         
     | 
| 
       147 
147 
     | 
    
         
             
                end
         
     | 
| 
       148 
148 
     | 
    
         
             
                it "should support single-value arguments (as opposed to a hash of values with array indexes as keys)" do
         
     | 
| 
       149 
149 
     | 
    
         
             
                  # In other words, { [:journal, :title_info]=>"dork" } should have the same effect as { [:journal, :title_info]=>{"0"=>"dork"} }
         
     | 
| 
       150 
150 
     | 
    
         
             
                  result = @article.update_values( { [{":person"=>"0"}, "role"]=>"the role" } )
         
     | 
| 
       151 
     | 
    
         
            -
                  result. 
     | 
| 
       152 
     | 
    
         
            -
                  @article.term_values({:person=>0}, :role).first. 
     | 
| 
       153 
     | 
    
         
            -
                  @article.term_values('//oxns:name[@type="personal"][1]/oxns:role').first. 
     | 
| 
      
 151 
     | 
    
         
            +
                  expect(result).to eq({"person_0_role"=>{"0"=>"the role"}})
         
     | 
| 
      
 152 
     | 
    
         
            +
                  expect(@article.term_values({:person=>0}, :role).first).to eq("the role")
         
     | 
| 
      
 153 
     | 
    
         
            +
                  expect(@article.term_values('//oxns:name[@type="personal"][1]/oxns:role').first).to eq("the role")
         
     | 
| 
       154 
154 
     | 
    
         
             
                end
         
     | 
| 
       155 
155 
     | 
    
         
             
                it "should do nothing if field key is a string (must be an array or symbol).  Will not accept xpath queries!" do
         
     | 
| 
       156 
156 
     | 
    
         
             
                  xml_before = @article.to_xml
         
     | 
| 
       157 
     | 
    
         
            -
                  @article.update_values( { "fubar"=>"the role" } ). 
     | 
| 
       158 
     | 
    
         
            -
                  @article.to_xml. 
     | 
| 
      
 157 
     | 
    
         
            +
                  expect(@article.update_values( { "fubar"=>"the role" } )).to eq({})
         
     | 
| 
      
 158 
     | 
    
         
            +
                  expect(@article.to_xml).to eq(xml_before)
         
     | 
| 
       159 
159 
     | 
    
         
             
                end
         
     | 
| 
       160 
160 
     | 
    
         
             
                it "should do nothing if there is no term corresponding to the given field key" do
         
     | 
| 
       161 
161 
     | 
    
         
             
                  xml_before = @article.to_xml
         
     | 
| 
       162 
     | 
    
         
            -
                  @article.update_values( { [{"fubar"=>"0"}]=>"the role" } ). 
     | 
| 
       163 
     | 
    
         
            -
                  @article.to_xml. 
     | 
| 
      
 162 
     | 
    
         
            +
                  expect(@article.update_values( { [{"fubar"=>"0"}]=>"the role" } )).to eq({})
         
     | 
| 
      
 163 
     | 
    
         
            +
                  expect(@article.to_xml).to eq(xml_before)
         
     | 
| 
       164 
164 
     | 
    
         
             
                end
         
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
                it "should work for text fields" do 
     | 
| 
       167 
     | 
    
         
            -
                  att= {[{"person"=>"0"},"description"]=>{"-1"=>"mork", "1"=>"york"}}
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
                it "should work for text fields" do
         
     | 
| 
      
 167 
     | 
    
         
            +
                  att = {[{"person"=>"0"},"description"]=>{"-1"=>"mork", "1"=>"york"}}
         
     | 
| 
       168 
168 
     | 
    
         
             
                  result = @article.update_values(att)
         
     | 
| 
       169 
     | 
    
         
            -
                  result. 
     | 
| 
       170 
     | 
    
         
            -
                  @article.term_values({:person=>0},:description). 
     | 
| 
       171 
     | 
    
         
            -
                  att= {[{"person"=>"0"},"description"]=>{"-1"=>"dork"}}
         
     | 
| 
      
 169 
     | 
    
         
            +
                  expect(result).to eq({"person_0_description"=>{"0"=>"mork","1"=>"york"}})
         
     | 
| 
      
 170 
     | 
    
         
            +
                  expect(@article.term_values({:person=>0},:description)).to eq(['mork', 'york'])
         
     | 
| 
      
 171 
     | 
    
         
            +
                  att = {[{"person"=>"0"},"description"]=>{"-1"=>"dork"}}
         
     | 
| 
       172 
172 
     | 
    
         
             
                  result2 = @article.update_values(att)
         
     | 
| 
       173 
     | 
    
         
            -
                  result2. 
     | 
| 
       174 
     | 
    
         
            -
                  @article.term_values({:person=>0},:description). 
     | 
| 
      
 173 
     | 
    
         
            +
                  expect(result2).to eq({"person_0_description"=>{"2"=>"dork"}})
         
     | 
| 
      
 174 
     | 
    
         
            +
                  expect(@article.term_values({:person=>0},:description)).to eq(['mork', 'york', 'dork'])
         
     | 
| 
       175 
175 
     | 
    
         
             
                end
         
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
       177 
177 
     | 
    
         
             
                it "should return the new index of any added values" do
         
     | 
| 
       178 
     | 
    
         
            -
                  @article.term_values({:title_info=>0},:main_title). 
     | 
| 
      
 178 
     | 
    
         
            +
                  expect(@article.term_values({:title_info=>0},:main_title)).to eq(["ARTICLE TITLE HYDRANGEA ARTICLE 1", "TITLE OF HOST JOURNAL"])
         
     | 
| 
       179 
179 
     | 
    
         
             
                  result = @article.update_values [{"title_info"=>"0"},"main_title"]=>{"-1"=>"mork"}
         
     | 
| 
       180 
     | 
    
         
            -
                  result. 
     | 
| 
      
 180 
     | 
    
         
            +
                  expect(result).to eq({"title_info_0_main_title"=>{"2"=>"mork"}})
         
     | 
| 
       181 
181 
     | 
    
         
             
                end
         
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
       183 
183 
     | 
    
         
             
                it "should return accurate response when multiple values have been added in a single run" do
         
     | 
| 
       184 
     | 
    
         
            -
                   
     | 
| 
      
 184 
     | 
    
         
            +
                  skip "THIS SHOULD BE FIXED"
         
     | 
| 
       185 
185 
     | 
    
         
             
                  att= {[:journal, :title_info]=>{"-1"=>"mork", "0"=>"york"}}
         
     | 
| 
       186 
     | 
    
         
            -
                  @article.update_values(att). 
     | 
| 
       187 
     | 
    
         
            -
                  @article.term_values(*att.keys.first). 
     | 
| 
      
 186 
     | 
    
         
            +
                  expect(@article.update_values(att)).to eq({"journal_title_info"=>{"0"=>"york", "1"=>"mork"}})
         
     | 
| 
      
 187 
     | 
    
         
            +
                  expect(@article.term_values(*att.keys.first)).to eq(["york", "mork"])
         
     | 
| 
       188 
188 
     | 
    
         
             
                end
         
     | 
| 
       189 
     | 
    
         
            -
             
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
       190 
190 
     | 
    
         
             
                it "should append nodes at the specified index if possible" do
         
     | 
| 
       191 
191 
     | 
    
         
             
                  @article.update_values([:journal, :title_info]=>["all", "for", "the"])
         
     | 
| 
       192 
192 
     | 
    
         
             
                  att = {[:journal, :title_info]=>{"3"=>'glory'}}
         
     | 
| 
       193 
193 
     | 
    
         
             
                  result = @article.update_values(att)
         
     | 
| 
       194 
     | 
    
         
            -
                  result. 
     | 
| 
       195 
     | 
    
         
            -
                  @article.term_values(:journal, :title_info). 
     | 
| 
      
 194 
     | 
    
         
            +
                  expect(result).to eq({"journal_title_info"=>{"3"=>"glory"}})
         
     | 
| 
      
 195 
     | 
    
         
            +
                  expect(@article.term_values(:journal, :title_info)).to eq(["all", "for", "the", "glory"])
         
     | 
| 
       196 
196 
     | 
    
         
             
                end
         
     | 
| 
       197 
     | 
    
         
            -
             
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
       198 
198 
     | 
    
         
             
                it "should append values to the end of the array if the specified index is higher than the length of the values array" do
         
     | 
| 
       199 
199 
     | 
    
         
             
                  att = {[:journal, :issue, :pages, :end]=>{"3"=>'108'}}
         
     | 
| 
       200 
     | 
    
         
            -
                  @article.term_values(:journal, :issue, :pages, :end). 
     | 
| 
      
 200 
     | 
    
         
            +
                  expect(@article.term_values(:journal, :issue, :pages, :end)).to eq([])
         
     | 
| 
       201 
201 
     | 
    
         
             
                  result = @article.update_values(att)
         
     | 
| 
       202 
     | 
    
         
            -
                  result. 
     | 
| 
       203 
     | 
    
         
            -
                  @article.term_values(:journal, :issue, :pages, :end). 
     | 
| 
      
 202 
     | 
    
         
            +
                  expect(result).to eq({"journal_issue_pages_end"=>{"0"=>"108"}})
         
     | 
| 
      
 203 
     | 
    
         
            +
                  expect(@article.term_values(:journal, :issue, :pages, :end)).to eq(["108"])
         
     | 
| 
       204 
204 
     | 
    
         
             
                end
         
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
       206 
206 
     | 
    
         
             
                it "should allow deleting of values and should delete values so that to_xml does not return emtpy nodes" do
         
     | 
| 
       207 
207 
     | 
    
         
             
                  att= {[:journal, :title_info]=>{"0"=>"york", "1"=>"mangle","2"=>"mork"}}
         
     | 
| 
       208 
208 
     | 
    
         
             
                  @article.update_values(att)
         
     | 
| 
       209 
     | 
    
         
            -
                  @article.term_values(:journal, :title_info). 
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
      
 209 
     | 
    
         
            +
                  expect(@article.term_values(:journal, :title_info)).to eq(['york', 'mangle', 'mork'])
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
       211 
211 
     | 
    
         
             
                  @article.update_values({[:journal, :title_info]=>{"1"=>""}})
         
     | 
| 
       212 
     | 
    
         
            -
                  @article.term_values(:journal, :title_info). 
     | 
| 
       213 
     | 
    
         
            -
             
     | 
| 
      
 212 
     | 
    
         
            +
                  expect(@article.term_values(:journal, :title_info)).to eq(['york', 'mork'])
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
       214 
214 
     | 
    
         
             
                  @article.update_values({[:journal, :title_info]=>{"0"=>:delete}})
         
     | 
| 
       215 
     | 
    
         
            -
                  @article.term_values(:journal, :title_info). 
     | 
| 
      
 215 
     | 
    
         
            +
                  expect(@article.term_values(:journal, :title_info)).to eq(['mork'])
         
     | 
| 
       216 
216 
     | 
    
         
             
                end
         
     | 
| 
       217 
217 
     | 
    
         | 
| 
       218 
218 
     | 
    
         
             
                describe "delete_on_update?" do
         
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
       220 
219 
     | 
    
         
             
                  before(:each) do
         
     | 
| 
       221 
220 
     | 
    
         
             
                    att= {[:journal, :title_info]=>{"0"=>"york", "1"=>"mangle","2"=>"mork"}}
         
     | 
| 
       222 
221 
     | 
    
         
             
                    @article.update_values(att)
         
     | 
| 
       223 
     | 
    
         
            -
                    @article.term_values(:journal, :title_info). 
     | 
| 
      
 222 
     | 
    
         
            +
                    expect(@article.term_values(:journal, :title_info)).to eq(['york', 'mangle', 'mork'])
         
     | 
| 
       224 
223 
     | 
    
         
             
                  end
         
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
       226 
224 
     | 
    
         
             
                  it "by default, setting to empty string deletes the node" do
         
     | 
| 
       227 
225 
     | 
    
         
             
                    @article.update_values({[:journal, :title_info]=>{"1"=>""}})
         
     | 
| 
       228 
     | 
    
         
            -
                    @article.term_values(:journal, :title_info). 
     | 
| 
      
 226 
     | 
    
         
            +
                    expect(@article.term_values(:journal, :title_info)).to eq(['york', 'mork'])
         
     | 
| 
       229 
227 
     | 
    
         
             
                  end
         
     | 
| 
       230 
     | 
    
         
            -
             
     | 
| 
       231 
228 
     | 
    
         
             
                  it "if delete_on_update? returns false, setting to empty string won't delete node" do
         
     | 
| 
       232 
     | 
    
         
            -
                    @article. 
     | 
| 
      
 229 
     | 
    
         
            +
                    allow(@article).to receive('delete_on_update?').and_return(false)
         
     | 
| 
       233 
230 
     | 
    
         
             
                    @article.update_values({[:journal, :title_info]=>{"1"=>""}})
         
     | 
| 
       234 
     | 
    
         
            -
                    @article.term_values(:journal, :title_info). 
     | 
| 
      
 231 
     | 
    
         
            +
                    expect(@article.term_values(:journal, :title_info)).to eq(['york', '', 'mork'])
         
     | 
| 
       235 
232 
     | 
    
         
             
                  end
         
     | 
| 
       236 
     | 
    
         
            -
             
     | 
| 
       237 
233 
     | 
    
         
             
                end
         
     | 
| 
       238 
234 
     | 
    
         | 
| 
       239 
235 
     | 
    
         
             
                it "should retain other child nodes when updating a text content term and shoud not append an additional text node but update text in place" do
         
     | 
| 
       240 
     | 
    
         
            -
                  @article.term_values(:name,:name_content). 
     | 
| 
      
 236 
     | 
    
         
            +
                  expect(@article.term_values(:name,:name_content)).to eq(["Describes a person"])
         
     | 
| 
       241 
237 
     | 
    
         
             
                  @article.update_values({[:name, :name_content]=>"Test text"})
         
     | 
| 
       242 
     | 
    
         
            -
                  @article.term_values(:name,:name_content). 
     | 
| 
       243 
     | 
    
         
            -
                  @article.find_by_terms(:name).children.length(). 
     | 
| 
      
 238 
     | 
    
         
            +
                  expect(@article.term_values(:name,:name_content)).to eq(["Test text"])
         
     | 
| 
      
 239 
     | 
    
         
            +
                  expect(@article.find_by_terms(:name).children.length()).to eq(35)
         
     | 
| 
       244 
240 
     | 
    
         
             
                end
         
     | 
| 
       245 
     | 
    
         
            -
             
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
       246 
242 
     | 
    
         
             
              end
         
     | 
| 
       247 
     | 
    
         
            -
             
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
       248 
244 
     | 
    
         
             
              describe ".term_values_append" do
         
     | 
| 
       249 
     | 
    
         
            -
             
     | 
| 
       250 
     | 
    
         
            -
              	it "looks up the parent using :parent_select, uses :parent_index to choose the parent node from the result set, uses :template to build the node(s) to be inserted, inserts the :values(s) into the node(s) and adds the node(s) to the parent" do 
     | 
| 
      
 245 
     | 
    
         
            +
             
     | 
| 
      
 246 
     | 
    
         
            +
              	it "looks up the parent using :parent_select, uses :parent_index to choose the parent node from the result set, uses :template to build the node(s) to be inserted, inserts the :values(s) into the node(s) and adds the node(s) to the parent" do
         
     | 
| 
       251 
247 
     | 
    
         
             
            	    @sample.term_values_append(
         
     | 
| 
       252 
248 
     | 
    
         
             
                    :parent_select => [:person, {:first_name=>"Tim", :last_name=>"Berners-Lee"}] ,
         
     | 
| 
       253 
249 
     | 
    
         
             
                    :parent_index => :first,
         
     | 
| 
       254 
250 
     | 
    
         
             
                    :template => [:person, :affiliation],
         
     | 
| 
       255 
     | 
    
         
            -
                    :values => ["my new value", "another new value"] 
     | 
| 
      
 251 
     | 
    
         
            +
                    :values => ["my new value", "another new value"]
         
     | 
| 
       256 
252 
     | 
    
         
             
                  )
         
     | 
| 
       257 
253 
     | 
    
         
             
                end
         
     | 
| 
       258 
     | 
    
         
            -
             
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
       259 
255 
     | 
    
         
             
                it "should accept parent_select and template [term_reference, find_by_terms_and_value_opts] as argument arrays for generators/find_by_terms_and_values" do
         
     | 
| 
       260 
256 
     | 
    
         
             
                  # this appends two affiliation nodes into the first person node whose name is Tim Berners-Lee
         
     | 
| 
       261 
257 
     | 
    
         
             
                  expected_result = '<ns3:name type="personal">
         
     | 
| 
         @@ -266,193 +262,192 @@ describe "OM::XML::TermValueOperators" do 
     | 
|
| 
       266 
262 
     | 
    
         
             
                      <ns3:roleTerm type="code" authority="marcrelator">cre</ns3:roleTerm>
         
     | 
| 
       267 
263 
     | 
    
         
             
                  </ns3:role>
         
     | 
| 
       268 
264 
     | 
    
         
             
              <ns3:affiliation>my new value</ns3:affiliation><ns3:affiliation>another new value</ns3:affiliation></ns3:name>'
         
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
            	    @sample.term_values_append(
         
     | 
| 
      
 265 
     | 
    
         
            +
             
     | 
| 
      
 266 
     | 
    
         
            +
            	    expect(@sample.term_values_append(
         
     | 
| 
       271 
267 
     | 
    
         
             
                    :parent_select => [:person, {:first_name=>"Tim", :last_name=>"Berners-Lee"}] ,
         
     | 
| 
       272 
268 
     | 
    
         
             
                    :parent_index => :first,
         
     | 
| 
       273 
269 
     | 
    
         
             
                    :template => [:person, :affiliation],
         
     | 
| 
       274 
     | 
    
         
            -
                    :values => ["my new value", "another new value"] 
     | 
| 
       275 
     | 
    
         
            -
                  ).to_xml. 
     | 
| 
       276 
     | 
    
         
            -
             
     | 
| 
       277 
     | 
    
         
            -
                  @sample.find_by_terms(:person, {:first_name=>"Tim", :last_name=>"Berners-Lee"}).first.to_xml. 
     | 
| 
      
 270 
     | 
    
         
            +
                    :values => ["my new value", "another new value"]
         
     | 
| 
      
 271 
     | 
    
         
            +
                  ).to_xml).to eq(expected_result)
         
     | 
| 
      
 272 
     | 
    
         
            +
             
     | 
| 
      
 273 
     | 
    
         
            +
                  expect(@sample.find_by_terms(:person, {:first_name=>"Tim", :last_name=>"Berners-Lee"}).first.to_xml).to eq(expected_result)
         
     | 
| 
       278 
274 
     | 
    
         
             
                end
         
     | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
       280 
276 
     | 
    
         
             
                it "should support adding attribute values" do
         
     | 
| 
       281 
277 
     | 
    
         
             
                  pointer = [{:title_info=>0}, :language]
         
     | 
| 
       282 
278 
     | 
    
         
             
                  test_val = "language value"
         
     | 
| 
       283 
     | 
    
         
            -
                  @article.term_values_append( 
     | 
| 
      
 279 
     | 
    
         
            +
                  @article.term_values_append(
         
     | 
| 
       284 
280 
     | 
    
         
             
                    :parent_select => [{:title_info=>0}],
         
     | 
| 
       285 
281 
     | 
    
         
             
                    :parent_index => 0,
         
     | 
| 
       286 
282 
     | 
    
         
             
                    :template => [{:title_info=>0}, :language],
         
     | 
| 
       287 
283 
     | 
    
         
             
                    :values => test_val
         
     | 
| 
       288 
284 
     | 
    
         
             
                  )
         
     | 
| 
       289 
     | 
    
         
            -
                  @article.term_values(*pointer).first. 
     | 
| 
      
 285 
     | 
    
         
            +
                  expect(@article.term_values(*pointer).first).to eq(test_val)
         
     | 
| 
       290 
286 
     | 
    
         
             
                end
         
     | 
| 
       291 
     | 
    
         
            -
             
     | 
| 
      
 287 
     | 
    
         
            +
             
     | 
| 
       292 
288 
     | 
    
         
             
                it "should accept symbols as arguments for generators/find_by_terms_and_values" do
         
     | 
| 
       293 
289 
     | 
    
         
             
                  # this appends a role of "my role" into the third "person" node in the document
         
     | 
| 
       294 
290 
     | 
    
         
             
                  @sample.term_values_append(
         
     | 
| 
       295 
291 
     | 
    
         
             
                    :parent_select => :person ,
         
     | 
| 
       296 
292 
     | 
    
         
             
                    :parent_index => 3,
         
     | 
| 
       297 
293 
     | 
    
         
             
                    :template => :role,
         
     | 
| 
       298 
     | 
    
         
            -
                    :values => "my role" 
     | 
| 
       299 
     | 
    
         
            -
                  ) 
     | 
| 
       300 
     | 
    
         
            -
                  @sample.find_by_terms(:person)[3].search("./ns3:role[3]").first.text. 
     | 
| 
      
 294 
     | 
    
         
            +
                    :values => "my role"
         
     | 
| 
      
 295 
     | 
    
         
            +
                  )
         
     | 
| 
      
 296 
     | 
    
         
            +
                  expect(@sample.find_by_terms(:person)[3].search("./ns3:role[3]").first.text).to eq("my role")
         
     | 
| 
       301 
297 
     | 
    
         
             
                end
         
     | 
| 
       302 
     | 
    
         
            -
             
     | 
| 
      
 298 
     | 
    
         
            +
             
     | 
| 
       303 
299 
     | 
    
         
             
                it "should accept parent_select as an (xpath) string and template as a (template) string" do
         
     | 
| 
       304 
300 
     | 
    
         
             
                  # this uses the provided template to add a node into the first node resulting from the xpath '//oxns:name[@type="personal"]'
         
     | 
| 
       305 
301 
     | 
    
         
             
                  expected_result = "<ns3:name type=\"personal\">\n      <ns3:namePart type=\"family\">Berners-Lee</ns3:namePart>\n      <ns3:namePart type=\"given\">Tim</ns3:namePart>\n      <ns3:role>\n          <ns3:roleTerm type=\"text\" authority=\"marcrelator\">creator</ns3:roleTerm>\n          <ns3:roleTerm type=\"code\" authority=\"marcrelator\">cre</ns3:roleTerm>\n      </ns3:role>\n  <ns3:role type=\"code\" authority=\"marcrelator\"><ns3:roleTerm>creator</ns3:roleTerm></ns3:role></ns3:name>"
         
     | 
| 
       306 
     | 
    
         
            -
             
     | 
| 
       307 
     | 
    
         
            -
                  @sample.ng_xml.xpath('//oxns:name[@type="personal" and position()=1]/oxns:role', @sample.ox_namespaces).length. 
     | 
| 
       308 
     | 
    
         
            -
             
     | 
| 
      
 302 
     | 
    
         
            +
             
     | 
| 
      
 303 
     | 
    
         
            +
                  expect(@sample.ng_xml.xpath('//oxns:name[@type="personal" and position()=1]/oxns:role', @sample.ox_namespaces).length).to eq(1)
         
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
       309 
305 
     | 
    
         
             
                  @sample.term_values_append(
         
     | 
| 
       310 
306 
     | 
    
         
             
                    :parent_select =>'//oxns:name[@type="personal"]',
         
     | 
| 
       311 
307 
     | 
    
         
             
                    :parent_index => 0,
         
     | 
| 
       312 
308 
     | 
    
         
             
                    :template => 'xml.role { xml.roleTerm( \'#{builder_new_value}\', :type=>\'code\', :authority=>\'marcrelator\') }',
         
     | 
| 
       313 
     | 
    
         
            -
                    :values => "founder" 
     | 
| 
      
 309 
     | 
    
         
            +
                    :values => "founder"
         
     | 
| 
       314 
310 
     | 
    
         
             
                  )
         
     | 
| 
       315 
311 
     | 
    
         | 
| 
       316 
     | 
    
         
            -
                  @sample.ng_xml.xpath('//oxns:name[@type="personal" and position()=1]/oxns:role', @sample.ox_namespaces).length. 
     | 
| 
       317 
     | 
    
         
            -
                  @sample.ng_xml.xpath('//oxns:name[@type="personal" and position()=1]/oxns:role[last()]/oxns:roleTerm', @sample.ox_namespaces).first.text. 
     | 
| 
      
 312 
     | 
    
         
            +
                  expect(@sample.ng_xml.xpath('//oxns:name[@type="personal" and position()=1]/oxns:role', @sample.ox_namespaces).length).to eq(2)
         
     | 
| 
      
 313 
     | 
    
         
            +
                  expect(@sample.ng_xml.xpath('//oxns:name[@type="personal" and position()=1]/oxns:role[last()]/oxns:roleTerm', @sample.ox_namespaces).first.text).to eq("founder")
         
     | 
| 
       318 
314 
     | 
    
         | 
| 
       319 
315 
     | 
    
         
             
                  # @sample.find_by_terms_and_value(:person).first.to_xml.should == expected_result
         
     | 
| 
       320 
316 
     | 
    
         
             
                end
         
     | 
| 
       321 
     | 
    
         
            -
             
     | 
| 
      
 317 
     | 
    
         
            +
             
     | 
| 
       322 
318 
     | 
    
         
             
            	  it "should support more complex mixing & matching" do
         
     | 
| 
       323 
     | 
    
         
            -
            	     
     | 
| 
       324 
     | 
    
         
            -
                  @sample.ng_xml.xpath('//oxns:name[@type="personal"][2]/oxns:role[1]/oxns:roleTerm', @sample.ox_namespaces).length. 
     | 
| 
      
 319 
     | 
    
         
            +
            	    skip "not working because builder_template is not returning the correct template (returns builder for role instead of roleTerm)"
         
     | 
| 
      
 320 
     | 
    
         
            +
                  expect(@sample.ng_xml.xpath('//oxns:name[@type="personal"][2]/oxns:role[1]/oxns:roleTerm', @sample.ox_namespaces).length).to eq(2)
         
     | 
| 
       325 
321 
     | 
    
         
             
            	    @sample.term_values_append(
         
     | 
| 
       326 
322 
     | 
    
         
             
                    :parent_select =>'//oxns:name[@type="personal"][2]/oxns:role',
         
     | 
| 
       327 
323 
     | 
    
         
             
                    :parent_index => 0,
         
     | 
| 
       328 
324 
     | 
    
         
             
                    :template => [ :person, :role, :text, {:attributes=>{"authority"=>"marcrelator"}} ],
         
     | 
| 
       329 
     | 
    
         
            -
                    :values => "foo" 
     | 
| 
      
 325 
     | 
    
         
            +
                    :values => "foo"
         
     | 
| 
       330 
326 
     | 
    
         
             
                  )
         
     | 
| 
       331 
327 
     | 
    
         | 
| 
       332 
     | 
    
         
            -
                  @sample.ng_xml.xpath('//oxns:name[@type="personal"][2]/oxns:role[1]/oxns:roleTerm', @sample.ox_namespaces).length. 
     | 
| 
       333 
     | 
    
         
            -
                  @sample.find_by_terms({:person=>1},:role)[0].search("./oxns:roleTerm[@type=\"text\" and @authority=\"marcrelator\"]", @sample.ox_namespaces).first.text. 
     | 
| 
      
 328 
     | 
    
         
            +
                  expect(@sample.ng_xml.xpath('//oxns:name[@type="personal"][2]/oxns:role[1]/oxns:roleTerm', @sample.ox_namespaces).length).to eq(3)
         
     | 
| 
      
 329 
     | 
    
         
            +
                  expect(@sample.find_by_terms({:person=>1},:role)[0].search("./oxns:roleTerm[@type=\"text\" and @authority=\"marcrelator\"]", @sample.ox_namespaces).first.text).to eq("foo")
         
     | 
| 
       334 
330 
     | 
    
         
             
            	  end
         
     | 
| 
       335 
     | 
    
         
            -
             
     | 
| 
      
 331 
     | 
    
         
            +
             
     | 
| 
       336 
332 
     | 
    
         
             
              	it "should create the necessary ancestor nodes when you insert a new term value" do
         
     | 
| 
       337 
     | 
    
         
            -
              	  @sample.find_by_terms(:person).length. 
     | 
| 
      
 333 
     | 
    
         
            +
              	  expect(@sample.find_by_terms(:person).length).to eq(4)
         
     | 
| 
       338 
334 
     | 
    
         
             
              	  @sample.term_values_append(
         
     | 
| 
       339 
335 
     | 
    
         
             
                    :parent_select => :person ,
         
     | 
| 
       340 
336 
     | 
    
         
             
                    :parent_index => 8,
         
     | 
| 
       341 
337 
     | 
    
         
             
                    :template => :role,
         
     | 
| 
       342 
     | 
    
         
            -
                    :values => "my role" 
     | 
| 
      
 338 
     | 
    
         
            +
                    :values => "my role"
         
     | 
| 
       343 
339 
     | 
    
         
             
                  )
         
     | 
| 
       344 
340 
     | 
    
         
             
                  person_entries = @sample.find_by_terms(:person)
         
     | 
| 
       345 
     | 
    
         
            -
                  person_entries.length. 
     | 
| 
       346 
     | 
    
         
            -
                  person_entries[4].search("./ns3:role").first.text. 
     | 
| 
      
 341 
     | 
    
         
            +
                  expect(person_entries.length).to eq(5)
         
     | 
| 
      
 342 
     | 
    
         
            +
                  expect(person_entries[4].search("./ns3:role").first.text).to eq("my role")
         
     | 
| 
       347 
343 
     | 
    
         
             
            	  end
         
     | 
| 
       348 
     | 
    
         
            -
             
     | 
| 
      
 344 
     | 
    
         
            +
             
     | 
| 
       349 
345 
     | 
    
         
             
            	  it "should create the necessary ancestor nodes for deep trees of ancestors" do
         
     | 
| 
       350 
346 
     | 
    
         
             
              	  deep_pointer = [{:journal=>0}, {:issue=>3}, :pages, :start]
         
     | 
| 
       351 
     | 
    
         
            -
              	  @article.find_by_terms({:journal=>0}).length. 
     | 
| 
       352 
     | 
    
         
            -
              	  @article.find_by_terms({:journal=>0}, :issue).length. 
     | 
| 
      
 347 
     | 
    
         
            +
              	  expect(@article.find_by_terms({:journal=>0}).length).to eq(1)
         
     | 
| 
      
 348 
     | 
    
         
            +
              	  expect(@article.find_by_terms({:journal=>0}, :issue).length).to eq(1)
         
     | 
| 
       353 
349 
     | 
    
         
             
              	  @article.term_values_append(
         
     | 
| 
       354 
350 
     | 
    
         
             
                    :parent_select => deep_pointer[0..deep_pointer.length-2] ,
         
     | 
| 
       355 
351 
     | 
    
         
             
                    :parent_index => 0,
         
     | 
| 
       356 
352 
     | 
    
         
             
                    :template => deep_pointer,
         
     | 
| 
       357 
     | 
    
         
            -
                    :values => "451" 
     | 
| 
      
 353 
     | 
    
         
            +
                    :values => "451"
         
     | 
| 
       358 
354 
     | 
    
         
             
                  )
         
     | 
| 
       359 
     | 
    
         
            -
                  @article.find_by_terms({:journal=>0}, :issue).length. 
     | 
| 
       360 
     | 
    
         
            -
                  @article.find_by_terms({:journal=>0}, {:issue=>1}, :pages).length. 
     | 
| 
       361 
     | 
    
         
            -
                  @article.find_by_terms({:journal=>0}, {:issue=>1}, :pages, :start).length. 
     | 
| 
       362 
     | 
    
         
            -
                  @article.find_by_terms({:journal=>0}, {:issue=>1}, :pages, :start).first.text. 
     | 
| 
       363 
     | 
    
         
            -
                  
         
     | 
| 
      
 355 
     | 
    
         
            +
                  expect(@article.find_by_terms({:journal=>0}, :issue).length).to eq(2)
         
     | 
| 
      
 356 
     | 
    
         
            +
                  expect(@article.find_by_terms({:journal=>0}, {:issue=>1}, :pages).length).to eq(1)
         
     | 
| 
      
 357 
     | 
    
         
            +
                  expect(@article.find_by_terms({:journal=>0}, {:issue=>1}, :pages, :start).length).to eq(1)
         
     | 
| 
      
 358 
     | 
    
         
            +
                  expect(@article.find_by_terms({:journal=>0}, {:issue=>1}, :pages, :start).first.text).to eq("451")
         
     | 
| 
       364 
359 
     | 
    
         
             
            	  end
         
     | 
| 
       365 
     | 
    
         
            -
             
     | 
| 
      
 360 
     | 
    
         
            +
             
     | 
| 
       366 
361 
     | 
    
         
             
              end
         
     | 
| 
       367 
     | 
    
         
            -
             
     | 
| 
      
 362 
     | 
    
         
            +
             
     | 
| 
       368 
363 
     | 
    
         
             
              describe ".term_value_update" do
         
     | 
| 
       369 
     | 
    
         
            -
             
     | 
| 
      
 364 
     | 
    
         
            +
             
     | 
| 
       370 
365 
     | 
    
         
             
                it "should accept an xpath as :parent_select" do
         
     | 
| 
       371 
366 
     | 
    
         
             
            	    sample_xpath = '//oxns:name[@type="personal"][4]/oxns:role/oxns:roleTerm[@type="text"]'
         
     | 
| 
       372 
367 
     | 
    
         
             
            	    @sample.term_value_update(sample_xpath,1,"artist")
         
     | 
| 
       373 
     | 
    
         
            -
                  @sample.ng_xml.xpath(sample_xpath, @sample.ox_namespaces)[1].text. 
     | 
| 
      
 368 
     | 
    
         
            +
                  expect(@sample.ng_xml.xpath(sample_xpath, @sample.ox_namespaces)[1].text).to eq("artist")
         
     | 
| 
       374 
369 
     | 
    
         
             
                end
         
     | 
| 
       375 
     | 
    
         
            -
             
     | 
| 
      
 370 
     | 
    
         
            +
             
     | 
| 
       376 
371 
     | 
    
         
             
                it "if :select is provided, should update the first node provided by that xpath statement" do
         
     | 
| 
       377 
372 
     | 
    
         
             
                  sample_xpath = '//oxns:name[@type="personal"][1]/oxns:namePart[@type="given"]'
         
     | 
| 
       378 
373 
     | 
    
         
             
                  @sample.term_value_update(sample_xpath,0,"Timmeh")
         
     | 
| 
       379 
     | 
    
         
            -
                  @sample.ng_xml.xpath(sample_xpath, @sample.ox_namespaces).first.text. 
     | 
| 
      
 374 
     | 
    
         
            +
                  expect(@sample.ng_xml.xpath(sample_xpath, @sample.ox_namespaces).first.text).to eq("Timmeh")
         
     | 
| 
       380 
375 
     | 
    
         
             
                end
         
     | 
| 
       381 
     | 
    
         
            -
             
     | 
| 
      
 376 
     | 
    
         
            +
             
     | 
| 
       382 
377 
     | 
    
         
             
                it "should replace the existing node if you pass a template and values" do
         
     | 
| 
       383 
     | 
    
         
            -
                   
     | 
| 
      
 378 
     | 
    
         
            +
                  skip 'unimplemented'
         
     | 
| 
       384 
379 
     | 
    
         
             
                  @sample.term_value_update(
         
     | 
| 
       385 
380 
     | 
    
         
             
                    :parent_select =>'//oxns:name[@type="personal"]',
         
     | 
| 
       386 
381 
     | 
    
         
             
                    :parent_index => 1,
         
     | 
| 
       387 
382 
     | 
    
         
             
                    :template => [ :person, :role, {:attributes=>{"type"=>"code", "authority"=>"marcrelator"}} ],
         
     | 
| 
       388 
383 
     | 
    
         
             
                    :value => "foo"
         
     | 
| 
       389 
384 
     | 
    
         
             
                  )
         
     | 
| 
       390 
     | 
    
         
            -
                  1. 
     | 
| 
      
 385 
     | 
    
         
            +
                  expect(1).to eq(2)
         
     | 
| 
       391 
386 
     | 
    
         
             
                end
         
     | 
| 
       392 
387 
     | 
    
         
             
                it "should delete nodes if value is :delete or empty string" do
         
     | 
| 
       393 
388 
     | 
    
         
             
                  @article.update_values([:title_info]=>{"0"=>"york", "1"=>"mangle","2"=>"mork"})
         
     | 
| 
       394 
389 
     | 
    
         
             
                  xpath = @article.class.terminology.xpath_for(:title_info)
         
     | 
| 
       395 
     | 
    
         
            -
             
     | 
| 
      
 390 
     | 
    
         
            +
             
     | 
| 
       396 
391 
     | 
    
         
             
                  @article.term_value_update([:title_info], 1, "")
         
     | 
| 
       397 
     | 
    
         
            -
                  @article.term_values(:title_info). 
     | 
| 
       398 
     | 
    
         
            -
             
     | 
| 
      
 392 
     | 
    
         
            +
                  expect(@article.term_values(:title_info)).to eq(['york', 'mork'])
         
     | 
| 
      
 393 
     | 
    
         
            +
             
     | 
| 
       399 
394 
     | 
    
         
             
                  @article.term_value_update([:title_info], 1, :delete)
         
     | 
| 
       400 
     | 
    
         
            -
                  @article.term_values(:title_info). 
     | 
| 
      
 395 
     | 
    
         
            +
                  expect(@article.term_values(:title_info)).to eq(['york'])
         
     | 
| 
       401 
396 
     | 
    
         
             
                end
         
     | 
| 
       402 
397 
     | 
    
         
             
                it "should create empty nodes if value is nil" do
         
     | 
| 
       403 
398 
     | 
    
         
             
                  @article.update_values([:title_info]=>{"0"=>"york", "1"=>nil,"2"=>"mork"})
         
     | 
| 
       404 
     | 
    
         
            -
                  @article.term_values(:title_info). 
     | 
| 
      
 399 
     | 
    
         
            +
                  expect(@article.term_values(:title_info)).to eq(['york', "", "mork"])
         
     | 
| 
       405 
400 
     | 
    
         
             
                end
         
     | 
| 
       406 
401 
     | 
    
         
             
              end
         
     | 
| 
       407 
     | 
    
         
            -
             
     | 
| 
      
 402 
     | 
    
         
            +
             
     | 
| 
       408 
403 
     | 
    
         
             
              describe ".term_value_delete" do
         
     | 
| 
       409 
404 
     | 
    
         
             
                it "should accept an xpath query as :select option" do
         
     | 
| 
       410 
405 
     | 
    
         
             
                  generic_xpath = '//oxns:name[@type="personal" and position()=4]/oxns:role'
         
     | 
| 
       411 
406 
     | 
    
         
             
                  specific_xpath = '//oxns:name[@type="personal" and position()=4]/oxns:role[oxns:roleTerm="visionary"]'
         
     | 
| 
       412 
407 
     | 
    
         
             
                  select_xpath = '//oxns:name[@type="personal" and position()=4]/oxns:role[last()]'
         
     | 
| 
       413 
     | 
    
         
            -
             
     | 
| 
      
 408 
     | 
    
         
            +
             
     | 
| 
       414 
409 
     | 
    
         
             
                  # Check that we're starting with 2 roles
         
     | 
| 
       415 
410 
     | 
    
         
             
                  # Check that the specific node we want to delete exists
         
     | 
| 
       416 
     | 
    
         
            -
                  @sample.find_by_terms_and_value(generic_xpath).length. 
     | 
| 
       417 
     | 
    
         
            -
                  @sample.find_by_terms_and_value(specific_xpath).length. 
     | 
| 
      
 411 
     | 
    
         
            +
                  expect(@sample.find_by_terms_and_value(generic_xpath).length).to eq(2)
         
     | 
| 
      
 412 
     | 
    
         
            +
                  expect(@sample.find_by_terms_and_value(specific_xpath).length).to eq(1)
         
     | 
| 
       418 
413 
     | 
    
         | 
| 
       419 
414 
     | 
    
         
             
                  @sample.term_value_delete(
         
     | 
| 
       420 
415 
     | 
    
         
             
                    :select =>select_xpath
         
     | 
| 
       421 
416 
     | 
    
         
             
                  )
         
     | 
| 
       422 
417 
     | 
    
         
             
                  # Check that we're finishing with 1 role
         
     | 
| 
       423 
     | 
    
         
            -
                  @sample.find_by_terms_and_value(generic_xpath).length. 
     | 
| 
      
 418 
     | 
    
         
            +
                  expect(@sample.find_by_terms_and_value(generic_xpath).length).to eq(1)
         
     | 
| 
       424 
419 
     | 
    
         
             
                  # Check that the specific node we want to delete no longer exists
         
     | 
| 
       425 
     | 
    
         
            -
                  @sample.find_by_terms_and_value(specific_xpath).length. 
     | 
| 
       426 
     | 
    
         
            -
                end 
     | 
| 
      
 420 
     | 
    
         
            +
                  expect(@sample.find_by_terms_and_value(specific_xpath).length).to eq(0)
         
     | 
| 
      
 421 
     | 
    
         
            +
                end
         
     | 
| 
       427 
422 
     | 
    
         
             
                it "should accept :parent_select, :parent_index and :parent_index options instead of a :select" do
         
     | 
| 
       428 
     | 
    
         
            -
             
     | 
| 
      
 423 
     | 
    
         
            +
             
     | 
| 
       429 
424 
     | 
    
         
             
                  generic_xpath = '//oxns:name[@type="personal" and position()=4]/oxns:role/oxns:roleTerm'
         
     | 
| 
       430 
425 
     | 
    
         
             
                  specific_xpath = '//oxns:name[@type="personal" and position()=4]/oxns:role[oxns:roleTerm="visionary"]'
         
     | 
| 
       431 
     | 
    
         
            -
             
     | 
| 
      
 426 
     | 
    
         
            +
             
     | 
| 
       432 
427 
     | 
    
         
             
                  # Check that we're starting with 2 roles
         
     | 
| 
       433 
428 
     | 
    
         
             
                  # Check that the specific node we want to delete exists
         
     | 
| 
       434 
     | 
    
         
            -
                  @sample.find_by_terms_and_value(generic_xpath).length. 
     | 
| 
       435 
     | 
    
         
            -
                  @sample.find_by_terms_and_value(specific_xpath).length. 
     | 
| 
      
 429 
     | 
    
         
            +
                  expect(@sample.find_by_terms_and_value(generic_xpath).length).to eq(4)
         
     | 
| 
      
 430 
     | 
    
         
            +
                  expect(@sample.find_by_terms_and_value(specific_xpath).length).to eq(1)
         
     | 
| 
       436 
431 
     | 
    
         | 
| 
       437 
     | 
    
         
            -
                  # this is attempting to delete the last child (in this case roleTerm) from the 3rd role in the document. 
     | 
| 
      
 432 
     | 
    
         
            +
                  # this is attempting to delete the last child (in this case roleTerm) from the 3rd role in the document.
         
     | 
| 
       438 
433 
     | 
    
         
             
                  @sample.term_value_delete(
         
     | 
| 
       439 
434 
     | 
    
         
             
                    :parent_select => [:person, :role],
         
     | 
| 
       440 
435 
     | 
    
         
             
                    :parent_index => 3,
         
     | 
| 
       441 
436 
     | 
    
         
             
                    :child_index => :last
         
     | 
| 
       442 
437 
     | 
    
         
             
                  )
         
     | 
| 
       443 
     | 
    
         
            -
             
     | 
| 
      
 438 
     | 
    
         
            +
             
     | 
| 
       444 
439 
     | 
    
         
             
                  # Check that we're finishing with 1 role
         
     | 
| 
       445 
     | 
    
         
            -
                  @sample.find_by_terms_and_value(generic_xpath).length. 
     | 
| 
      
 440 
     | 
    
         
            +
                  expect(@sample.find_by_terms_and_value(generic_xpath).length).to eq(3)
         
     | 
| 
       446 
441 
     | 
    
         
             
                  # Check that the specific node we want to delete no longer exists
         
     | 
| 
       447 
     | 
    
         
            -
                  @sample.find_by_terms_and_value(specific_xpath).length. 
     | 
| 
      
 442 
     | 
    
         
            +
                  expect(@sample.find_by_terms_and_value(specific_xpath).length).to eq(1)
         
     | 
| 
       448 
443 
     | 
    
         
             
                end
         
     | 
| 
       449 
444 
     | 
    
         
             
                it "should work if only :parent_select and :parent_index are provided" do
         
     | 
| 
       450 
445 
     | 
    
         
             
                  generic_xpath = '//oxns:name[@type="personal"]/oxns:role'
         
     | 
| 
       451 
446 
     | 
    
         
             
                  # specific_xpath = '//oxns:name[@type="personal"]/oxns:role'
         
     | 
| 
       452 
     | 
    
         
            -
             
     | 
| 
      
 447 
     | 
    
         
            +
             
     | 
| 
       453 
448 
     | 
    
         
             
                  # Check that we're starting with 2 roles
         
     | 
| 
       454 
449 
     | 
    
         
             
                  # Check that the specific node we want to delete exists
         
     | 
| 
       455 
     | 
    
         
            -
                  @sample.find_by_terms_and_value(generic_xpath).length. 
     | 
| 
      
 450 
     | 
    
         
            +
                  expect(@sample.find_by_terms_and_value(generic_xpath).length).to eq(4)
         
     | 
| 
       456 
451 
     | 
    
         
             
                  # @sample.find_by_terms_and_value(specific_xpath).length.should == 1
         
     | 
| 
       457 
452 
     | 
    
         | 
| 
       458 
453 
     | 
    
         
             
                  @sample.term_value_delete(
         
     | 
| 
         @@ -460,14 +455,14 @@ describe "OM::XML::TermValueOperators" do 
     | 
|
| 
       460 
455 
     | 
    
         
             
                    :child_index => 3
         
     | 
| 
       461 
456 
     | 
    
         
             
                  )
         
     | 
| 
       462 
457 
     | 
    
         
             
                  # Check that we're finishing with 1 role
         
     | 
| 
       463 
     | 
    
         
            -
                  @sample.find_by_terms_and_value(generic_xpath).length. 
     | 
| 
      
 458 
     | 
    
         
            +
                  expect(@sample.find_by_terms_and_value(generic_xpath).length).to eq(3)
         
     | 
| 
       464 
459 
     | 
    
         
             
                end
         
     | 
| 
       465 
460 
     | 
    
         
             
              end
         
     | 
| 
       466 
     | 
    
         
            -
             
     | 
| 
      
 461 
     | 
    
         
            +
             
     | 
| 
       467 
462 
     | 
    
         
             
              describe "build_ancestors" do
         
     | 
| 
       468 
463 
     | 
    
         
             
                it "should raise an error if it cant find a starting point for building from" do
         
     | 
| 
       469 
     | 
    
         
            -
                   
     | 
| 
      
 464 
     | 
    
         
            +
                  expect { @empty_sample.build_ancestors( [:journal, :issue], 0) }.to raise_error(OM::XML::TemplateMissingException, "Cannot insert nodes into the document because it is empty.  Try defining self.xml_template on the OM::Samples::ModsArticle class.")
         
     | 
| 
       470 
465 
     | 
    
         
             
                end
         
     | 
| 
       471 
466 
     | 
    
         
             
              end
         
     | 
| 
       472 
     | 
    
         
            -
             
     | 
| 
      
 467 
     | 
    
         
            +
             
     | 
| 
       473 
468 
     | 
    
         
             
            end
         
     |