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,10 +2,10 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::Base do
4
4
 
5
- describe "deletgating multiple terms to one datastream" do
5
+ describe 'deletgating multiple terms to one datastream' do
6
6
  class BarnyardDocument < ActiveFedora::OmDatastream
7
7
  set_terminology do |t|
8
- t.root(:path=>"animals", :xmlns=>"urn:zoobar")
8
+ t.root(:path => 'animals', :xmlns => 'urn:zoobar')
9
9
  t.waterfowl do
10
10
  t.ducks do
11
11
  t.duck
@@ -16,60 +16,58 @@ describe ActiveFedora::Base do
16
16
  t.horse()
17
17
  t.chicken()
18
18
  t.pig()
19
- t.duck(:ref=>[:waterfowl,:ducks,:duck])
19
+ t.duck(:ref => [:waterfowl, :ducks, :duck])
20
20
  end
21
21
 
22
22
  def self.xml_template
23
- Nokogiri::XML::Document.parse '<animals xmlns="urn:zoobar">
24
- <waterfowl>
25
- <ducks>
26
- <duck/>
27
- </ducks>
28
- </waterfowl>
29
- <donkey></donkey>
30
- <cow></cow>
31
- <horse></horse>
32
- <chicken></chicken>
33
- <pig></pig>
34
- </animals>'
23
+ Nokogiri::XML::Document.parse '<animals xmlns="urn:zoobar">
24
+ <waterfowl>
25
+ <ducks>
26
+ <duck/>
27
+ </ducks>
28
+ </waterfowl>
29
+ <donkey></donkey>
30
+ <cow></cow>
31
+ <horse></horse>
32
+ <chicken></chicken>
33
+ <pig></pig>
34
+ </animals>'
35
35
  end
36
36
  end
37
37
 
38
38
  class Barnyard < ActiveFedora::Base
39
- has_metadata :type=>BarnyardDocument, :name=>"xmlish"
39
+ has_metadata :type => BarnyardDocument, :name => 'xmlish'
40
40
  delegate_to :xmlish, [:cow, :chicken, :pig, :duck], multiple: true
41
- delegate_to :xmlish, [:donkey, :horse], :unique=>true
42
- #delegate :donkey, :to=>'xmlish', :unique=>true
41
+ delegate_to :xmlish, [:donkey, :horse], :unique => true
42
+ # delegate :donkey, :to=>'xmlish', :unique=>true
43
43
  end
44
44
  before :each do
45
45
  @n = Barnyard.new()
46
46
  end
47
- it "should save a delegated property uniquely" do
48
- @n.donkey="Bray"
49
- @n.donkey.should == "Bray"
50
- @n.xmlish.term_values(:donkey).first.should == 'Bray'
51
- @n.horse="Winee"
52
- @n.horse.should == "Winee"
53
- @n.xmlish.term_values(:horse).first.should == 'Winee'
47
+ it 'should save a delegated property uniquely' do
48
+ @n.donkey = 'Bray'
49
+ expect(@n.donkey).to eq('Bray')
50
+ expect(@n.xmlish.term_values(:donkey).first).to eq('Bray')
51
+ @n.horse = 'Winee'
52
+ expect(@n.horse).to eq('Winee')
53
+ expect(@n.xmlish.term_values(:horse).first).to eq('Winee')
54
54
  end
55
- it "should return an array if not marked as unique" do
56
- ### Metadata datastream does not appear to support multiple value setting
57
- @n.cow=["one", "two"]
58
- @n.cow.should == ["one", "two"]
55
+ it 'should return an array if not marked as unique' do
56
+ # Metadata datastream does not appear to support multiple value setting
57
+ @n.cow = ['one', 'two']
58
+ expect(@n.cow).to eq(['one', 'two'])
59
59
  end
60
60
 
61
- it "should be able to delegate deeply into the terminology" do
62
- @n.duck=["Quack", "Peep"]
63
- @n.duck.should == ["Quack", "Peep"]
61
+ it 'should be able to delegate deeply into the terminology' do
62
+ @n.duck = ['Quack', 'Peep']
63
+ expect(@n.duck).to eq(['Quack', 'Peep'])
64
64
  end
65
65
 
66
- it "should be able to track change status" do
67
- @n.chicken_changed?.should be_false
68
- @n.chicken = ["Cheep"]
69
- @n.chicken_changed?.should be_true
70
- end
66
+ it 'should be able to track change status' do
67
+ expect(@n.chicken_changed?).to be_falsey
68
+ @n.chicken = ['Cheep']
69
+ expect(@n.chicken_changed?).to be_truthy
70
+ end
71
71
 
72
72
  end
73
73
  end
74
-
75
-
@@ -1,81 +1,81 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::Base do
4
-
4
+
5
5
  before(:each) do
6
6
  @test_object = ActiveFedora::Base.new
7
7
  end
8
8
 
9
- describe ".update_index" do
9
+ describe '.update_index' do
10
10
  before do
11
- mock_conn = double("SolrConnection")
12
- mock_conn.should_receive(:add)
13
- mock_conn.should_receive(:commit)
14
- mock_ss = double("SolrService")
15
- mock_ss.stub(:conn).and_return(mock_conn)
16
- ActiveFedora::SolrService.stub(:instance).and_return(mock_ss)
11
+ mock_conn = double('SolrConnection')
12
+ expect(mock_conn).to receive(:add)
13
+ expect(mock_conn).to receive(:commit)
14
+ mock_ss = double('SolrService')
15
+ allow(mock_ss).to receive(:conn).and_return(mock_conn)
16
+ allow(ActiveFedora::SolrService).to receive(:instance).and_return(mock_ss)
17
17
  end
18
-
19
- it "should call .to_solr on all SimpleDatastreams AND RelsExtDatastreams and pass the resulting document to solr" do
18
+
19
+ it 'should call .to_solr on all SimpleDatastreams AND RelsExtDatastreams and pass the resulting document to solr' do
20
20
  # Actually uses self.to_solr internally to gather solr info from all metadata datastreams
21
- mock1 = double("ds1", :to_solr => {})
22
- mock2 = double("ds2", :to_solr => {})
23
- mock3 = double("RELS-EXT", :to_solr => {})
24
-
21
+ mock1 = double('ds1', :to_solr => {})
22
+ mock2 = double('ds2', :to_solr => {})
23
+ mock3 = double('RELS-EXT', :to_solr => {})
24
+
25
25
  mock_datastreams = {:ds1 => mock1, :ds2 => mock2, :rels_ext => mock3}
26
- mock1.should_receive(:solrize_profile).and_return({})
27
- mock2.should_receive(:solrize_profile).and_return({})
28
- mock3.should_receive(:solrize_profile).and_return({})
29
- @test_object.should_receive(:datastreams).twice.and_return(mock_datastreams)
30
- @test_object.should_receive(:solrize_relationships)
26
+ expect(mock1).to receive(:solrize_profile).and_return({})
27
+ expect(mock2).to receive(:solrize_profile).and_return({})
28
+ expect(mock3).to receive(:solrize_profile).and_return({})
29
+ expect(@test_object).to receive(:datastreams).twice.and_return(mock_datastreams)
30
+ expect(@test_object).to receive(:solrize_relationships)
31
31
  @test_object.update_index
32
32
  end
33
33
 
34
- it "should call .to_solr on all RDFDatastreams and pass the resulting document to solr" do
34
+ it 'should call .to_solr on all RDFDatastreams and pass the resulting document to solr' do
35
35
  # Actually uses self.to_solr internally to gather solr info from all metadata datastreams
36
- mock1 = double("ds1", :to_solr => {})
37
- mock2 = double("ds2", :to_solr => {})
38
- mock3 = double("RELS-EXT", :to_solr => {})
39
-
36
+ mock1 = double('ds1', :to_solr => {})
37
+ mock2 = double('ds2', :to_solr => {})
38
+ mock3 = double('RELS-EXT', :to_solr => {})
39
+
40
40
  mock_datastreams = {:ds1 => mock1, :ds2 => mock2, :rels_ext => mock3}
