active-fedora 6.7.8 → 6.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.rubocop.yml +1 -0
  4. data/.rubocop_todo.yml +938 -0
  5. data/.travis.yml +5 -6
  6. data/Gemfile +3 -1
  7. data/Rakefile +7 -5
  8. data/active-fedora.gemspec +7 -8
  9. data/lib/active_fedora/om_datastream.rb +1 -0
  10. data/lib/active_fedora/rdf_xml_writer.rb +31 -62
  11. data/lib/active_fedora/version.rb +1 -1
  12. data/spec/config_helper.rb +14 -14
  13. data/spec/integration/associations_spec.rb +232 -232
  14. data/spec/integration/attributes_spec.rb +11 -12
  15. data/spec/integration/auditable_spec.rb +10 -10
  16. data/spec/integration/base_spec.rb +163 -163
  17. data/spec/integration/bug_spec.rb +7 -7
  18. data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
  19. data/spec/integration/datastream_collections_spec.rb +69 -69
  20. data/spec/integration/datastream_spec.rb +43 -43
  21. data/spec/integration/datastreams_spec.rb +63 -63
  22. data/spec/integration/delegating_spec.rb +14 -14
  23. data/spec/integration/delete_all_spec.rb +38 -42
  24. data/spec/integration/fedora_solr_sync_spec.rb +5 -5
  25. data/spec/integration/full_featured_model_spec.rb +101 -101
  26. data/spec/integration/has_many_associations_spec.rb +24 -24
  27. data/spec/integration/model_spec.rb +30 -30
  28. data/spec/integration/nested_attribute_spec.rb +41 -41
  29. data/spec/integration/ntriples_datastream_spec.rb +107 -107
  30. data/spec/integration/om_datastream_spec.rb +67 -67
  31. data/spec/integration/persistence_spec.rb +6 -6
  32. data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
  33. data/spec/integration/relation_delegation_spec.rb +24 -26
  34. data/spec/integration/rels_ext_datastream_spec.rb +20 -20
  35. data/spec/integration/scoped_query_spec.rb +40 -41
  36. data/spec/integration/solr_instance_loader_spec.rb +4 -4
  37. data/spec/integration/solr_service_spec.rb +46 -46
  38. data/spec/rails3_test_app/config/application.rb +1 -1
  39. data/spec/rails3_test_app/config/environments/development.rb +0 -1
  40. data/spec/rails3_test_app/config/environments/production.rb +1 -1
  41. data/spec/rails3_test_app/spec/spec_helper.rb +3 -3
  42. data/spec/rails3_test_app/spec/unit/rails_3_init.rb +4 -4
  43. data/spec/samples/hydra-mods_article_datastream.rb +334 -334
  44. data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
  45. data/spec/samples/marpa-dc_datastream.rb +17 -17
  46. data/spec/samples/models/audio_record.rb +16 -16
  47. data/spec/samples/models/image.rb +2 -2
  48. data/spec/samples/models/mods_article.rb +5 -5
  49. data/spec/samples/models/oral_history.rb +18 -18
  50. data/spec/samples/models/seminar.rb +24 -24
  51. data/spec/samples/models/seminar_audio_file.rb +17 -17
  52. data/spec/samples/oral_history_sample_model.rb +21 -21
  53. data/spec/samples/special_thing.rb +14 -14
  54. data/spec/spec_helper.rb +7 -11
  55. data/spec/support/an_active_model.rb +2 -2
  56. data/spec/support/mock_fedora.rb +16 -17
  57. data/spec/unit/active_fedora_spec.rb +58 -58
  58. data/spec/unit/association_proxy_spec.rb +5 -7
  59. data/spec/unit/base_active_model_spec.rb +25 -26
  60. data/spec/unit/base_cma_spec.rb +5 -5
  61. data/spec/unit/base_datastream_management_spec.rb +27 -27
  62. data/spec/unit/base_delegate_spec.rb +80 -82
  63. data/spec/unit/base_delegate_to_spec.rb +37 -39
  64. data/spec/unit/base_extra_spec.rb +48 -48
  65. data/spec/unit/base_spec.rb +300 -300
  66. data/spec/unit/callback_spec.rb +19 -19
  67. data/spec/unit/code_configurator_spec.rb +17 -17
  68. data/spec/unit/config_spec.rb +16 -8
  69. data/spec/unit/content_model_spec.rb +60 -60
  70. data/spec/unit/datastream_collections_spec.rb +229 -229
  71. data/spec/unit/datastream_spec.rb +57 -54
  72. data/spec/unit/datastreams_spec.rb +77 -77
  73. data/spec/unit/file_configurator_spec.rb +217 -217
  74. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +26 -26
  75. data/spec/unit/has_many_collection_spec.rb +9 -9
  76. data/spec/unit/inheritance_spec.rb +12 -13
  77. data/spec/unit/model_spec.rb +41 -51
  78. data/spec/unit/nom_datastream_spec.rb +15 -15
  79. data/spec/unit/ntriples_datastream_spec.rb +112 -112
  80. data/spec/unit/om_datastream_spec.rb +233 -227
  81. data/spec/unit/persistence_spec.rb +6 -6
  82. data/spec/unit/predicates_spec.rb +73 -73
  83. data/spec/unit/property_spec.rb +9 -17
  84. data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
  85. data/spec/unit/query_spec.rb +188 -217
  86. data/spec/unit/rdf_datastream_spec.rb +28 -21
  87. data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
  88. data/spec/unit/rdf_list_spec.rb +80 -104
  89. data/spec/unit/rdf_node_spec.rb +7 -7
  90. data/spec/unit/rdf_xml_writer_spec.rb +10 -10
  91. data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
  92. data/spec/unit/relationship_graph_spec.rb +51 -51
  93. data/spec/unit/rels_ext_datastream_spec.rb +75 -69
  94. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
  95. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
  96. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
  97. data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
  98. data/spec/unit/rubydora_connection_spec.rb +5 -5
  99. data/spec/unit/semantic_node_spec.rb +59 -59
  100. data/spec/unit/serializers_spec.rb +4 -4
  101. data/spec/unit/service_definitions_spec.rb +26 -26
  102. data/spec/unit/simple_datastream_spec.rb +17 -17
  103. data/spec/unit/solr_config_options_spec.rb +27 -28
  104. data/spec/unit/solr_digital_object_spec.rb +21 -21
  105. data/spec/unit/solr_service_spec.rb +81 -81
  106. data/spec/unit/unsaved_digital_object_spec.rb +20 -20
  107. data/spec/unit/validations_spec.rb +21 -21
  108. metadata +70 -58
  109. data/gemfiles/gemfile.rails3 +0 -11
  110. data/gemfiles/gemfile.rails4 +0 -10
