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
@@ -1,90 +1,90 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  require 'active_fedora'
4
- require "rexml/document"
4
+ require 'rexml/document'
5
5
 
6
6
  describe ActiveFedora::Datastream do
7
7
 
8
8
  before(:all) do
9
9
  class MockAFBase < ActiveFedora::Base
10
- has_metadata :name => "descMetadata", :type => ActiveFedora::QualifiedDublinCoreDatastream, :autocreate => true
10
+ has_metadata :name => 'descMetadata', :type => ActiveFedora::QualifiedDublinCoreDatastream, :autocreate => true
11
11
  end
12
12
  end
13
-
13
+
14
14
  before(:each) do
15
15
  @test_object = MockAFBase.new
16
16
  @test_object.save
17
17
  end
18
-
18
+
19
19
  after(:each) do
20
20
  @test_object.delete
21
21
  end
22
22
 
23
- it "should be able to access Datastreams using datastreams method" do
24
- descMetadata = @test_object.datastreams["descMetadata"]
25
- descMetadata.should be_a_kind_of(ActiveFedora::Datastream)
26
- descMetadata.dsid.should eql("descMetadata")
23
+ it 'should be able to access Datastreams using datastreams method' do
24
+ descMetadata = @test_object.datastreams['descMetadata']
25
+ expect(descMetadata).to be_a_kind_of(ActiveFedora::Datastream)
26
+ expect(descMetadata.dsid).to eql('descMetadata')
27
27
  end
28
28
 
29
- it "should be able to access Datastream content using content method" do
30
- descMetadata = @test_object.datastreams["descMetadata"].content
31
- descMetadata.should_not be_nil
29
+ it 'should be able to access Datastream content using content method' do
30
+ descMetadata = @test_object.datastreams['descMetadata'].content
31
+ expect(descMetadata).not_to be_nil
32
32
  end
33
-
34
- it "should be able to update XML Datastream content and save to Fedora" do
35
- xml_content = Nokogiri::XML::Document.parse(@test_object.datastreams["descMetadata"].content)
36
- title = Nokogiri::XML::Element.new "title", xml_content
37
- title.content = "Test Title"
33
+
34
+ it 'should be able to update XML Datastream content and save to Fedora' do
35
+ xml_content = Nokogiri::XML::Document.parse(@test_object.datastreams['descMetadata'].content)
36
+ title = Nokogiri::XML::Element.new 'title', xml_content
37
+ title.content = 'Test Title'
38
38
  xml_content.root.add_child title
39
-
40
- @test_object.datastreams["descMetadata"].stub(:before_save)
41
- @test_object.datastreams["descMetadata"].content = xml_content.to_s
42
- @test_object.datastreams["descMetadata"].save
43
-
39
+
40
+ allow(@test_object.datastreams['descMetadata']).to receive(:before_save)
41
+ @test_object.datastreams['descMetadata'].content = xml_content.to_s
42
+ @test_object.datastreams['descMetadata'].save
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
-
48
- it "should be able to update Blob Datastream content and save to Fedora" do
47
+
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
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
54
+ expect(@test_object.datastreams[dsid]).not_to be_changed
55
+ to = ActiveFedora::Base.find(@test_object.pid)
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
-
61
- it "should be able to set the versionable attribute" do
60
+
61
+ it 'should be able to set the versionable attribute' do
62
62
  dsid = "ds#{Time.now.to_i}"
63
- v1 = "<version1>data</version1>"
64
- v2 = "<version2>data</version2>"
63
+ v1 = '<version1>data</version1>'
64
+ v2 = '<version2>data</version2>'
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
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  require 'active_fedora'
4
- require "rexml/document"
4
+ require 'rexml/document'
5
5
 
6
6
  describe ActiveFedora::Datastreams do
7
- describe "serializing datastreams" do
7
+ describe 'serializing datastreams' do
8
8
  before :all do
9
9
  class TestingMetadataSerializing < ActiveFedora::Base
10
- has_metadata :name => "nokogiri_autocreate_on", :autocreate => true, :type => ActiveFedora::OmDatastream
11
- has_metadata :name => "nokogiri_autocreate_off", :autocreate => false, :type => ActiveFedora::OmDatastream
10
+ has_metadata :name => 'nokogiri_autocreate_on', :autocreate => true, :type => ActiveFedora::OmDatastream
11
+ has_metadata :name => 'nokogiri_autocreate_off', :autocreate => false, :type => ActiveFedora::OmDatastream
12
12
  end
13
13
  end
14
14
 
@@ -18,115 +18,115 @@ describe ActiveFedora::Datastreams do
18
18
 
19
19
  subject { TestingMetadataSerializing.new }
20
20
 
21
- it "should work" do
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
 
28
28
 
29
- describe "#has_metadata" do
29
+ describe '#has_metadata' do
30
30
  before :all do