41
- mock1.should_receive(:solrize_profile).and_return({})
42
- mock2.should_receive(:solrize_profile).and_return({})
43
- mock3.should_receive(:solrize_profile).and_return({})
44
- @test_object.should_receive(:datastreams).twice.and_return(mock_datastreams)
45
- @test_object.should_receive(:solrize_relationships)
41
+ expect(mock1).to receive(:solrize_profile).and_return({})
42
+ expect(mock2).to receive(:solrize_profile).and_return({})
43
+ expect(mock3).to receive(:solrize_profile).and_return({})
44
+ expect(@test_object).to receive(:datastreams).twice.and_return(mock_datastreams)
45
+ expect(@test_object).to receive(:solrize_relationships)
46
46
  @test_object.update_index
47
47
  end
48
48
 
49
- it "should retrieve a solr Connection and call Connection.add" do
49
+ it 'should retrieve a solr Connection and call Connection.add' do
50
50
  @test_object.update_index
51
51
  end
52
52
 
53
53
  end
54
-
55
- describe ".delete" do
56
-
54
+
55
+ describe '.delete' do
56
+
57
57
  before(:each) do
58
58
  end
59
-
60
- it "should delete object from repository and index" do
61
- @test_object.inner_object.stub(:delete)
62
- mock_conn = double("SolrConnection")
63
- mock_conn.should_receive(:delete_by_id).with(nil)
64
- mock_conn.should_receive(:commit)
65
- mock_ss = double("SolrService")
66
- mock_ss.stub(:conn).and_return(mock_conn)
67
- ActiveFedora::SolrService.stub(:instance).and_return(mock_ss)
59
+
60
+ it 'should delete object from repository and index' do
61
+ allow(@test_object.inner_object).to receive(:delete)
62
+ mock_conn = double('SolrConnection')
63
+ expect(mock_conn).to receive(:delete_by_id).with(nil)
64
+ expect(mock_conn).to receive(:commit)
65
+ mock_ss = double('SolrService')
66
+ allow(mock_ss).to receive(:conn).and_return(mock_conn)
67
+ allow(ActiveFedora::SolrService).to receive(:instance).and_return(mock_ss)
68
68
  @test_object.delete
69
69
  end
70
70
 
71
71
  end
72
-
73
- describe '#pids_from_uris' do
74
- it "should strip the info:fedora/ out of a given string" do
75
- ActiveFedora::Base.pids_from_uris("info:fedora/FOOBAR").should == "FOOBAR"
72
+
73
+ describe '#pids_from_uris' do
74
+ it 'should strip the info:fedora/ out of a given string' do
75
+ expect(ActiveFedora::Base.pids_from_uris('info:fedora/FOOBAR')).to eq('FOOBAR')
76
76
  end
77
- it "should accept an array of strings"do
78
- ActiveFedora::Base.pids_from_uris(["info:fedora/FOOBAR", "info:fedora/BAZFOO"]).should == ["FOOBAR", "BAZFOO"]
77
+ it 'should accept an array of strings'do
78
+ expect(ActiveFedora::Base.pids_from_uris(['info:fedora/FOOBAR', 'info:fedora/BAZFOO'])).to eq(['FOOBAR', 'BAZFOO'])
79
79
  end
80
80
  end
81
81
 
@@ -1,81 +1,81 @@
1
1
  require 'spec_helper'
2
- @@last_pid = 0
2
+ @@last_pid = 0
3
3
 
4
4
  describe ActiveFedora::Base do
5
- it_behaves_like "An ActiveModel"
5
+ it_behaves_like 'An ActiveModel'
6
6
 
7
7
  describe 'descendants' do
8
- it "should record the decendants" do
9
- ActiveFedora::Base.descendants.should include(ModsArticle, SpecialThing)
8
+ it 'should record the decendants' do
9
+ expect(ActiveFedora::Base.descendants).to include(ModsArticle, SpecialThing)
10
10
  end
11
11
  end
12
12
 
13
- describe "sharding" do
14
- it "should have a shard_index" do
15
- ActiveFedora::Base.shard_index(@this_pid).should == 0
13
+ describe 'sharding' do
14
+ it 'should have a shard_index' do
15
+ expect(ActiveFedora::Base.shard_index(@this_pid)).to eq(0)
16
16
  end
17
17
 
18
- context "When the repository is NOT sharded" do
18
+ context 'When the repository is NOT sharded' do
19
19
  subject {ActiveFedora::Base.connection_for_pid('test:bar')}
20
20
  before(:each) do
21
- ActiveFedora.config.stub(:sharded?).and_return(false)
21
+ allow(ActiveFedora.config).to receive(:sharded?).and_return(false)
22
22
  ActiveFedora::Base.fedora_connection = {}
23
- ActiveFedora.config.stub(:credentials).and_return(:url=>'myfedora')
23
+ allow(ActiveFedora.config).to receive(:credentials).and_return(:url => 'myfedora')
24
24
  end
25
- it { should be_kind_of Rubydora::Repository}
26
- it "should be the standard connection" do
27
- subject.client.url.should == 'myfedora'
25
+ it { is_expected.to be_kind_of Rubydora::Repository}
26
+ it 'should be the standard connection' do
27
+ expect(subject.client.url).to eq('myfedora')
28
28
  end
29
- describe "assign_pid" do
30
- it "should use fedora to generate pids" do
29
+ describe 'assign_pid' do
30
+ it 'should use fedora to generate pids' do
31
31
  # TODO: This juggling of Fedora credentials & establishing connections should be handled by an establish_fedora_connection method,
32
32
  # possibly wrap it all into a fedora_connection method - MZ 06-05-2012
33
- stubfedora = double("Fedora")
34
- stubfedora.should_receive(:connection).and_return(double("Connection", :mint =>"sample:newpid"))
33
+ stubfedora = double('Fedora')
34
+ expect(stubfedora).to receive(:connection).and_return(double('Connection', :mint => 'sample:newpid'))
35
35
  # Should use ActiveFedora.config.credentials as a single hash rather than an array of shards
36
- ActiveFedora::RubydoraConnection.should_receive(:new).with(ActiveFedora.config.credentials).and_return(stubfedora)
36
+ expect(ActiveFedora::RubydoraConnection).to receive(:new).with(ActiveFedora.config.credentials).and_return(stubfedora)
37
37
  ActiveFedora::Base.assign_pid(ActiveFedora::Base.new.inner_object)
38
38
  end
39
39
  end
40
- describe "shard_index" do
41
- it "should always return zero (the first and only connection)" do
42
- ActiveFedora::Base.shard_index('test:bar').should == 0
40
+ describe 'shard_index' do
41
+ it 'should always return zero (the first and only connection)' do
42
+ expect(ActiveFedora::Base.shard_index('test:bar')).to eq(0)
43
43
  end
44
44
  end
45
45
  end
46
- context "When the repository is sharded" do
46
+ context 'When the repository is sharded' do
47
47
  before :each do
48
- ActiveFedora.config.stub(:sharded?).and_return(true)
48
+ allow(ActiveFedora.config).to receive(:sharded?).and_return(true)
49
49
  ActiveFedora::Base.fedora_connection = {}
50
- ActiveFedora.config.stub(:credentials).and_return([{:url=>'shard1'}, {:url=>'shard2'} ])
51
- end
52
- describe "assign_pid" do
53
- it "should always use the first shard to generate pids" do
54
- stubhard1 = double("Shard")
55
- stubhard2 = double("Shard")
56
- stubhard1.should_receive(:connection).and_return(double("Connection", :mint =>"sample:newpid"))
57
- stubhard2.should_receive(:connection).never
50
+ allow(ActiveFedora.config).to receive(:credentials).and_return([{:url => 'shard1'}, {:url => 'shard2'} ])
51
+ end
52
+ describe 'assign_pid' do
53
+ it 'should always use the first shard to generate pids' do
54
+ stubhard1 = double('Shard')
55
+ stubhard2 = double('Shard')
56
+ expect(stubhard1).to receive(:connection).and_return(double('Connection', :mint => 'sample:newpid'))
57
+ expect(stubhard2).to receive(:connection).never
58
58
  ActiveFedora::Base.fedora_connection = {0 => stubhard1, 1 => stubhard2}