@@ -2,12 +2,19 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe ActiveFedora::RDFDatastream do
5
- describe "a new instance" do
6
- its(:metadata?) { should be_true}
7
- its(:content_changed?) { should be_false}
5
+ describe 'a new instance' do
6
+ describe '#metadata?' do
7
+ subject { super().metadata? }
8
+ it { is_expected.to be_truthy}
9
+ end
10
+
11
+ describe '#content_changed?' do
12
+ subject { super().content_changed? }
13
+ it { is_expected.to be_falsey}
14
+ end
8
15
  end
9
16
  describe "an instance that exists in the datastore, but hasn't been loaded" do
10
- before do
17
+ before do
11
18
  class MyDatastream < ActiveFedora::NtriplesRDFDatastream
12
19
  map_predicates do |map|
13
20
  map.title(in: RDF::DC)
@@ -26,43 +33,43 @@ describe ActiveFedora::RDFDatastream do
26
33
  Object.send(:remove_const, :MyDatastream)
27
34
  Object.send(:remove_const, :MyObj)
28
35
  end
29
- subject { @obj.reload.descMetadata }
30
- it "should not load the descMetadata datastream when calling content_changed?" do
31
- @obj.inner_object.repository.should_not_receive(:datastream_dissemination).with(hash_including(:dsid=>'descMetadata'))
32
- subject.should_not be_content_changed
36
+ subject { @obj.reload.descMetadata }
37
+ it 'should not load the descMetadata datastream when calling content_changed?' do
38
+ expect(@obj.inner_object.repository).not_to receive(:datastream_dissemination).with(hash_including(:dsid => 'descMetadata'))
39
+ expect(subject).not_to be_content_changed
33
40
  end
