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
@@ -2,14 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  require 'active_fedora'
4
4
  require 'active_fedora/model'
5
- require "rexml/document"
5
+ require 'rexml/document'
6
6
  include ActiveFedora::Model
7
7
 
8
8
  describe 'bugs' do
9
9
  before do
10
10
  class FooHistory < ActiveFedora::Base
11
- has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"someData" do |m|
12
- m.field "fubar", :string
11
+ has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'someData' do |m|
12
+ m.field 'fubar', :string
13
13
  end
14
14
  end
15
15
  @test_object = FooHistory.new
@@ -26,17 +26,17 @@ describe 'bugs' do
26
26
  }.to raise_error(ActiveFedora::ObjectNotFoundError)
27
27
  end
28
28
 
29
- it "should not clobber everything when setting a value" do
30
- @test_object.someData.fubar=['initial']
29
+ it 'should not clobber everything when setting a value' do
30
+ @test_object.someData.fubar = ['initial']
31
31
  @test_object.save!
32
32
 
33
33
  x = FooHistory.find(@test_object.pid)
34
- x.someData.fubar = ["replacement"] # set a new value
34
+ x.someData.fubar = ['replacement'] # set a new value
35
35
  x.save!
36
36
 
37
37
 
38
38
  x = FooHistory.find(@test_object.pid)
39
- x.someData.fubar.should == ["replacement"] # recall the value
39
+ expect(x.someData.fubar).to eq(['replacement']) # recall the value
40
40
  x.save
41
41
  end
42
42
  end
@@ -1,258 +1,258 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Nested Rdf Objects" do
4
- describe "without type" do
5
- before(:each) do
3
+ describe 'Nested Rdf Objects' do
4
+ describe 'without type' do
5
+ before(:each) do
6
6
  class SpecDatastream < ActiveFedora::NtriplesRDFDatastream
7
7
  map_predicates do |map|
8
- map.parts(:in=> RDF::DC, :to=>'hasPart', :class_name=>'Component')
8
+ map.parts(:in => RDF::DC, :to => 'hasPart', :class_name => 'Component')
9
9
  end
10
10
 
11
11
  class Component
12
12
  include ActiveFedora::RdfObject
13
13
  map_predicates do |map|
14
- map.label(:in=> RDF::DC, :to=>'title')
14
+ map.label(:in => RDF::DC, :to => 'title')
15
15
  end
16
16
  end
17
17
  end
18
18
 
19
19
  end
20
-
20
+
21
21
  after(:each) do
22
22
  Object.send(:remove_const, :SpecDatastream)
23
23
  end
24
24
 
25
25
  let (:ds) do
26
- mock_obj = double(:mock_obj, :pid=>'test:124', :new_record? => true)
26
+ mock_obj = double(:mock_obj, :pid => 'test:124', :new_record? => true)
27
27
  ds = SpecDatastream.new(mock_obj)
28
28
  end
29
29
 
30
- describe "#new_record?" do
31
- it "should be true when its built" do
30
+ describe '#new_record?' do
31
+ it 'should be true when its built' do
32
32
  v = ds.parts.build(label: 'Alternator')
33
- v.should be_new_record
33
+ expect(v).to be_new_record
34
34
  end
35
35
 
36
36
  it "should not be new when it's loaded from fedora" do
37
37
  ds.content = '_:g70324142325120 <http://purl.org/dc/terms/title> "Alternator" .
38
38
  <info:fedora/test:124> <http://purl.org/dc/terms/hasPart> _:g70324142325120 .'
39
- ds.parts.first.should_not be_new_record
39
+ expect(ds.parts.first).not_to be_new_record
40
40
  end
41
41
  end
42
42
 
43
- it "should not choke on invalid data" do
43
+ it 'should not choke on invalid data' do
44
44
  # set a string in the graph where model expects a node
45
- ds.parts = ["foo"]
45
+ ds.parts = ['foo']
46
46
  expect {ds.parts.inspect}.to raise_error(ArgumentError, "Expected the value of http://purl.org/dc/terms/hasPart to be an RDF object but it is a String \"foo\"")
47
47
  end
48
-
49
- it "should be able to nest a complex object" do
48
+
49
+ it 'should be able to nest a complex object' do
50
50
  comp = SpecDatastream::Component.new(ds.graph)