59
59
  ActiveFedora::Base.assign_pid(ActiveFedora::Base.new.inner_object)
60
60
  end
61
61
  end
62
- describe "shard_index" do
63
- it "should use modulo of md5 of the pid to distribute objects across shards" do
64
- ActiveFedora::Base.shard_index('test:bar').should == 0
65
- ActiveFedora::Base.shard_index('test:nanana').should == 1
62
+ describe 'shard_index' do
63
+ it 'should use modulo of md5 of the pid to distribute objects across shards' do
64
+ expect(ActiveFedora::Base.shard_index('test:bar')).to eq(0)
65
+ expect(ActiveFedora::Base.shard_index('test:nanana')).to eq(1)
66
66
  end
67
67
  end
68
- describe "the repository" do
69
- describe "for test:bar" do
68
+ describe 'the repository' do
69
+ describe 'for test:bar' do
70
70
  subject {ActiveFedora::Base.connection_for_pid('test:bar')}
71
- it "should be shard1" do
72
- subject.client.url.should == 'shard1'
71
+ it 'should be shard1' do
72
+ expect(subject.client.url).to eq('shard1')
73
73
  end
74
74
  end
75
- describe "for test:baz" do
75
+ describe 'for test:baz' do
76
76
  subject {ActiveFedora::Base.connection_for_pid('test:nanana')}
77
- it "should be shard1" do
78
- subject.client.url.should == 'shard2'
77
+ it 'should be shard1' do
78
+ expect(subject.client.url).to eq('shard2')
79
79
  end
80
80
  end
81
81
  end
@@ -83,53 +83,53 @@ describe ActiveFedora::Base do
83
83
 
84
84
  end
85
85
 
86
- describe "reindex_everything" do
87
- it "should call update_index on every object except for the fedora-system objects" do
88
- Rubydora::Repository.any_instance.should_receive(:search).
89
- and_yield(double(pid:'XXX')).and_yield(double(pid:'YYY')).and_yield(double(pid:'ZZZ')).
90
- and_yield(double(pid:'fedora-system:ServiceDeployment-3.0')).
91
- and_yield(double(pid:'fedora-system:ServiceDefinition-3.0')).
92
- and_yield(double(pid:'fedora-system:FedoraObject-3.0'))
86
+ describe 'reindex_everything' do
87
+ it 'should call update_index on every object except for the fedora-system objects' do
88
+ expect_any_instance_of(Rubydora::Repository).to receive(:search).
89
+ and_yield(double(pid: 'XXX')).and_yield(double(pid: 'YYY')).and_yield(double(pid: 'ZZZ')).
90
+ and_yield(double(pid: 'fedora-system:ServiceDeployment-3.0')).
91
+ and_yield(double(pid: 'fedora-system:ServiceDefinition-3.0')).
92
+ and_yield(double(pid: 'fedora-system:FedoraObject-3.0'))
93
93
 
94
94
  mock_update = double(:mock_obj)
95
- mock_update.should_receive(:update_index).exactly(3).times
96
- ActiveFedora::Base.should_receive(:find).with('XXX', :cast=>true).and_return(mock_update)
97
- ActiveFedora::Base.should_receive(:find).with('YYY', :cast=>true).and_return(mock_update)
98
- ActiveFedora::Base.should_receive(:find).with('ZZZ', :cast=>true).and_return(mock_update)
95
+ expect(mock_update).to receive(:update_index).exactly(3).times
96
+ expect(ActiveFedora::Base).to receive(:find).with('XXX', :cast => true).and_return(mock_update)
97
+ expect(ActiveFedora::Base).to receive(:find).with('YYY', :cast => true).and_return(mock_update)
98
+ expect(ActiveFedora::Base).to receive(:find).with('ZZZ', :cast => true).and_return(mock_update)
99
99
  ActiveFedora::Base.reindex_everything
100
100
  end
101
101
 
102
- it "should accept a query param for the search" do
103
- query_string = "pid~*"
104
- Rubydora::Repository.any_instance.should_receive(:search).with(query_string).
105
- and_yield(double(pid:'XXX')).and_yield(double(pid:'YYY')).and_yield(double(pid:'ZZZ'))
102
+ it 'should accept a query param for the search' do
103
+ query_string = 'pid~*'
104
+ expect_any_instance_of(Rubydora::Repository).to receive(:search).with(query_string).
105
+ and_yield(double(pid: 'XXX')).and_yield(double(pid: 'YYY')).and_yield(double(pid: 'ZZZ'))
106
106
  mock_update = double(:mock_obj)
107
- mock_update.should_receive(:update_index).exactly(3).times
108
- ActiveFedora::Base.should_receive(:find).with('XXX', :cast=>true).and_return(mock_update)
109
- ActiveFedora::Base.should_receive(:find).with('YYY', :cast=>true).and_return(mock_update)
110
- ActiveFedora::Base.should_receive(:find).with('ZZZ', :cast=>true).and_return(mock_update)
107
+ expect(mock_update).to receive(:update_index).exactly(3).times
108
+ expect(ActiveFedora::Base).to receive(:find).with('XXX', :cast => true).and_return(mock_update)
109
+ expect(ActiveFedora::Base).to receive(:find).with('YYY', :cast => true).and_return(mock_update)
110
+ expect(ActiveFedora::Base).to receive(:find).with('ZZZ', :cast => true).and_return(mock_update)
111
111
  ActiveFedora::Base.reindex_everything(query_string)
112
112
  end
113
113
  end
114
114
 
115
- describe "With a test class" do
115
+ describe 'With a test class' do
116
116
  before :all do
117
117
  class FooHistory < ActiveFedora::Base
118
- has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"someData", :autocreate => true do |m|
119
- m.field "fubar", :string
120
- m.field "swank", :text
118
+ has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'someData', :autocreate => true do |m|
119
+ m.field 'fubar', :string
120
+ m.field 'swank', :text
121
121
  end
122
- has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText", :autocreate => true do |m|
123
- m.field "fubar", :text
122
+ has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'withText', :autocreate => true do |m|
123
+ m.field 'fubar', :text
124
124
  end
125
- has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText2", :label=>"withLabel", :autocreate => true do |m|
126
- m.field "fubar", :text
127
- end
128
- delegate :fubar, :to=>'withText', multiple: true
129
- delegate :swank, :to=>'someData', multiple: true
125
+ has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'withText2', :label => 'withLabel', :autocreate => true do |m|
126
+ m.field 'fubar', :text
127
+ end
128
+ delegate :fubar, :to => 'withText', multiple: true
129
+ delegate :swank, :to => 'someData', multiple: true
130
130
  end
131
131
  class FooAdaptation < ActiveFedora::Base
132
- has_metadata :type=>ActiveFedora::OmDatastream, :name=>'someData'
132
+ has_metadata :type => ActiveFedora::OmDatastream, :name => 'someData'
133
133
  end
134
134
 
135
135
  class FooInherited < FooHistory
@@ -150,15 +150,15 @@ describe ActiveFedora::Base do
150
150
  before(:each) do
151
151
  @this_pid = increment_pid.to_s
152
152
  stub_get(@this_pid)
153
- Rubydora::Repository.any_instance.stub(:client).and_return(@mock_client)
154
- ActiveFedora::Base.stub(:assign_pid).and_return(@this_pid)
153
+ allow_any_instance_of(Rubydora::Repository).to receive(:client).and_return(@mock_client)
154
+ allow(ActiveFedora::Base).to receive(:assign_pid).and_return(@this_pid)
155
155
 
156
156
  @test_object = ActiveFedora::Base.new
157
157
  end
158
158
 
159
159
  after(:each) do
160
160
  begin
161
- ActiveFedora::SolrService.stub(:instance)
161
+ allow(ActiveFedora::SolrService).to receive(:instance)
162
162
  #@test_object.delete
163
163
  rescue