34
41
 
35
- it "should allow asserting an empty string" do
42
+ it 'should allow asserting an empty string' do
36
43
  subject.title = ['']
37
- subject.title.should == ['']
44
+ expect(subject.title).to eq([''])
38
45
  end
39
46
 
40
- describe "when multivalue: false" do
41
- it "should return single values" do
47
+ describe 'when multivalue: false' do
48
+ it 'should return single values' do
42
49
  subject.description = 'my description'
43
- subject.description.should == 'my description'
50
+ expect(subject.description).to eq('my description')
44
51
  end
45
52
  end
46
53
 
47
- it "should clear stuff" do
54
+ it 'should clear stuff' do
48
55
  subject.title = ['one', 'two', 'three']
49
56
  subject.title.clear
50
- subject.graph.query([subject.rdf_subject, RDF::DC.title, nil]).first.should be_nil
57
+ expect(subject.graph.query([subject.rdf_subject, RDF::DC.title, nil]).first).to be_nil
51
58
  end
52
59
 
53
- it "should have a list of fields" do
54
- MyDatastream.fields.should == [:title, :description]
60
+ it 'should have a list of fields' do
61
+ expect(MyDatastream.fields).to eq([:title, :description])
55
62
  end
56
63
  end
57
64
 
58
- describe "deserialize" do
59
- it "should be able to handle non-utf-8 characters" do
65
+ describe 'deserialize' do
66
+ it 'should be able to handle non-utf-8 characters' do
60
67
  # see https://github.com/ruby-rdf/rdf/issues/142
61
68
  ds = ActiveFedora::NtriplesRDFDatastream.new
62
69
  data = "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT')
63
-
70
+
64
71
  result = ds.deserialize(data)
65
- result.dump(:ntriples).should == "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
72
+ expect(result.dump(:ntriples)).to eq("<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n")
66
73
  end
67
74
  end
68
75
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::RdfList do
4
4
  before :each do
5
- class MADS < RDF::Vocabulary("http://www.loc.gov/mads/rdf/v1#")
5
+ class MADS < RDF::Vocabulary('http://www.loc.gov/mads/rdf/v1#')
6
6
  property :MADSScheme
7
7
  property :isMemberOfMADSScheme
8
8
  property :authoritativeLabel
@@ -18,22 +18,22 @@ describe ActiveFedora::RdfList do
18
18
  include ActiveFedora::RdfObject
19
19
  rdf_type MADS.TopicElement
20
20
  map_predicates do |map|
21
- map.elementValue(:in=> MADS)
21
+ map.elementValue(:in => MADS)
22
22
  end
23
23
  end
24
24
  class TemporalElement
25
25
  include ActiveFedora::RdfObject
26
26
  rdf_type MADS.TemporalElement
27
27
  map_predicates do |map|
28
- map.elementValue(:in=> MADS)
28
+ map.elementValue(:in => MADS)
29
29
  end
30
30
  end
31
31
  class ElementList
32
32
  include ActiveFedora::RdfList
33
-
33
+
34
34
  map_predicates do |map|
35
- map.topicElement(:in=> MADS, :to =>"TopicElement", :class_name => "TopicElement")
36
- map.temporalElement(:in=> MADS, :to =>"TemporalElement", :class_name => "TemporalElement")
35
+ map.topicElement(:in => MADS, :to => 'TopicElement', :class_name => 'TopicElement')
36
+ map.temporalElement(:in => MADS, :to => 'TemporalElement', :class_name => 'TemporalElement')
37
37
  end
