active-fedora 8.2.1 → 8.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/active-fedora.gemspec +1 -2
  3. data/lib/active_fedora/datastream_collections.rb +4 -8
  4. data/lib/active_fedora/datastreams.rb +7 -9
  5. data/lib/active_fedora/version.rb +1 -1
  6. data/spec/config_helper.rb +3 -3
  7. data/spec/integration/associations_spec.rb +76 -76
  8. data/spec/integration/auditable_spec.rb +7 -7
  9. data/spec/integration/autosave_association_spec.rb +3 -3
  10. data/spec/integration/base_spec.rb +51 -51
  11. data/spec/integration/belongs_to_association_spec.rb +27 -27
  12. data/spec/integration/bug_spec.rb +1 -1
  13. data/spec/integration/collection_association_spec.rb +2 -2
  14. data/spec/integration/complex_rdf_datastream_spec.rb +32 -32
  15. data/spec/integration/datastream_collections_spec.rb +42 -42
  16. data/spec/integration/datastream_spec.rb +19 -19
  17. data/spec/integration/datastreams_spec.rb +25 -25
  18. data/spec/integration/delete_all_spec.rb +5 -5
  19. data/spec/integration/fedora_solr_sync_spec.rb +1 -1
  20. data/spec/integration/full_featured_model_spec.rb +9 -9
  21. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +46 -47
  22. data/spec/integration/has_many_associations_spec.rb +17 -17
  23. data/spec/integration/json_serialization_spec.rb +2 -2
  24. data/spec/integration/load_from_solr_spec.rb +1 -1
  25. data/spec/integration/model_spec.rb +9 -9
  26. data/spec/integration/nested_attribute_spec.rb +17 -17
  27. data/spec/integration/ntriples_datastream_spec.rb +43 -43
  28. data/spec/integration/om_datastream_spec.rb +37 -37
  29. data/spec/integration/persistence_spec.rb +1 -1
  30. data/spec/integration/rdf_nested_attributes_spec.rb +9 -9
  31. data/spec/integration/relation_delegation_spec.rb +7 -7
  32. data/spec/integration/relation_spec.rb +2 -2
  33. data/spec/integration/rels_ext_datastream_spec.rb +3 -3
  34. data/spec/integration/scoped_query_spec.rb +14 -14
  35. data/spec/integration/solr_service_spec.rb +24 -24
  36. data/spec/support/mock_fedora.rb +9 -10
  37. data/spec/unit/active_fedora_spec.rb +20 -20
  38. data/spec/unit/attributes_spec.rb +24 -24
  39. data/spec/unit/base_active_model_spec.rb +6 -6
  40. data/spec/unit/base_cma_spec.rb +2 -2
  41. data/spec/unit/base_datastream_management_spec.rb +7 -7
  42. data/spec/unit/base_extra_spec.rb +20 -20
  43. data/spec/unit/base_spec.rb +141 -141
  44. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
  45. data/spec/unit/callback_spec.rb +12 -12
  46. data/spec/unit/code_configurator_spec.rb +7 -7
  47. data/spec/unit/config_spec.rb +2 -2
  48. data/spec/unit/content_model_spec.rb +19 -20
  49. data/spec/unit/core_spec.rb +1 -1
  50. data/spec/unit/datastream_collections_spec.rb +101 -101
  51. data/spec/unit/datastream_spec.rb +12 -12
  52. data/spec/unit/datastreams_spec.rb +39 -39
  53. data/spec/unit/file_configurator_spec.rb +117 -117
  54. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +16 -16
  55. data/spec/unit/has_many_collection_spec.rb +5 -5
  56. data/spec/unit/inheritance_spec.rb +5 -5
  57. data/spec/unit/model_spec.rb +5 -5
  58. data/spec/unit/nom_datastream_spec.rb +5 -5
  59. data/spec/unit/ntriples_datastream_spec.rb +56 -56
  60. data/spec/unit/om_datastream_spec.rb +99 -99
  61. data/spec/unit/persistence_spec.rb +2 -2
  62. data/spec/unit/predicates_spec.rb +28 -28
  63. data/spec/unit/property_spec.rb +5 -5
  64. data/spec/unit/qualified_dublin_core_datastream_spec.rb +10 -10
  65. data/spec/unit/query_spec.rb +66 -66
  66. data/spec/unit/rdf_datastream_spec.rb +10 -10
  67. data/spec/unit/rdf_resource_datastream_spec.rb +2 -2
  68. data/spec/unit/rdf_xml_writer_spec.rb +3 -3
  69. data/spec/unit/rdfxml_rdf_datastream_spec.rb +9 -9
  70. data/spec/unit/relationship_graph_spec.rb +31 -31
  71. data/spec/unit/reload_on_save_spec.rb +3 -3
  72. data/spec/unit/rels_ext_datastream_spec.rb +28 -28
  73. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +11 -11
  74. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +11 -11
  75. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +11 -11
  76. data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +7 -7
  77. data/spec/unit/rubydora_connection_spec.rb +3 -3
  78. data/spec/unit/semantic_node_spec.rb +17 -17
  79. data/spec/unit/serializers_spec.rb +1 -1
  80. data/spec/unit/service_definitions_spec.rb +11 -11
  81. data/spec/unit/simple_datastream_spec.rb +6 -6
  82. data/spec/unit/solr_config_options_spec.rb +10 -10
  83. data/spec/unit/solr_digital_object_spec.rb +4 -4
  84. data/spec/unit/solr_service_spec.rb +41 -41
  85. data/spec/unit/unsaved_digital_object_spec.rb +8 -8
  86. data/spec/unit/validations_spec.rb +6 -6
  87. metadata +4 -4