164
164
  end
@@ -166,449 +166,449 @@ describe ActiveFedora::Base do
166
166
 
167
167
 
168
168
  describe '#new' do
169
- it "should create an inner object" do
169
+ it 'should create an inner object' do
170
170
  # for doing AFObject.new(params[:foo]) when nothing is in params[:foo]
171
- Rubydora::DigitalObject.any_instance.should_receive(:save).never
171
+ expect_any_instance_of(Rubydora::DigitalObject).to receive(:save).never
172
172
  result = ActiveFedora::Base.new(nil)
173
- result.inner_object.should be_kind_of(ActiveFedora::UnsavedDigitalObject)
173
+ expect(result.inner_object).to be_kind_of(ActiveFedora::UnsavedDigitalObject)
174
174
  end
175
175
 
176
- it "should not save or get an pid on init" do
177
- Rubydora::DigitalObject.any_instance.should_receive(:save).never
178
- ActiveFedora::Base.should_receive(:assign_pid).never
176
+ it 'should not save or get an pid on init' do
177
+ expect_any_instance_of(Rubydora::DigitalObject).to receive(:save).never
178
+ expect(ActiveFedora::Base).to receive(:assign_pid).never
179
179
  f = FooHistory.new
180
180
  end
181
181
 
182
- it "should be able to create with a custom pid" do
183
- f = FooHistory.new(:pid=>'numbnuts:1')
184
- f.pid.should == 'numbnuts:1'
182
+ it 'should be able to create with a custom pid' do
183
+ f = FooHistory.new(:pid => 'numbnuts:1')
184
+ expect(f.pid).to eq('numbnuts:1')
185
185
  end
186
186
  end
187
187
 
188
- describe ".datastream_class_for_name" do
189
- it "should return the specifed class" do
190
- FooAdaptation.datastream_class_for_name('someData').should == ActiveFedora::OmDatastream
188
+ describe '.datastream_class_for_name' do
189
+ it 'should return the specifed class' do
190
+ expect(FooAdaptation.datastream_class_for_name('someData')).to eq(ActiveFedora::OmDatastream)
191
191
  end
192
- it "should return the specifed class" do
193
- FooAdaptation.datastream_class_for_name('content').should == ActiveFedora::Datastream
192
+ it 'should return the specifed class' do
193
+ expect(FooAdaptation.datastream_class_for_name('content')).to eq(ActiveFedora::Datastream)
194
194
  end
195
195
  end
196
196
 
197
- describe ".internal_uri" do
198
- it "should return pid as fedors uri" do
199
- @test_object.internal_uri.should eql("info:fedora/#{@test_object.pid}")
197
+ describe '.internal_uri' do
198
+ it 'should return pid as fedors uri' do
199
+ expect(@test_object.internal_uri).to eql("info:fedora/#{@test_object.pid}")
200
200
  end
201
201
  end
202
202
 
203
203
  ### Methods for ActiveModel::Conversions
204
204
  it "should have to_param once it's saved" do
205
- @test_object.to_param.should be_nil
205
+ expect(@test_object.to_param).to be_nil
206
206
  @test_object.inner_object.stub(:new? => false, :pid => 'foo:123')
207
- @test_object.to_param.should == 'foo:123'
207
+ expect(@test_object.to_param).to eq('foo:123')
208
208
  end
209
209
 
210
210
  it "should have to_key once it's saved" do
211
- @test_object.to_key.should be_nil
211
+ expect(@test_object.to_key).to be_nil
212
212
  @test_object.inner_object.stub(:new? => false)
213
- @test_object.to_key.should == [@test_object.pid]
213
+ expect(@test_object.to_key).to eq([@test_object.pid])
214
214
  end
215
215
 
216
216
  it "should have to_model when it's saved" do
217
- @test_object.to_model.should be @test_object
217
+ expect(@test_object.to_model).to be @test_object
218
218
  end
219
219
  ### end ActiveModel::Conversions
220
220
 
221
221
  ### Methods for ActiveModel::Naming
222
- it "Should know the model_name" do
223
- FooHistory.model_name.should == 'FooHistory'
224
- FooHistory.model_name.human.should == 'Foo history'
222
+ it 'Should know the model_name' do
223
+ expect(FooHistory.model_name).to eq('FooHistory')
224
+ expect(FooHistory.model_name.human).to eq('Foo history')
225
225
  end
226
226
  ### End ActiveModel::Naming
227
227
 
228
228
 
229
- describe ".datastreams" do
229
+ describe '.datastreams' do
230
230
  before do
231
231
  @test_history = FooHistory.new
232
232
  end
233
- it "should create dynamic accessors" do
234
- @test_history.withText.should == @test_history.datastreams['withText']
233
+ it 'should create dynamic accessors' do
234
+ expect(@test_history.withText).to eq(@test_history.datastreams['withText'])
235
235
  end
236
- it "dynamic accessors should convert dashes to underscores" do
237
- ds = double('datastream', :dsid=>'eac-cpf')
236
+ it 'dynamic accessors should convert dashes to underscores' do
237
+ ds = double('datastream', :dsid => 'eac-cpf')
238
238
  @test_history.add_datastream(ds)
239
- @test_history.eac_cpf.should == ds
239
+ expect(@test_history.eac_cpf).to eq(ds)
240
240
  end
241
- it "dynamic accessors should not convert datastreams named with underscore" do
242
- ds = double('datastream', :dsid=>'foo_bar')
241
+ it 'dynamic accessors should not convert datastreams named with underscore' do
242
+ ds = double('datastream', :dsid => 'foo_bar')
243
243
  @test_history.add_datastream(ds)
244
- @test_history.foo_bar.should == ds
244
+ expect(@test_history.foo_bar).to eq(ds)
245
245
  end
246
246
  end
247
247
 
248
248
  it 'should provide #find' do
249
- ActiveFedora::Base.should respond_to(:find)
249
+ expect(ActiveFedora::Base).to respond_to(:find)
250
250
  end
251
251
 
252
- it "should provide .create_date" do
253
- @test_object.should respond_to(:create_date)
252
+ it 'should provide .create_date' do
253
+ expect(@test_object).to respond_to(:create_date)
254
254
  end
255
255
 
256
- it "should provide .modified_date" do
257
- @test_object.should respond_to(:modified_date)
256
+ it 'should provide .modified_date' do
257
+ expect(@test_object).to respond_to(:modified_date)
258
258
  end
259
259
 
260
260
  it 'should respond to .rels_ext' do
261
- @test_object.should respond_to(:rels_ext)
261
+ expect(@test_object).to respond_to(:rels_ext)
262
262
  end
263
263
 
264
264
  describe '.rels_ext' do
265
265
 
266
266
  it 'should return the RelsExtDatastream object from the datastreams array' do
267
- @test_object.stub(:datastreams => {"RELS-EXT" => "foo"})
268
- @test_object.rels_ext.should == "foo"
267
+ @test_object.stub(:datastreams => {'RELS-EXT' => 'foo'})
268
+ expect(@test_object.rels_ext).to eq('foo')
269
269
  end
270
270
  end
271
271
 
272
272
  it 'should provide #add_relationship' do
273
- @test_object.should respond_to(:add_relationship)
273
+ expect(@test_object).to respond_to(:add_relationship)
274
274
  end
275
275
 
276
276
  describe '#add_relationship' do
277
277
  it 'should call #add_relationship on the rels_ext datastream' do
278
- @test_object.add_relationship("predicate", "info:fedora/object")
279
- pred = ActiveFedora::Predicates.vocabularies["info:fedora/fedora-system:def/relations-external#"]["predicate"]
280
- @test_object.relationships.should have_statement(RDF::Statement.new(RDF::URI.new(@test_object.internal_uri), pred, RDF::URI.new("info:fedora/object")))
278
+ @test_object.add_relationship('predicate', 'info:fedora/object')
279
+ pred = ActiveFedora::Predicates.vocabularies['info:fedora/fedora-system:def/relations-external#']['predicate']
280
+ expect(@test_object.relationships).to have_statement(RDF::Statement.new(RDF::URI.new(@test_object.internal_uri), pred, RDF::URI.new('info:fedora/object')))
281
281
  end