38
38
  accepts_nested_attributes_for :topicElement, :temporalElement
39
39
  end
@@ -44,7 +44,7 @@ describe ActiveFedora::RdfList do
44
44
  rdf_subject { |ds| RDF::URI.new(Rails.configuration.id_namespace + ds.pid)}
45
45
  map_predicates do |map|
46
46
  map.name(:in => MADS, :to => 'authoritativeLabel')
47
- map.elementList(:in => MADS, :class_name=>'ElementList')
47
+ map.elementList(:in => MADS, :class_name => 'ElementList')
48
48
  map.externalAuthority(:in => MADS, :to => 'hasExactExternalAuthority')
49
49
  end
50
50
  accepts_nested_attributes_for :elementList
@@ -57,15 +57,15 @@ describe ActiveFedora::RdfList do
57
57
  Object.send(:remove_const, :TemporalElement)
58
58
  Object.send(:remove_const, :MADS)
59
59
  end
60
-
61
- describe "nested_attributes" do
62
- it "should insert new nodes into RdfLists (rather than calling .build)" do
60
+
61
+ describe 'nested_attributes' do
62
+ it 'should insert new nodes into RdfLists (rather than calling .build)' do
63
63
  params = {
64
64
  topic: {
65
- name: "Baseball",
66
- externalAuthority: "http://id.loc.gov/authorities/subjects/sh85012026",
65
+ name: 'Baseball',
66
+ externalAuthority: 'http://id.loc.gov/authorities/subjects/sh85012026',
67
67
  elementList_attributes: [
68
- topicElement_attributes: [{ elementValue: "Baseball" }, elementValue: "Football"],
68
+ topicElement_attributes: [{ elementValue: 'Baseball' }, elementValue: 'Football']
69
69
  ]
70
70
  }
71
71
  }
@@ -73,25 +73,25 @@ describe ActiveFedora::RdfList do
73
73
  topic = Topic.new(RDF::Graph.new)
74
74
  topic.attributes = params[:topic]
75
75
  # puts topic.graph.dump(:ntriples)
76
- topic.elementList.first.size.should == 2
77
- topic.elementList.first[0].should be_kind_of(TopicElement)
78
- topic.elementList.first[0].elementValue.should == ["Baseball"]
79
- topic.elementList.first[1].should be_kind_of(TopicElement)
80
- topic.elementList.first[1].elementValue.should == ["Football"]
76
+ expect(topic.elementList.first.size).to eq(2)
77
+ expect(topic.elementList.first[0]).to be_kind_of(TopicElement)
78
+ expect(topic.elementList.first[0].elementValue).to eq(['Baseball'])
79
+ expect(topic.elementList.first[1]).to be_kind_of(TopicElement)
80
+ expect(topic.elementList.first[1].elementValue).to eq(['Football'])
81
81
 
82
82
  # only one rdf:rest rdf:nil
83
- topic.graph.query([nil, RDF.rest, RDF.nil]).size.should == 1
83
+ expect(topic.graph.query([nil, RDF.rest, RDF.nil]).size).to eq(1)
84
84
  end
85
- it "should insert new nodes of varying types into RdfLists (rather than calling .build)" do
86
- # It's Not clear what the syntax should be when an RDF list contains multiple types of sub-nodes.
85
+ it 'should insert new nodes of varying types into RdfLists (rather than calling .build)' do
86
+ # It's Not clear what the syntax should be when an RDF list contains multiple types of sub-nodes.
87
87
  # This is a guess, which currently works.
88
88
  params = {
89
89
  topic: {
90
- name: "Baseball",
91
- externalAuthority: "http://id.loc.gov/authorities/subjects/sh85012026",
90
+ name: 'Baseball',
91
+ externalAuthority: 'http://id.loc.gov/authorities/subjects/sh85012026',
92
92
  elementList_attributes: [
93
- topicElement_attributes: [{ elementValue: "Baseball" }, elementValue: "Football"],
94
- temporalElement_attributes: [{elementValue: "1960"}, {elementValue:"Twentieth Century"}],
93
+ topicElement_attributes: [{ elementValue: 'Baseball' }, elementValue: 'Football'],
94
+ temporalElement_attributes: [{elementValue: '1960'}, {elementValue: 'Twentieth Century'}]
95
95
  ]
96
96
  }
97
97
  }