31
31
  class HasMetadata < ActiveFedora::Base
32
- has_metadata :name => "with_versions", :autocreate => true, :label => "Versioned DS", :type => ActiveFedora::SimpleDatastream
33
- has_metadata :name => "without_versions", :autocreate => true, :versionable => false, :type => ActiveFedora::SimpleDatastream
32
+ has_metadata :name => 'with_versions', :autocreate => true, :label => 'Versioned DS', :type => ActiveFedora::SimpleDatastream
33
+ has_metadata :name => 'without_versions', :autocreate => true, :versionable => false, :type => ActiveFedora::SimpleDatastream
34
34
  end
35
35
  end
36
36
  after :all do
37
37
  Object.send(:remove_const, :HasMetadata)
38
38
  end
39
39
  before :each do
40
- @base = ActiveFedora::Base.new(:pid=>"test:has_metadata_base")
41
- @base.add_datastream(@base.create_datastream(ActiveFedora::Datastream, "testDS", :dsLabel => "Test DS"))
42
- @base.datastreams["testDS"].content = "blah blah blah"
40
+ @base = ActiveFedora::Base.new(:pid => 'test:has_metadata_base')
41
+ @base.add_datastream(@base.create_datastream(ActiveFedora::Datastream, 'testDS', :dsLabel => 'Test DS'))
42
+ @base.datastreams['testDS'].content = 'blah blah blah'
43
43
  @base.save
44
- @test = HasMetadata.new(:pid=>"test:has_metadata_model")
44
+ @test = HasMetadata.new(:pid => 'test:has_metadata_model')
45
45
  @test.save
46
46
  end
47
-
47
+
48
48
  after :each do
49
49
  @base.delete
50
50
  @test.delete
51
51
  end
52
-
53
- it "should create datastreams from the spec on new objects" do
54
- @test.without_versions.versionable.should be_false
55
- @test.with_versions.versionable.should be_true
56
- @test.with_versions.dsLabel.should == "Versioned DS"
57
- @test.without_versions.content= "blah blah blah"
52
+
53
+ it 'should create datastreams from the spec on new objects' do
54
+ expect(@test.without_versions.versionable).to be_falsey
55
+ expect(@test.with_versions.versionable).to be_truthy
56
+ expect(@test.with_versions.dsLabel).to eq('Versioned DS')
57
+ @test.without_versions.content = 'blah blah blah'
58
58
  @test.save
59
- HasMetadata.find(@test.pid).without_versions.versionable.should be_false
59
+ expect(HasMetadata.find(@test.pid).without_versions.versionable).to be_falsey
60
60
  end
61
-
62
- it "should use ds_specs and preserve existing datastreams on migrated objects" do
61
+
62
+ it 'should use ds_specs and preserve existing datastreams on migrated objects' do
63
63
  test_obj = HasMetadata.find(@base.pid)
64
- test_obj.datastreams["testDS"].dsLabel.should == "Test DS"
65
- test_obj.datastreams["testDS"].new?.should be_false
66
- test_obj.with_versions.dsLabel.should == "Versioned DS"
67
- test_obj.without_versions.versionable.should be_false
68
- test_obj.with_versions.new?.should be_true
64
+ expect(test_obj.datastreams['testDS'].dsLabel).to eq('Test DS')
65
+ expect(test_obj.datastreams['testDS'].new?).to be_falsey
66
+ expect(test_obj.with_versions.dsLabel).to eq('Versioned DS')
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
72
-
73
- describe "#has_file_datastream" do
72
+
73
+ describe '#has_file_datastream' do
74
74
  before :all do
75
75
  class HasFile < ActiveFedora::Base
76
- has_file_datastream :name => "file_ds", :versionable => false
77
- has_file_datastream :name => "file_ds2", :versionable => false, :autocreate => false
76
+ has_file_datastream :name => 'file_ds', :versionable => false
77
+ has_file_datastream :name => 'file_ds2', :versionable => false, :autocreate => false
78
78
  end
79
79
  end
80
80
  after :all do
81
81
  Object.send(:remove_const, :HasFile)
82
82
  end
83
83
  before :each do
84
- @base = ActiveFedora::Base.new(:pid=>"test:ds_versionable_base")
84
+ @base = ActiveFedora::Base.new(:pid => 'test:ds_versionable_base')
85
85
  @base.save
86
- @base2 = ActiveFedora::Base.new(:pid=>"test:ds_versionable_base2")
87
- @base2.add_datastream(@base2.create_datastream(ActiveFedora::Datastream,"file_ds", :versionable=>true,:dsLabel=>"Pre-existing DS"))
88
- @base2.datastreams["file_ds"].content = "blah blah blah"
86
+ @base2 = ActiveFedora::Base.new(:pid => 'test:ds_versionable_base2')
87
+ @base2.add_datastream(@base2.create_datastream(ActiveFedora::Datastream, 'file_ds', :versionable => true, :dsLabel => 'Pre-existing DS'))
88
+ @base2.datastreams['file_ds'].content = 'blah blah blah'
89
89
  @base2.save