282
282
 
283
- it "should update the RELS-EXT datastream and set the datastream as dirty when relationships are added" do
284
- mock_ds = double("Rels-Ext")
285
- mock_ds.stub(:content_will_change!)
286
- @test_object.datastreams["RELS-EXT"] = mock_ds
287
- @test_object.add_relationship(:is_member_of, "info:fedora/demo:5")
288
- @test_object.add_relationship(:is_member_of, "info:fedora/demo:10")
283
+ it 'should update the RELS-EXT datastream and set the datastream as dirty when relationships are added' do
284
+ mock_ds = double('Rels-Ext')
285
+ allow(mock_ds).to receive(:content_will_change!)
286
+ @test_object.datastreams['RELS-EXT'] = mock_ds
287
+ @test_object.add_relationship(:is_member_of, 'info:fedora/demo:5')
288
+ @test_object.add_relationship(:is_member_of, 'info:fedora/demo:10')
289
289
  end
290
290
 
291
291
  it 'should add a relationship to an object only if it does not exist already' do
292
292
  next_pid = increment_pid.to_s
293
- ActiveFedora::Base.stub(:assign_pid).and_return(next_pid)
293
+ allow(ActiveFedora::Base).to receive(:assign_pid).and_return(next_pid)
294
294
  stub_get(next_pid)
295
295
 
296
296
  @test_object3 = ActiveFedora::Base.new
297
- @test_object.add_relationship(:has_part,@test_object3)
298
- @test_object.ids_for_outbound(:has_part).should == [@test_object3.pid]
297
+ @test_object.add_relationship(:has_part, @test_object3)
298
+ expect(@test_object.ids_for_outbound(:has_part)).to eq([@test_object3.pid])
299
299
  #try adding again and make sure not there twice
300
- @test_object.add_relationship(:has_part,@test_object3)
301
- @test_object.ids_for_outbound(:has_part).should == [@test_object3.pid]
300
+ @test_object.add_relationship(:has_part, @test_object3)
301
+ expect(@test_object.ids_for_outbound(:has_part)).to eq([@test_object3.pid])
302
302
  end
303
303
 
304
304
  it 'should add literal relationships if requested' do
305
- @test_object.add_relationship(:conforms_to,"AnInterface",true)
306
- @test_object.ids_for_outbound(:conforms_to).should == ["AnInterface"]
305
+ @test_object.add_relationship(:conforms_to, 'AnInterface', true)
306
+ expect(@test_object.ids_for_outbound(:conforms_to)).to eq(['AnInterface'])
307
307
  end
308
308
  end
309
309
 
310
310
  it 'should provide #remove_relationship' do
311
- @test_object.should respond_to(:remove_relationship)
311
+ expect(@test_object).to respond_to(:remove_relationship)
312
312
  end
313
313
 
314
314
  describe '#remove_relationship' do
315
315
  it 'should remove a relationship from the relationships hash' do
316
316
  @test_object3 = ActiveFedora::Base.new()
317
- @test_object3.stub(:pid=>'7')
317
+ @test_object3.stub(:pid => '7')
318
318
  @test_object4 = ActiveFedora::Base.new()
319
- @test_object4.stub(:pid=>'8')
320
- @test_object.add_relationship(:has_part,@test_object3)
321
- @test_object.add_relationship(:has_part,@test_object4)
319
+ @test_object4.stub(:pid => '8')
320
+ @test_object.add_relationship(:has_part, @test_object3)
321
+ @test_object.add_relationship(:has_part, @test_object4)
322
322
  #check both are there
323
- @test_object.ids_for_outbound(:has_part).should == [@test_object3.pid,@test_object4.pid]
324
- @test_object.remove_relationship(:has_part,@test_object3)
323
+ expect(@test_object.ids_for_outbound(:has_part)).to eq([@test_object3.pid, @test_object4.pid])
324
+ @test_object.remove_relationship(:has_part, @test_object3)
325
325
  #check only one item removed
326
- @test_object.ids_for_outbound(:has_part).should == [@test_object4.pid]
327
- @test_object.remove_relationship(:has_part,@test_object4)
326
+ expect(@test_object.ids_for_outbound(:has_part)).to eq([@test_object4.pid])
327
+ @test_object.remove_relationship(:has_part, @test_object4)
328
328
  #check last item removed and predicate removed since now emtpy
329
- @test_object.relationships.size.should == 0
329
+ expect(@test_object.relationships.size).to eq(0)
330
330
  end
331
331
  end
332
332
 
333
333
  it 'should provide #relationships' do
334
- @test_object.should respond_to(:relationships)
334
+ expect(@test_object).to respond_to(:relationships)
335
335
  end
336
336
 
337
337
  describe '#relationships' do
338
338
  it 'should return a graph' do
339
- @test_object.relationships.kind_of?(RDF::Graph).should be_true
340
- @test_object.relationships.size.should == 0
339
+ expect(@test_object.relationships.kind_of?(RDF::Graph)).to be_truthy
340
+ expect(@test_object.relationships.size).to eq(0)
341
341
  end
342
342
  end
343
343
 
344
344
  describe '.assert_content_model' do
345
- it "should default to the name of the class" do
345
+ it 'should default to the name of the class' do
346
346
  stub_get(@this_pid)
347
347
  stub_add_ds(@this_pid, ['RELS-EXT'])
348
348
  @test_object.assert_content_model
349
- @test_object.relationships(:has_model).should == ["info:fedora/afmodel:ActiveFedora_Base"]
349
+ expect(@test_object.relationships(:has_model)).to eq(['info:fedora/afmodel:ActiveFedora_Base'])
350
350
 
351
351
  end
352
352
  end
353
353
 
354
354
  describe '.save' do
355
- it "should create a new record" do
355
+ it 'should create a new record' do
356
356
  @test_object.stub(:new_record? => true)
357
- @test_object.should_receive(:create)
358
- @test_object.should_receive(:update_index)
357
+ expect(@test_object).to receive(:create)
358
+ expect(@test_object).to receive(:update_index)
359
359
  @test_object.save
360
360
  end
361
361
 
362
- it "should update an existing record" do
362
+ it 'should update an existing record' do
363
363
  @test_object.stub(:new_record? => false)
364
- @test_object.should_receive(:update_record)
365
- @test_object.should_receive(:update_index)
364
+ expect(@test_object).to receive(:update_record)
365
+ expect(@test_object).to receive(:update_index)
366
366
  @test_object.save
367
367
  end
368
368
  end
369
369
 
370
- describe "#create" do
371
- it "should build a new record and save it" do
370
+ describe '#create' do
371
+ it 'should build a new record and save it' do
372
372
  obj = double()
373
- obj.should_receive(:save)
374
- FooHistory.should_receive(:new).and_return(obj)
375
- @hist = FooHistory.create(:fubar=>'ta', :swank=>'da')
373
+ expect(obj).to receive(:save)
374
+ expect(FooHistory).to receive(:new).and_return(obj)
375
+ @hist = FooHistory.create(:fubar => 'ta', :swank => 'da')
376
376
  end
377
377
 
378
378
  end
379
379
 
380
- describe ".adapt_to" do
381
- it "should return an adapted object of the requested type" do
380
+ describe '.adapt_to' do
381
+ it 'should return an adapted object of the requested type' do
382
382
  @test_object = FooHistory.new()
383
- @test_object.adapt_to(FooAdaptation).class.should == FooAdaptation
383
+ expect(@test_object.adapt_to(FooAdaptation).class).to eq(FooAdaptation)
384
384
  end
385
- it "should not make an additional call to fedora to create the adapted object" do
385
+ it 'should not make an additional call to fedora to create the adapted object' do
386
386
  @test_object = FooHistory.new()
387
387
  adapted = @test_object.adapt_to(FooAdaptation)
388
388
  end
389
- it "should propagate new datastreams to the adapted object" do
389
+ it 'should propagate new datastreams to the adapted object' do
390
390
  @test_object = FooHistory.new()