@@ -25,14 +25,14 @@ describe "Nested Rdf Objects" do
25
25
  describe "#new_record?" do
26
26
  it "should be true when its built" do
27
27
  v = ds.parts.build(label: 'Alternator')
28
- v.should be_new_record
28
+ expect(v).to be_new_record
29
29
  end
30
30
 
31
31
  it "should not be new when it's loaded from fedora" do
32
32
  ds.content = '_:g70324142325120 <http://purl.org/dc/terms/title> "Alternator" .
33
33
  <info:fedora/test:124> <http://purl.org/dc/terms/hasPart> _:g70324142325120 .'
34
34
  ds.resource.persist!
35
- ds.parts.first.should_not be_new_record
35
+ expect(ds.parts.first).not_to be_new_record
36
36
  end
37
37
  end
38
38
 
@@ -40,24 +40,24 @@ describe "Nested Rdf Objects" do
40
40
  comp = SpecDatastream::Component.new(ds.graph)
41
41
  comp.label = ["Alternator"]
42
42
  ds.parts = comp
43
- ds.parts.first.label.should == ["Alternator"]
43
+ expect(ds.parts.first.label).to eq(["Alternator"])
44
44
  end
45
45
 
46
46
  it "should be able to replace attributes" do
47
47
  v = ds.parts.build(label: 'Alternator')
48
- ds.parts.first.label.should == ['Alternator']
48
+ expect(ds.parts.first.label).to eq(['Alternator'])
49
49
  ds.parts.first.label = ['Distributor']
50
- ds.parts.first.label.should == ['Distributor']
50
+ expect(ds.parts.first.label).to eq(['Distributor'])
51
51
  end
52
52
 
53
53
  it "should be able to replace objects" do
54
54
  ds.parts.build(label: 'Alternator')
55
55
  ds.parts.build(label: 'Distributor')
56
- ds.parts.size.should == 2
56
+ expect(ds.parts.size).to eq(2)
57
57
  comp = SpecDatastream::Component.new(ds.graph)
58
58
  comp.label = "Injector port"
59
59
  ds.parts = [comp]
60
- ds.parts.size.should == 1
60
+ expect(ds.parts.size).to eq(1)
61
61
  end