@@ -99,15 +99,15 @@ describe ActiveFedora::RdfList do
99
99
  topic = Topic.new(RDF::Graph.new)
100
100
  topic.attributes = params[:topic]
101
101
  # puts topic.graph.dump(:ntriples)
102
- topic.elementList.first.size.should == 4
103
- topic.elementList.first[0].should be_kind_of(TopicElement)
104
- topic.elementList.first[0].elementValue.should == ["Baseball"]
105
- topic.elementList.first[1].should be_kind_of(TopicElement)
106
- topic.elementList.first[1].elementValue.should == ["Football"]
107
- topic.elementList.first[2].should be_kind_of(TemporalElement)
108
- topic.elementList.first[2].elementValue.should == ["1960"]
109
- topic.elementList.first[3].should be_kind_of(TemporalElement)
110
- topic.elementList.first[3].elementValue.should == ["Twentieth Century"]
102
+ expect(topic.elementList.first.size).to eq(4)
103
+ expect(topic.elementList.first[0]).to be_kind_of(TopicElement)
104
+ expect(topic.elementList.first[0].elementValue).to eq(['Baseball'])
105
+ expect(topic.elementList.first[1]).to be_kind_of(TopicElement)
106
+ expect(topic.elementList.first[1].elementValue).to eq(['Football'])
107
+ expect(topic.elementList.first[2]).to be_kind_of(TemporalElement)
108
+ expect(topic.elementList.first[2].elementValue).to eq(['1960'])
109
+ expect(topic.elementList.first[3]).to be_kind_of(TemporalElement)
110
+ expect(topic.elementList.first[3].elementValue).to eq(['Twentieth Century'])
111
111
  end
112
112
  end
113
113
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::RdfList do
4
4
  before :each do
5
- class MADS < RDF::Vocabulary("http://www.loc.gov/mads/rdf/v1#")
5
+ class MADS < RDF::Vocabulary('http://www.loc.gov/mads/rdf/v1#')
6
6
  property :complexSubject
7
7
  property :authoritativeLabel
8
8
  property :elementList
@@ -12,27 +12,27 @@ describe ActiveFedora::RdfList do
12
12
  end
13
13
  class DemoList < ActiveFedora::RdfxmlRDFDatastream
14
14
  map_predicates do |map|
15
- map.elementList(:in => MADS, :to => 'elementList', :class_name=>'List')
16
- end
17
- class List
15
+ map.elementList(:in => MADS, :to => 'elementList', :class_name => 'List')
16
+ end
17
+ class List
18
18
  include ActiveFedora::RdfList
19
19
  map_predicates do |map|
20
- map.topicElement(:in=> MADS, :to =>"TopicElement", :class_name => "TopicElement")
21
- map.temporalElement(:in=> MADS, :to =>"TemporalElement", :class_name => "TemporalElement")
20
+ map.topicElement(:in => MADS, :to => 'TopicElement', :class_name => 'TopicElement')
21
+ map.temporalElement(:in => MADS, :to => 'TemporalElement', :class_name => 'TemporalElement')
22
22
  end
23
-
23
+
24
24
  class TopicElement
25
25
  include ActiveFedora::RdfObject
26
26
  rdf_type MADS.TopicElement
27
- map_predicates do |map|
28
- map.elementValue(:in=> MADS)
27
+ map_predicates do |map|
28
+ map.elementValue(:in => MADS)
29
29
  end
30
30
  end
31
31
  class TemporalElement
32
32
  include ActiveFedora::RdfObject
33
33
  rdf_type MADS.TemporalElement
34
- map_predicates do |map|
35
- map.elementValue(:in=> MADS)
34
+ map_predicates do |map|
35
+ map.elementValue(:in => MADS)
36
36
  end