51
- comp.label = ["Alternator"]
51
+ comp.label = ['Alternator']
52
52
  ds.parts = comp
53
- ds.parts.first.label.should == ["Alternator"]
53
+ expect(ds.parts.first.label).to eq(['Alternator'])
54
54
  end
55
55
 
56
- it "should be able to replace attributes" do
56
+ it 'should be able to replace attributes' do
57
57
  v = ds.parts.build(label: 'Alternator')
58
- ds.parts.first.label.should == ['Alternator']
58
+ expect(ds.parts.first.label).to eq(['Alternator'])
59
59
  ds.parts.first.label = ['Distributor']
60
- ds.parts.first.label.should == ['Distributor']
60
+ expect(ds.parts.first.label).to eq(['Distributor'])
61
61
  end
62
62
 
63
- it "should be able to replace objects" do
63
+ it 'should be able to replace objects' do
64
64
  ds.parts.build(label: 'Alternator')
65
65
  ds.parts.build(label: 'Distributor')
66
- ds.parts.size.should == 2
66
+ expect(ds.parts.size).to eq(2)
67
67
  comp = SpecDatastream::Component.new(ds.graph)
68
- comp.label = "Injector port"
68
+ comp.label = 'Injector port'
69
69
  ds.parts = [comp]
70
- ds.parts.size.should == 1
70
+ expect(ds.parts.size).to eq(1)
71
71
  end
72
72
 
73
- it "should be able to nest many complex objects" do
73
+ it 'should be able to nest many complex objects' do
74
74
  comp1 = SpecDatastream::Component.new ds.graph
75
- comp1.label = ["Alternator"]
75
+ comp1.label = ['Alternator']
76
76
  comp2 = SpecDatastream::Component.new ds.graph
77
- comp2.label = ["Crankshaft"]
77
+ comp2.label = ['Crankshaft']
78
78
  ds.parts = [comp1, comp2]
79
- ds.parts.first.label.should == ["Alternator"]
80
- ds.parts.last.label.should == ["Crankshaft"]
79
+ expect(ds.parts.first.label).to eq(['Alternator'])
80
+ expect(ds.parts.last.label).to eq(['Crankshaft'])
81
81
  end
82
82
 
83
- it "should be able to clear complex objects" do
83
+ it 'should be able to clear complex objects' do
84
84
  comp1 = SpecDatastream::Component.new ds.graph
85
- comp1.label = ["Alternator"]
85
+ comp1.label = ['Alternator']
86
86
  comp2 = SpecDatastream::Component.new ds.graph
87
- comp2.label = ["Crankshaft"]
87
+ comp2.label = ['Crankshaft']
88
88
  ds.parts = [comp1, comp2]
89
89
  ds.parts = []
90
- ds.parts.should == []
90
+ expect(ds.parts).to eq([])
91
91
  end
92
92
 
93
- it "should load complex objects" do
93
+ it 'should load complex objects' do
94
94
  ds.content = <<END
95
95
  _:g70350851837440 <http://purl.org/dc/terms/title> "Alternator" .
96
96
  <info:fedora/test:124> <http://purl.org/dc/terms/hasPart> _:g70350851837440 .
97
97
  <info:fedora/test:124> <http://purl.org/dc/terms/hasPart> _:g70350851833380 .
98
98
  _:g70350851833380 <http://purl.org/dc/terms/title> "Crankshaft" .
99
99
  END
100
- ds.parts.first.label.should == ["Alternator"]
100
+ expect(ds.parts.first.label).to eq(['Alternator'])
101
101
  end
102
102
 
103
103
  it "should build complex objects when a parent node doesn't exist" do
104
104
  part = ds.parts.build
105
- part.should be_kind_of SpecDatastream::Component
106
- part.label = "Wheel bearing"
107
- ds.parts.first.label.should == ['Wheel bearing']
105
+ expect(part).to be_kind_of SpecDatastream::Component
106
+ part.label = 'Wheel bearing'
107
+ expect(ds.parts.first.label).to eq(['Wheel bearing'])
108
108
  end
109
109
 
110
- it "should not create a child node when hitting the accessor" do
110
+ it 'should not create a child node when hitting the accessor' do
111
111
  ds.parts