90
- @has_file = HasFile.new(:pid=>"test:ds_versionable_has_file")
90
+ @has_file = HasFile.new(:pid => 'test:ds_versionable_has_file')
91
91
  @has_file.save
92
92
  end
93
-
93
+
94
94
  after :each do
95
95
  @base.delete
96
96
  @base2.delete
97
97
  @has_file.delete
98
98
  end
99
-
100
- it "should create datastreams from the spec on new objects" do
101
- @has_file.file_ds.versionable.should be_false
102
- @has_file.file_ds.content = "blah blah blah"
103
- @has_file.file_ds.changed?.should be_true
104
- @has_file.file_ds2.changed?.should be_false # no autocreate
105
- @has_file.file_ds2.new?.should be_true
99
+
100
+ it 'should create datastreams from the spec on new objects' do
101
+ expect(@has_file.file_ds.versionable).to be_falsey
102
+ @has_file.file_ds.content = 'blah blah blah'
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
- @has_file.file_ds.versionable.should be_false
107
+ expect(@has_file.file_ds.versionable).to be_falsey
108
108
  test_obj = HasFile.find(@has_file.pid)
109
- test_obj.file_ds.versionable.should be_false
110
- test_obj.rels_ext.changed?.should be_false
111
- test_obj.file_ds.changed?.should be_false
112
- test_obj.file_ds2.changed?.should be_false
113
- test_obj.file_ds2.new?.should 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
-
116
- it "should use ds_specs on migrated objects" do
115
+
116
+ it 'should use ds_specs on migrated objects' do
117
117
  test_obj = HasFile.find(@base.pid)
118
- test_obj.file_ds.versionable.should be_false
119
- test_obj.file_ds.new?.should be_true
120
- test_obj.file_ds.content = "blah blah blah"
118
+ expect(test_obj.file_ds.versionable).to be_falsey
119
+ expect(test_obj.file_ds.new?).to be_truthy
120
+ test_obj.file_ds.content = 'blah blah blah'
121
121
  test_obj.save
122
- test_obj.file_ds.versionable.should 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)
125
- test_obj.file_ds.versionable.should be_false
126
- test_obj.file_ds.dsLabel.should == "File Datastream"
125
+ expect(test_obj.file_ds.versionable).to be_falsey
126
+ expect(test_obj.file_ds.dsLabel).to eq('File Datastream')
127
127
  test_obj = HasFile.find(@base2.pid)
128
- test_obj.file_ds.versionable.should be_true
129
- test_obj.file_ds.dsLabel.should == "Pre-existing DS"
128
+ expect(test_obj.file_ds.versionable).to be_truthy
129
+ expect(test_obj.file_ds.dsLabel).to eq('Pre-existing DS')
130
130
  end
131
131
  end
132
132
  end
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "delegating properties" do
4
- describe "that have a reader and writer" do
3
+ describe 'delegating properties' do
4
+ describe 'that have a reader and writer' do
5
5
  before :all do
6
6
  class TitledObject < ActiveFedora::Base
7
7
  has_metadata 'foo', type: ActiveFedora::SimpleDatastream do |m|
8
- m.field "title", :string
8
+ m.field 'title', :string
9
9
  end
10
10
  delegate :title, to: 'foo', multiple: false
11
11
  end
@@ -14,25 +14,25 @@ describe "delegating properties" do
14
14
  Object.send(:remove_const, :TitledObject)
15
15
  end
16
16
 
17
- describe "save" do
17
+ describe 'save' do
18
18
  subject do
19
- obj = TitledObject.create
20
- obj.title = "Hydra for Dummies"
19
+ obj = TitledObject.create
20
+ obj.title = 'Hydra for Dummies'
21
21
  obj.save
22
22
  obj
23
23
  end
24
- it "should keep a list of changes after a successful save" do
25
- subject.previous_changes.should_not be_empty
26
- subject.previous_changes.keys.should include("title")
24
+ it 'should keep a list of changes after a successful save' do
25
+ expect(subject.previous_changes).not_to be_empty
26
+ expect(subject.previous_changes.keys).to include('title')
27
27
  end
28
- it "should clean out changes" do
29
- subject.title_changed?.should be_false
30
- subject.changes.should be_empty
28
+ it 'should clean out changes' do
29
+ expect(subject.title_changed?).to be_falsey
30
+ expect(subject.changes).to be_empty
31
31
  end
32
32
  end
33
33
  end
34
34
 
35
- describe "that only have a writer" do
35
+ describe 'that only have a writer' do
36
36
  before :all do
