active-fedora 8.2.1 → 8.2.2

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 (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
@@ -69,7 +69,7 @@ describe ActiveFedora::Base do
69
69
  expect(subject.inspect).to eq "#<BarHistory2 pid: nil, cow: \"\", fubar: [], pig: nil, horse: [], duck: [\"\"], animal_id: nil>"
70
70
  end
71
71
  describe "with a pid" do
72
- before { subject.stub(pid: 'test:123') }
72
+ before { allow(subject).to receive_messages(pid: 'test:123') }
73
73
  it "should show a pid" do
74
74
  expect(subject.inspect).to eq "#<BarHistory2 pid: \"test:123\", cow: \"\", fubar: [], pig: nil, horse: [], duck: [\"\"], animal_id: nil>"
75
75
  end
@@ -108,58 +108,58 @@ describe ActiveFedora::Base do
108
108
  end
109
109
 
110
110
  it "should reveal the unique properties" do
111
- BarHistory2.unique?(:horse).should be false
112
- BarHistory2.unique?(:pig).should be true
113
- BarHistory2.unique?(:cow).should be true
111
+ expect(BarHistory2.unique?(:horse)).to be false
112
+ expect(BarHistory2.unique?(:pig)).to be true
113
+ expect(BarHistory2.unique?(:cow)).to be true
114
114
  end
115
115
 
116
116
  it "should save a delegated property uniquely" do
117
117
  subject.fubar = ["Quack"]
118
- subject.fubar.should == ["Quack"]
119
- subject.withText.get_values(:fubar).first.should == 'Quack'
118
+ expect(subject.fubar).to eq(["Quack"])
119
+ expect(subject.withText.get_values(:fubar).first).to eq('Quack')
120
120
  subject.cow = "Low"
121
- subject.cow.should == "Low"
122
- subject.xmlish.term_values(:cow).first.should == 'Low'
121
+ expect(subject.cow).to eq("Low")
122
+ expect(subject.xmlish.term_values(:cow).first).to eq('Low')
123
123
 
124
124
  subject.pig = "Oink"
125
- subject.pig.should == "Oink"
125
+ expect(subject.pig).to eq("Oink")
126
126
  end
127
127
 
128
128
  it "should allow passing parameters to the delegate accessor" do
129
129
  subject.fubar = ["one", "two"]
130
- subject.fubar(1).should == ['two']
130
+ expect(subject.fubar(1)).to eq(['two'])
131
131
  end
132
132
 
133
133
  it "should return an array if marked as multiple" do
134
134
  subject.horse=["neigh", "whinny"]
135
- subject.horse.should == ["neigh", "whinny"]
135
+ expect(subject.horse).to eq(["neigh", "whinny"])
136
136
  end
137
137
 
138
138
  it "should be able to delegate deeply into the terminology" do
139
139
  subject.duck = ["Quack", "Peep"]
140
- subject.duck.should == ["Quack", "Peep"]
140
+ expect(subject.duck).to eq(["Quack", "Peep"])
141
141
  end
142
142
 
143
143
  it "should be able to track change status" do
144
- subject.fubar_changed?.should be false
144
+ expect(subject.fubar_changed?).to be false
145
145
  subject.fubar = ["Meow"]
146
- subject.fubar_changed?.should be true
146
+ expect(subject.fubar_changed?).to be true
147
147
  end
148
148
 
149
149
  describe "array getters and setters" do
150
150
  it "should accept symbol keys" do
151
151
  subject[:duck] = ["Cluck", "Gobble"]
152
- subject[:duck].should == ["Cluck", "Gobble"]
152
+ expect(subject[:duck]).to eq(["Cluck", "Gobble"])
153
153
  end
154
154
 
155
155
  it "should accept string keys" do
156
156
  subject['duck'] = ["Cluck", "Gobble"]
157
- subject['duck'].should == ["Cluck", "Gobble"]
157
+ expect(subject['duck']).to eq(["Cluck", "Gobble"])
158
158
  end
159
159
 
160
160
  it "should accept field names with _id that are not associations" do
161
161
  subject['animal_id'] = "lemur"
162
- subject['animal_id'].should == "lemur"
162
+ expect(subject['animal_id']).to eq("lemur")
163
163
  end
164
164
 
165
165
  it "should raise an error on the reader when the field isn't delegated" do
@@ -206,13 +206,13 @@ describe ActiveFedora::Base do
206
206
 
207
207
  it "should be able to delegate deeply into the terminology" do
208
208
  subject.donkey = ["Bray", "Hee-haw"]
209
- subject.donkey.should == ["Bray", "Hee-haw"]
209
+ expect(subject.donkey).to eq(["Bray", "Hee-haw"])
210
210
  end
211
211
 
212
212
  it "should be able to track change status" do
213
- subject.cow_changed?.should be false
213
+ expect(subject.cow_changed?).to be false
214
214
  subject.cow = ["Moo"]
215
- subject.cow_changed?.should be true
215
+ expect(subject.cow_changed?).to be true
216
216
  end
217
217
  end
218
218
 
@@ -247,9 +247,9 @@ describe ActiveFedora::Base do
247
247
 
248
248
  describe "with a multivalued field" do
249
249
  it "should be able to track change status" do
250
- subject.title_changed?.should be false
250
+ expect(subject.title_changed?).to be false
251
251
  subject.title = ["Title1", "Title2"]
252
- subject.title_changed?.should be true
252
+ expect(subject.title_changed?).to be true
253
253
  end
254
254
  it "should not accept a single literal value" do
255
255
  expect { subject.title = "Title1" }.to raise_error
@@ -261,9 +261,9 @@ describe ActiveFedora::Base do
261
261
  end
262
262
  describe "with a single-valued field" do
263
263
  it "should be able to track change status" do
264
- subject.description_changed?.should be false
264
+ expect(subject.description_changed?).to be false
265
265
  subject.description = "A brief description"
266
- subject.description_changed?.should be true
266
+ expect(subject.description_changed?).to be true
267
267
  end
268
268
  it "should not accept an array of literal values" do
269
269
  expect { subject.description = ["A brief description", "A longer description"] }.to raise_error
@@ -37,18 +37,18 @@ describe ActiveFedora::Base do
37
37
  describe "attributes=" do
38
38
  it "should set attributes" do
39
39
  @n.attributes = {:fubar=>"baz", :duck=>"Quack"}
40
- @n.fubar.should == "baz"
41
- @n.withText.get_values(:fubar).first.should == 'baz'
42
- @n.duck.should == "Quack"
43
- @n.xmlish.term_values(:duck).first.should == 'Quack'
40
+ expect(@n.fubar).to eq("baz")
41
+ expect(@n.withText.get_values(:fubar).first).to eq('baz')
42
+ expect(@n.duck).to eq("Quack")
43
+ expect(@n.xmlish.term_values(:duck).first).to eq('Quack')
44
44
  end
45
45
  end
46
46
  describe "update_attributes" do
47
47
  it "should set attributes and save " do
48
48
  @n.update_attributes(:fubar=>"baz", :duck=>"Quack")
49
49
  @q = BarHistory.find(@n.pid)
50
- @q.fubar.should == "baz"
51
- @q.duck.should == "Quack"
50
+ expect(@q.fubar).to eq("baz")
51
+ expect(@q.duck).to eq("Quack")
52
52
  end
53
53
  after do
54
54
  @n.delete
@@ -9,8 +9,8 @@ describe ActiveFedora::Base do
9
9
  describe '.save' do
10
10
 
11
11
  it "should add hasModel relationship that points to the CModel if @new_object" do
12
- @test_object.stub(:update_index)
13
- @test_object.should_receive(:refresh)
12
+ allow(@test_object).to receive(:update_index)
13
+ expect(@test_object).to receive(:refresh)
14
14
  @test_object.save
15
15
  end
16
16
  end
@@ -9,25 +9,25 @@ describe ActiveFedora::Base do
9
9
  describe '.add_datastream' do
10
10
  it "should not call Datastream.save" do
11
11
  ds = ActiveFedora::Datastream.new(@test_object.inner_object, 'ds_to_add')
12
- ds.should_receive(:save).never
12
+ expect(ds).to receive(:save).never
13
13
  @test_object.add_datastream(ds)
14
14
  end
15
15
  it "should add the datastream to the datastreams_in_memory array" do
16
16
  ds = ActiveFedora::Datastream.new(@test_object.inner_object, 'ds_to_add')
17
- @test_object.datastreams.should_not have_key(ds.dsid)
17
+ expect(@test_object.datastreams).not_to have_key(ds.dsid)
18
18
  @test_object.add_datastream(ds)
19
- @test_object.datastreams.should have_key(ds.dsid)
19
+ expect(@test_object.datastreams).to have_key(ds.dsid)
20
20
  end
21
21
  it "should auto-assign dsids using auto-incremented integers if dsid is nil or an empty string" do
22
22
  ds = ActiveFedora::Datastream.new(@test_object.inner_object, nil)
23
- ds.dsid.should == 'DS1'
24
- @test_object.add_datastream(ds).should == 'DS1'
23
+ expect(ds.dsid).to eq('DS1')
24
+ expect(@test_object.add_datastream(ds)).to eq('DS1')
25
25
  ds_emptystringid = ActiveFedora::Datastream.new(@test_object.inner_object, '')
26
- @test_object.add_datastream(ds_emptystringid).should == 'DS2'
26
+ expect(@test_object.add_datastream(ds_emptystringid)).to eq('DS2')
27
27
  end
28
28
  it "should accept a prefix option and apply it to automatically assigned dsids" do
29
29
  ds = ActiveFedora::Datastream.new(@test_object.inner_object, nil, :prefix=> "FOO")
30
- ds.dsid.should == 'FOO1'
30
+ expect(ds.dsid).to eq('FOO1')
31
31
  end
32
32
  end
33
33
  end
@@ -9,12 +9,12 @@ describe ActiveFedora::Base do
9
9
  describe ".update_index" do
10
10
  before do
11
11
  mock_conn = double("SolrConnection")
12
- mock_conn.should_receive(:add) do |_, opts|
13
- opts.should == {:params=>{:softCommit=>true}}
12
+ expect(mock_conn).to receive(:add) do |_, opts|
13
+ expect(opts).to eq({:params=>{:softCommit=>true}})
14
14
  end
15
15
  mock_ss = double("SolrService")
16
- mock_ss.stub(:conn).and_return(mock_conn)
17
- ActiveFedora::SolrService.stub(:instance).and_return(mock_ss)
16
+ allow(mock_ss).to receive(:conn).and_return(mock_conn)
17
+ allow(ActiveFedora::SolrService).to receive(:instance).and_return(mock_ss)
18
18
  end
19
19
 
20
20
  it "should call .to_solr on all SimpleDatastreams AND RelsExtDatastreams and pass the resulting document to solr" do
@@ -24,11 +24,11 @@ describe ActiveFedora::Base do
24
24
  mock3 = double("RELS-EXT", :to_solr => {})
25
25
 
26
26
  mock_datastreams = {:ds1 => mock1, :ds2 => mock2, :rels_ext => mock3}
27
- mock1.should_receive(:solrize_profile).and_return({})
28
- mock2.should_receive(:solrize_profile).and_return({})
29
- mock3.should_receive(:solrize_profile).and_return({})
30
- @test_object.should_receive(:datastreams).twice.and_return(mock_datastreams)
31
- @test_object.should_receive(:solrize_relationships)
27
+ expect(mock1).to receive(:solrize_profile).and_return({})
28
+ expect(mock2).to receive(:solrize_profile).and_return({})
29
+ expect(mock3).to receive(:solrize_profile).and_return({})
30
+ expect(@test_object).to receive(:datastreams).twice.and_return(mock_datastreams)
31
+ expect(@test_object).to receive(:solrize_relationships)
32
32
  @test_object.update_index
33
33
  end
34
34
 
@@ -39,11 +39,11 @@ describe ActiveFedora::Base do
39
39
  mock3 = double("RELS-EXT", :to_solr => {})
40
40
 
41
41
  mock_datastreams = {:ds1 => mock1, :ds2 => mock2, :rels_ext => mock3}
42
- mock1.should_receive(:solrize_profile).and_return({})
43
- mock2.should_receive(:solrize_profile).and_return({})
44
- mock3.should_receive(:solrize_profile).and_return({})
45
- @test_object.should_receive(:datastreams).twice.and_return(mock_datastreams)
46
- @test_object.should_receive(:solrize_relationships)
42
+ expect(mock1).to receive(:solrize_profile).and_return({})
43
+ expect(mock2).to receive(:solrize_profile).and_return({})
44
+ expect(mock3).to receive(:solrize_profile).and_return({})
45
+ expect(@test_object).to receive(:datastreams).twice.and_return(mock_datastreams)
46
+ expect(@test_object).to receive(:solrize_relationships)
47
47
  @test_object.update_index
48
48
  end
49
49
 
@@ -59,12 +59,12 @@ describe ActiveFedora::Base do
59
59
  end
60
60
 
61
61
  it "should delete object from repository and index" do
62
- @test_object.inner_object.stub(:delete)
62
+ allow(@test_object.inner_object).to receive(:delete)
63
63
  mock_conn = double("SolrConnection")
64
- mock_conn.should_receive(:delete_by_id).with(nil, {:params=>{"softCommit"=>true}})
64
+ expect(mock_conn).to receive(:delete_by_id).with(nil, {:params=>{"softCommit"=>true}})
65
65
  mock_ss = double("SolrService")
66
- mock_ss.stub(:conn).and_return(mock_conn)
67
- ActiveFedora::SolrService.stub(:instance).and_return(mock_ss)
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
 
@@ -87,13 +87,13 @@ describe ActiveFedora::Base do
87
87
 
88
88
  context "with the namespace declared in the model" do
89
89
  before do
90
- subject.stub(:pid_namespace).and_return("test-cModel")
90
+ allow(subject).to receive(:pid_namespace).and_return("test-cModel")
91
91
  end
92
92
  its(:to_class_uri) {should == 'info:fedora/test-cModel:SpecModel_CamelCased' }
93
93
  end
94
94
  context "with the suffix declared in the model" do
95
95
  before do
96
- subject.stub(:pid_suffix).and_return("-TEST-SUFFIX")
96
+ allow(subject).to receive(:pid_suffix).and_return("-TEST-SUFFIX")
97
97
  end
98
98
  its(:to_class_uri) {should == 'info:fedora/afmodel:SpecModel_CamelCased-TEST-SUFFIX' }
99
99
  end
@@ -6,80 +6,80 @@ describe ActiveFedora::Base do
6
6
 
7
7
  describe 'descendants' do
8
8
  it "should record the decendants" do
9
- ActiveFedora::Base.descendants.should include(ModsArticle, SpecialThing)
9
+ expect(ActiveFedora::Base.descendants).to include(ModsArticle, SpecialThing)
10
10
  end
11
11
  end
12
12
 
13
13
  describe "sharding" do
14
14
  it "should have a shard_index" do
15
- ActiveFedora::Base.shard_index(@this_pid).should == 0
15
+ expect(ActiveFedora::Base.shard_index(@this_pid)).to eq(0)
16
16
  end
17
17
 
18
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')
24
- Rubydora::Fc3Service.any_instance.stub(:repository_profile)
23
+ allow(ActiveFedora.config).to receive(:credentials).and_return(:url=>'myfedora')
24
+ allow_any_instance_of(Rubydora::Fc3Service).to receive(:repository_profile)
25
25
  end
26
- it { should be_kind_of Rubydora::Repository}
26
+ it { is_expected.to be_kind_of Rubydora::Repository}
27
27
  it "should be the standard connection" do
28
- subject.client.url.should == 'myfedora'
28
+ expect(subject.client.url).to eq('myfedora')
29
29
  end
30
30
  describe "assign_pid" do
31
31
  it "should use fedora to generate pids" do
32
32
  # TODO: This juggling of Fedora credentials & establishing connections should be handled by an establish_fedora_connection method,
33
33
  # possibly wrap it all into a fedora_connection method - MZ 06-05-2012
34
34
  stubfedora = double("Fedora")
35
- stubfedora.should_receive(:connection).and_return(double("Connection", :mint =>"sample:newpid"))
35
+ expect(stubfedora).to receive(:connection).and_return(double("Connection", :mint =>"sample:newpid"))
36
36
  # Should use ActiveFedora.config.credentials as a single hash rather than an array of shards
37
- ActiveFedora::RubydoraConnection.should_receive(:new).with(ActiveFedora.config.credentials).and_return(stubfedora)
37
+ expect(ActiveFedora::RubydoraConnection).to receive(:new).with(ActiveFedora.config.credentials).and_return(stubfedora)
38
38
  ActiveFedora::Base.assign_pid(ActiveFedora::Base.new.inner_object)
39
39
  end
40
40
  end
41
41
  describe "shard_index" do
42
42
  it "should always return zero (the first and only connection)" do
43
- ActiveFedora::Base.shard_index('test:bar').should == 0
43
+ expect(ActiveFedora::Base.shard_index('test:bar')).to eq(0)
44
44
  end
45
45
  end
46
46
  end
47
47
  context "When the repository is sharded" do
48
48
  before :each do
49
- ActiveFedora.config.stub(:sharded?).and_return(true)
49
+ allow(ActiveFedora.config).to receive(:sharded?).and_return(true)
50
50
  ActiveFedora::Base.fedora_connection = {}
51
- ActiveFedora.config.stub(:credentials).and_return([{:url=>'shard1'}, {:url=>'shard2'} ])
51
+ allow(ActiveFedora.config).to receive(:credentials).and_return([{:url=>'shard1'}, {:url=>'shard2'} ])
52
52
  end
53
53
  describe "assign_pid" do
54
54
  it "should always use the first shard to generate pids" do
55
55
  stubhard1 = double("Shard")
56
56
  stubhard2 = double("Shard")
57
- stubhard1.should_receive(:connection).and_return(double("Connection", :mint =>"sample:newpid"))
58
- stubhard2.should_receive(:connection).never
57
+ expect(stubhard1).to receive(:connection).and_return(double("Connection", :mint =>"sample:newpid"))
58
+ expect(stubhard2).to receive(:connection).never
59
59
  ActiveFedora::Base.fedora_connection = {0 => stubhard1, 1 => stubhard2}
60
60
  ActiveFedora::Base.assign_pid(ActiveFedora::Base.new.inner_object)
61
61
  end
62
62
  end
63
63
  describe "shard_index" do
64
64
  it "should use modulo of md5 of the pid to distribute objects across shards" do
65
- ActiveFedora::Base.shard_index('test:bar').should == 0
66
- ActiveFedora::Base.shard_index('test:nanana').should == 1
65
+ expect(ActiveFedora::Base.shard_index('test:bar')).to eq(0)
66
+ expect(ActiveFedora::Base.shard_index('test:nanana')).to eq(1)
67
67
  end
68
68
  end
69
69
  describe "the repository" do
70
70
  before do
71
- Rubydora::Fc3Service.any_instance.stub(:repository_profile)
71
+ allow_any_instance_of(Rubydora::Fc3Service).to receive(:repository_profile)
72
72
  end
73
73
  describe "for test:bar" do
74
74
  subject {ActiveFedora::Base.connection_for_pid('test:bar')}
75
75
  it "should be shard1" do
76
- subject.client.url.should == 'shard1'
76
+ expect(subject.client.url).to eq('shard1')
77
77
  end
78
78
  end
79
79
  describe "for test:baz" do
80
80
  subject {ActiveFedora::Base.connection_for_pid('test:nanana')}
81
81
  it "should be shard1" do
82
- subject.client.url.should == 'shard2'
82
+ expect(subject.client.url).to eq('shard2')
83
83
  end
84
84
  end
85
85
  end
@@ -89,29 +89,29 @@ describe ActiveFedora::Base do
89
89
 
90
90
  describe "reindex_everything" do
91
91
  it "should call update_index on every object except for the fedora-system objects" do
92
- Rubydora::Repository.any_instance.should_receive(:search).
92
+ expect_any_instance_of(Rubydora::Repository).to receive(:search).
93
93
  and_yield(double(pid:'XXX')).and_yield(double(pid:'YYY')).and_yield(double(pid:'ZZZ')).
94
94
  and_yield(double(pid:'fedora-system:ServiceDeployment-3.0')).
95
95
  and_yield(double(pid:'fedora-system:ServiceDefinition-3.0')).
96
96
  and_yield(double(pid:'fedora-system:FedoraObject-3.0'))
97
97
 
98
98
  mock_update = double(:mock_obj)
99
- mock_update.should_receive(:update_index).exactly(3).times
100
- ActiveFedora::Base.should_receive(:find).with('XXX').and_return(mock_update)
101
- ActiveFedora::Base.should_receive(:find).with('YYY').and_return(mock_update)
102
- ActiveFedora::Base.should_receive(:find).with('ZZZ').and_return(mock_update)
99
+ expect(mock_update).to receive(:update_index).exactly(3).times
100
+ expect(ActiveFedora::Base).to receive(:find).with('XXX').and_return(mock_update)
101
+ expect(ActiveFedora::Base).to receive(:find).with('YYY').and_return(mock_update)
102
+ expect(ActiveFedora::Base).to receive(:find).with('ZZZ').and_return(mock_update)
103
103
  ActiveFedora::Base.reindex_everything
104
104
  end
105
105
 
106
106
  it "should accept a query param for the search" do
107
107
  query_string = "pid~*"
108
- Rubydora::Repository.any_instance.should_receive(:search).with(query_string).
108
+ expect_any_instance_of(Rubydora::Repository).to receive(:search).with(query_string).
109
109
  and_yield(double(pid:'XXX')).and_yield(double(pid:'YYY')).and_yield(double(pid:'ZZZ'))
110
110
  mock_update = double(:mock_obj)
111
- mock_update.should_receive(:update_index).exactly(3).times
112
- ActiveFedora::Base.should_receive(:find).with('XXX').and_return(mock_update)
113
- ActiveFedora::Base.should_receive(:find).with('YYY').and_return(mock_update)
114
- ActiveFedora::Base.should_receive(:find).with('ZZZ').and_return(mock_update)
111
+ expect(mock_update).to receive(:update_index).exactly(3).times
112
+ expect(ActiveFedora::Base).to receive(:find).with('XXX').and_return(mock_update)
113
+ expect(ActiveFedora::Base).to receive(:find).with('YYY').and_return(mock_update)
114
+ expect(ActiveFedora::Base).to receive(:find).with('ZZZ').and_return(mock_update)
115
115
  ActiveFedora::Base.reindex_everything(query_string)
116
116
  end
117
117
  end
@@ -154,15 +154,15 @@ describe ActiveFedora::Base do
154
154
  before(:each) do
155
155
  @this_pid = increment_pid.to_s
156
156
  stub_get(@this_pid)
157
- Rubydora::Repository.any_instance.stub(:client).and_return(@mock_client)
158
- ActiveFedora::Base.stub(:assign_pid).and_return(@this_pid)
157
+ allow_any_instance_of(Rubydora::Repository).to receive(:client).and_return(@mock_client)
158
+ allow(ActiveFedora::Base).to receive(:assign_pid).and_return(@this_pid)
159
159
 
160
160
  @test_object = ActiveFedora::Base.new
161
161
  end
162
162
 
163
163
  after(:each) do
164
164
  begin
165
- ActiveFedora::SolrService.stub(:instance)
165
+ allow(ActiveFedora::SolrService).to receive(:instance)
166
166
  #@test_object.delete
167
167
  rescue
168
168
  end
@@ -172,60 +172,60 @@ describe ActiveFedora::Base do
172
172
  describe '#new' do
173
173
  it "should create an inner object" do
174
174
  # for doing AFObject.new(params[:foo]) when nothing is in params[:foo]
175
- Rubydora::DigitalObject.any_instance.should_receive(:save).never
175
+ expect_any_instance_of(Rubydora::DigitalObject).to receive(:save).never
176
176
  result = ActiveFedora::Base.new(nil)
177
- result.inner_object.should be_kind_of(ActiveFedora::UnsavedDigitalObject)
177
+ expect(result.inner_object).to be_kind_of(ActiveFedora::UnsavedDigitalObject)
178
178
  end
179
179
 
180
180
  it "should not save or get an pid on init" do
181
- Rubydora::DigitalObject.any_instance.should_receive(:save).never
182
- ActiveFedora::Base.should_receive(:assign_pid).never
181
+ expect_any_instance_of(Rubydora::DigitalObject).to receive(:save).never
182
+ expect(ActiveFedora::Base).to receive(:assign_pid).never
183
183
  f = FooHistory.new
184
184
  end
185
185
 
186
186
  it "should be able to create with a custom pid" do
187
187
  f = FooHistory.new(:pid=>'numbnuts:1')
188
- f.pid.should == 'numbnuts:1'
188
+ expect(f.pid).to eq('numbnuts:1')
189
189
  end
190
190
  end
191
191
 
192
192
  describe ".datastream_class_for_name" do
193
193
  it "should return the specifed class" do
194
- FooAdaptation.datastream_class_for_name('someData').should == ActiveFedora::OmDatastream
194
+ expect(FooAdaptation.datastream_class_for_name('someData')).to eq(ActiveFedora::OmDatastream)
195
195
  end
196
196
  it "should return the specifed class" do
197
- FooAdaptation.datastream_class_for_name('content').should == ActiveFedora::Datastream
197
+ expect(FooAdaptation.datastream_class_for_name('content')).to eq(ActiveFedora::Datastream)
198
198
  end
199
199
  end
200
200
 
201
201
  describe ".internal_uri" do
202
202
  it "should return pid as fedors uri" do
203
- @test_object.internal_uri.should eql("info:fedora/#{@test_object.pid}")
203
+ expect(@test_object.internal_uri).to eql("info:fedora/#{@test_object.pid}")
204
204
  end
205
205
  end
206
206
 
207
207
  ### Methods for ActiveModel::Conversions
208
208
  it "should have to_param once it's saved" do
209
- @test_object.to_param.should be_nil
210
- @test_object.inner_object.stub(new_record?: false, pid: 'foo:123')
211
- @test_object.to_param.should == 'foo:123'
209
+ expect(@test_object.to_param).to be_nil
210
+ allow(@test_object.inner_object).to receive_messages(new_record?: false, pid: 'foo:123')
211
+ expect(@test_object.to_param).to eq('foo:123')
212
212
  end
213
213
 
214
214
  it "should have to_key once it's saved" do
215
- @test_object.to_key.should be_nil
216
- @test_object.inner_object.stub(new_record?: false, pid: 'foo:123')
217
- @test_object.to_key.should == ['foo:123']
215
+ expect(@test_object.to_key).to be_nil
216
+ allow(@test_object.inner_object).to receive_messages(new_record?: false, pid: 'foo:123')
217
+ expect(@test_object.to_key).to eq(['foo:123'])
218
218
  end
219
219
 
220
220
  it "should have to_model when it's saved" do
221
- @test_object.to_model.should be @test_object
221
+ expect(@test_object.to_model).to be @test_object
222
222
  end
223
223
  ### end ActiveModel::Conversions
224
224
 
225
225
  ### Methods for ActiveModel::Naming
226
226
  it "Should know the model_name" do
227
- FooHistory.model_name.should == 'FooHistory'
228
- FooHistory.model_name.human.should == 'Foo history'
227
+ expect(FooHistory.model_name).to eq('FooHistory')
228
+ expect(FooHistory.model_name.human).to eq('Foo history')
229
229
  end
230
230
  ### End ActiveModel::Naming
231
231
 
@@ -233,7 +233,7 @@ describe ActiveFedora::Base do
233
233
  describe ".datastreams" do
234
234
  let(:test_history) { FooHistory.new }
235
235
  it "should create accessors for datastreams declared with has_metadata" do
236
- test_history.withText.should == test_history.datastreams['withText']
236
+ expect(test_history.withText).to eq(test_history.datastreams['withText'])
237
237
  end
238
238
  describe "dynamic accessors" do
239
239
  before do
@@ -243,56 +243,56 @@ describe ActiveFedora::Base do
243
243
  describe "when the datastream is named with dash" do
244
244
  let(:ds) {double('datastream', :dsid=>'eac-cpf')}
245
245
  it "should convert dashes to underscores" do
246
- test_history.eac_cpf.should == ds
246
+ expect(test_history.eac_cpf).to eq(ds)
247
247
  end
248
248
  end
249
249
  describe "when the datastream is named with underscore" do
250
250
  let (:ds) { double('datastream', :dsid=>'foo_bar') }
251
251
  it "should preserve the underscore" do
252
- test_history.foo_bar.should == ds
252
+ expect(test_history.foo_bar).to eq(ds)
253
253
  end
254
254
  end
255
255
  end
256
256
  end
257
257
 
258
258
  it 'should provide #find' do
259
- ActiveFedora::Base.should respond_to(:find)
259
+ expect(ActiveFedora::Base).to respond_to(:find)
260
260
  end
261
261
 
262
262
  it "should provide .create_date" do
263
- @test_object.should respond_to(:create_date)
263
+ expect(@test_object).to respond_to(:create_date)
264
264
  end
265
265
 
266
266
  it "should provide .modified_date" do
267
- @test_object.should respond_to(:modified_date)
267
+ expect(@test_object).to respond_to(:modified_date)
268
268
  end
269
269
 
270
270
  it 'should respond to .rels_ext' do
271
- @test_object.should respond_to(:rels_ext)
271
+ expect(@test_object).to respond_to(:rels_ext)
272
272
  end
273
273
 
274
274
  describe '.rels_ext' do
275
275
 
276
276
  it 'should return the RelsExtDatastream object from the datastreams array' do
277
- @test_object.stub(:datastreams => {"RELS-EXT" => "foo"})
278
- @test_object.rels_ext.should == "foo"
277
+ allow(@test_object).to receive_messages(:datastreams => {"RELS-EXT" => "foo"})
278
+ expect(@test_object.rels_ext).to eq("foo")
279
279
  end
280
280
  end
281
281
 
282
282
  it 'should provide #add_relationship' do
283
- @test_object.should respond_to(:add_relationship)
283
+ expect(@test_object).to respond_to(:add_relationship)
284
284
  end
285
285
 
286
286
  describe '#add_relationship' do
287
287
  it 'should call #add_relationship on the rels_ext datastream' do
288
288
  @test_object.add_relationship("predicate", "info:fedora/object")
289
289
  pred = ActiveFedora::Predicates.vocabularies["info:fedora/fedora-system:def/relations-external#"]["predicate"]
290
- @test_object.relationships.should have_statement(RDF::Statement.new(RDF::URI.new(@test_object.internal_uri), pred, RDF::URI.new("info:fedora/object")))
290
+ expect(@test_object.relationships).to have_statement(RDF::Statement.new(RDF::URI.new(@test_object.internal_uri), pred, RDF::URI.new("info:fedora/object")))
291
291
  end
292
292
 
293
293
  it "should update the RELS-EXT datastream and set the datastream as dirty when relationships are added" do
294
294
  mock_ds = double("Rels-Ext")
295
- mock_ds.stub(:content_will_change!)
295
+ allow(mock_ds).to receive(:content_will_change!)
296
296
  @test_object.datastreams["RELS-EXT"] = mock_ds
297
297
  @test_object.add_relationship(:is_member_of, "info:fedora/demo:5")
298
298
  @test_object.add_relationship(:is_member_of, "info:fedora/demo:10")
@@ -300,54 +300,54 @@ describe ActiveFedora::Base do
300
300
 
301
301
  it 'should add a relationship to an object only if it does not exist already' do
302
302
  next_pid = increment_pid.to_s
303
- ActiveFedora::Base.stub(:assign_pid).and_return(next_pid)
303
+ allow(ActiveFedora::Base).to receive(:assign_pid).and_return(next_pid)
304
304
  stub_get(next_pid)
305
305
 
306
306
  @test_object3 = ActiveFedora::Base.new
307
307
  @test_object.add_relationship(:has_part,@test_object3)
308
- @test_object.ids_for_outbound(:has_part).should == [@test_object3.pid]
308
+ expect(@test_object.ids_for_outbound(:has_part)).to eq([@test_object3.pid])
309
309
  #try adding again and make sure not there twice
310
310
  @test_object.add_relationship(:has_part,@test_object3)
311
- @test_object.ids_for_outbound(:has_part).should == [@test_object3.pid]
311
+ expect(@test_object.ids_for_outbound(:has_part)).to eq([@test_object3.pid])
312
312
  end
313
313
 
314
314
  it 'should add literal relationships if requested' do
315
315
  @test_object.add_relationship(:conforms_to,"AnInterface",true)
316
- @test_object.ids_for_outbound(:conforms_to).should == ["AnInterface"]
316
+ expect(@test_object.ids_for_outbound(:conforms_to)).to eq(["AnInterface"])
317
317
  end
318
318
  end
319
319
 
320
320
  it 'should provide #remove_relationship' do
321
- @test_object.should respond_to(:remove_relationship)
321
+ expect(@test_object).to respond_to(:remove_relationship)
322
322
  end
323
323
 
324
324
  describe '#remove_relationship' do
325
325
  it 'should remove a relationship from the relationships hash' do
326
326
  @test_object3 = ActiveFedora::Base.new()
327
- @test_object3.stub(:pid=>'7')
327
+ allow(@test_object3).to receive_messages(:pid=>'7')
328
328
  @test_object4 = ActiveFedora::Base.new()
329
- @test_object4.stub(:pid=>'8')
329
+ allow(@test_object4).to receive_messages(:pid=>'8')
330
330
  @test_object.add_relationship(:has_part,@test_object3)
331
331
  @test_object.add_relationship(:has_part,@test_object4)
332
332
  #check both are there
333
- @test_object.ids_for_outbound(:has_part).should == [@test_object3.pid,@test_object4.pid]
333
+ expect(@test_object.ids_for_outbound(:has_part)).to eq([@test_object3.pid,@test_object4.pid])
334
334
  @test_object.remove_relationship(:has_part,@test_object3)
335
335
  #check only one item removed
336
- @test_object.ids_for_outbound(:has_part).should == [@test_object4.pid]
336
+ expect(@test_object.ids_for_outbound(:has_part)).to eq([@test_object4.pid])
337
337
  @test_object.remove_relationship(:has_part,@test_object4)
338
338
  #check last item removed and predicate removed since now emtpy
339
- @test_object.relationships.size.should == 0
339
+ expect(@test_object.relationships.size).to eq(0)
340
340
  end
341
341
  end
342
342
 
343
343
  it 'should provide #relationships' do
344
- @test_object.should respond_to(:relationships)
344
+ expect(@test_object).to respond_to(:relationships)
345
345
  end
346
346
 
347
347
  describe '#relationships' do
348
348
  it 'should return a graph' do
349
- @test_object.relationships.kind_of?(RDF::Graph).should be_true
350
- @test_object.relationships.size.should == 0
349
+ expect(@test_object.relationships.kind_of?(RDF::Graph)).to be_truthy
350
+ expect(@test_object.relationships.size).to eq(0)
351
351
  end
352
352
  end
353
353
 
@@ -356,26 +356,26 @@ describe ActiveFedora::Base do
356
356
  stub_get(@this_pid)
357
357
  stub_add_ds(@this_pid, ['RELS-EXT'])
358
358
  @test_object.assert_content_model
359
- @test_object.relationships(:has_model).should == ["info:fedora/afmodel:ActiveFedora_Base"]
359
+ expect(@test_object.relationships(:has_model)).to eq(["info:fedora/afmodel:ActiveFedora_Base"])
360
360
 
361
361
  end
362
362
  end
363
363
 
364
364
  describe '.save' do
365
365
  it "should create a new record" do
366
- @test_object.stub(:new_record? => true)
367
- @test_object.should_receive(:assign_pid)
368
- @test_object.should_receive(:serialize_datastreams)
369
- @test_object.inner_object.should_receive(:save)
370
- @test_object.should_receive(:update_index)
366
+ allow(@test_object).to receive_messages(:new_record? => true)
367
+ expect(@test_object).to receive(:assign_pid)
368
+ expect(@test_object).to receive(:serialize_datastreams)
369
+ expect(@test_object.inner_object).to receive(:save)
370
+ expect(@test_object).to receive(:update_index)
371
371
  @test_object.save
372
372
  end
373
373
 
374
374
  it "should update an existing record" do
375
- @test_object.stub(:new_record? => false)
376
- @test_object.should_receive(:serialize_datastreams)
377
- @test_object.inner_object.should_receive(:save)
378
- @test_object.should_receive(:update_index)
375
+ allow(@test_object).to receive_messages(:new_record? => false)
376
+ expect(@test_object).to receive(:serialize_datastreams)
377
+ expect(@test_object.inner_object).to receive(:save)
378
+ expect(@test_object).to receive(:update_index)
379
379
  @test_object.save
380
380
  end
381
381
  end
@@ -383,8 +383,8 @@ describe ActiveFedora::Base do
383
383
  describe "#create" do
384
384
  it "should build a new record and save it" do
385
385
  obj = double()
386
- obj.should_receive(:save)
387
- FooHistory.should_receive(:new).and_return(obj)
386
+ expect(obj).to receive(:save)
387
+ expect(FooHistory).to receive(:new).and_return(obj)
388
388
  @hist = FooHistory.create(:fubar=>'ta', :swank=>'da')
389
389
  end
390
390
 
@@ -393,7 +393,7 @@ describe ActiveFedora::Base do
393
393
  describe ".adapt_to" do
394
394
  it "should return an adapted object of the requested type" do
395
395
  @test_object = FooHistory.new()
396
- @test_object.adapt_to(FooAdaptation).class.should == FooAdaptation
396
+ expect(@test_object.adapt_to(FooAdaptation).class).to eq(FooAdaptation)
397
397
  end
398
398
  it "should not make an additional call to fedora to create the adapted object" do
399
399
  @test_object = FooHistory.new()
@@ -403,25 +403,25 @@ describe ActiveFedora::Base do
403
403
  @test_object = FooHistory.new()
404
404
  @test_object.add_file_datastream("XXX", :dsid=>'MY_DSID')
405
405
  adapted = @test_object.adapt_to(FooAdaptation)
406
- adapted.datastreams.keys.should include 'MY_DSID'
407
- adapted.datastreams['MY_DSID'].content.should == "XXX"
408
- adapted.datastreams['MY_DSID'].changed?.should be_true
406
+ expect(adapted.datastreams.keys).to include 'MY_DSID'
407
+ expect(adapted.datastreams['MY_DSID'].content).to eq("XXX")
408
+ expect(adapted.datastreams['MY_DSID'].changed?).to be_truthy
409
409
  end
410
410
  it "should propagate modified datastreams to the adapted object" do
411
411
  @test_object = FooHistory.new()
412
412
  orig_ds = @test_object.datastreams['someData']
413
413
  orig_ds.content="<YYY/>"
414
414
  adapted = @test_object.adapt_to(FooAdaptation)
415
- adapted.datastreams.keys.should include 'someData'
416
- adapted.datastreams['someData'].should == orig_ds
417
- adapted.datastreams['someData'].content.strip.should == "<YYY/>"
418
- adapted.datastreams['someData'].changed?.should be_true
415
+ expect(adapted.datastreams.keys).to include 'someData'
416
+ expect(adapted.datastreams['someData']).to eq(orig_ds)
417
+ expect(adapted.datastreams['someData'].content.strip).to eq("<YYY/>")
418
+ expect(adapted.datastreams['someData'].changed?).to be_truthy
419
419
  end
420
420
  it "should use the datastream definitions from the adapted object" do
421
421
  @test_object = FooHistory.new()
422
422
  adapted = @test_object.adapt_to(FooAdaptation)
423
- adapted.datastreams.keys.should include 'someData'
424
- adapted.datastreams['someData'].class.should == ActiveFedora::OmDatastream
423
+ expect(adapted.datastreams.keys).to include 'someData'
424
+ expect(adapted.datastreams['someData'].class).to eq(ActiveFedora::OmDatastream)
425
425
  end
426
426
  end
427
427
 
@@ -429,16 +429,16 @@ describe ActiveFedora::Base do
429
429
  subject { FooHistory.new }
430
430
 
431
431
  it "should raise an exception if the object class is not equal to or a subclass of any known model" do
432
- ActiveFedora::ContentModel.should_receive(:known_models_for).with(subject).and_return([FooAdaptation])
432
+ expect(ActiveFedora::ContentModel).to receive(:known_models_for).with(subject).and_return([FooAdaptation])
433
433
  expect { subject.adapt_to_cmodel }.to raise_error(ActiveFedora::ModelNotAsserted)
434
434
  end
435
435
  it "should cast to an inherited model over a random one" do
436
- ActiveFedora::ContentModel.should_receive(:known_models_for).with(subject).and_return([FooAdaptation, FooInherited])
437
- subject.adapt_to_cmodel.should be_kind_of FooInherited
436
+ expect(ActiveFedora::ContentModel).to receive(:known_models_for).with(subject).and_return([FooAdaptation, FooInherited])
437
+ expect(subject.adapt_to_cmodel).to be_kind_of FooInherited
438
438
  end
439
439
  it "should not cast when a cmodel is same as the class" do
440
- ActiveFedora::ContentModel.should_receive(:known_models_for).with(subject).and_return([FooHistory])
441
- subject.adapt_to_cmodel.should === subject
440
+ expect(ActiveFedora::ContentModel).to receive(:known_models_for).with(subject).and_return([FooHistory])
441
+ expect(subject.adapt_to_cmodel).to be === subject
442
442
  end
443
443
  end
444
444
 
@@ -446,36 +446,36 @@ describe ActiveFedora::Base do
446
446
  subject { ActiveFedora::Base.new }
447
447
 
448
448
  it "should cast to the first cmodel if ActiveFedora::Base (or no specified cmodel)" do
449
- ActiveFedora::ContentModel.should_receive(:known_models_for).with(subject).and_return([FooAdaptation, FooHistory])
450
- subject.adapt_to_cmodel.should be_kind_of FooAdaptation
449
+ expect(ActiveFedora::ContentModel).to receive(:known_models_for).with(subject).and_return([FooAdaptation, FooHistory])
450
+ expect(subject.adapt_to_cmodel).to be_kind_of FooAdaptation
451
451
  end
452
452
  end
453
453
 
454
454
 
455
455
  describe ".to_solr" do
456
456
  it "should provide .to_solr" do
457
- @test_object.should respond_to(:to_solr)
457
+ expect(@test_object).to respond_to(:to_solr)
458
458
  end
459
459
 
460
460
  it "should add pid, system_create_date, system_modified_date and object_state from object attributes" do
461
- @test_object.should_receive(:create_date).and_return("2012-03-04T03:12:02Z")
462
- @test_object.should_receive(:modified_date).and_return("2012-03-07T03:12:02Z")
463
- @test_object.stub(pid: 'changeme:123')
461
+ expect(@test_object).to receive(:create_date).and_return("2012-03-04T03:12:02Z")
462
+ expect(@test_object).to receive(:modified_date).and_return("2012-03-07T03:12:02Z")
463
+ allow(@test_object).to receive_messages(pid: 'changeme:123')
464
464
  @test_object.state = "D"
465
465
  solr_doc = @test_object.to_solr
466
- solr_doc[ActiveFedora::SolrService.solr_name("system_create", :stored_sortable, type: :date)].should eql("2012-03-04T03:12:02Z")
467
- solr_doc[ActiveFedora::SolrService.solr_name("system_modified", :stored_sortable, type: :date)].should eql("2012-03-07T03:12:02Z")
468
- solr_doc[ActiveFedora::SolrService.solr_name("object_state", :stored_sortable)].should eql("D")
469
- solr_doc[:id].should eql("changeme:123")
466
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("system_create", :stored_sortable, type: :date)]).to eql("2012-03-04T03:12:02Z")
467
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("system_modified", :stored_sortable, type: :date)]).to eql("2012-03-07T03:12:02Z")
468
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("object_state", :stored_sortable)]).to eql("D")
469
+ expect(solr_doc[:id]).to eql("changeme:123")
470
470
  end
