active-fedora 6.7.8 → 6.8.0

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.
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
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
- require "solrizer"
2
+ require 'solrizer'
3
3
 
4
4
  describe ActiveFedora::OmDatastream do
5
-
6
- describe "a new instance with an inline datastream" do
7
- before(:all) do
5
+
6
+ describe 'a new instance with an inline datastream' do
7
+ before(:all) do
8
8
  class ModsArticle3 < ActiveFedora::Base
9
9
  # Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
10
- has_metadata "descMetadata", type: Hydra::ModsArticleDatastream, control_group: 'X', autocreate: true
10
+ has_metadata 'descMetadata', type: Hydra::ModsArticleDatastream, control_group: 'X', autocreate: true
11
11
  end
12
12
  end
13
13
 
@@ -25,38 +25,38 @@ describe ActiveFedora::OmDatastream do
25
25
  @obj.destroy
26
26
  end
27
27
 
28
- it "should report being inline" do
29
- @obj.descMetadata.should be_inline
28
+ it 'should report being inline' do
29
+ expect(@obj.descMetadata).to be_inline
30
30
  end
31
31
 
32
- it "should not be changed when no fields have been set" do
33
- @obj.descMetadata.should_not be_content_changed
32
+ it 'should not be changed when no fields have been set' do
33
+ expect(@obj.descMetadata).not_to be_content_changed
34
34
  end
35
- it "should be changed when a field has been set" do
35
+ it 'should be changed when a field has been set' do
36
36
  @obj.descMetadata.title = 'Foobar'
37
- @obj.descMetadata.should be_content_changed
37
+ expect(@obj.descMetadata).to be_content_changed
38
38
  end
39
- describe "#changed?" do
40
- it "should not be changed if the new xml matches the old xml" do
39
+ describe '#changed?' do
40
+ it 'should not be changed if the new xml matches the old xml' do
41
41
  @obj.descMetadata.content = @obj.descMetadata.content
42
- @obj.descMetadata.should_not be_changed
42
+ expect(@obj.descMetadata).not_to be_changed
43
43
  end
44
44
 
45
- it "should not be changed if there are minor differences in whitespace" do
46
- @obj.descMetadata.content = "<a><b>1</b></a>"
45
+ it 'should not be changed if there are minor differences in whitespace' do
46
+ @obj.descMetadata.content = '<a><b>1</b></a>'
47
47
  @obj.save
48
- @obj.descMetadata.should_not be_changed
48
+ expect(@obj.descMetadata).not_to be_changed
49
49
  @obj.descMetadata.content = "<a>\n<b>1</b>\n</a>"
50
- @obj.descMetadata.should_not be_changed
50
+ expect(@obj.descMetadata).not_to be_changed
51
51
  end
52
52
  end
53
53
  end
54
54
 
55
- describe "an instance that is a managed datastream" do
55
+ describe 'an instance that is a managed datastream' do
56
56
  before(:all) do
57
57
  class ModsArticle2 < ActiveFedora::Base
58
58
  # Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
59
- has_metadata "descMetadata", type: Hydra::ModsArticleDatastream, autocreate: true
59
+ has_metadata 'descMetadata', type: Hydra::ModsArticleDatastream, autocreate: true
60
60
  end
61
61
  end
62
62
 
@@ -74,28 +74,28 @@ describe ActiveFedora::OmDatastream do
74
74
  @obj.destroy
75
75
  end
76
76
 
77
- it "should not report being inline" do
78
- @obj.descMetadata.should be_managed
77
+ it 'should not report being inline' do
78
+ expect(@obj.descMetadata).to be_managed
79
79
  end
80
80
 
81
- describe "#changed?" do
82
- it "should not be changed if the new xml matches the old xml" do
81
+ describe '#changed?' do
82
+ it 'should not be changed if the new xml matches the old xml' do
83
83
  @obj.descMetadata.content = @obj.descMetadata.content
84
- @obj.descMetadata.should_not be_changed
84
+ expect(@obj.descMetadata).not_to be_changed
85
85
  end
86
86
 