391
- @test_object.add_file_datastream("XXX", :dsid=>'MY_DSID')
391
+ @test_object.add_file_datastream('XXX', :dsid => 'MY_DSID')
392
392
  adapted = @test_object.adapt_to(FooAdaptation)
393
- adapted.datastreams.keys.should include 'MY_DSID'
394
- adapted.datastreams['MY_DSID'].content.should == "XXX"
395
- adapted.datastreams['MY_DSID'].changed?.should be_true
393
+ expect(adapted.datastreams.keys).to include 'MY_DSID'
394
+ expect(adapted.datastreams['MY_DSID'].content).to eq('XXX')
395
+ expect(adapted.datastreams['MY_DSID'].changed?).to be_truthy
396
396
  end
397
- it "should propagate modified datastreams to the adapted object" do
397
+ it 'should propagate modified datastreams to the adapted object' do
398
398
  @test_object = FooHistory.new()
399
399
  orig_ds = @test_object.datastreams['someData']
400
- orig_ds.content="<YYY/>"
400
+ orig_ds.content = '<YYY/>'
401
401
  adapted = @test_object.adapt_to(FooAdaptation)
402
- adapted.datastreams.keys.should include 'someData'
403
- adapted.datastreams['someData'].should == orig_ds
404
- adapted.datastreams['someData'].content.strip.should == "<YYY/>"
405
- adapted.datastreams['someData'].changed?.should be_true
402
+ expect(adapted.datastreams.keys).to include 'someData'
403
+ expect(adapted.datastreams['someData']).to eq(orig_ds)
404
+ expect(adapted.datastreams['someData'].content.strip).to eq('<YYY/>')
405
+ expect(adapted.datastreams['someData'].changed?).to be_truthy
406
406
  end
407
- it "should use the datastream definitions from the adapted object" do
407
+ it 'should use the datastream definitions from the adapted object' do
408
408
  @test_object = FooHistory.new()
409
409
  adapted = @test_object.adapt_to(FooAdaptation)
410
- adapted.datastreams.keys.should include 'someData'
411
- adapted.datastreams['someData'].class.should == ActiveFedora::OmDatastream
410
+ expect(adapted.datastreams.keys).to include 'someData'
411
+ expect(adapted.datastreams['someData'].class).to eq(ActiveFedora::OmDatastream)
412
412
  end
413
413
  end
414
414
 
415
- describe ".adapt_to_cmodel with implemented (non-ActiveFedora::Base) cmodel" do
415
+ describe '.adapt_to_cmodel with implemented (non-ActiveFedora::Base) cmodel' do
416
416
  subject { FooHistory.new }
417
417
 
418
- it "should not cast to a random first cmodel if it has a specific cmodel already" do
419
- ActiveFedora::ContentModel.should_receive(:known_models_for).with(subject).and_return([FooAdaptation])
420
- subject.adapt_to_cmodel.should be_kind_of FooHistory
418
+ it 'should not cast to a random first cmodel if it has a specific cmodel already' do
419
+ expect(ActiveFedora::ContentModel).to receive(:known_models_for).with(subject).and_return([FooAdaptation])
420
+ expect(subject.adapt_to_cmodel).to be_kind_of FooHistory
421
421
  end
422
- it "should cast to an inherited model over a random one" do
423
- ActiveFedora::ContentModel.should_receive(:known_models_for).with(subject).and_return([FooAdaptation, FooInherited])
424
- subject.adapt_to_cmodel.should be_kind_of FooInherited
422
+ it 'should cast to an inherited model over a random one' do
423
+ expect(ActiveFedora::ContentModel).to receive(:known_models_for).with(subject).and_return([FooAdaptation, FooInherited])
424
+ expect(subject.adapt_to_cmodel).to be_kind_of FooInherited
425
425
  end
426
- it "should not cast when a cmodel is same as the class" do
427
- ActiveFedora::ContentModel.should_receive(:known_models_for).with(subject).and_return([FooHistory])
428
- subject.adapt_to_cmodel.should === subject
426
+ it 'should not cast when a cmodel is same as the class' do
427
+ expect(ActiveFedora::ContentModel).to receive(:known_models_for).with(subject).and_return([FooHistory])
428
+ expect(subject.adapt_to_cmodel).to be === subject
429
429
  end
430
430
  end
431
431
 
432
- describe ".adapt_to_cmodel with ActiveFedora::Base" do
432
+ describe '.adapt_to_cmodel with ActiveFedora::Base' do
433
433
  subject { ActiveFedora::Base.new }
434
434
 
435
- it "should cast to the first cmodel if ActiveFedora::Base (or no specified cmodel)" do
436
- ActiveFedora::ContentModel.should_receive(:known_models_for).with(subject).and_return([FooAdaptation, FooHistory])
437
- subject.adapt_to_cmodel.should be_kind_of FooAdaptation
435
+ it 'should cast to the first cmodel if ActiveFedora::Base (or no specified cmodel)' do
436
+ expect(ActiveFedora::ContentModel).to receive(:known_models_for).with(subject).and_return([FooAdaptation, FooHistory])
437
+ expect(subject.adapt_to_cmodel).to be_kind_of FooAdaptation
438
438
  end
439
439
  end
440
440
 
441
441
 
442
- describe ".to_solr" do
443
- it "should provide .to_solr" do
444
- @test_object.should respond_to(:to_solr)
442
+ describe '.to_solr' do
443
+ it 'should provide .to_solr' do
444
+ expect(@test_object).to respond_to(:to_solr)
445
445
  end
446
446
 
447
- it "should add pid, system_create_date, system_modified_date and object_state from object attributes" do
448
- @test_object.should_receive(:create_date).and_return("2012-03-04T03:12:02Z")
449
- @test_object.should_receive(:modified_date).and_return("2012-03-07T03:12:02Z")
447
+ it 'should add pid, system_create_date, system_modified_date and object_state from object attributes' do
448
+ expect(@test_object).to receive(:create_date).and_return('2012-03-04T03:12:02Z')
449
+ expect(@test_object).to receive(:modified_date).and_return('2012-03-07T03:12:02Z')
450
450
  @test_object.stub(pid: 'changeme:123')
451
- @test_object.state = "D"
451
+ @test_object.state = 'D'
452
452
  solr_doc = @test_object.to_solr
453
- solr_doc[ActiveFedora::SolrService.solr_name("system_create", :stored_sortable, type: :date)].should eql("2012-03-04T03:12:02Z")
454
- solr_doc[ActiveFedora::SolrService.solr_name("system_modified", :stored_sortable, type: :date)].should eql("2012-03-07T03:12:02Z")
455
- solr_doc[ActiveFedora::SolrService.solr_name("object_state", :stored_sortable)].should eql("D")
456
- solr_doc[:id].should eql("changeme:123")
453
+ expect(solr_doc[ActiveFedora::SolrService.solr_name('system_create', :stored_sortable, type: :date)]).to eql('2012-03-04T03:12:02Z')
454
+ expect(solr_doc[ActiveFedora::SolrService.solr_name('system_modified', :stored_sortable, type: :date)]).to eql('2012-03-07T03:12:02Z')
455
+ expect(solr_doc[ActiveFedora::SolrService.solr_name('object_state', :stored_sortable)]).to eql('D')
456
+ expect(solr_doc[:id]).to eql('changeme:123')
457
457
  end
458
458
 
459
- it "should omit base metadata and RELS-EXT if :model_only==true" do
460
- @test_object.add_relationship(:has_part, "foo", true)
461
- solr_doc = @test_object.to_solr(Hash.new, :model_only => true)
462
- solr_doc[ActiveFedora::SolrService.solr_name("system_create", type: :date)].should be_nil
463
- solr_doc[ActiveFedora::SolrService.solr_name("system_modified", type: :date)].should be_nil
464
- solr_doc["id"].should be_nil
465
- solr_doc[ActiveFedora::SolrService.solr_name("has_part", :symbol)].should be_nil
459
+ it 'should omit base metadata and RELS-EXT if :model_only==true' do
460
+ @test_object.add_relationship(:has_part, 'foo', true)
461
+ solr_doc = @test_object.to_solr({}, :model_only => true)
462
+ expect(solr_doc[ActiveFedora::SolrService.solr_name('system_create', type: :date)]).to be_nil
463
+ expect(solr_doc[ActiveFedora::SolrService.solr_name('system_modified', type: :date)]).to be_nil
464
+ expect(solr_doc['id']).to be_nil
465
+ expect(solr_doc[ActiveFedora::SolrService.solr_name('has_part', :symbol)]).to be_nil
466
466
  end