62
62
 
63
63
  it "should be able to nest many complex objects" do
@@ -66,8 +66,8 @@ describe "Nested Rdf Objects" do
66
66
  comp2 = SpecDatastream::Component.new ds.graph
67
67
  comp2.label = ["Crankshaft"]
68
68
  ds.parts = [comp1, comp2]
69
- ds.parts.first.label.should == ["Alternator"]
70
- ds.parts.last.label.should == ["Crankshaft"]
69
+ expect(ds.parts.first.label).to eq(["Alternator"])
70
+ expect(ds.parts.last.label).to eq(["Crankshaft"])
71
71
  end
72
72
 
73
73
  it "should be able to clear complex objects" do
@@ -77,7 +77,7 @@ describe "Nested Rdf Objects" do
77
77
  comp2.label = ["Crankshaft"]
78
78
  ds.parts = [comp1, comp2]
79
79
  ds.parts = []
80
- ds.parts.should == []
80
+ expect(ds.parts).to eq([])
81
81
  end
82
82
 
83
83
  it "should load complex objects" do
@@ -87,41 +87,41 @@ _:g70350851837440 <http://purl.org/dc/terms/title> "Alternator" .
87
87
  <info:fedora/test:124> <http://purl.org/dc/terms/hasPart> _:g70350851833380 .
88
88
  _:g70350851833380 <http://purl.org/dc/terms/title> "Crankshaft" .
89
89
  END
90
- ds.parts.first.label.should == ["Alternator"]
90
+ expect(ds.parts.first.label).to eq(["Alternator"])
91
91
  end
92
92
 
93
93
  it "should build complex objects when a parent node doesn't exist" do
94
94
  part = ds.parts.build
95
- part.should be_kind_of SpecDatastream::Component
95
+ expect(part).to be_kind_of SpecDatastream::Component
96
96
  part.label = "Wheel bearing"
97
- ds.parts.first.label.should == ['Wheel bearing']
97
+ expect(ds.parts.first.label).to eq(['Wheel bearing'])
98
98
  end
99
99
 
100
100
  it "should not create a child node when hitting the accessor" do
101
101
  ds.parts
102
- ds.parts.first.should be_nil
103
- ds.serialize.should == ''
102
+ expect(ds.parts.first).to be_nil
103
+ expect(ds.serialize).to eq('')
104
104
  end
105
105
 
106
106
  it "should build complex objects when a parent node exists" do
107
107
  part = ds.parts.build
108
- part.should be_kind_of SpecDatastream::Component
108
+ expect(part).to be_kind_of SpecDatastream::Component
109
109
  part.label = "Wheel bearing"
110
- ds.parts.first.label.should == ['Wheel bearing']
110
+ expect(ds.parts.first.label).to eq(['Wheel bearing'])
111
111
  end
112
112
 
113
113
  describe "#first_or_create" do
114
114
  it "should return a result if the predicate exists" do
115
115
  part1 = ds.parts.build
116
116
  part2 = ds.parts.build
117
- ds.parts.first_or_create.should == part1
117
+ expect(ds.parts.first_or_create).to eq(part1)
118
118
  end
119
119
 
120
120
  it "should create a new result if the predicate doesn't exist" do
121
- ds.parts.should == []
121
+ expect(ds.parts).to eq([])
122
122
  part = ds.parts.first_or_create(label: 'Front control arm bushing')
123
- part.label.should == ['Front control arm bushing']
124
- ds.parts.should == [part]
123
+ expect(part.label).to eq(['Front control arm bushing'])
124
+ expect(ds.parts).to eq([part])
125
125
  end
126
126
 
127
127
  end
@@ -155,9 +155,9 @@ END
155
155
  comp = SpecDatastream::MediatorUser.new ds.graph
156
156
  comp.title = ["Doctor"]
157
157
  ds.mediator = comp