87
- it "should be changed if there are minor differences in whitespace" do
88
- @obj.descMetadata.content = "<a><b>1</b></a>"
87
+ it 'should be changed if there are minor differences in whitespace' do
88
+ @obj.descMetadata.content = '<a><b>1</b></a>'
89
89
  @obj.save
90
- @obj.descMetadata.should_not be_changed
90
+ expect(@obj.descMetadata).not_to be_changed
91
91
  @obj.descMetadata.content = "<a>\n<b>1</b>\n</a>"
92
- @obj.descMetadata.should be_changed
92
+ expect(@obj.descMetadata).to be_changed
93
93
  end
94
94
  end
95
95
 
96
- describe "empty datastream content" do
97
- it "should not break when there is empty datastream content" do
98
- @obj.descMetadata.content = ""
96
+ describe 'empty datastream content' do
97
+ it 'should not break when there is empty datastream content' do
98
+ @obj.descMetadata.content = ''
99
99
  @obj.save
100
100
  end
101
101
  end
@@ -108,35 +108,35 @@ describe ActiveFedora::OmDatastream do
108
108
  @solr_obj = ActiveFedora::Base.load_instance_from_solr(@obj.pid)
109
109
  end
110
110
 
111
- it "should return the same values whether getting from solr or Fedora" do
112
- @solr_obj.datastreams["descMetadata"].term_values(:name,:role,:text).should == ["Creator","Contributor","Funder","Host"]
113
- @solr_obj.datastreams["descMetadata"].term_values({:name=>0},:role,:text).should == ["Creator"]
114
- @solr_obj.datastreams["descMetadata"].term_values({:name=>1},:role,:text).should == ["Contributor"]
115
- @solr_obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).should == ["Creator"]
116
- @solr_obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>0},:text).should == ["Contributor"]
117
- @solr_obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>1},:text).should == []
118
- ar = @solr_obj.datastreams["descMetadata"].term_values(:name,{:role=>0},:text)
119
- ar.length.should == 4
120
- ar.include?("Creator").should == true
121
- ar.include?("Contributor").should == true
122
- ar.include?("Funder").should == true
123
- ar.include?("Host").should == true
124
-
125
- @obj.datastreams["descMetadata"].term_values(:name,:role,:text).should == ["Creator","Contributor","Funder","Host"]
126
- @obj.datastreams["descMetadata"].term_values({:name=>0},:role,:text).should == ["Creator"]
127
- @obj.datastreams["descMetadata"].term_values({:name=>1},:role,:text).should == ["Contributor"]
128
- @obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).should == ["Creator"]
129
- @obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>0},:text).should == ["Contributor"]
130
- @obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>1},:text).should == []
131
- ar = @obj.datastreams["descMetadata"].term_values(:name,{:role=>0},:text)
132
- ar.length.should == 4
133
- ar.include?("Creator").should == true
134
- ar.include?("Contributor").should == true
135
- ar.include?("Funder").should == true
136
- ar.include?("Host").should == true
111
+ it 'should return the same values whether getting from solr or Fedora' do
112
+ expect(@solr_obj.datastreams['descMetadata'].term_values(:name, :role, :text)).to eq(['Creator', 'Contributor', 'Funder', 'Host'])
113
+ expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 0}, :role, :text)).to eq(['Creator'])
114
+ expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 1}, :role, :text)).to eq(['Contributor'])
115
+ expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 0}, {:role => 0}, :text)).to eq(['Creator'])
116
+ expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 0}, :text)).to eq(['Contributor'])
117
+ expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 1}, :text)).to eq([])
118
+ ar = @solr_obj.datastreams['descMetadata'].term_values(:name, {:role => 0}, :text)
119
+ expect(ar.length).to eq(4)
120
+ expect(ar.include?('Creator')).to eq(true)
121
+ expect(ar.include?('Contributor')).to eq(true)
122
+ expect(ar.include?('Funder')).to eq(true)
123
+ expect(ar.include?('Host')).to eq(true)
124
+
125
+ expect(@obj.datastreams['descMetadata'].term_values(:name, :role, :text)).to eq(['Creator', 'Contributor', 'Funder', 'Host'])
126
+ expect(@obj.datastreams['descMetadata'].term_values({:name => 0}, :role, :text)).to eq(['Creator'])
127
+ expect(@obj.datastreams['descMetadata'].term_values({:name => 1}, :role, :text)).to eq(['Contributor'])
128
+ expect(@obj.datastreams['descMetadata'].term_values({:name => 0}, {:role => 0}, :text)).to eq(['Creator'])
129
+ expect(@obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 0}, :text)).to eq(['Contributor'])
130
+ expect(@obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 1}, :text)).to eq([])
131
+ ar = @obj.datastreams['descMetadata'].term_values(:name, {:role => 0}, :text)
132
+ expect(ar.length).to eq(4)
133
+ expect(ar.include?('Creator')).to eq(true)
134
+ expect(ar.include?('Contributor')).to eq(true)
135
+ expect(ar.include?('Funder')).to eq(true)
136
+ expect(ar.include?('Host')).to eq(true)
137
137
  end
