active-fedora 6.4.2 → 6.4.3

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/.mailmap +15 -6
  3. data/active-fedora.gemspec +2 -2
  4. data/gemfiles/gemfile.rails4 +1 -1
  5. data/lib/active_fedora.rb +8 -12
  6. data/lib/active_fedora/digital_object.rb +1 -0
  7. data/lib/active_fedora/model.rb +6 -6
  8. data/lib/active_fedora/om_datastream.rb +14 -3
  9. data/lib/active_fedora/querying.rb +6 -5
  10. data/lib/active_fedora/solr_service.rb +15 -10
  11. data/lib/active_fedora/version.rb +1 -1
  12. data/lib/tasks/active_fedora_dev.rake +1 -17
  13. data/spec/config_helper.rb +1 -1
  14. data/spec/{unit → integration}/auditable_spec.rb +5 -7
  15. data/spec/integration/base_spec.rb +2 -1
  16. data/spec/integration/bug_spec.rb +6 -0
  17. data/spec/integration/complex_rdf_datastream_spec.rb +3 -3
  18. data/spec/integration/model_spec.rb +8 -7
  19. data/spec/integration/om_datastream_spec.rb +78 -73
  20. data/spec/integration/rdf_nested_attributes_spec.rb +2 -2
  21. data/spec/integration/solr_instance_loader_spec.rb +9 -4
  22. data/spec/integration/solr_service_spec.rb +2 -8
  23. data/spec/support/mock_fedora.rb +6 -6
  24. data/spec/unit/active_fedora_spec.rb +12 -1
  25. data/spec/unit/base_extra_spec.rb +10 -10
  26. data/spec/unit/base_spec.rb +18 -18
  27. data/spec/unit/content_model_spec.rb +6 -6
  28. data/spec/unit/datastream_spec.rb +1 -1
  29. data/spec/unit/datastreams_spec.rb +19 -19
  30. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +6 -6
  31. data/spec/unit/has_many_collection_spec.rb +3 -3
  32. data/spec/unit/ntriples_datastream_spec.rb +2 -2
  33. data/spec/unit/om_datastream_spec.rb +6 -6
  34. data/spec/unit/query_spec.rb +11 -11
  35. data/spec/unit/rdf_list_spec.rb +2 -2
  36. data/spec/unit/rdfxml_rdf_datastream_spec.rb +2 -2
  37. data/spec/unit/rels_ext_datastream_spec.rb +6 -6
  38. data/spec/unit/semantic_node_spec.rb +5 -5
  39. data/spec/unit/solr_config_options_spec.rb +1 -1
  40. data/spec/unit/solr_service_spec.rb +42 -20
  41. metadata +10 -23
  42. data/spec/fixtures/auditable.foxml.xml +0 -110
  43. data/spec/fixtures/changeme155.xml +0 -255
  44. data/spec/fixtures/test_12.foxml.xml +0 -60
  45. data/spec/fixtures/test_fixture_mods_article1.foxml.xml +0 -234
  46. data/spec/fixtures/test_fixture_mods_article2.foxml.xml +0 -234
  47. data/spec/hydrangea_fixture_mods_article1.foxml.xml +0 -225
  48. data/spec/integration/mods_article_integration_spec.rb +0 -22
@@ -66,7 +66,7 @@ describe "Nesting attribute behavior of RDFDatastream" do
66
66
  Object.send(:remove_const, :ComplexRDFDatastream)
67
67
  Object.send(:remove_const, :DummyMADS)
68
68
  end
69
- subject { ComplexRDFDatastream.new(stub('inner object', :pid=>'foo', :new? =>true), 'descMetadata') }
69
+ subject { ComplexRDFDatastream.new(double('inner object', :pid=>'foo', :new? =>true), 'descMetadata') }
70
70
  let(:params) do