158
- ds.mediator.first.type.first.should be_instance_of RDF::URI
159
- ds.mediator.first.type.first.to_s.should == "http://purl.org/dc/terms/AgentClass"
160
- ds.mediator.first.title.first.should == 'Doctor'
158
+ expect(ds.mediator.first.type.first).to be_instance_of RDF::URI
159
+ expect(ds.mediator.first.type.first.to_s).to eq("http://purl.org/dc/terms/AgentClass")
160
+ expect(ds.mediator.first.title.first).to eq('Doctor')
161
161
  end
162
162
 
163
163
  it "should add the type of complex object when it is not provided" do
@@ -165,7 +165,7 @@ END
165
165
  _:g70350851837440 <http://purl.org/dc/terms/title> "Mediation Person" .
166
166
  <info:fedora/test:124> <http://purl.org/dc/terms/mediator> _:g70350851837440 .
167
167
  END
168
- ds.mediator.first.type.first.to_s.should == "http://purl.org/dc/terms/AgentClass"
168
+ expect(ds.mediator.first.type.first.to_s).to eq("http://purl.org/dc/terms/AgentClass")
169
169
  end
170
170
 
171
171
  it "should add load the type of complex objects when provided (superceeding what is specified by the class)" do
@@ -174,7 +174,7 @@ END
174
174
  _:g70350851837440 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.ebu.ch/metadata/ontologies/ebucore#Organisation> .
175
175
  <info:fedora/test:124> <http://purl.org/dc/terms/mediator> _:g70350851837440 .
176
176
  END
177
- ds.mediator.first.type.first.to_s.should == "http://www.ebu.ch/metadata/ontologies/ebucore#Organisation"
177
+ expect(ds.mediator.first.type.first.to_s).to eq("http://www.ebu.ch/metadata/ontologies/ebucore#Organisation")
178
178
  end
179
179
  end
180
180
 
@@ -221,15 +221,15 @@ END
221
221
  program.title = ["This old House"]
222
222
  ds.program = program
223
223
 
224
- ds.program.first.type.size.should == 1
225
- ds.program.first.type.first.to_s.should == 'http://www.ebu.ch/metadata/ontologies/ebucore#Programme'
226
- ds.series.first.type.size.should == 1
227
- ds.series.first.type.first.to_s.should == 'http://www.ebu.ch/metadata/ontologies/ebucore#Series'
224
+ expect(ds.program.first.type.size).to eq(1)
225
+ expect(ds.program.first.type.first.to_s).to eq('http://www.ebu.ch/metadata/ontologies/ebucore#Programme')
226
+ expect(ds.series.first.type.size).to eq(1)
227
+ expect(ds.series.first.type.first.to_s).to eq('http://www.ebu.ch/metadata/ontologies/ebucore#Series')
228
228
  end
229
229
 
230
230
  it "should create an object of the correct type" do
231
- ds.program.build.should be_kind_of SpecDatastream::Program
232
- ds.series.build.should be_kind_of SpecDatastream::Series
231
+ expect(ds.program.build).to be_kind_of SpecDatastream::Program
232
+ expect(ds.series.build).to be_kind_of SpecDatastream::Series
233
233
  end
234
234
  end
235
235
  end
@@ -17,31 +17,31 @@ describe ActiveFedora::DatastreamCollections do
17
17
  @test_object2 = MockAFBaseDatastream.new
18
18
  f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
19
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")
20
+ allow(f2).to receive(:original_filename).and_return("dino.jpg")
21
+ allow(f).to receive(:content_type).and_return("image/jpeg")
22
22
  @test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f, :label=>"testDS"})
23
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
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
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
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
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
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
 
@@ -49,18 +49,18 @@ describe ActiveFedora::DatastreamCollections 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
51
  f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
52
- f.stub(:content_type).and_return("image/jpeg")
52
+ allow(f).to receive(:content_type).and_return("image/jpeg")
53
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
57
+ expect(@test_object2.named_datastreams["thumbnail"].size).to eq(1)
58
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"
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
 