112
- ds.parts.first.should be_nil
113
- ds.serialize.should == ''
112
+ expect(ds.parts.first).to be_nil
113
+ expect(ds.serialize).to eq('')
114
114
  end
115
115
 
116
- it "should build complex objects when a parent node exists" do
116
+ it 'should build complex objects when a parent node exists' do
117
117
  part = ds.parts.build
118
- part.should be_kind_of SpecDatastream::Component
119
- part.label = "Wheel bearing"
120
- ds.parts.first.label.should == ['Wheel bearing']
118
+ expect(part).to be_kind_of SpecDatastream::Component
119
+ part.label = 'Wheel bearing'
120
+ expect(ds.parts.first.label).to eq(['Wheel bearing'])
121
121
  end
122
122
 
123
- describe "#first_or_create" do
124
- it "should return a result if the predicate exists" do
123
+ describe '#first_or_create' do
124
+ it 'should return a result if the predicate exists' do
125
125
  part1 = ds.parts.build
126
126
  part2 = ds.parts.build
127
- ds.parts.first_or_create.should == part1
127
+ expect(ds.parts.first_or_create).to eq(part1)
128
128
  end
129
129
 
130
130
  it "should create a new result if the predicate doesn't exist" do
131
- ds.parts.should == []
131
+ expect(ds.parts).to eq([])
132
132
  part = ds.parts.first_or_create(label: 'Front control arm bushing')
133
- part.label.should == ['Front control arm bushing']
134
- ds.parts.should == [part]
133
+ expect(part.label).to eq(['Front control arm bushing'])
134
+ expect(ds.parts).to eq([part])
135
135
  end
136
136
 
137
137
  end
138
138
  end
139
139
 
140
140
 
141
- describe "with type" do
142
- describe "one class per assertion" do
143
- before(:each) do
141
+ describe 'with type' do
142
+ describe 'one class per assertion' do
143
+ before(:each) do
144
144
  class SpecDatastream < ActiveFedora::NtriplesRDFDatastream
145
145
  map_predicates do |map|
146
- map.mediator(:in=> RDF::DC, :class_name=>'MediatorUser')
146
+ map.mediator(:in => RDF::DC, :class_name => 'MediatorUser')
147
147
  end
148
148
 
149
149
  class MediatorUser
150
150
  include ActiveFedora::RdfObject
151
151
  rdf_type RDF::DC.AgentClass
152
152
  map_predicates do |map|
153
- map.title(:in=> RDF::DC)
153
+ map.title(:in => RDF::DC)
154
154
  end
155
155
  end
156
156
  end
157
157
  end
158
-
158
+
159
159
  after(:each) do
160
160
  Object.send(:remove_const, :SpecDatastream)
161
161
  end
162
162
 
163
163
  let (:ds) do
164
- mock_obj = double(:mock_obj, :pid=>'test:124', :new_record? => true)
164
+ mock_obj = double(:mock_obj, :pid => 'test:124', :new_record? => true)
165
165
  ds = SpecDatastream.new(mock_obj)
166
166
  end
167
167
 
168
168
 
169
- it "should store the type of complex objects when type is specified" do
169
+ it 'should store the type of complex objects when type is specified' do
170
170
  comp = SpecDatastream::MediatorUser.new ds.graph
171
- comp.title = ["Doctor"]
171
+ comp.title = ['Doctor']
172
172
  ds.mediator = comp
173
- ds.mediator.first.type.first.should be_instance_of RDF::URI
174
- ds.mediator.first.type.first.to_s.should == "http://purl.org/dc/terms/AgentClass"
175
- ds.mediator.first.title.first.should == 'Doctor'
173
+ expect(ds.mediator.first.type.first).to be_instance_of RDF::Vocabulary::Term
174
+ expect(ds.mediator.first.type.first.to_s).to eq('http://purl.org/dc/terms/AgentClass')
175
+ expect(ds.mediator.first.title.first).to eq('Doctor')
176
176
  end
177
177
 
178
- it "should add the type of complex object when it is not provided" do
178
+ it 'should add the type of complex object when it is not provided' do
179
179
  ds.content = <<END
180
180
  _:g70350851837440 <http://purl.org/dc/terms/title> "Mediation Person" .
181
181
  <info:fedora/test:124> <http://purl.org/dc/terms/mediator> _:g70350851837440 .
182
182
  END