138
138
  end
139
-
139
+
140
140
  describe '.update_values' do
141
141
  before do
142
142
  @obj.descMetadata.content = File.read(fixture('mods_articles/mods_article1.xml'))
@@ -144,24 +144,24 @@ describe ActiveFedora::OmDatastream do
144
144
  @obj.reload
145
145
  end
146
146
 
147
- it "should not be dirty after .update_values is saved" do
148
- @obj.datastreams["descMetadata"].update_values([{:name=>0},{:role=>0},:text] =>"Funder")
149
- @obj.datastreams["descMetadata"].should be_changed
147
+ it 'should not be dirty after .update_values is saved' do
148
+ @obj.datastreams['descMetadata'].update_values([{:name => 0}, {:role => 0}, :text] => 'Funder')
149
+ expect(@obj.datastreams['descMetadata']).to be_changed
150
150
  @obj.save
151
- @obj.datastreams["descMetadata"].should_not be_changed
152
- @obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).should == ["Funder"]
153
- end
151
+ expect(@obj.datastreams['descMetadata']).not_to be_changed
152
+ expect(@obj.datastreams['descMetadata'].term_values({:name => 0}, {:role => 0}, :text)).to eq(['Funder'])
153
+ end
154
154
  end
155
155
 
156
156
 
157
- describe ".to_solr" do
157
+ describe '.to_solr' do
158
158
  before do
159
159
  @obj.descMetadata.journal.issue.publication_date = Date.parse('2012-11-02')
160
160
  @obj.save!
161
161
  @obj.reload
162
162
  end
163
163
  it "should solrize terms with :type=>'date' to *_dt solr terms" do
164
- @obj.to_solr[ActiveFedora::SolrService.solr_name('journal_issue_publication_date', type: :date)].should == ['2012-11-02T00:00:00Z']
164
+ expect(@obj.to_solr[ActiveFedora::SolrService.solr_name('journal_issue_publication_date', type: :date)]).to eq(['2012-11-02T00:00:00Z'])
165
165
  end
166
166
  end
167
167
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "persisting objects" do
3
+ describe 'persisting objects' do
4
4
  before :all do
5
5
  class MockAFBaseRelationship < ActiveFedora::Base
6
- has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"foo" do |m|
7
- m.field "name", :string
6
+ has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'foo' do |m|
7
+ m.field 'name', :string
8
8
  end
9
9
  delegate :name, to: 'foo', multiple: false
10
10
  validates :name, presence: true
@@ -14,9 +14,9 @@ describe "persisting objects" do
14
14
  Object.send(:remove_const, :MockAFBaseRelationship)
15
15
  end
16
16
 
17
- describe "#create!" do
18
- it "should validate" do
19
- lambda { MockAFBaseRelationship.create!}.should raise_error ActiveFedora::RecordInvalid, "Validation failed: Name can't be blank"
17
+ describe '#create!' do
18
+ it 'should validate' do
19
+ expect { MockAFBaseRelationship.create!}.to raise_error ActiveFedora::RecordInvalid, "Validation failed: Name can't be blank"
20
20
  end
21
21
  end