@@ -73,37 +73,37 @@ describe ActiveFedora::DatastreamCollections do
73
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
81
  @test_object2.add_named_datastream("thumbnail",{:file=>f})
82
82
  @test_object2.save
83
83
  @test_object2 = MockAFBaseDatastream.find(@test_object2.pid)
84
84
 
85
- @test_object2.thumbnail.size.should == 1
85
+ expect(@test_object2.thumbnail.size).to eq(1)
86
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
94
+ expect(ds.content).to eq(minivan)
95
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
98
+ expect(@test_object2.thumbnail.size).to eq(1)
99
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
 
@@ -22,13 +22,13 @@ describe ActiveFedora::Datastream do
22
22
 
23
23
  it "should be able to access Datastreams using datastreams method" do
24
24
  descMetadata = @test_object.datastreams["descMetadata"]
25
- descMetadata.should be_a_kind_of(ActiveFedora::Datastream)
26
- descMetadata.dsid.should eql("descMetadata")
25
+ expect(descMetadata).to be_a_kind_of(ActiveFedora::Datastream)
26
+ expect(descMetadata.dsid).to eql("descMetadata")
27
27
  end
28
28
 
29
29
  it "should be able to access Datastream content using content method" do
30
30
  descMetadata = @test_object.datastreams["descMetadata"].content
31
- descMetadata.should_not be_nil
31
+ expect(descMetadata).not_to be_nil
32
32
  end
33
33
 
34
34
  it "should be able to update XML Datastream content and save to Fedora" do
@@ -37,25 +37,25 @@ describe ActiveFedora::Datastream do
37
37
  title.content = "Test Title"
38
38
  xml_content.root.add_child title
39
39
 
40
- @test_object.datastreams["descMetadata"].stub(:before_save)
40
+ allow(@test_object.datastreams["descMetadata"]).to receive(:before_save)
41
41
  @test_object.datastreams["descMetadata"].content = xml_content.to_s
42
42
  @test_object.datastreams["descMetadata"].save
43
43
 
44
44
  found = Nokogiri::XML::Document.parse(@test_object.class.find(@test_object.pid).datastreams['descMetadata'].content)
45
- found.xpath('//dc/title/text()').first.inner_text.should == title.content
45
+ expect(found.xpath('//dc/title/text()').first.inner_text).to eq(title.content)
46
46
  end
47
47
 
48
48
  it "should be able to update Blob Datastream content and save to Fedora" do
49
49
  dsid = "ds#{Time.now.to_i}"
50
50
  ds = ActiveFedora::Datastream.new(@test_object.inner_object, dsid)
51
51
  ds.content = fixture('dino.jpg')
52
- @test_object.add_datastream(ds).should be_true
52
+ expect(@test_object.add_datastream(ds)).to be_truthy
53
53
  @test_object.save
54
- @test_object.datastreams[dsid].should_not be_changed
54
+ expect(@test_object.datastreams[dsid]).not_to be_changed
55
55
  to = ActiveFedora::Base.find(@test_object.pid)
56
- to.should_not be_nil
57
- to.datastreams[dsid].should_not be_nil
58
- to.datastreams[dsid].content.should == fixture('dino.jpg').read
56
+ expect(to).not_to be_nil
57
+ expect(to.datastreams[dsid]).not_to be_nil
58
+ expect(to.datastreams[dsid].content).to eq(fixture('dino.jpg').read)
59
59
  end
60
60
 
61
61
  it "should be able to set the versionable attribute" do
@@ -65,26 +65,26 @@ describe ActiveFedora::Datastream do
65
65
  ds = ActiveFedora::Datastream.new(@test_object.inner_object, dsid)
66
66
  ds.content = v1
67
67
  ds.versionable = false
68
- @test_object.add_datastream(ds).should be_true
68
+ expect(@test_object.add_datastream(ds)).to be_truthy
69
69
  @test_object.save