471
471
 
472
472
  it "should omit base metadata and RELS-EXT if :model_only==true" do
473
473
  @test_object.add_relationship(:has_part, "foo", true)
474
474
  solr_doc = @test_object.to_solr(Hash.new, :model_only => true)
475
- solr_doc[ActiveFedora::SolrService.solr_name("system_create", type: :date)].should be_nil
476
- solr_doc[ActiveFedora::SolrService.solr_name("system_modified", type: :date)].should be_nil
477
- solr_doc["id"].should be_nil
478
- solr_doc[ActiveFedora::SolrService.solr_name("has_part", :symbol)].should be_nil
475
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("system_create", type: :date)]).to be_nil
476
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("system_modified", type: :date)]).to be_nil
477
+ expect(solr_doc["id"]).to be_nil
478
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("has_part", :symbol)]).to be_nil
479
479
  end
480
480
 
481
481
  it "should add self.class as the :active_fedora_model" do
@@ -483,35 +483,35 @@ describe ActiveFedora::Base do
483
483
  stub_get_content(@this_pid, ['RELS-EXT', 'someData', 'withText2', 'withText'])
484
484
  @test_history = FooHistory.new()
485
485
  solr_doc = @test_history.to_solr
486
- solr_doc[ActiveFedora::SolrService.solr_name("active_fedora_model", :stored_sortable)].should eql("FooHistory")
486
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("active_fedora_model", :stored_sortable)]).to eql("FooHistory")
487
487
  end