37
37
  end
38
38
  end
@@ -43,102 +43,91 @@ describe ActiveFedora::RdfList do
43
43
  Object.send(:remove_const, :MADS)
44
44
  end
45
45
 
46
- describe "a new list" do
47
- let (:ds) { DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true), 'descMetadata')}
46
+ describe 'a new list' do
47
+ let (:ds) { DemoList.new(double('inner object', :pid => 'foo', :new_record? => true), 'descMetadata')}
48
48
  subject { ds.elementList.build}
49
49
 
50
- it "should insert at the end" do
51
- subject.should be_kind_of DemoList::List
52
- subject.size.should == 0
50
+ it 'should insert at the end' do
51
+ expect(subject).to be_kind_of DemoList::List
52
+ expect(subject.size).to eq(0)
53
53
  subject[1] = DemoList::List::TopicElement.new(subject.graph)
54
- subject.size.should == 2
54
+ expect(subject.size).to eq(2)
55
55
  end
56
56
 
57
- it "should insert at the head" do
58
- subject.should be_kind_of DemoList::List
59
- subject.size.should == 0
57
+ it 'should insert at the head' do
58
+ expect(subject).to be_kind_of DemoList::List
59
+ expect(subject.size).to eq(0)
60
60
  subject[0] = DemoList::List::TopicElement.new(subject.graph)
61
- subject.size.should == 1
61
+ expect(subject.size).to eq(1)
62
62
  end
63
63
 
64
- describe "that has 4 elements" do
64
+ describe 'that has 4 elements' do
65
65
  before do
66
66
  subject[3] = DemoList::List::TopicElement.new(subject.graph)
67
- subject.size.should == 4
67
+ expect(subject.size).to eq(4)
68
68
  end
69
- it "should insert in the middle" do
69
+ it 'should insert in the middle' do
70
70
  subject[1] = DemoList::List::TopicElement.new(subject.graph)
71
- subject.size.should == 4
71
+ expect(subject.size).to eq(4)
72
72
  end
73
73
  end
74
74
 
75
- describe "return updated xml" do
76
- it "should be built" do
77
- subject[0] = RDF::URI.new "http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"
75
+ describe 'return updated xml' do
76
+ it 'should be built' do
77
+ subject[0] = RDF::URI.new 'http://library.ucsd.edu/ark:/20775/bbXXXXXXX6'
78
78
  subject[1] = DemoList::List::TopicElement.new(ds.graph)
79
- subject[1].elementValue = "Relations with Mexican Americans"
80
- subject[2] = RDF::URI.new "http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"
79
+ subject[1].elementValue = 'Relations with Mexican Americans'
80
+ subject[2] = RDF::URI.new 'http://library.ucsd.edu/ark:/20775/bbXXXXXXX4'
81
81
  subject[3] = DemoList::List::TemporalElement.new(ds.graph)
82
82
  subject[3].elementValue = "20th century"