70
70
  to = ActiveFedora::Base.find(@test_object.pid)
71
71
  ds = to.datastreams[dsid]
72
- ds.versionable.should be_false
72
+ expect(ds.versionable).to be_falsey
73
73
  ds.versionable = true
74
74
  to.save
75
75
  ds.content = v2
76
76
  to.save
77
77
  versions = ds.versions
78
- versions.length.should == 2
78
+ expect(versions.length).to eq(2)
79
79
  # order of versions not guaranteed
80
80
  if versions[0].content == v2
81
- versions[1].content.should == v1
82
- versions[0].asOfDateTime.should be >= versions[1].asOfDateTime
81
+ expect(versions[1].content).to eq(v1)
82
+ expect(versions[0].asOfDateTime).to be >= versions[1].asOfDateTime
83
83
  else
84
- versions[0].content.should == v1
85
- versions[1].content.should == v2
86
- versions[1].asOfDateTime.should be >= versions[0].asOfDateTime
84
+ expect(versions[0].content).to eq(v1)
85
+ expect(versions[1].content).to eq(v2)
86
+ expect(versions[1].asOfDateTime).to be >= versions[0].asOfDateTime
87
87
  end
88
- ds.content.should == v2
88
+ expect(ds.content).to eq(v2)
89
89
  end
90
90
  end
@@ -20,8 +20,8 @@ describe ActiveFedora::Datastreams do
20
20
 
21
21
  it "should work" do
22
22
  subject.save(validate: false)
23
- subject.nokogiri_autocreate_on.should_not be_new
24
- subject.nokogiri_autocreate_off.should be_new
23
+ expect(subject.nokogiri_autocreate_on).not_to be_new
24
+ expect(subject.nokogiri_autocreate_off).to be_new
25
25
  end
26
26
  end
27
27
 
@@ -51,21 +51,21 @@ describe ActiveFedora::Datastreams do
51
51
  end
52
52
 
53
53
  it "should create datastreams from the spec on new objects" do
54
- expect(@test.without_versions.versionable).to be_false
55
- expect(@test.with_versions.versionable).to be_true
54
+ expect(@test.without_versions.versionable).to be_falsey
55
+ expect(@test.with_versions.versionable).to be_truthy
56
56
  expect(@test.with_versions.dsLabel).to eql "Versioned DS"
57
57
  @test.without_versions.content= "blah blah blah"
58
58
  @test.save
59
- expect(HasMetadata.find(@test.pid).without_versions.versionable).to be_false
59
+ expect(HasMetadata.find(@test.pid).without_versions.versionable).to be_falsey
60
60
  end
61
61
 
62
62
  it "should use ds_specs and preserve existing datastreams on migrated objects" do
63
63
  test_obj = HasMetadata.find(@base.pid, cast: false)
64
64
  expect(test_obj.datastreams["testDS"].dsLabel).to eql "Test DS"
65
- expect(test_obj.datastreams["testDS"].new?).to be_false
65
+ expect(test_obj.datastreams["testDS"].new?).to be_falsey
66
66
  expect(test_obj.with_versions.dsLabel).to eql "Versioned DS"
67
- expect(test_obj.without_versions.versionable).to be_false
68
- expect(test_obj.with_versions.new?).to be_true
67
+ expect(test_obj.without_versions.versionable).to be_falsey
68
+ expect(test_obj.with_versions.new?).to be_truthy
69
69
  end
70
70
 
71
71
  end
@@ -98,34 +98,34 @@ describe ActiveFedora::Datastreams do
98
98
  end
99
99
 
100
100
  it "should create datastreams from the spec on new objects" do
101
- expect(@has_file.file_ds.versionable).to be_false
101
+ expect(@has_file.file_ds.versionable).to be_falsey
102
102
  @has_file.file_ds.content = "blah blah blah"