183
- ds.mediator.first.type.first.to_s.should == "http://purl.org/dc/terms/AgentClass"
183
+ expect(ds.mediator.first.type.first.to_s).to eq('http://purl.org/dc/terms/AgentClass')
184
184
  end
185
185
 
186
- it "should add load the type of complex objects when provided (superceeding what is specified by the class)" do
186
+ it 'should add load the type of complex objects when provided (superceeding what is specified by the class)' do
187
187
  ds.content = <<END
188
188
  _:g70350851837440 <http://purl.org/dc/terms/title> "Mediation Orgainzation" .
189
189
  _:g70350851837440 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.ebu.ch/metadata/ontologies/ebucore#Organisation> .
190
190
  <info:fedora/test:124> <http://purl.org/dc/terms/mediator> _:g70350851837440 .
191
191
  END
192
- ds.mediator.first.type.first.to_s.should == "http://www.ebu.ch/metadata/ontologies/ebucore#Organisation"
192
+ expect(ds.mediator.first.type.first.to_s).to eq('http://www.ebu.ch/metadata/ontologies/ebucore#Organisation')
193
193
  end
194
194
  end
195
195
 
196
- describe "shared assertion to different classes" do
197
- before(:each) do
198
- class EbuCore < RDF::Vocabulary("http://www.ebu.ch/metadata/ontologies/ebucore#")
196
+ describe 'shared assertion to different classes' do
197
+ before(:each) do
198
+ class EbuCore < RDF::Vocabulary('http://www.ebu.ch/metadata/ontologies/ebucore#')
199
199
  property :isEpisodeOf
200
200
  property :title
201
201
  end
202
-
202
+
203
203
  class SpecDatastream < ActiveFedora::NtriplesRDFDatastream
204
204
  map_predicates do |map|
205
- map.series(:to => 'isEpisodeOf', :in=> EbuCore, :class_name=>'Series')
206
- map.program(:to => 'isEpisodeOf', :in=> EbuCore, :class_name=>'Program')
205
+ map.series(:to => 'isEpisodeOf', :in => EbuCore, :class_name => 'Series')
206
+ map.program(:to => 'isEpisodeOf', :in => EbuCore, :class_name => 'Program')
207
207
  end
208
208
 
209
209
  class Series
210
210
  include ActiveFedora::RdfObject
211
211
  rdf_type 'http://www.ebu.ch/metadata/ontologies/ebucore#Series'
212
212
  map_predicates do |map|
213
- map.title(:in=> EbuCore)
213
+ map.title(:in => EbuCore)
214
214
  end
215
215
  end
216
216
 
217
- class Program
217
+ class Program
218
218
  include ActiveFedora::RdfObject
219
219
  rdf_type 'http://www.ebu.ch/metadata/ontologies/ebucore#Programme'
220
220
  map_predicates do |map|
221
- map.title(:in=> EbuCore)
221
+ map.title(:in => EbuCore)
222
222
  end
223
223
  end
224
224
  end
225
225
 
226
226
  end
227
-
227
+
228
228
  after(:each) do
229
229
  Object.send(:remove_const, :SpecDatastream)
230
230
  end
231
231
 
232
232
  let (:ds) do
233
- mock_obj = double(:mock_obj, :pid=>'test:124', :new_record? => true)
233
+ mock_obj = double(:mock_obj, :pid => 'test:124', :new_record? => true)
234
234
  ds = SpecDatastream.new(mock_obj)
235
235
  end
236
236
 
237
237
 
238
- it "should store the type of complex objects when type is specified" do
238
+ it 'should store the type of complex objects when type is specified' do
239
239
  series = SpecDatastream::Series.new ds.graph
240
- series.title = ["renovating bathrooms"]
240
+ series.title = ['renovating bathrooms']
241
241
  ds.series = series
242
242
 
243
243
  program = SpecDatastream::Program.new ds.graph
244
- program.title = ["This old House"]
244
+ program.title = ['This old House']
245
245
  ds.program = program
246
246
 