22
22
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Nesting attribute behavior of RDFDatastream" do
4
- describe ".attributes=" do
5
- describe "complex properties" do
6
- before do
7
- class DummyMADS < RDF::Vocabulary("http://www.loc.gov/mads/rdf/v1#")
3
+ describe 'Nesting attribute behavior of RDFDatastream' do
4
+ describe '.attributes=' do
5
+ describe 'complex properties' do
6
+ before do
7
+ class DummyMADS < RDF::Vocabulary('http://www.loc.gov/mads/rdf/v1#')
8
8
  # componentList and Types of components
9
9
  property :componentList
10
10
  property :Topic
@@ -12,8 +12,8 @@ describe "Nesting attribute behavior of RDFDatastream" do
12
12
  property :PersonalName
13
13
  property :CorporateName
14
14
  property :ComplexSubject
15
-
16
-
15
+
16
+
17
17
  # elementList and elementList values
18
18
  property :elementList
19
19
  property :elementValue
@@ -26,8 +26,8 @@ describe "Nesting attribute behavior of RDFDatastream" do
26
26
 
27
27
  class ComplexRDFDatastream < ActiveFedora::NtriplesRDFDatastream
28
28
  map_predicates do |map|
29
- map.topic(in: DummyMADS, to: "Topic", class_name:"Topic")
30
- map.personalName(in: DummyMADS, to: "PersonalName", class_name:"PersonalName")
29
+ map.topic(in: DummyMADS, to: 'Topic', class_name: 'Topic')
30
+ map.personalName(in: DummyMADS, to: 'PersonalName', class_name: 'PersonalName')
31
31
  map.title(in: RDF::DC)
32
32
  end
33
33
 
@@ -36,15 +36,15 @@ describe "Nesting attribute behavior of RDFDatastream" do
36
36
  class Topic
37
37
  include ActiveFedora::RdfObject
38
38
  map_predicates do |map|
39
- map.elementList(in: DummyMADS, class_name:"ComplexRDFDatastream::ElementList")
39
+ map.elementList(in: DummyMADS, class_name: 'ComplexRDFDatastream::ElementList')
40
40
  end
41
41
  accepts_nested_attributes_for :elementList
42
42
  end
43
43
  class PersonalName
44
44
  include ActiveFedora::RdfObject
45
45
  map_predicates do |map|
46
- map.elementList(in: DummyMADS, to: "elementList", class_name:"ComplexRDFDatastream::ElementList")
47
- map.extraProperty(in: DummyMADS, to: "elementValue", class_name:"ComplexRDFDatastream::Topic")
46
+ map.elementList(in: DummyMADS, to: 'elementList', class_name: 'ComplexRDFDatastream::ElementList')
47
+ map.extraProperty(in: DummyMADS, to: 'elementValue', class_name: 'ComplexRDFDatastream::Topic')
48
48
  end
49
49
  accepts_nested_attributes_for :elementList, :extraProperty
50
50
  end
@@ -52,11 +52,11 @@ describe "Nesting attribute behavior of RDFDatastream" do
52
52
  include ActiveFedora::RdfList
53
53
  rdf_type DummyMADS.elementList
54
54
  map_predicates do |map|
55
- map.topicElement(in: DummyMADS, to: "TopicElement", :class_name => "MadsTopicElement")
56
- map.temporalElement(in: DummyMADS, to: "TemporalElement")
57
- map.fullNameElement(in: DummyMADS, to: "FullNameElement")
58
- map.dateNameElement(in: DummyMADS, to: "DateNameElement")
59
- map.nameElement(in: DummyMADS, to: "NameElement")
55
+ map.topicElement(in: DummyMADS, to: 'TopicElement', :class_name => 'MadsTopicElement')
56
+ map.temporalElement(in: DummyMADS, to: 'TemporalElement')
57
+ map.fullNameElement(in: DummyMADS, to: 'FullNameElement')
58
+ map.dateNameElement(in: DummyMADS, to: 'DateNameElement')
59
+ map.nameElement(in: DummyMADS, to: 'NameElement')
60
60
  map.elementValue(in: DummyMADS)
61
61
  end
62
62
  accepts_nested_attributes_for :topicElement
@@ -74,58 +74,58 @@ describe "Nesting attribute behavior of RDFDatastream" do
74
74
  Object.send(:remove_const, :ComplexRDFDatastream)