71
71
  { myResource:
72
72
  {
@@ -138,7 +138,7 @@ describe "Nesting attribute behavior of RDFDatastream" do
138
138
  after(:each) do
139
139
  Object.send(:remove_const, :SpecDatastream)
140
140
  end
141
- subject { SpecDatastream.new(stub('inner object', :pid=>'foo', :new? =>true), 'descMetadata') }
141
+ subject { SpecDatastream.new(double('inner object', :pid=>'foo', :new? =>true), 'descMetadata') }
142
142
  before do
143
143
  subject.attributes = { parts_attributes: [
144
144
  {label: 'Alternator'},
@@ -3,6 +3,11 @@ require 'spec_helper'
3
3
  require 'active_fedora'
4
4
 
5
5
  describe ActiveFedora::SolrInstanceLoader do
6
+ before(:all) do
7
+ @test_object = ActiveFedora::Base.create
8
+ @test_object2 = ActiveFedora::Base.create
9
+ end
10
+
6
11
  let(:context) { ActiveFedora::Base }
7
12
  let(:pid) { nil }
8
13
  let(:solr_doc) { nil }
@@ -10,7 +15,7 @@ describe ActiveFedora::SolrInstanceLoader do
10
15
  subject { ActiveFedora::SolrInstanceLoader.new(context, pid, solr_doc) }
11
16
 
12
17
  describe 'existing pid' do
13
- let(:pid) { 'test:fixture_mods_article1' }
18
+ let(:pid) { @test_object.pid }
14
19
  describe 'without a solr document' do
15
20
  it 'it finds the SOLR document and casts into an AF::Base object' do
16
21
  expect(subject.object).to eq(active_fedora_object)
@@ -23,7 +28,7 @@ describe ActiveFedora::SolrInstanceLoader do
23
28
  end
24
29
  end
25
30
  describe 'with a mismatching solr document' do
26
- let(:mismatching_pid) { 'test:fixture_mods_article2' }
31
+ let(:mismatching_pid) { @test_object2.pid }
27
32
  let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>mismatching_pid).first }
28
33
  it 'it raise ObjectNotFoundError' do
29
34
  expect {
@@ -33,7 +38,7 @@ describe ActiveFedora::SolrInstanceLoader do
33
38
  end
34
39
  end
35
40
  describe 'missing pid' do
36
- let(:pid) { 'test:fixture_mods_article8675309' }
41
+ let(:pid) { 'test:missing_pid' }
37
42
  describe 'without a solr document' do
38
43
  it 'it raise ObjectNotFoundError' do
39
44
  expect {
@@ -50,7 +55,7 @@ describe ActiveFedora::SolrInstanceLoader do
50
55
  end
51
56
  end
52
57
  describe 'with a mismatching solr document' do
53
- let(:mismatching_pid) { 'test:fixture_mods_article2' }
58
+ let(:mismatching_pid) { @test_object2.pid }
54
59
  let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>mismatching_pid).first }
55
60
  it 'it raise ObjectNotFoundError' do
56
61
  expect {
@@ -9,9 +9,6 @@ describe ActiveFedora::SolrService do
9
9
  def self.pid_namespace
10
10
  "foo"
11
11
  end
12
- has_metadata :name => "properties", :type => ActiveFedora::SimpleDatastream do |m|
13
- m.field "holding_id", :string
14
- end
15
12
 
16
13
  has_metadata :name => "descMetadata", :type => ActiveFedora::QualifiedDublinCoreDatastream
17
14
  end
@@ -19,8 +16,7 @@ describe ActiveFedora::SolrService do
19
16
  @test_object.label = 'test_object'
20
17
  @foo_object = FooObject.new
21
18
  @foo_object.label = 'foo_object'
22
- attributes = {"holding_id"=>{0=>"Holding 1"},
23
- "language"=>{0=>"Italian"},
19
+ attributes = {"language"=>{0=>"Italian"},
24
20
  "creator"=>{0=>"Linguist, A."},
25
21
  "geography"=>{0=>"Italy"},
26
22
  "title"=>{0=>"Italian and Spanish: A Comparison of Common Phrases"}}
@@ -30,7 +26,6 @@ describe ActiveFedora::SolrService do
30
26
  @profiles = {
31
27
  'test' => @test_object.inner_object.profile,
32
28
  'foo' => @foo_object.inner_object.profile,
33
- 'foo_properties' => @foo_object.datastreams['properties'].profile,
34
29
  'foo_descMetadata' => @foo_object.datastreams['descMetadata'].profile
35
30
  }
36
31
  @foo_content = @foo_object.datastreams['descMetadata'].content
@@ -61,14 +56,13 @@ describe ActiveFedora::SolrService do
61
56
  ['test_object','foo_object'].should include(r.label)
62
57
  @test_object.inner_object.profile.should == @profiles['test']
63
58
  @foo_object.inner_object.profile.should == @profiles['foo']
64
- @foo_object.datastreams['properties'].profile.should == @profiles['foo_properties']
65
59
  @foo_object.datastreams['descMetadata'].profile.should == @profiles['foo_descMetadata']
66
60
  @foo_object.datastreams['descMetadata'].content.should be_equivalent_to(@foo_content)
67
61
  end
68
62
  end
69
63
 
70
64
  it 'should instantiate all datastreams in the solr doc, even ones undeclared by the class' do
71
- obj = ActiveFedora::Base.load_instance_from_solr "test:fixture_mods_article1"
65
+ obj = ActiveFedora::Base.load_instance_from_solr @foo_object.pid
72
66
  obj.datastreams.keys.should include('descMetadata')
73
67
  end
74
68
 
@@ -1,7 +1,7 @@
1
1
  def mock_client
2
2
  return @mock_client if @mock_client
3
- @mock_client = mock("client")
4
- @getter = mock("getter")
3
+ @mock_client = double("client")
4
+ @getter = double("getter")
5
5
  @getter.stub(:get).and_return('')
6
6
  @mock_client.stub(:[]).with("describe?xml=true").and_return('')
7
7
  @mock_client
@@ -10,7 +10,7 @@ end
10
10
  def stub_get(pid, datastreams=nil, record_exists=false)
11
11
  pid.gsub!(/:/, '%3A')
12
12
  if record_exists
13
- mock_client.stub(:[]).with("objects/#{pid}?format=xml").and_return(stub('get getter', :get=>'foobar'))
13
+ mock_client.stub(:[]).with("objects/#{pid}?format=xml").and_return(double('get getter', :get=>'foobar'))
14
14
  else
15
15
  mock_client.stub(:[]).with("objects/#{pid}?format=xml").and_raise(RestClient::ResourceNotFound)
16
16
  end
@@ -23,7 +23,7 @@ end
23
23
 
24
24
  def stub_ingest(pid=nil)
25
25
  n = pid ? pid.gsub(/:/, '%3A') : nil
26
- mock_client.should_receive(:[]).with("objects/#{n || 'new'}").and_return(stub("ingester", :post=>pid))
26
+ mock_client.should_receive(:[]).with("objects/#{n || 'new'}").and_return(double("ingester", :post=>pid))
27
27
  end
28
28
 
29
29
  def stub_add_ds(pid, dsids)
@@ -32,14 +32,14 @@ def stub_add_ds(pid, dsids)
32
32
  client = mock_client.stub(:[]).with do |params|
33
33
  /objects\/#{pid}\/datastreams\/#{dsid}/.match(params)
34
34
  end
35
- client.and_return(stub("ds_adder", :post=>pid, :get=>''))
35
+ client.and_return(double("ds_adder", :post=>pid, :get=>''))
36
36
  end
37
37
  end
38
38
 
39
39
  def stub_get_content(pid, dsids)
40
40
  pid.gsub!(/:/, '%3A')
41
41
  dsids.each do |dsid|
42
- mock_client.stub(:[]).with { |params| /objects\/#{pid}\/datastreams\/#{dsid}\/content/.match(params)}.and_return(stub("content_accessor", :post=>pid, :get=>''))
42
+ mock_client.stub(:[]).with { |params| /objects\/#{pid}\/datastreams\/#{dsid}\/content/.match(params)}.and_return(double("content_accessor", :post=>pid, :get=>''))
43
43
  end
44
44
  end
45
45
 
@@ -104,11 +104,22 @@ describe ActiveFedora do
104
104
  end
105
105
 
106
106
  describe "#class_from_string" do
107
+ before do
108
+ module ParentClass
109
+ class SiblingClass
110
+ end
111
+ class OtherSiblingClass
112
+ end
113
+ end
114
+ end
107
115
  it "should return class constants based on strings" do
108
116
  ActiveFedora.class_from_string("Om").should == Om
109
117
  ActiveFedora.class_from_string("ActiveFedora::RdfNode::TermProxy").should == ActiveFedora::RdfNode::TermProxy
110
118
  ActiveFedora.class_from_string("TermProxy", ActiveFedora::RdfNode).should == ActiveFedora::RdfNode::TermProxy
111
-
119
+ end
120
+
121
+ it "should find sibling classes" do
122
+ ActiveFedora.class_from_string("SiblingClass", ParentClass::OtherSiblingClass).should == ParentClass::SiblingClass
112
123
  end
113
124
  end
114
125
  end
@@ -8,19 +8,19 @@ describe ActiveFedora::Base do
8
8
 
9
9
  describe ".update_index" do
10
10
  before do
11
- mock_conn = mock("SolrConnection")
11
+ mock_conn = double("SolrConnection")
12
12
  mock_conn.should_receive(:add)
13
13
  mock_conn.should_receive(:commit)
14
- mock_ss = mock("SolrService")
14
+ mock_ss = double("SolrService")
15
15
  mock_ss.stub(:conn).and_return(mock_conn)
16
16
  ActiveFedora::SolrService.stub(:instance).and_return(mock_ss)
17
17
  end
18
18
 
19
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 = mock("ds1", :to_solr => {})
22
- mock2 = mock("ds2", :to_solr => {})
23
- mock3 = mock("RELS-EXT", :to_solr => {})
21
+ mock1 = double("ds1", :to_solr => {})
22
+ mock2 = double("ds2", :to_solr => {})
23
+ mock3 = double("RELS-EXT", :to_solr => {})
24
24
 
25
25
  mock_datastreams = {:ds1 => mock1, :ds2 => mock2, :rels_ext => mock3}
26
26
  mock1.should_receive(:solrize_profile).and_return({})
@@ -33,9 +33,9 @@ describe ActiveFedora::Base do
33
33
 
34
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 = mock("ds1", :to_solr => {})
37
- mock2 = mock("ds2", :to_solr => {})
38
- mock3 = mock("RELS-EXT", :to_solr => {})
36
+ mock1 = double("ds1", :to_solr => {})
37
+ mock2 = double("ds2", :to_solr => {})
38
+ mock3 = double("RELS-EXT", :to_solr => {})
39
39
 
40
40
  mock_datastreams = {:ds1 => mock1, :ds2 => mock2, :rels_ext => mock3}
41
41
  mock1.should_receive(:solrize_profile).and_return({})
@@ -59,10 +59,10 @@ describe ActiveFedora::Base do
59
59
 
60
60
  it "should delete object from repository and index" do
61
61
  @test_object.inner_object.stub(:delete)
62
- mock_conn = mock("SolrConnection")
62
+ mock_conn = double("SolrConnection")
63
63
  mock_conn.should_receive(:delete_by_id).with("__DO_NOT_USE__")
64
64
  mock_conn.should_receive(:commit)
65
- mock_ss = mock("SolrService")
65
+ mock_ss = double("SolrService")
66
66
  mock_ss.stub(:conn).and_return(mock_conn)
67
67
  ActiveFedora::SolrService.stub(:instance).and_return(mock_ss)
68
68
  @test_object.delete
@@ -28,8 +28,8 @@ describe ActiveFedora::Base do
28
28
  it "should use fedora to generate pids" do
29
29
  # TODO: This juggling of Fedora credentials & establishing connections should be handled by an establish_fedora_connection method,
30
30
  # possibly wrap it all into a fedora_connection method - MZ 06-05-2012
31
- stubfedora = mock("Fedora")
32
- stubfedora.should_receive(:connection).and_return(mock("Connection", :mint =>"sample:newpid"))
31
+ stubfedora = double("Fedora")
32
+ stubfedora.should_receive(:connection).and_return(double("Connection", :mint =>"sample:newpid"))
33
33
  # Should use ActiveFedora.config.credentials as a single hash rather than an array of shards
34
34
  ActiveFedora::RubydoraConnection.should_receive(:new).with(ActiveFedora.config.credentials).and_return(stubfedora)
35
35
  ActiveFedora::Base.assign_pid(ActiveFedora::Base.new.inner_object)
@@ -49,9 +49,9 @@ describe ActiveFedora::Base do
49
49
  end
50
50
  describe "assign_pid" do
51
51
  it "should always use the first shard to generate pids" do
52
- stubhard1 = mock("Shard")
53
- stubhard2 = mock("Shard")
54
- stubhard1.should_receive(:connection).and_return(mock("Connection", :mint =>"sample:newpid"))
52
+ stubhard1 = double("Shard")
53
+ stubhard2 = double("Shard")
54
+ stubhard1.should_receive(:connection).and_return(double("Connection", :mint =>"sample:newpid"))
55
55
  stubhard2.should_receive(:connection).never
56
56
  ActiveFedora::Base.fedora_connection = {0 => stubhard1, 1 => stubhard2}
57
57
  ActiveFedora::Base.assign_pid(ActiveFedora::Base.new.inner_object)
@@ -84,8 +84,8 @@ describe ActiveFedora::Base do
84
84
  describe "reindex_everything" do
85
85
  it "should call update_index on every object" do
86
86
  Rubydora::Repository.any_instance.should_receive(:search).
87
- and_yield(stub(pid:'XXX')).and_yield(stub(pid:'YYY')).and_yield(stub(pid:'ZZZ'))
88
- mock_update = stub(:mock_obj)
87
+ and_yield(double(pid:'XXX')).and_yield(double(pid:'YYY')).and_yield(double(pid:'ZZZ'))
88
+ mock_update = double(:mock_obj)
89
89
  mock_update.should_receive(:update_index).exactly(3).times
90
90
  ActiveFedora::Base.should_receive(:find).with('XXX', :cast=>true).and_return(mock_update)
91
91
  ActiveFedora::Base.should_receive(:find).with('YYY', :cast=>true).and_return(mock_update)
@@ -212,12 +212,12 @@ describe ActiveFedora::Base do
212
212
  @test_history.withText.should == @test_history.datastreams['withText']
213
213
  end
214
214
  it "dynamic accessors should convert dashes to underscores" do
215
- ds = stub('datastream', :dsid=>'eac-cpf')
215
+ ds = double('datastream', :dsid=>'eac-cpf')
216
216
  @test_history.add_datastream(ds)
217
217
  @test_history.eac_cpf.should == ds
218
218
  end
219
219
  it "dynamic accessors should not convert datastreams named with underscore" do
220
- ds = stub('datastream', :dsid=>'foo_bar')
220
+ ds = double('datastream', :dsid=>'foo_bar')
221
221
  @test_history.add_datastream(ds)
222
222
  @test_history.foo_bar.should == ds
223
223
  end
@@ -259,7 +259,7 @@ describe ActiveFedora::Base do
259
259
  end
260
260
 
261
261
  it "should update the RELS-EXT datastream and set the datastream as dirty when relationships are added" do
262
- mock_ds = mock("Rels-Ext")
262
+ mock_ds = double("Rels-Ext")
263
263
  mock_ds.stub(:content_will_change!)
264
264
  @test_object.datastreams["RELS-EXT"] = mock_ds
265
265
  @test_object.add_relationship(:is_member_of, "info:fedora/demo:5")
@@ -347,7 +347,7 @@ describe ActiveFedora::Base do
347
347
 
348
348
  describe "#create" do
349
349
  it "should build a new record and save it" do
350
- obj = mock()
350
+ obj = double()
351
351
  obj.should_receive(:save)
352
352
  FooHistory.should_receive(:new).and_return(obj)
353
353
  @hist = FooHistory.create(:fubar=>'ta', :swank=>'da')
@@ -436,9 +436,9 @@ describe ActiveFedora::Base do
436
436
  end
437
437
 
438
438
  it "should call .to_solr on all SimpleDatastreams and OmDatastreams, passing the resulting document to solr" do
439
- mock1 = mock("ds1", :to_solr => {})
440
- mock2 = mock("ds2", :to_solr => {})
441
- ngds = mock("ngds", :to_solr => {})
439
+ mock1 = double("ds1", :to_solr => {})
440
+ mock2 = double("ds2", :to_solr => {})
441
+ ngds = double("ngds", :to_solr => {})
442
442
  ngds.should_receive(:solrize_profile)
443
443
  mock1.should_receive(:solrize_profile)
444
444
  mock2.should_receive(:solrize_profile)
@@ -448,7 +448,7 @@ describe ActiveFedora::Base do
448
448
  @test_object.to_solr
449
449
  end
450
450
  it "should call .to_solr on all RDFDatastreams, passing the resulting document to solr" do
451
- mock = mock("ds1", :to_solr => {})
451
+ mock = double("ds1", :to_solr => {})
452
452
  mock.should_receive(:solrize_profile)
453
453
 
454
454
  @test_object.should_receive(:datastreams).twice.and_return({:ds1 => mock})
@@ -484,7 +484,7 @@ describe ActiveFedora::Base do
484
484
 
485
485
  describe "get_values_from_datastream" do
486
486
  it "should look up the named datastream and call get_values with the given pointer/field_name" do
487
- mock_ds = mock("Datastream", :get_values=>["value1", "value2"])
487
+ mock_ds = double("Datastream", :get_values=>["value1", "value2"])
488
488
  @test_object.stub(:datastreams).and_return({"ds1"=>mock_ds})
489
489
  @test_object.get_values_from_datastream("ds1", "--my xpath--").should == ["value1", "value2"]
490
490
  end
@@ -492,8 +492,8 @@ describe ActiveFedora::Base do
492
492
 
493
493
  describe "update_datastream_attributes" do
494
494
  it "should look up any datastreams specified as keys in the given hash and call update_attributes on the datastream" do
495
- mock_desc_metadata = mock("descMetadata")
496
- mock_properties = mock("properties")
495
+ mock_desc_metadata = double("descMetadata")
496
+ mock_properties = double("properties")
497
497
  mock_ds_hash = {'descMetadata'=>mock_desc_metadata, 'properties'=>mock_properties}
498
498
 
499
499
  ds_values_hash = {
@@ -53,12 +53,12 @@ describe ActiveFedora::ContentModel do
53
53
 
54
54
  describe "models_asserted_by" do
55
55
  it "should return an array of all of the content models asserted by the given object" do
56
- mock_object = mock("ActiveFedora Object")
56
+ mock_object = double("ActiveFedora Object")
57
57
  mock_object.should_receive(:relationships).with(:has_model).and_return(["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"])
58
58
  ActiveFedora::ContentModel.models_asserted_by(mock_object).should == ["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"]
59
59
  end
60
60
  it "should return an empty array if the object doesn't have a RELS-EXT datastream" do
61
- mock_object = mock("ActiveFedora Object")
61
+ mock_object = double("ActiveFedora Object")
62
62
  mock_object.should_receive(:relationships).with(:has_model).and_return([])
63
63
  ActiveFedora::ContentModel.models_asserted_by(mock_object).should == []
64
64
  end
@@ -66,23 +66,23 @@ describe ActiveFedora::ContentModel do
66
66
 
67
67
  describe "known_models_asserted_by" do
68
68
  it "should figure out the applicable models to load" do
69
- mock_object = mock("ActiveFedora Object")
69
+ mock_object = double("ActiveFedora Object")
70
70
  mock_object.should_receive(:relationships).with(:has_model).and_return(["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"])
71
71
  ActiveFedora::ContentModel.known_models_for(mock_object).should == [SampleModel]
72
72
  end
73
73
  it "should support namespaced models" do
74
74
  pending "This is harder than it looks."
75
- mock_object = mock("ActiveFedora Object")
75
+ mock_object = double("ActiveFedora Object")
76
76
  mock_object.should_receive(:relationships).with(:has_model).and_return(["info:fedora/afmodel:Sample_NamespacedModel"])
77
77
  ActiveFedora::ContentModel.known_models_for(mock_object).should == [Sample::NamespacedModel]
78
78
  end
79
79
  it "should default to using ActiveFedora::Base as the model" do
80
- mock_object = mock("ActiveFedora Object")
80
+ mock_object = double("ActiveFedora Object")
81
81
  mock_object.should_receive(:relationships).with(:has_model).and_return(["info:fedora/afmodel:NonDefinedModel"])
82
82
  ActiveFedora::ContentModel.known_models_for(mock_object).should == [ActiveFedora::Base]
83
83
  end
84
84
  it "should still work even if the object doesn't have a RELS-EXT datastream" do
85
- mock_object = mock("ActiveFedora Object")
85
+ mock_object = double("ActiveFedora Object")
86
86
  mock_object.should_receive(:relationships).with(:has_model).and_return([])
87
87
  ActiveFedora::ContentModel.known_models_for(mock_object).should == [ActiveFedora::Base]
88
88
  end
@@ -99,7 +99,7 @@ describe ActiveFedora::Datastream do
99
99
  </datastreamProfile>"
100
100
  EOS
101
101
 
102
- mock_repo = mock('repository', :config=>{})
102
+ mock_repo = double('repository', :config=>{})
103
103
  @test_object.inner_object.stub(:repository).and_return(mock_repo)
104
104
  mock_repo.should_receive(:datastream).with(:dsid => 'abcd', :pid => @test_object.pid).and_return(ds_profile)
105
105
  @test_datastream.size.should == 9999
@@ -40,8 +40,8 @@ describe ActiveFedora::Datastreams do
40
40
 
41
41
  describe "#serialize_datastreams" do
42
42
  it "should touch each datastream" do
43
- m1 = mock()
44
- m2 = mock()
43
+ m1 = double()
44
+ m2 = double()
45
45
 
46
46
  m1.should_receive(:serialize!)
47
47
  m2.should_receive(:serialize!)
@@ -54,7 +54,7 @@ describe ActiveFedora::Datastreams do
54
54
  it "should infer dsLocations for E datastreams without hitting Fedora" do
55
55
 
56
56
  mock_specs = {:e => { :disseminator => 'xyz' }}
57
- mock_ds = mock(:controlGroup => 'E')
57
+ mock_ds = double(:controlGroup => 'E')
58
58
  ActiveFedora::Base.stub(:ds_specs => mock_specs)
59
59
  ActiveFedora.stub(:config_for_environment => { :url => 'http://localhost'})
60
60
  subject.stub(:pid => 'test:1', :datastreams => {:e => mock_ds})
@@ -65,7 +65,7 @@ describe ActiveFedora::Datastreams do
65
65
 
66
66
  describe "#corresponding_datastream_name" do
67
67
  before(:each) do
68
- subject.stub(:datastreams => { 'abc' => mock(), 'a_b_c' => mock(), 'a-b' => mock()})
68
+ subject.stub(:datastreams => { 'abc' => double(), 'a_b_c' => double(), 'a-b' => double()})
69
69
  end
70
70
 
71
71
  it "should use the name, if it exists" do
@@ -92,27 +92,27 @@ describe ActiveFedora::Datastreams do
92
92
  it "should look up the ds_spec" do
93
93
  mock_dsspec = { :type => nil }
94
94
  subject.stub(:ds_specs => {'abc' => mock_dsspec})
95
- subject.configure_datastream(mock(:dsid => 'abc'))
95
+ subject.configure_datastream(double(:dsid => 'abc'))
96
96
  end
97
97
 
98
98
  it "should be ok if there is no ds spec" do
99
- mock_dsspec = mock()
99
+ mock_dsspec = double()
100
100
  subject.stub(:ds_specs => {})
101
- subject.configure_datastream(mock(:dsid => 'abc'))
101
+ subject.configure_datastream(double(:dsid => 'abc'))
102
102
  end
103
103
 
104
104
  it "should configure RelsExtDatastream" do
105
105
  mock_dsspec = { :type => ActiveFedora::RelsExtDatastream }
106
106
  subject.stub(:ds_specs => {'abc' => mock_dsspec})
107
107
 
108
- ds = mock(:dsid => 'abc')
108
+ ds = double(:dsid => 'abc')
109
109
  ds.should_receive(:model=).with(subject)
110
110
 
111
111
  subject.configure_datastream(ds)
112
112
  end
113
113
 
114
114
  it "should run a Proc" do
115
- ds = mock(:dsid => 'abc')
115
+ ds = double(:dsid => 'abc')
116
116
  @count = 0
117
117
  mock_dsspec = { :block => lambda { |x| @count += 1 } }
118
118
  subject.stub(:ds_specs => {'abc' => mock_dsspec})
@@ -139,7 +139,7 @@ describe ActiveFedora::Datastreams do
139
139
 
140
140
  describe "#add_datastream" do
141
141
  it "should add the datastream to the object" do
142
- ds = mock(:dsid => 'Abc')
142
+ ds = double(:dsid => 'Abc')
143
143
  subject.add_datastream(ds)
144
144
  subject.datastreams['Abc'].should == ds
145
145
  end
@@ -152,11 +152,11 @@ describe ActiveFedora::Datastreams do
152
152
 
153
153
  describe "#metadata_streams" do
154
154
  it "should only be metadata datastreams" do
155
- ds1 = mock(:metadata? => true)
156
- ds2 = mock(:metadata? => true)
157
- ds3 = mock(:metadata? => true)
155
+ ds1 = double(:metadata? => true)
156
+ ds2 = double(:metadata? => true)
157
+ ds3 = double(:metadata? => true)
158
158
  relsextds = ActiveFedora::RelsExtDatastream.new
159
- file_ds = mock(:metadata? => false)
159
+ file_ds = double(:metadata? => false)
160
160
  subject.stub(:datastreams => {:a => ds1, :b => ds2, :c => ds3, :d => relsextds, :e => file_ds})
161
161
  subject.metadata_streams.should include(ds1, ds2, ds3)
162
162
  subject.metadata_streams.should_not include(relsextds)
@@ -170,14 +170,14 @@ describe ActiveFedora::Datastreams do
170
170
  end
171
171
 
172
172
  it "should start from the highest existin dsid" do
173
- subject.stub(:datastreams => {'FOO56' => mock()})
173
+ subject.stub(:datastreams => {'FOO56' => double()})
174
174
  subject.generate_dsid('FOO').should == 'FOO57'
175
175
  end
176
176
  end
177
177
 
178
178
  describe "#relsext" do
179
179
  it "should be the RELS-EXT datastream" do
180
- m = mock
180
+ m = double
181
181
  subject.stub(:datastreams => { 'RELS-EXT' => m})
182
182
  subject.rels_ext.should == m
183
183
  end
@@ -204,19 +204,19 @@ describe ActiveFedora::Datastreams do
204
204
  end
205
205
 
206
206
  it "should try to get a mime type from the blob" do
207
- mock_file = mock(:content_type => 'x-application/asdf')
207
+ mock_file = double(:content_type => 'x-application/asdf')
208
208
  ds = subject.create_datastream(ActiveFedora::Datastream, nil, {:blob => mock_file})
209
209
  ds.mimeType.should == 'x-application/asdf'
210
210
  end
211
211
 
212
212
  it "should provide a default mime type" do
213
- mock_file = mock()
213
+ mock_file = double()
214
214
  ds = subject.create_datastream(ActiveFedora::Datastream, nil, {:blob => mock_file})
215
215
  ds.mimeType.should == 'application/octet-stream'
216
216
  end
217
217
 
218
218
  it "should use the filename as a default label" do
219
- mock_file = mock(:path => '/asdf/fdsa')
219
+ mock_file = double(:path => '/asdf/fdsa')
220
220
  ds = subject.create_datastream(ActiveFedora::Datastream, nil, {:blob => mock_file})
221
221
  ds.dsLabel.should == 'fdsa'
222
222
  end