247
- ds.program.first.type.size.should == 1
248
- ds.program.first.type.first.to_s.should == 'http://www.ebu.ch/metadata/ontologies/ebucore#Programme'
249
- ds.series.first.type.size.should == 1
250
- ds.series.first.type.first.to_s.should == 'http://www.ebu.ch/metadata/ontologies/ebucore#Series'
247
+ expect(ds.program.first.type.size).to eq(1)
248
+ expect(ds.program.first.type.first.to_s).to eq('http://www.ebu.ch/metadata/ontologies/ebucore#Programme')
249
+ expect(ds.series.first.type.size).to eq(1)
250
+ expect(ds.series.first.type.first.to_s).to eq('http://www.ebu.ch/metadata/ontologies/ebucore#Series')
251
251
  end
252
252
 
253
- it "should create an object of the correct type" do
254
- ds.program.build.should be_kind_of SpecDatastream::Program
255
- ds.series.build.should be_kind_of SpecDatastream::Series
253
+ it 'should create an object of the correct type' do
254
+ expect(ds.program.build).to be_kind_of SpecDatastream::Program
255
+ expect(ds.series.build).to be_kind_of SpecDatastream::Series
256
256
  end
257
257
  end
258
258
  end
@@ -4,8 +4,8 @@ describe ActiveFedora::DatastreamCollections do
4
4
  before(:all) do
5
5
  class MockAFBaseDatastream < ActiveFedora::Base
6
6
  include ActiveFedora::DatastreamCollections
7
- has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
8
- has_datastream :name=>"high", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
7
+ has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
8
+ has_datastream :name => 'high', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
9
9
  end
10
10
  end
11
11
 
@@ -15,113 +15,113 @@ describe ActiveFedora::DatastreamCollections do
15
15
  describe '#add_named_datastream' do
16
16
  it 'should add a datastream with the given name to the object in fedora' do
17
17
  @test_object2 = MockAFBaseDatastream.new
18
- f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
19
- f2 = File.open(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ), 'rb')
20
- f2.stub(:original_filename).and_return("dino.jpg")
21
- f.stub(:content_type).and_return("image/jpeg")
22
- @test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f, :label=>"testDS"})
23
- @test_object2.add_named_datastream("high",{:content_type=>"image/jpeg",:blob=>f2})
18
+ f = File.open(File.join( File.dirname(__FILE__), '../fixtures/minivan.jpg'), 'rb')
19
+ f2 = File.open(File.join( File.dirname(__FILE__), '../fixtures/dino.jpg' ), 'rb')
20
+ allow(f2).to receive(:original_filename).and_return('dino.jpg')
21
+ allow(f).to receive(:content_type).and_return('image/jpeg')
22
+ @test_object2.add_named_datastream('thumbnail', {:content_type => 'image/jpeg', :blob => f, :label => 'testDS'})
23
+ @test_object2.add_named_datastream('high', {:content_type => 'image/jpeg', :blob => f2})
24
24
  ds = @test_object2.thumbnail.first
25
25
  ds2 = @test_object2.high.first
26
26
  @test_object2.save
27
27
  @test_object2 = MockAFBaseDatastream.find(@test_object2.pid)
28
- @test_object2.named_datastreams.keys.size.should == 2
29
- @test_object2.named_datastreams.keys.include?("thumbnail").should == true
30
- @test_object2.named_datastreams.keys.include?("high").should == true
31
- @test_object2.named_datastreams["thumbnail"].size.should == 1
32
- @test_object2.named_datastreams["high"].size.should == 1
33
- t2_thumb1 = @test_object2.named_datastreams["thumbnail"].first
34
- t2_thumb1.dsid.should == ds.dsid
35
- t2_thumb1.mimeType.should == ds.mimeType
36
- t2_thumb1.pid.should == ds.pid
37
- t2_thumb1.dsLabel.should == ds.dsLabel
38
- t2_thumb1.controlGroup.should == ds.controlGroup
39
- t2_high1 = @test_object2.named_datastreams["high"].first
40
- t2_high1.dsid.should == ds2.dsid
41
- t2_high1.mimeType.should == ds2.mimeType
42
- t2_high1.pid.should == ds2.pid
43
- t2_high1.dsLabel.should == ds2.dsLabel
44
- t2_high1.controlGroup.should == ds2.controlGroup
28
+ expect(@test_object2.named_datastreams.keys.size).to eq(2)
29
+ expect(@test_object2.named_datastreams.keys.include?('thumbnail')).to eq(true)
30
+ expect(@test_object2.named_datastreams.keys.include?('high')).to eq(true)
31
+ expect(@test_object2.named_datastreams['thumbnail'].size).to eq(1)
32
+ expect(@test_object2.named_datastreams['high'].size).to eq(1)
33
+ t2_thumb1 = @test_object2.named_datastreams['thumbnail'].first
34
+ expect(t2_thumb1.dsid).to eq(ds.dsid)
35
+ expect(t2_thumb1.mimeType).to eq(ds.mimeType)
36
+ expect(t2_thumb1.pid).to eq(ds.pid)
37
+ expect(t2_thumb1.dsLabel).to eq(ds.dsLabel)
38
+ expect(t2_thumb1.controlGroup).to eq(ds.controlGroup)
39
+ t2_high1 = @test_object2.named_datastreams['high'].first
40
+ expect(t2_high1.dsid).to eq(ds2.dsid)
41
+ expect(t2_high1.mimeType).to eq(ds2.mimeType)
42
+ expect(t2_high1.pid).to eq(ds2.pid)
43
+ expect(t2_high1.dsLabel).to eq(ds2.dsLabel)
44
+ expect(t2_high1.controlGroup).to eq(ds2.controlGroup)
45
45
  end