467
467
 
468
- it "should add self.class as the :active_fedora_model" do
468
+ it 'should add self.class as the :active_fedora_model' do
469
469
  stub_get(@this_pid)
470
470
  stub_get_content(@this_pid, ['RELS-EXT', 'someData', 'withText2', 'withText'])
471
471
  @test_history = FooHistory.new()
472
472
  solr_doc = @test_history.to_solr
473
- solr_doc[ActiveFedora::SolrService.solr_name("active_fedora_model", :stored_sortable)].should eql("FooHistory")
473
+ expect(solr_doc[ActiveFedora::SolrService.solr_name('active_fedora_model', :stored_sortable)]).to eql('FooHistory')
474
474
  end
475
475
 
476
- it "should call .to_solr on all SimpleDatastreams and OmDatastreams, passing the resulting document to solr" do
477
- mock1 = double("ds1", :to_solr => {})
478
- mock2 = double("ds2", :to_solr => {})
479
- ngds = double("ngds", :to_solr => {})
480
- ngds.should_receive(:solrize_profile)
481
- mock1.should_receive(:solrize_profile)
482
- mock2.should_receive(:solrize_profile)
476
+ it 'should call .to_solr on all SimpleDatastreams and OmDatastreams, passing the resulting document to solr' do
477
+ mock1 = double('ds1', :to_solr => {})
478
+ mock2 = double('ds2', :to_solr => {})
479
+ ngds = double('ngds', :to_solr => {})
480
+ expect(ngds).to receive(:solrize_profile)
481
+ expect(mock1).to receive(:solrize_profile)
482
+ expect(mock2).to receive(:solrize_profile)
483
483
 
484
- @test_object.should_receive(:datastreams).twice.and_return({:ds1 => mock1, :ds2 => mock2, :ngds => ngds})
485
- @test_object.should_receive(:solrize_relationships)
484
+ expect(@test_object).to receive(:datastreams).twice.and_return({:ds1 => mock1, :ds2 => mock2, :ngds => ngds})
485
+ expect(@test_object).to receive(:solrize_relationships)
486
486
  @test_object.to_solr
487
487
  end
488
- it "should call .to_solr on all RDFDatastreams, passing the resulting document to solr" do
489
- mock = double("ds1", :to_solr => {})
490
- mock.should_receive(:solrize_profile)
488
+ it 'should call .to_solr on all RDFDatastreams, passing the resulting document to solr' do
489
+ mock = double('ds1', :to_solr => {})
490
+ expect(mock).to receive(:solrize_profile)
491
491
 
492
- @test_object.should_receive(:datastreams).twice.and_return({:ds1 => mock})
493
- @test_object.should_receive(:solrize_relationships)
492
+ expect(@test_object).to receive(:datastreams).twice.and_return({:ds1 => mock})
493
+ expect(@test_object).to receive(:solrize_relationships)
494
494
  @test_object.to_solr
495
495
  end
496
496
 
497
- it "should call .to_solr on the relationships rels-ext is dirty" do
498
- @test_object.add_relationship(:has_collection_member, "info:fedora/test:member")
497
+ it 'should call .to_solr on the relationships rels-ext is dirty' do
498
+ @test_object.add_relationship(:has_collection_member, 'info:fedora/test:member')
499
499
  rels_ext = @test_object.rels_ext
500
- rels_ext.should be_changed
501
- @test_object.should_receive(:solrize_relationships)
500
+ expect(rels_ext).to be_changed
501
+ expect(@test_object).to receive(:solrize_relationships)
502
502
  @test_object.to_solr
503
503
  end
504
504
 
505
505
  end
506
506
 
507
- describe ".label" do
508
- it "should return the label of the inner object" do
509
- @test_object.inner_object.should_receive(:label).and_return("foo label")
510
- @test_object.label.should == "foo label"
507
+ describe '.label' do
508
+ it 'should return the label of the inner object' do
509
+ expect(@test_object.inner_object).to receive(:label).and_return('foo label')
510
+ expect(@test_object.label).to eq('foo label')
511
511
  end
512
512
  end
513
513
 
514
- describe ".label=" do
515
- it "should set the label of the inner object" do
516
- @test_object.label.should_not == "foo label"
517
- @test_object.label = "foo label"
518
- @test_object.label.should == "foo label"
514
+ describe '.label=' do
515
+ it 'should set the label of the inner object' do
516
+ expect(@test_object.label).not_to eq('foo label')
517
+ @test_object.label = 'foo label'
518
+ expect(@test_object.label).to eq('foo label')
519
519
  end
520
520
  end
521
521
 
522
522
 
523
- describe "get_values_from_datastream" do
524
- it "should look up the named datastream and call get_values with the given pointer/field_name" do
525
- mock_ds = double("Datastream", :get_values=>["value1", "value2"])
526
- @test_object.stub(:datastreams).and_return({"ds1"=>mock_ds})
527
- @test_object.get_values_from_datastream("ds1", "--my xpath--").should == ["value1", "value2"]
523
+ describe 'get_values_from_datastream' do
524
+ it 'should look up the named datastream and call get_values with the given pointer/field_name' do
525
+ mock_ds = double('Datastream', :get_values => ['value1', 'value2'])
526
+ allow(@test_object).to receive(:datastreams).and_return({'ds1' => mock_ds})
527
+ expect(@test_object.get_values_from_datastream('ds1', '--my xpath--')).to eq(['value1', 'value2'])
528
528
  end
529
529
  end
530
530
 
531
- describe "update_datastream_attributes" do
532
- it "should look up any datastreams specified as keys in the given hash and call update_attributes on the datastream" do
533
- mock_desc_metadata = double("descMetadata")
534
- mock_properties = double("properties")
535
- mock_ds_hash = {'descMetadata'=>mock_desc_metadata, 'properties'=>mock_properties}
531
+ describe 'update_datastream_attributes' do
532
+ it 'should look up any datastreams specified as keys in the given hash and call update_attributes on the datastream' do
533
+ mock_desc_metadata = double('descMetadata')
534
+ mock_properties = double('properties')
535
+ mock_ds_hash = {'descMetadata' => mock_desc_metadata, 'properties' => mock_properties}
536
536
 
537
537
  ds_values_hash = {
538
- "descMetadata"=>{ [{:person=>0}, :role]=>{"0"=>"role1", "1"=>"role2", "2"=>"role3"} },
539
- "properties"=>{ "notes"=>"foo" }
538
+ 'descMetadata' => { [{:person => 0}, :role] => {'0' => 'role1', '1' => 'role2', '2' => 'role3'} },
539
+ 'properties' => { 'notes' => 'foo' }
540
540
  }
541
541
  m = FooHistory.new
542
- m.stub(:datastreams).and_return(mock_ds_hash)
543
- mock_desc_metadata.should_receive(:update_indexed_attributes).with( ds_values_hash['descMetadata'] )
544
- mock_properties.should_receive(:update_indexed_attributes).with( ds_values_hash['properties'] )
542
+ allow(m).to receive(:datastreams).and_return(mock_ds_hash)
543
+ expect(mock_desc_metadata).to receive(:update_indexed_attributes).with( ds_values_hash['descMetadata'] )
544
+ expect(mock_properties).to receive(:update_indexed_attributes).with( ds_values_hash['properties'] )
545
545
  m.update_datastream_attributes( ds_values_hash )
546
546
  end