488
488
 
489
489
  it "should call .to_solr on all SimpleDatastreams and OmDatastreams, passing the resulting document to solr" do
490
490
  mock1 = double("ds1", :to_solr => {})
491
491
  mock2 = double("ds2", :to_solr => {})
492
492
  ngds = double("ngds", :to_solr => {})
493
- ngds.should_receive(:solrize_profile)
494
- mock1.should_receive(:solrize_profile)
495
- mock2.should_receive(:solrize_profile)
493
+ expect(ngds).to receive(:solrize_profile)
494
+ expect(mock1).to receive(:solrize_profile)
495
+ expect(mock2).to receive(:solrize_profile)
496
496
 
497
- @test_object.should_receive(:datastreams).twice.and_return({:ds1 => mock1, :ds2 => mock2, :ngds => ngds})
498
- @test_object.should_receive(:solrize_relationships)
497
+ expect(@test_object).to receive(:datastreams).twice.and_return({:ds1 => mock1, :ds2 => mock2, :ngds => ngds})
498
+ expect(@test_object).to receive(:solrize_relationships)
499
499
  @test_object.to_solr
500
500
  end
501
501
  it "should call .to_solr on all RDFDatastreams, passing the resulting document to solr" do
502
502
  mock = double("ds1", :to_solr => {})