46
46
  end
47
-
47
+
48
48
  describe '#add_named_file_datastream' do
49
49
  it 'should add a file datastream with the given name to the object in fedora' do
50
50
  @test_object2 = MockAFBaseDatastream.new
51
- f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
52
- f.stub(:content_type).and_return("image/jpeg")
53
- @test_object2.add_named_file_datastream("thumbnail",f)
51
+ f = File.open(File.join( File.dirname(__FILE__), '../fixtures/minivan.jpg'), 'rb')
52
+ allow(f).to receive(:content_type).and_return('image/jpeg')
53
+ @test_object2.add_named_file_datastream('thumbnail', f)
54
54
  ds = @test_object2.thumbnail.first
55
55
  @test_object2.save
56
56
  @test_object2 = MockAFBaseDatastream.find(@test_object2.pid)
57
- @test_object2.named_datastreams["thumbnail"].size.should == 1
58
- t2_thumb1 = @test_object2.named_datastreams["thumbnail"].first
59
- t2_thumb1.dsid.should == "THUMB1"
60
- t2_thumb1.mimeType.should == "image/jpeg"
61
- t2_thumb1.pid.should == @test_object2.pid
62
- t2_thumb1.dsLabel.should == "minivan.jpg"
63
- t2_thumb1.controlGroup.should == "M"
57
+ expect(@test_object2.named_datastreams['thumbnail'].size).to eq(1)
58
+ t2_thumb1 = @test_object2.named_datastreams['thumbnail'].first
59
+ expect(t2_thumb1.dsid).to eq('THUMB1')
60
+ expect(t2_thumb1.mimeType).to eq('image/jpeg')
61
+ expect(t2_thumb1.pid).to eq(@test_object2.pid)
62
+ expect(t2_thumb1.dsLabel).to eq('minivan.jpg')
63
+ expect(t2_thumb1.controlGroup).to eq('M')
64
64
  end
65
65
  end
66
-
66
+
67
67
  describe '#update_named_datastream' do
68
68
  it 'should update a named datastream to have a new file' do
69
69
  @test_object2 = MockAFBaseDatastream.new
70
- f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
70
+ f = File.open(File.join( File.dirname(__FILE__), '../fixtures/minivan.jpg'), 'rb')
71
71
  minivan = f.read
72
72
  f.rewind
73
- f2 = File.open(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ), 'rb')
73
+ f2 = File.open(File.join( File.dirname(__FILE__), '../fixtures/dino.jpg' ), 'rb')
74
74
  dino = f2.read
75
75
  f2.rewind
76
- f.stub(:content_type).and_return("image/jpeg")
77
- f.stub(:original_filename).and_return("minivan.jpg")
78
- f2.stub(:content_type).and_return("image/jpeg")
79
- f2.stub(:original_filename).and_return("dino.jpg")
76
+ allow(f).to receive(:content_type).and_return('image/jpeg')
77
+ allow(f).to receive(:original_filename).and_return('minivan.jpg')
78
+ allow(f2).to receive(:content_type).and_return('image/jpeg')
79
+ allow(f2).to receive(:original_filename).and_return('dino.jpg')
80
80
  #check raise exception if dsid not supplied