75
75
  Object.send(:remove_const, :DummyMADS)
76
76
  end
77
- subject { ComplexRDFDatastream.new(double('inner object', :pid=>'foo', :new_record? =>true), 'descMetadata') }
78
- let(:params) do
79
- { myResource:
77
+ subject { ComplexRDFDatastream.new(double('inner object', :pid => 'foo', :new_record? => true), 'descMetadata') }
78
+ let(:params) do
79
+ { myResource:
80
80
  {
81
81
  topic_attributes: {
82
82
  '0' =>
83
83
  {
84
84
  elementList_attributes: [{
85
- topicElement_attributes: [{elementValue:"Cosmology"}]
85
+ topicElement_attributes: [{elementValue: 'Cosmology'}]
86
86
  }]
87
87
  },
88
88
  '1' =>
89
89
  {
90
90
  elementList_attributes: [{
91
- topicElement_attributes: {'0' => {elementValue:"Quantum Behavior"}}
91
+ topicElement_attributes: {'0' => {elementValue: 'Quantum Behavior'}}
92
92
  }]
93
93
  }
94
94
  },
95
95
  personalName_attributes: [
96
- {
96
+ {
97
97
  elementList_attributes: [{
98
- fullNameElement: "Jefferson, Thomas",
99
- dateNameElement: "1743-1826"
98
+ fullNameElement: 'Jefferson, Thomas',
99
+ dateNameElement: '1743-1826'
100
100
  }]
101
- }
101
+ }
102
102
  #, "Hemings, Sally"
103
- ],
103
+ ]
104
104
  }
105
105
  }
106
106
  end
107
107
 
108
- describe "on lists" do
109
- subject { ComplexRDFDatastream::PersonalName.new(RDF::Graph.new) }
110
- it "should accept a hash" do
111
- subject.elementList_attributes = [{ topicElement_attributes: {'0' => { elementValue:"Quantum Behavior" }, '1' => { elementValue:"Wave Function" }}}]
112
- subject.elementList.first[0].elementValue.should == ["Quantum Behavior"]
113
- subject.elementList.first[1].elementValue.should == ["Wave Function"]
108
+ describe 'on lists' do
109
+ subject { ComplexRDFDatastream::PersonalName.new(RDF::Graph.new) }
110
+ it 'should accept a hash' do
111
+ subject.elementList_attributes = [{ topicElement_attributes: {'0' => { elementValue: 'Quantum Behavior' }, '1' => { elementValue: 'Wave Function' }}}]
112
+ expect(subject.elementList.first[0].elementValue).to eq(['Quantum Behavior'])
113
+ expect(subject.elementList.first[1].elementValue).to eq(['Wave Function'])
114
114
 
115
115
  end
116
- it "should accept an array" do
117
- subject.elementList_attributes = [{ topicElement_attributes: [{ elementValue:"Quantum Behavior" }, { elementValue:"Wave Function" }]}]
118
- subject.elementList.first[0].elementValue.should == ["Quantum Behavior"]
119
- subject.elementList.first[1].elementValue.should == ["Wave Function"]
116
+ it 'should accept an array' do
117
+ subject.elementList_attributes = [{ topicElement_attributes: [{ elementValue: 'Quantum Behavior' }, { elementValue: 'Wave Function' }]}]
118
+ expect(subject.elementList.first[0].elementValue).to eq(['Quantum Behavior'])
119
+ expect(subject.elementList.first[1].elementValue).to eq(['Wave Function'])
120
120
  end
121
121
  end
122
122
 
123
- it "should create nested objects" do
123
+ it 'should create nested objects' do
124
124
  # Replace the graph's contents with the Hash
125
125
  subject.attributes = params[:myResource]
126
126
 
127
127
  # Here's how this would happen if we didn't have attributes=
128
- # personal_name = subject.personalName.build
128
+ # personal_name = subject.personalName.build
129
129
  # elem_list = personal_name.elementList.build
130
130
  # elem_list.fullNameElement = "Jefferson, Thomas"
131
131
  # elem_list.dateNameElement = "1743-1826"