37
37
  class TestDatastream < ActiveFedora::NtriplesRDFDatastream
38
38
  # accepts_nested_attributes_for :title, would generate a method like this:
@@ -51,7 +51,7 @@ describe "delegating properties" do
51
51
 
52
52
  subject { TitledObject.new }
53
53
 
54
- it "Should delegate the method" do
54
+ it 'Should delegate the method' do
55
55
  subject.title_attributes = {'0' => {'title' => 'Hello'}}
56
56
  end
57
57
 
@@ -1,60 +1,56 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ActiveFedora::Base do
4
-
5
- before(:all) do
6
- module SpecModel
7
- class Basic < ActiveFedora::Base
8
- class_attribute :callback_counter
9
-
10
- before_destroy :inc_counter
11
-
12
- def inc_counter
13
- self.class.callback_counter += 1
14
- end
15
- end
3
+ module SpecModelD
4
+ class Basic < ActiveFedora::Base
5
+ class_attribute :callback_counter
6
+ before_destroy :inc_counter
7
+
8
+ def inc_counter
9
+ self.class.callback_counter += 1
16
10
  end
17
11
  end
18
-
19
- after(:all) do
20
- Object.send(:remove_const, :SpecModel)
21
- end
12
+ end
13
+
14
+ describe ActiveFedora::Base do
22
15
 
23
- let!(:model1) { SpecModel::Basic.create! }
24
- let!(:model2) { SpecModel::Basic.create! }
16
+ let!(:model1) { SpecModelD::Basic.create! }
17
+ let!(:model2) { SpecModelD::Basic.create! }
25
18
 
26
- before do
27
- SpecModel::Basic.callback_counter = 0
19
+ before :each do
20
+ SpecModelD::Basic.callback_counter = 0
28
21
  end
29
22
 
30
-
31
- describe ".destroy_all" do
32
- it "should remove both and run callbacks" do
33
- SpecModel::Basic.destroy_all
34
- SpecModel::Basic.count.should == 0
35
- SpecModel::Basic.callback_counter.should == 2
23
+ describe '.destroy_all' do
24
+ it 'should remove both and run callbacks' do
25
+ model1
26
+ model2
27
+ expect(SpecModelD::Basic.count).to eq(2)
28
+ expect(SpecModelD::Basic.callback_counter).to eq(0)
29
+ SpecModelD::Basic.destroy_all
30
+ expect(SpecModelD::Basic.count).to eq(0)
31
+ expect(SpecModelD::Basic.callback_counter).to eq(2)
36
32
  end
37
33
 
38
- describe "when a model is missing" do
39
- let(:model3) { SpecModel::Basic.create! }
34
+ describe 'when a model is missing' do
35
+ let(:model3) { SpecModelD::Basic.create! }
40
36
  after { model3.delete }
41
- it "should be able to skip a missing model" do
42
- model1.should_receive(:destroy).and_call_original
43
- model2.should_receive(:destroy).and_call_original
44
- model3.should_receive(:destroy).and_raise(ActiveFedora::ObjectNotFoundError)
45
- ActiveFedora::Relation.any_instance.should_receive(:to_a).and_return([model1, model3, model2])
46
- ActiveFedora::Relation.logger.should_receive(:error).with("When trying to destroy #{model3.pid}, encountered an ObjectNotFoundError. Solr may be out of sync with Fedora")
47
- SpecModel::Basic.destroy_all
48
- SpecModel::Basic.count.should == 1
37
+ it 'should be able to skip a missing model' do
38
+ expect(model1).to receive(:destroy).and_call_original
39
+ expect(model2).to receive(:destroy).and_call_original
40
+ expect(model3).to receive(:destroy).and_raise(ActiveFedora::ObjectNotFoundError)
41
+ expect_any_instance_of(ActiveFedora::Relation).to receive(:to_a).and_return([model1, model3, model2])
42
+ expect(ActiveFedora::Relation.logger).to receive(:error).with("When trying to destroy #{model3.pid}, encountered an ObjectNotFoundError. Solr may be out of sync with Fedora")
43
+ SpecModelD::Basic.destroy_all
44
+ expect(SpecModelD::Basic.count).to eq(1)
49
45
  end
50
46
  end
51
47
  end
52
48
 
53
- describe ".delete_all" do
54
- it "should remove both and not run callbacks" do
55
- SpecModel::Basic.delete_all
56
- SpecModel::Basic.count.should == 0
57
- SpecModel::Basic.callback_counter.should == 0
49
+ describe '.delete_all' do
50
+ it 'should remove both and not run callbacks' do
51
+ SpecModelD::Basic.delete_all
52
+ expect(SpecModelD::Basic.count).to eq(0)
53
+ expect(SpecModelD::Basic.callback_counter).to eq(0)
58
54
  end
59
55
  end
60
56
  end