83
- expected_xml =<<END
84
- <rdf:RDF
85
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:mads="http://www.loc.gov/mads/rdf/v1#">
86
-
87
- <rdf:Description rdf:about="info:fedora/foo">
88
- <mads:elementList rdf:parseType="Collection">
89
- <rdf:Description rdf:about="http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"/>
90
- <mads:TopicElement>
91
- <mads:elementValue>Relations with Mexican Americans</mads:elementValue>
92
- </mads:TopicElement>
93
- <rdf:Description rdf:about="http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"/>
94
- <mads:TemporalElement>
95
- <mads:elementValue>20th century</mads:elementValue>
96
- </mads:TemporalElement>
97
- </mads:elementList>
98
- </rdf:Description>
99
- </rdf:RDF>
100
- END
101
- ds.content.should be_equivalent_to expected_xml
83
+ doc = Nokogiri::XML(ds.content)
84
+ ns = {rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", mads: "http://www.loc.gov/mads/rdf/v1#"}
85
+ expect(doc.xpath('/rdf:RDF/rdf:Description/@rdf:about', ns).map(&:value)).to eq ["info:fedora/foo"]
86
+ expect(doc.xpath('//rdf:Description/mads:elementList/@rdf:parseType', ns).map(&:value)).to eq ["Collection"]
87
+ expect(doc.xpath('//rdf:Description/mads:elementList/*[position() = 1]/@rdf:about', ns).map(&:value)).to eq ["http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"]
88
+ expect(doc.xpath('//rdf:Description/mads:elementList/*[position() = 2]/mads:elementValue', ns).map(&:text)).to eq ["Relations with Mexican Americans"]
89
+ expect(doc.xpath('//rdf:Description/mads:elementList/*[position() = 3]/@rdf:about', ns).map(&:value)).to eq ["http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"]
90
+ expect(doc.xpath('//rdf:Description/mads:elementList/*[position() = 4]/mads:elementValue', ns).map(&:text)).to eq ["20th century"]
102
91
  end
103
92
  end
104
93
 
105
94
 
106
95
  end
107
96
 
108
- describe "an empty list" do
109
- subject { DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true)).elementList.build }
110
- it "should have to_ary" do
111
- subject.to_ary.should == []
97
+ describe 'an empty list' do
98
+ subject { DemoList.new(double('inner object', :pid => 'foo', :new_record? => true)).elementList.build }
99
+ it 'should have to_ary' do
100
+ expect(subject.to_ary).to eq([])
112
101
  end
113
102
  end
114
103
 
115
- describe "a list that has a constructed element" do
116
- let(:ds) { DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true)) }
117
- let(:list) { ds.elementList.build }
104
+ describe 'a list that has a constructed element' do
105
+ let(:ds) { DemoList.new(double('inner object', :pid => 'foo', :new_record? => true)) }
106
+ let(:list) { ds.elementList.build }
118
107
  let!(:topic) { list.topicElement.build }
119
-
120
- it "should have to_ary" do
121
- list.to_ary.size.should == 1
122
- list.to_ary.first.class.should == DemoList::List::TopicElement
108
+
109
+ it 'should have to_ary' do
110
+ expect(list.to_ary.size).to eq(1)
111
+ expect(list.to_ary.first.class).to eq(DemoList::List::TopicElement)
123
112
  end
124
113
 
125
- it "should be able to be cleared" do
114
+ it 'should be able to be cleared' do
126
115
  list.topicElement.build
127
116
  list.topicElement.build
128
117
  list.topicElement.build
129
- list.size.should == 4
118
+ expect(list.size).to eq(4)
130
119
  list.clear
131
- list.size.should == 0
120
+ expect(list.size).to eq(0)
132
121
  end
133
122
  end
134
123
 
135
- describe "a list with content" do
124
+ describe 'a list with content' do
136
125
  subject do
137
- subject = DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true), 'descMetadata')
138
- subject.content =<<END
126
+ subject = DemoList.new(double('inner object', :pid => 'foo', :new_record? => true), 'descMetadata')
127
+ subject.content = <<END
139
128
  <rdf:RDF
140
129
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:mads="http://www.loc.gov/mads/rdf/v1#">
141
-
130
+
142
131
  <mads:ComplexSubject rdf:about="info:fedora/foo">
143
132
  <mads:elementList rdf:parseType="Collection">
144
133
  <rdf:Description rdf:about="http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"/>
@@ -156,60 +145,47 @@ END
156
145
 
157
146
  subject
158
147
  end
159
- it "should have a subject" do
160
- subject.rdf_subject.to_s.should == "info:fedora/foo"
148
+ it 'should have a subject' do
149
+ expect(subject.rdf_subject.to_s).to eq('info:fedora/foo')
161
150
  end
162
151
 
163
152
  let (:list) { subject.elementList.first }
164
153
 