503
- mock.should_receive(:solrize_profile)
503
+ expect(mock).to receive(:solrize_profile)
504
504
 
505
- @test_object.should_receive(:datastreams).twice.and_return({:ds1 => mock})
506
- @test_object.should_receive(:solrize_relationships)
505
+ expect(@test_object).to receive(:datastreams).twice.and_return({:ds1 => mock})
506
+ expect(@test_object).to receive(:solrize_relationships)
507
507
  @test_object.to_solr
508
508
  end
509
509
 
510
510
  it "should call .to_solr on the relationships rels-ext is dirty" do
511
511
  @test_object.add_relationship(:has_collection_member, "info:fedora/test:member")
512
512
  rels_ext = @test_object.rels_ext
513
- rels_ext.should be_changed
514
- @test_object.should_receive(:solrize_relationships)
513
+ expect(rels_ext).to be_changed
514
+ expect(@test_object).to receive(:solrize_relationships)
515
515
  @test_object.to_solr
516
516
  end
517
517
 
@@ -519,16 +519,16 @@ describe ActiveFedora::Base do
519
519
 
520
520
  describe ".label" do
521
521
  it "should return the label of the inner object" do
522
- @test_object.inner_object.should_receive(:label).and_return("foo label")
523
- @test_object.label.should == "foo label"
522
+ expect(@test_object.inner_object).to receive(:label).and_return("foo label")
523
+ expect(@test_object.label).to eq("foo label")
524
524
  end