@@ -133,35 +133,35 @@ describe "Nesting attribute behavior of RDFDatastream" do
133
133
  # elem_list = topic.elementList.build
134
134
  # elem_list.fullNameElement = 'Cosmology'
135
135
 
136
- subject.topic[0].elementList.first[0].elementValue.should == ["Cosmology"]
137
- subject.topic[1].elementList.first[0].elementValue.should == ["Quantum Behavior"]
138
- subject.personalName.first.elementList.first.fullNameElement.should == ["Jefferson, Thomas"]
139
- subject.personalName.first.elementList.first.dateNameElement.should == ["1743-1826"]
136
+ expect(subject.topic[0].elementList.first[0].elementValue).to eq(['Cosmology'])
137
+ expect(subject.topic[1].elementList.first[0].elementValue).to eq(['Quantum Behavior'])
138
+ expect(subject.personalName.first.elementList.first.fullNameElement).to eq(['Jefferson, Thomas'])
139
+ expect(subject.personalName.first.elementList.first.dateNameElement).to eq(['1743-1826'])
140
140
  end
141
141
  end
142
142
 
143
- describe "with an existing object" do
144
- before(:each) do
143
+ describe 'with an existing object' do
144
+ before(:each) do
145
145
  class SpecDatastream < ActiveFedora::NtriplesRDFDatastream
146
146
  map_predicates do |map|
147
- map.parts(:in=> RDF::DC, :to=>'hasPart', :class_name=>'Component')
147
+ map.parts(:in => RDF::DC, :to => 'hasPart', :class_name => 'Component')
148
148
  end
149
149
  accepts_nested_attributes_for :parts, allow_destroy: true
150
150
 
151
151
  class Component
152
152
  include ActiveFedora::RdfObject
153
153
  map_predicates do |map|
154
- map.label(:in=> RDF::DC, :to=>'title')
154
+ map.label(:in => RDF::DC, :to => 'title')
155
155
  end
156
156
  end
157
157
  end
158
158
 
159
159
  end
160
-
160
+
161
161
  after(:each) do
162
162
  Object.send(:remove_const, :SpecDatastream)
163
163
  end
164
- subject { SpecDatastream.new(double('inner object', :pid=>'foo', :new_record? =>true), 'descMetadata') }
164
+ subject { SpecDatastream.new(double('inner object', :pid => 'foo', :new_record? => true), 'descMetadata') }
165
165
  before do
166
166
  subject.attributes = { parts_attributes: [
167
167
  {label: 'Alternator'},
@@ -172,16 +172,16 @@ describe "Nesting attribute behavior of RDFDatastream" do
172
172
  let (:replace_object_id) { subject.parts[1].rdf_subject.to_s }
173
173
  let (:remove_object_id) { subject.parts[3].rdf_subject.to_s }
174
174
 
175
- it "should update nested objects" do
176
- subject.parts_attributes= [{id: replace_object_id, label: "Universal Joint"}, {label:"Oil Pump"}, {id: remove_object_id, _destroy: '1', label: "bar1 uno"}]
175
+ it 'should update nested objects' do
176
+ subject.parts_attributes = [{id: replace_object_id, label: 'Universal Joint'}, {label: 'Oil Pump'}, {id: remove_object_id, _destroy: '1', label: 'bar1 uno'}]
177
177
 
178
- subject.parts.map{|p| p.label.first}.should == ['Alternator', 'Universal Joint', 'Transmission', 'Oil Pump']
178
+ expect(subject.parts.map{|p| p.label.first}).to eq(['Alternator', 'Universal Joint', 'Transmission', 'Oil Pump'])
179
179
 
180
180
  end
181
- it "create a new object when the id is provided" do
182
- subject.parts_attributes= [{id: 'http://example.com/part#1', label: "Universal Joint"}]
183
- subject.parts.last.rdf_subject.should == 'http://example.com/part#1'
181
+ it 'create a new object when the id is provided' do
182
+ subject.parts_attributes = [{id: 'http://example.com/part#1', label: 'Universal Joint'}]
183
+ expect(subject.parts.last.rdf_subject).to eq('http://example.com/part#1')
184
184
  end
185
- end
185
+ end
186
186
  end
187
187
  end