81
- @test_object2.add_named_datastream("thumbnail",{:file=>f})
81
+ @test_object2.add_named_datastream('thumbnail', {:file => f})
82
82
  @test_object2.save
83
83
  @test_object2 = MockAFBaseDatastream.find(@test_object2.pid)
84
-
85
- @test_object2.thumbnail.size.should == 1
86
- @test_object2.thumbnail_ids == ["THUMB1"]
84
+
85
+ expect(@test_object2.thumbnail.size).to eq(1)
86
+ @test_object2.thumbnail_ids == ['THUMB1']
87
87
  ds = @test_object2.thumbnail.first
88
- ds.dsid.should == "THUMB1"
89
- ds.mimeType.should == "image/jpeg"
90
- ds.pid.should == @test_object2.pid
91
- ds.dsLabel.should == "minivan.jpg"
92
- ds.controlGroup.should == "M"
88
+ expect(ds.dsid).to eq('THUMB1')
89
+ expect(ds.mimeType).to eq('image/jpeg')
90
+ expect(ds.pid).to eq(@test_object2.pid)
91
+ expect(ds.dsLabel).to eq('minivan.jpg')
92
+ expect(ds.controlGroup).to eq('M')
93
93
 
94
- ds.content.should == minivan
95
- @test_object2.update_named_datastream("thumbnail",{:file=>f2,:dsid=>"THUMB1"})
94
+ expect(ds.content).to eq(minivan)
95
+ @test_object2.update_named_datastream('thumbnail', {:file => f2, :dsid => 'THUMB1'})
96
96
  @test_object2.save
97
97
  @test_object2 = MockAFBaseDatastream.find(@test_object2.pid)
98
- @test_object2.thumbnail.size.should == 1
99
- @test_object2.thumbnail_ids == ["THUMB1"]
98
+ expect(@test_object2.thumbnail.size).to eq(1)
99
+ @test_object2.thumbnail_ids == ['THUMB1']
100
100
  ds2 = @test_object2.thumbnail.first
101
- ds2.dsid.should == "THUMB1"
102
- ds2.mimeType.should == "image/jpeg"
103
- ds2.pid.should == @test_object2.pid
104
- ds2.dsLabel.should == "dino.jpg"
105
- ds2.controlGroup.should == "M"
106
- (ds2.content == dino).should be_true
101
+ expect(ds2.dsid).to eq('THUMB1')
102
+ expect(ds2.mimeType).to eq('image/jpeg')
103
+ expect(ds2.pid).to eq(@test_object2.pid)
104
+ expect(ds2.dsLabel).to eq('dino.jpg')
105
+ expect(ds2.controlGroup).to eq('M')
106
+ expect(ds2.content == dino).to be_truthy
107
107
  end
108
108
  end
109
-
109
+
110
110
  describe '#named_datastreams_ids' do
111
111
  it 'should return a hash of datastream name to an array of dsids' do
112
112
  @test_object2 = MockAFBaseDatastream.new
113
- f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
114
- f2 = File.open(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ), 'rb')
115
- @test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f})
116
- @test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f2})
113
+ f = File.open(File.join( File.dirname(__FILE__), '../fixtures/minivan.jpg'), 'rb')
114
+ f2 = File.open(File.join( File.dirname(__FILE__), '../fixtures/dino.jpg' ), 'rb')
115
+ @test_object2.add_named_datastream('thumbnail', {:content_type => 'image/jpeg', :blob => f})
116
+ @test_object2.add_named_datastream('thumbnail', {:content_type => 'image/jpeg', :blob => f2})
117
117
  @test_object2.save
118
118
  @test_object2 = MockAFBaseDatastream.find(@test_object2.pid)
119
119
  named_datastreams_ids = @test_object2.named_datastreams_ids
120
120
 
121
121
  expect(named_datastreams_ids.keys.sort).to eq(['high', 'thumbnail'])
122
122
  expect(named_datastreams_ids['high']).to eq([])
123
- expect(named_datastreams_ids['thumbnail'].sort).to eq(["THUMB1", "THUMB2"])
123
+ expect(named_datastreams_ids['thumbnail'].sort).to eq(['THUMB1', 'THUMB2'])
124
124
  end
125
125
  end
126
126
 
127
- end
127
+ end