103
- expect(@has_file.file_ds.changed?).to be_true
104
- expect(@has_file.file_ds2.changed?).to be_false # no autocreate
105
- expect(@has_file.file_ds2.new?).to be_true
103
+ expect(@has_file.file_ds.changed?).to be_truthy
104
+ expect(@has_file.file_ds2.changed?).to be_falsey # no autocreate
105
+ expect(@has_file.file_ds2.new?).to be_truthy
106
106
  @has_file.save
107
- expect(@has_file.file_ds.versionable).to be_false
107
+ expect(@has_file.file_ds.versionable).to be_falsey
108
108
  test_obj = HasFile.find(@has_file.pid)
109
- expect(test_obj.file_ds.versionable).to be_false
110
- expect(test_obj.rels_ext.changed?).to be_false
111
- expect(test_obj.file_ds.changed?).to be_false
112
- expect(test_obj.file_ds2.changed?).to be_false
113
- expect(test_obj.file_ds2.new?).to be_true
109
+ expect(test_obj.file_ds.versionable).to be_falsey
110
+ expect(test_obj.rels_ext.changed?).to be_falsey
111
+ expect(test_obj.file_ds.changed?).to be_falsey
112
+ expect(test_obj.file_ds2.changed?).to be_falsey
113
+ expect(test_obj.file_ds2.new?).to be_truthy
114
114
  end
115
115
 
116
116
  it "should use ds_specs on migrated objects" do
117
117
  test_obj = HasFile.find(@base.pid, cast: false)
118
- expect(test_obj.file_ds.versionable).to be_false
119
- expect(test_obj.file_ds.new?).to be_true
118
+ expect(test_obj.file_ds.versionable).to be_falsey
119
+ expect(test_obj.file_ds.new?).to be_truthy
120
120
  test_obj.file_ds.content = "blah blah blah"
121
121
  test_obj.save
122
- expect(test_obj.file_ds.versionable).to be_false
122
+ expect(test_obj.file_ds.versionable).to be_falsey
123
123
  # look it up again to check datastream profile
124
124
  test_obj = HasFile.find(@base.pid, cast: false)
125
- expect(test_obj.file_ds.versionable).to be_false
125
+ expect(test_obj.file_ds.versionable).to be_falsey
126
126
  expect(test_obj.file_ds.dsLabel).to eql "File Datastream"
127
127
  test_obj = HasFile.find(@base2.pid, cast: false)
128
- expect(test_obj.file_ds.versionable).to be_true
128
+ expect(test_obj.file_ds.versionable).to be_truthy
129
129
  expect(test_obj.file_ds.dsLabel).to eql "Pre-existing DS"
130
130
  end
131
131
  end
@@ -151,7 +151,7 @@ describe ActiveFedora::Datastreams do
151
151
  ds = @base.create_datastream('ActiveFedora::Datastream', 'someMetadata', ds_opts)
152
152
  @base.add_datastream(ds)
153
153
  @base.save
154
- expect(@base.datastreams.keys.include?('someMetadata')).to be_true
154
+ expect(@base.datastreams.keys.include?('someMetadata')).to be_truthy
155
155
  test_obj = ActiveFedora::Base.find(@base.pid)
156
156
  expect(test_obj.datastreams['someMetadata'].content).to eql @ds_content
157
157
  expect(test_obj.datastreams['someMetadata'].controlGroup).to eql 'E'
@@ -164,7 +164,7 @@ describe ActiveFedora::Datastreams do
164
164
  ds = @base.create_datastream('ActiveFedora::Datastream', 'someMetadata', ds_opts)
165
165
  @base.add_datastream(ds)
166
166
  @base.save
167
- expect(@base.datastreams.keys.include?('someMetadata')).to be_true
167
+ expect(@base.datastreams.keys.include?('someMetadata')).to be_truthy
168
168
  test_obj = ActiveFedora::Base.find(@base.pid)
169
169
  expect(test_obj.datastreams['someMetadata'].content).to eql @ds_content
170
170
  expect(test_obj.datastreams['someMetadata'].controlGroup).to eql 'M'