165
- it "should have fields" do
166
- list.first.should == "http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"
167
- list[1].should be_kind_of DemoList::List::TopicElement
168
- list[1].elementValue.should == ["Relations with Mexican Americans"]
169
- list[2].should == "http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"
170
- list[3].should be_kind_of DemoList::List::TemporalElement
171
- list[3].elementValue.should == ["20th century"]
154
+ it 'should have fields' do
155
+ expect(list.first).to eq('http://library.ucsd.edu/ark:/20775/bbXXXXXXX6')
156
+ expect(list[1]).to be_kind_of DemoList::List::TopicElement
157
+ expect(list[1].elementValue).to eq(['Relations with Mexican Americans'])
158
+ expect(list[2]).to eq('http://library.ucsd.edu/ark:/20775/bbXXXXXXX4')
159
+ expect(list[3]).to be_kind_of DemoList::List::TemporalElement
160
+ expect(list[3].elementValue).to eq(['20th century'])
172
161
  end
173
162
 
174
- it "should have each" do
163
+ it 'should have each' do
175
164
  foo = []
176
165
  list.each { |n| foo << n.class }
177
- foo.should == [RDF::URI, DemoList::List::TopicElement, RDF::URI, DemoList::List::TemporalElement]
166
+ expect(foo).to eq([RDF::URI, DemoList::List::TopicElement, RDF::URI, DemoList::List::TemporalElement])
178
167
  end
179
168
 
180
- it "should have to_ary" do
169
+ it 'should have to_ary' do
181
170
  ary = list.to_ary
182
- ary.size.should == 4
183
- ary[1].elementValue.should == ['Relations with Mexican Americans']
171
+ expect(ary.size).to eq(4)
172
+ expect(ary[1].elementValue).to eq(['Relations with Mexican Americans'])
184
173
  end
185
174
 
186
- it "should have size" do
187
- list.size.should == 4
175
+ it 'should have size' do
176
+ expect(list.size).to eq(4)
188
177
  end
189
178
 
190
179
  it "should update fields" do
191
180
  list[3].elementValue = ["1900s"]
192
- expected_xml =<<END
193
- <rdf:RDF
194
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:mads="http://www.loc.gov/mads/rdf/v1#">
195
-
196
- <mads:ComplexSubject rdf:about="info:fedora/foo">
197
- <mads:elementList rdf:parseType="Collection">
198
- <rdf:Description rdf:about="http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"/>
199
- <mads:TopicElement>
200
- <mads:elementValue>Relations with Mexican Americans</mads:elementValue>
201
- </mads:TopicElement>
202
- <rdf:Description rdf:about="http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"/>
203
- <mads:TemporalElement>
204
- <mads:elementValue>1900s</mads:elementValue>
205
- </mads:TemporalElement>
206
- </mads:elementList>
207
- </mads:ComplexSubject>
208
- </rdf:RDF>
209
-
210
- END
211
- subject.content.should be_equivalent_to expected_xml
181
+ doc = Nokogiri::XML(subject.content)
182
+ ns = {rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", mads: "http://www.loc.gov/mads/rdf/v1#"}
183
+ expect(doc.xpath('/rdf:RDF/mads:ComplexSubject/@rdf:about', ns).map(&:value)).to eq ["info:fedora/foo"]
184
+ expect(doc.xpath('//mads:ComplexSubject/mads:elementList/@rdf:parseType', ns).map(&:value)).to eq ["Collection"]
185
+ expect(doc.xpath('//mads:ComplexSubject/mads:elementList/*[position() = 1]/@rdf:about', ns).map(&:value)).to eq ["http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"]
186
+ expect(doc.xpath('//mads:ComplexSubject/mads:elementList/*[position() = 2]/mads:elementValue', ns).map(&:text)).to eq ["Relations with Mexican Americans"]
187
+ expect(doc.xpath('//mads:ComplexSubject/mads:elementList/*[position() = 3]/@rdf:about', ns).map(&:value)).to eq ["http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"]
188
+ expect(doc.xpath('//mads:ComplexSubject/mads:elementList/*[position() = 4]/mads:elementValue', ns).map(&:text)).to eq ["1900s"]
212
189
  end
213
190
  end
214
191
  end
215
-