525
525
  end
526
526
 
527
527
  describe ".label=" do
528
528
  it "should set the label of the inner object" do
529
- @test_object.label.should_not == "foo label"
529
+ expect(@test_object.label).not_to eq("foo label")
530
530
  @test_object.label = "foo label"
531
- @test_object.label.should == "foo label"
531
+ expect(@test_object.label).to eq("foo label")
532
532
  end
533
533
  end
534
534
  describe "update_attributes" do
@@ -536,9 +536,9 @@ describe ActiveFedora::Base do
536
536
  m = FooHistory.new
537
537
  att= {"fubar"=> '1234', "baz" =>'stuff'}
538
538
 
539
- m.should_receive(:fubar=).with('1234')
540
- m.should_receive(:baz=).with('stuff')
541
- m.should_receive(:save)
539
+ expect(m).to receive(:fubar=).with('1234')
540
+ expect(m).to receive(:baz=).with('stuff')
541
+ expect(m).to receive(:save)
542
542
  m.update_attributes(att)
543
543
  end
544
544
  end
@@ -548,9 +548,9 @@ describe ActiveFedora::Base do
548
548
  m = FooHistory.new
549
549
  att= {"fubar"=> '1234', "baz" =>'stuff'}
550
550
 
551
- m.should_receive(:fubar=).with('1234')
552
- m.should_receive(:baz=).with('stuff')
553
- m.should_receive(:save)
551
+ expect(m).to receive(:fubar=).with('1234')
552
+ expect(m).to receive(:baz=).with('stuff')
553
+ expect(m).to receive(:save)
554
554
  m.update(att)