547
- it "should not do anything and should return an empty hash if the specified datastream does not exist" do
548
- pending "This is broken, and deprecated. I don't want to fix it - jcoyne"
547
+ it 'should not do anything and should return an empty hash if the specified datastream does not exist' do
548
+ skip "This is broken, and deprecated. I don't want to fix it - jcoyne"
549
549
  ds_values_hash = {
550
- "nonexistentDatastream"=>{ "notes"=>"foo" }
550
+ 'nonexistentDatastream' => { 'notes' => 'foo' }
551
551
  }
552
552
  m = FooHistory.new
553
553
  untouched_xml = m.to_xml
554
- m.update_datastream_attributes( ds_values_hash ).should == {}
555
- m.to_xml.should == untouched_xml
554
+ expect(m.update_datastream_attributes( ds_values_hash )).to eq({})
555
+ expect(m.to_xml).to eq(untouched_xml)
556
556
  end
557
557
  end
558
558
 
559
- describe "update_attributes" do
560
- it "should set the attributes and save" do
559
+ describe 'update_attributes' do
560
+ it 'should set the attributes and save' do
561
561
  m = FooHistory.new
562
- att= {"fubar"=> '1234', "baz" =>'stuff'}
562
+ att = {'fubar' => '1234', 'baz' => 'stuff'}
563
563
 
564
- m.should_receive(:fubar=).with('1234')
565
- m.should_receive(:baz=).with('stuff')
566
- m.should_receive(:save)
564
+ expect(m).to receive(:fubar=).with('1234')
565
+ expect(m).to receive(:baz=).with('stuff')
566
+ expect(m).to receive(:save)
567
567
  m.update_attributes(att)
568
568
  end
569
569
  end
570
570
 
571
- describe "update" do
572
- it "should set the attributes and save" do
571
+ describe 'update' do
572
+ it 'should set the attributes and save' do
573
573
  m = FooHistory.new
574
- att= {"fubar"=> '1234', "baz" =>'stuff'}
574
+ att = {'fubar' => '1234', 'baz' => 'stuff'}
575
575
 
576
- m.should_receive(:fubar=).with('1234')
577
- m.should_receive(:baz=).with('stuff')
578
- m.should_receive(:save)
576
+ expect(m).to receive(:fubar=).with('1234')
577
+ expect(m).to receive(:baz=).with('stuff')
578
+ expect(m).to receive(:save)
579
579
  m.update(att)
580
580
  end
581
581
  end
582
582
 
583
- describe "update_indexed_attributes" do
583
+ describe 'update_indexed_attributes' do
584
584
  before do
585
- Deprecation.should_receive(:warn).at_least(1).times
585
+ expect(Deprecation).to receive(:warn).at_least(1).times
586
586
  end
587
- it "should call .update_indexed_attributes on all metadata datastreams & nokogiri datastreams" do
587
+ it 'should call .update_indexed_attributes on all metadata datastreams & nokogiri datastreams' do
588
588
  m = FooHistory.new
589
- att= {"fubar"=>{"-1"=>"mork", "0"=>"york", "1"=>"mangle"}}
589
+ att = {'fubar' => {'-1' => 'mork', '0' => 'york', '1' => 'mangle'}}
590
590
 
591
- m.datastreams['someData'].should_receive(:update_indexed_attributes)
592
- m.datastreams["withText"].should_receive(:update_indexed_attributes)
593
- m.datastreams['withText2'].should_receive(:update_indexed_attributes)
591
+ expect(m.datastreams['someData']).to receive(:update_indexed_attributes)
592
+ expect(m.datastreams['withText']).to receive(:update_indexed_attributes)
593
+ expect(m.datastreams['withText2']).to receive(:update_indexed_attributes)
594
594
  m.update_indexed_attributes(att)
595
595
  end
596
- it "should take a :datastreams argument" do
597
- att= {"fubar"=>{"-1"=>"mork", "0"=>"york", "1"=>"mangle"}}
596
+ it 'should take a :datastreams argument' do
597
+ att = {'fubar' => {'-1' => 'mork', '0' => 'york', '1' => 'mangle'}}
598
598
  stub_get(@this_pid)
599
599
  stub_get_content(@this_pid, ['RELS-EXT', 'someData', 'withText2', 'withText'])
600
600
  m = FooHistory.new()
601
- m.update_indexed_attributes(att, :datastreams=>"withText")
602
- m.should_not be_nil
603
- m.datastreams['someData'].fubar.should == []
604
- m.datastreams["withText"].fubar.should == ['mork', 'york', 'mangle']
605
- m.datastreams['withText2'].fubar.should == []
601
+ m.update_indexed_attributes(att, :datastreams => 'withText')
602
+ expect(m).not_to be_nil
603
+ expect(m.datastreams['someData'].fubar).to eq([])
604
+ expect(m.datastreams['withText'].fubar).to eq(['mork', 'york', 'mangle'])
605
+ expect(m.datastreams['withText2'].fubar).to eq([])
606
606
 
607
- att= {"fubar"=>{"-1"=>"tork", "0"=>"work", "1"=>"bork"}}
608
- m.update_indexed_attributes(att, :datastreams=>["someData", "withText2"])
609
- m.should_not be_nil
610
- m.datastreams['someData'].fubar.should == ['tork', 'work', 'bork']
611
- m.datastreams['withText2'].fubar.should == ['tork', 'work', 'bork']
607
+ att = {'fubar' => {'-1' => 'tork', '0' => 'work', '1' => 'bork'}}
608
+ m.update_indexed_attributes(att, :datastreams => ['someData', 'withText2'])
609
+ expect(m).not_to be_nil
610
+ expect(m.datastreams['someData'].fubar).to eq(['tork', 'work', 'bork'])
611
+ expect(m.datastreams['withText2'].fubar).to eq(['tork', 'work', 'bork'])
612
612
  end
613
613
  end
614
614
 
@@ -622,21 +622,21 @@ pending "This is broken, and deprecated. I don't want to fix it - jcoyne"
622
622
  end
623
623
  end
624
624
 
625
- describe ".solrize_relationships" do
626
- it "should serialize the relationships into a Hash" do
625
+ describe '.solrize_relationships' do
626
+ it 'should serialize the relationships into a Hash' do
627
627
  graph = RDF::Graph.new
628
- subject = RDF::URI.new "info:fedora/test:sample_pid"
628
+ subject = RDF::URI.new 'info:fedora/test:sample_pid'
629
629
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_member_of), RDF::URI.new('info:fedora/demo:10'))
630
630
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_part_of), RDF::URI.new('info:fedora/demo:11'))
631
631
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_part), RDF::URI.new('info:fedora/demo:12'))
632
- graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:conforms_to), "AnInterface")
632
+ graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:conforms_to), 'AnInterface')
633
633
 
634
- @test_object.should_receive(:relationships).and_return(graph)
634
+ expect(@test_object).to receive(:relationships).and_return(graph)
635
635
  solr_doc = @test_object.solrize_relationships
636
- solr_doc[ActiveFedora::SolrService.solr_name("is_member_of", :symbol)].should == "info:fedora/demo:10"
637
- solr_doc[ActiveFedora::SolrService.solr_name("is_part_of", :symbol)].should == "info:fedora/demo:11"
638
- solr_doc[ActiveFedora::SolrService.solr_name("has_part", :symbol)].should == "info:fedora/demo:12"
639
- solr_doc[ActiveFedora::SolrService.solr_name("conforms_to", :symbol)].should == "AnInterface"
636
+ expect(solr_doc[ActiveFedora::SolrService.solr_name('is_member_of', :symbol)]).to eq('info:fedora/demo:10')
637
+ expect(solr_doc[ActiveFedora::SolrService.solr_name('is_part_of', :symbol)]).to eq('info:fedora/demo:11')
638
+ expect(solr_doc[ActiveFedora::SolrService.solr_name('has_part', :symbol)]).to eq('info:fedora/demo:12')
639
+ expect(solr_doc[ActiveFedora::SolrService.solr_name('conforms_to', :symbol)]).to eq('AnInterface')
640
640
  end
641
641
  end
642
642
  end