555
555
  end
556
556
  end
@@ -564,12 +564,12 @@ describe ActiveFedora::Base do
564
564
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_part), RDF::URI.new('info:fedora/demo:12'))
565
565
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:conforms_to), "AnInterface")
566
566
 
567
- @test_object.should_receive(:relationships).and_return(graph)
567
+ expect(@test_object).to receive(:relationships).and_return(graph)
568
568
  solr_doc = @test_object.solrize_relationships
569
- solr_doc[ActiveFedora::SolrService.solr_name("is_member_of", :symbol)].should == "info:fedora/demo:10"
570
- solr_doc[ActiveFedora::SolrService.solr_name("is_part_of", :symbol)].should == "info:fedora/demo:11"
571
- solr_doc[ActiveFedora::SolrService.solr_name("has_part", :symbol)].should == "info:fedora/demo:12"
572
- solr_doc[ActiveFedora::SolrService.solr_name("conforms_to", :symbol)].should == "AnInterface"
569
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("is_member_of", :symbol)]).to eq("info:fedora/demo:10")
570
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("is_part_of", :symbol)]).to eq("info:fedora/demo:11")
571
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("has_part", :symbol)]).to eq("info:fedora/demo:12")
572
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("conforms_to", :symbol)]).to eq("AnInterface")
573
573
  end
574
574
  end
575
575
  end