active-fedora 8.2.1 → 8.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/active-fedora.gemspec +1 -2
  3. data/lib/active_fedora/datastream_collections.rb +4 -8
  4. data/lib/active_fedora/datastreams.rb +7 -9
  5. data/lib/active_fedora/version.rb +1 -1
  6. data/spec/config_helper.rb +3 -3
  7. data/spec/integration/associations_spec.rb +76 -76
  8. data/spec/integration/auditable_spec.rb +7 -7
  9. data/spec/integration/autosave_association_spec.rb +3 -3
  10. data/spec/integration/base_spec.rb +51 -51
  11. data/spec/integration/belongs_to_association_spec.rb +27 -27
  12. data/spec/integration/bug_spec.rb +1 -1
  13. data/spec/integration/collection_association_spec.rb +2 -2
  14. data/spec/integration/complex_rdf_datastream_spec.rb +32 -32
  15. data/spec/integration/datastream_collections_spec.rb +42 -42
  16. data/spec/integration/datastream_spec.rb +19 -19
  17. data/spec/integration/datastreams_spec.rb +25 -25
  18. data/spec/integration/delete_all_spec.rb +5 -5
  19. data/spec/integration/fedora_solr_sync_spec.rb +1 -1
  20. data/spec/integration/full_featured_model_spec.rb +9 -9
  21. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +46 -47
  22. data/spec/integration/has_many_associations_spec.rb +17 -17
  23. data/spec/integration/json_serialization_spec.rb +2 -2
  24. data/spec/integration/load_from_solr_spec.rb +1 -1
  25. data/spec/integration/model_spec.rb +9 -9
  26. data/spec/integration/nested_attribute_spec.rb +17 -17
  27. data/spec/integration/ntriples_datastream_spec.rb +43 -43
  28. data/spec/integration/om_datastream_spec.rb +37 -37
  29. data/spec/integration/persistence_spec.rb +1 -1
  30. data/spec/integration/rdf_nested_attributes_spec.rb +9 -9
  31. data/spec/integration/relation_delegation_spec.rb +7 -7
  32. data/spec/integration/relation_spec.rb +2 -2
  33. data/spec/integration/rels_ext_datastream_spec.rb +3 -3
  34. data/spec/integration/scoped_query_spec.rb +14 -14
  35. data/spec/integration/solr_service_spec.rb +24 -24
  36. data/spec/support/mock_fedora.rb +9 -10
  37. data/spec/unit/active_fedora_spec.rb +20 -20
  38. data/spec/unit/attributes_spec.rb +24 -24
  39. data/spec/unit/base_active_model_spec.rb +6 -6
  40. data/spec/unit/base_cma_spec.rb +2 -2
  41. data/spec/unit/base_datastream_management_spec.rb +7 -7
  42. data/spec/unit/base_extra_spec.rb +20 -20
  43. data/spec/unit/base_spec.rb +141 -141
  44. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
  45. data/spec/unit/callback_spec.rb +12 -12
  46. data/spec/unit/code_configurator_spec.rb +7 -7
  47. data/spec/unit/config_spec.rb +2 -2
  48. data/spec/unit/content_model_spec.rb +19 -20
  49. data/spec/unit/core_spec.rb +1 -1
  50. data/spec/unit/datastream_collections_spec.rb +101 -101
  51. data/spec/unit/datastream_spec.rb +12 -12
  52. data/spec/unit/datastreams_spec.rb +39 -39
  53. data/spec/unit/file_configurator_spec.rb +117 -117
  54. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +16 -16
  55. data/spec/unit/has_many_collection_spec.rb +5 -5
  56. data/spec/unit/inheritance_spec.rb +5 -5
  57. data/spec/unit/model_spec.rb +5 -5
  58. data/spec/unit/nom_datastream_spec.rb +5 -5
  59. data/spec/unit/ntriples_datastream_spec.rb +56 -56
  60. data/spec/unit/om_datastream_spec.rb +99 -99
  61. data/spec/unit/persistence_spec.rb +2 -2
  62. data/spec/unit/predicates_spec.rb +28 -28
  63. data/spec/unit/property_spec.rb +5 -5
  64. data/spec/unit/qualified_dublin_core_datastream_spec.rb +10 -10
  65. data/spec/unit/query_spec.rb +66 -66
  66. data/spec/unit/rdf_datastream_spec.rb +10 -10
  67. data/spec/unit/rdf_resource_datastream_spec.rb +2 -2
  68. data/spec/unit/rdf_xml_writer_spec.rb +3 -3
  69. data/spec/unit/rdfxml_rdf_datastream_spec.rb +9 -9
  70. data/spec/unit/relationship_graph_spec.rb +31 -31
  71. data/spec/unit/reload_on_save_spec.rb +3 -3
  72. data/spec/unit/rels_ext_datastream_spec.rb +28 -28
  73. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +11 -11
  74. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +11 -11
  75. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +11 -11
  76. data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +7 -7
  77. data/spec/unit/rubydora_connection_spec.rb +3 -3
  78. data/spec/unit/semantic_node_spec.rb +17 -17
  79. data/spec/unit/serializers_spec.rb +1 -1
  80. data/spec/unit/service_definitions_spec.rb +11 -11
  81. data/spec/unit/simple_datastream_spec.rb +6 -6
  82. data/spec/unit/solr_config_options_spec.rb +10 -10
  83. data/spec/unit/solr_digital_object_spec.rb +4 -4
  84. data/spec/unit/solr_service_spec.rb +41 -41
  85. data/spec/unit/unsaved_digital_object_spec.rb +8 -8
  86. data/spec/unit/validations_spec.rb +6 -6
  87. metadata +4 -4
@@ -16,7 +16,7 @@ describe "persisting objects" do
16
16
 
17
17
  describe "#create!" do
18
18
  it "should validate" do
19
- lambda { MockAFBaseRelationship.create!}.should raise_error ActiveFedora::RecordInvalid, "Validation failed: Name can't be blank"
19
+ expect { MockAFBaseRelationship.create!}.to raise_error ActiveFedora::RecordInvalid, "Validation failed: Name can't be blank"
20
20
  end
21
21
  end
22
22
  end
@@ -100,14 +100,14 @@ describe "Nesting attribute behavior of RDFDatastream" do
100
100
  subject { ComplexRDFDatastream::PersonalName.new(RDF::Graph.new) }
101
101
  it "should accept a hash" do
102
102
  subject.elementList_attributes = [{ topicElement_attributes: {'0' => { elementValue:"Quantum Behavior" }, '1' => { elementValue:"Wave Function" }}}]
103
- subject.elementList.first[0].elementValue.should == ["Quantum Behavior"]
104
- subject.elementList.first[1].elementValue.should == ["Wave Function"]
103
+ expect(subject.elementList.first[0].elementValue).to eq(["Quantum Behavior"])
104
+ expect(subject.elementList.first[1].elementValue).to eq(["Wave Function"])
105
105
 
106
106
  end
107
107
  it "should accept an array" do
108
108
  subject.elementList_attributes = [{ topicElement_attributes: [{ elementValue:"Quantum Behavior" }, { elementValue:"Wave Function" }]}]
109
- subject.elementList.first[0].elementValue.should == ["Quantum Behavior"]
110
- subject.elementList.first[1].elementValue.should == ["Wave Function"]
109
+ expect(subject.elementList.first[0].elementValue).to eq(["Quantum Behavior"])
110
+ expect(subject.elementList.first[1].elementValue).to eq(["Wave Function"])
111
111
  end
112
112
  end
113
113
 
@@ -118,10 +118,10 @@ describe "Nesting attribute behavior of RDFDatastream" do
118
118
  end
119
119
 
120
120
  it 'should have attributes' do
121
- subject.topic[0].elementList.first[0].elementValue.should == ["Cosmology"]
122
- subject.topic[1].elementList.first[0].elementValue.should == ["Quantum Behavior"]
123
- subject.personalName.first.elementList.first.fullNameElement.should == ["Jefferson, Thomas"]
124
- subject.personalName.first.elementList.first.dateNameElement.should == ["1743-1826"]
121
+ expect(subject.topic[0].elementList.first[0].elementValue).to eq(["Cosmology"])
122
+ expect(subject.topic[1].elementList.first[0].elementValue).to eq(["Quantum Behavior"])
123
+ expect(subject.personalName.first.elementList.first.fullNameElement).to eq(["Jefferson, Thomas"])
124
+ expect(subject.personalName.first.elementList.first.dateNameElement).to eq(["1743-1826"])
125
125
  end
126
126
 
127
127
  it 'should build nodes with ids' do
@@ -171,7 +171,7 @@ describe "Nesting attribute behavior of RDFDatastream" do
171
171
  it "should update nested objects" do
172
172
  subject.parts_attributes= [{id: replace_object_id, label: "Universal Joint"}, {label:"Oil Pump"}, {id: remove_object_id, _destroy: '1', label: "bar1 uno"}]
173
173
 
174
- subject.parts.map{|p| p.label.first}.should == ['Alternator', 'Universal Joint', 'Transmission', 'Oil Pump']
174
+ expect(subject.parts.map{|p| p.label.first}).to eq(['Alternator', 'Universal Joint', 'Transmission', 'Oil Pump'])
175
175
 
176
176
  end
177
177
  it "create a new object when the id is provided" do
@@ -38,27 +38,27 @@ describe ActiveFedora::Model do
38
38
  subject { ModelIntegrationSpec::Basic.where(bar: 'Peanuts') }
39
39
 
40
40
  it "should map" do
41
- subject.map(&:id).should == [instance2.id, instance3.id]
41
+ expect(subject.map(&:id)).to eq([instance2.id, instance3.id])
42
42
  end
43
43
 
44
44
  it "should collect" do
45
- subject.collect(&:id).should == [instance2.id, instance3.id]
45
+ expect(subject.collect(&:id)).to eq([instance2.id, instance3.id])
46
46
  end
47
47
 
48
48
  it "should have each" do
49
49
  t = double
50
- t.should_receive(:foo).twice
50
+ expect(t).to receive(:foo).twice
51
51
  subject.each { t.foo }
52
52
  end
53
53
 
54
54
  it "should have all?" do
55
- expect(subject.all? { |t| t.foo == ['Alpha']}).to be_false
56
- expect(subject.all? { |t| t.bar == ['Peanuts']}).to be_true
55
+ expect(subject.all? { |t| t.foo == ['Alpha']}).to be_falsey
56
+ expect(subject.all? { |t| t.bar == ['Peanuts']}).to be_truthy
57
57
  end
58
58
 
59
59
  it "should have include?" do
60
- expect(subject.include?(instance1)).to be_false
61
- expect(subject.include?(instance2)).to be_true
60
+ expect(subject.include?(instance1)).to be_falsey
61
+ expect(subject.include?(instance2)).to be_truthy
62
62
  end
63
63
  end
64
64
  end
@@ -14,7 +14,7 @@ describe ActiveFedora::Base do
14
14
  end
15
15
 
16
16
  subject { Library.all }
17
- its(:class) {should eq ActiveFedora::Relation }
17
+ its(:class) {is_expected.to eq ActiveFedora::Relation }
18
18
 
19
19
  before :all do
20
20
  Library.create
@@ -32,7 +32,7 @@ describe ActiveFedora::Base do
32
32
  expect(subject).to be_loaded
33
33
  end
34
34
  it "shouldn't reload" do
35
- ActiveFedora::Relation.any_instance.should_not_receive :find_each
35
+ expect_any_instance_of(ActiveFedora::Relation).not_to receive :find_each
36
36
  subject[0]
37
37
  end
38
38
  end
@@ -60,7 +60,7 @@ describe ActiveFedora::RelsExtDatastream do
60
60
  rexml1 = REXML::Document.new(@test_datastream.to_rels_ext())
61
61
  @test_datastream.serialize!
62
62
  rexml2 = REXML::Document.new(@test_object.datastreams["RELS-EXT"].content)
63
- rexml1.root.elements["rdf:Description"].inspect.should eql(rexml2.root.elements["rdf:Description"].inspect)
63
+ expect(rexml1.root.elements["rdf:Description"].inspect).to eql(rexml2.root.elements["rdf:Description"].inspect)
64
64
  end
65
65
 
66
66
  end
@@ -72,11 +72,11 @@ describe ActiveFedora::RelsExtDatastream do
72
72
  end
73
73
  @test_object.save
74
74
  # make sure that _something_ was actually added to the object's relationships hash
75
- @test_object.ids_for_outbound(:is_member_of).size.should == 1
75
+ expect(@test_object.ids_for_outbound(:is_member_of).size).to eq(1)
76
76
  new_rels = ActiveFedora::Base.find(@test_object.pid).relationships
77
77
  # This stopped working, need to push an issue into the rdf library. (when dumping ntriples, the order of assertions changed)
78
78
  #new_rels.should == @test_object.relationships
79
- new_rels.dump(:rdfxml).should == @test_object.relationships.dump(:rdfxml)
79
+ expect(new_rels.dump(:rdfxml)).to eq(@test_object.relationships.dump(:rdfxml))
80
80
  end
81
81
 
82
82
  end
@@ -39,18 +39,18 @@ describe "scoped queries" do
39
39
  describe ".all" do
40
40
  it "should return an array of instances of the calling Class" do
41
41
  result = ModelIntegrationSpec::Basic.all.to_a
42
- result.should be_instance_of(Array)
42
+ expect(result).to be_instance_of(Array)
43
43
  # this test is meaningless if the array length is zero
44
- result.length.should > 0
44
+ expect(result.length).to be > 0
45
45
  result.each do |obj|
46
- obj.class.should == ModelIntegrationSpec::Basic
46
+ expect(obj.class).to eq(ModelIntegrationSpec::Basic)
47
47
  end
48
48
  end
49
49
  end
50
50
 
51
51
  describe ".first" do
52
52
  it "should return one instance of the calling class" do
53
- ModelIntegrationSpec::Basic.first.should == test_instance
53
+ expect(ModelIntegrationSpec::Basic.first).to eq(test_instance)
54
54
  end
55
55
  end
56
56
  end
@@ -67,33 +67,33 @@ describe "scoped queries" do
67
67
  test_instance3.delete
68
68
  end
69
69
  it "should query" do
70
- ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', type: :string)=> 'Beta').should == [test_instance1]
71
- ModelIntegrationSpec::Basic.where('foo' => 'Beta').should == [test_instance1]
70
+ expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', type: :string)=> 'Beta')).to eq([test_instance1])
71
+ expect(ModelIntegrationSpec::Basic.where('foo' => 'Beta')).to eq([test_instance1])
72
72
  end
73
73
  it "should order" do
74
- ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').should == [test_instance2, test_instance1, test_instance3]
74
+ expect(ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc')).to eq([test_instance2, test_instance1, test_instance3])
75
75
  end
76
76
  it "should limit" do
77
- ModelIntegrationSpec::Basic.limit(1).should == [test_instance1]
77
+ expect(ModelIntegrationSpec::Basic.limit(1)).to eq([test_instance1])
78
78
  end
79
79
  it "should offset" do
80
- ModelIntegrationSpec::Basic.offset(1).should == [test_instance2, test_instance3]
80
+ expect(ModelIntegrationSpec::Basic.offset(1)).to eq([test_instance2, test_instance3])
81
81
  end
82
82
 
83
83
  it "should chain queries" do
84
- ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').limit(1).should == [test_instance2]
84
+ expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').limit(1)).to eq([test_instance2])
85
85
  end
86
86
 
87
87
  it "should wrap string conditions with parentheses" do
88
- ModelIntegrationSpec::Basic.where("foo:bar OR bar:baz").where_values.should == ["(foo:bar OR bar:baz)"]
88
+ expect(ModelIntegrationSpec::Basic.where("foo:bar OR bar:baz").where_values).to eq(["(foo:bar OR bar:baz)"])
89
89
  end
90
90
 
91
91
  it "should chain where queries" do
92
- ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').where("#{ActiveFedora::SolrService.solr_name('foo', type: :string)}:bar").where_values.should == ["#{ActiveFedora::SolrService.solr_name('bar', type: :string)}:Peanuts", "(#{ActiveFedora::SolrService.solr_name('foo', type: :string)}:bar)"]
92
+ expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').where("#{ActiveFedora::SolrService.solr_name('foo', type: :string)}:bar").where_values).to eq(["#{ActiveFedora::SolrService.solr_name('bar', type: :string)}:Peanuts", "(#{ActiveFedora::SolrService.solr_name('foo', type: :string)}:bar)"])
93
93
  end
94
94
 
95
95
  it "should chain count" do
96
- ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').count.should == 2
96
+ expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').count).to eq(2)
97
97
  end
98
98
 
99
99
  it "calling first should not affect the relation's ability to get all results later" do
@@ -125,7 +125,7 @@ describe "scoped queries" do
125
125
  end
126
126
  it "should log an error" do
127
127
  expect(ActiveFedora::Base.logger).to receive(:error).with("Although #{pid} was found in Solr, it doesn't seem to exist in Fedora. The index is out of synch.")
128
- ModelIntegrationSpec::Basic.all.should == [test_instance1, test_instance3]
128
+ expect(ModelIntegrationSpec::Basic.all).to eq([test_instance1, test_instance3])
129
129
  end
130
130
  end
131
131
  end
@@ -39,9 +39,9 @@ describe ActiveFedora::SolrService do
39
39
  query = "id\:#{RSolr.solr_escape(@test_object.pid)} OR id\:#{RSolr.solr_escape(@foo_object.pid)}"
40
40
  solr_result = ActiveFedora::SolrService.query(query)
41
41
  result = ActiveFedora::SolrService.reify_solr_results(solr_result)
42
- result.length.should == 2
42
+ expect(result.length).to eq(2)
43
43
  result.each do |r|
44
- (r.class == ActiveFedora::Base || r.class == FooObject).should be_true
44
+ expect(r.class == ActiveFedora::Base || r.class == FooObject).to be_truthy
45
45
  end
46
46
  end
47
47
 
@@ -49,21 +49,21 @@ describe ActiveFedora::SolrService do
49
49
  query = "id\:#{RSolr.solr_escape(@test_object.pid)} OR id\:#{RSolr.solr_escape(@foo_object.pid)}"
50
50
  solr_result = ActiveFedora::SolrService.query(query)
51
51
  result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
52
- result.length.should == 2
52
+ expect(result.length).to eq(2)
53
53
  result.each do |r|
54
- r.inner_object.should be_a(ActiveFedora::SolrDigitalObject)
55
- [ActiveFedora::Base, FooObject].should include(r.class)
56
- ['test_object','foo_object'].should include(r.label)
57
- @test_object.inner_object.profile.should == @profiles['test']
58
- @foo_object.inner_object.profile.should == @profiles['foo']
59
- @foo_object.datastreams['descMetadata'].profile.should == @profiles['foo_descMetadata']
60
- @foo_object.datastreams['descMetadata'].content.should be_equivalent_to(@foo_content)
54
+ expect(r.inner_object).to be_a(ActiveFedora::SolrDigitalObject)
55
+ expect([ActiveFedora::Base, FooObject]).to include(r.class)
56
+ expect(['test_object','foo_object']).to include(r.label)
57
+ expect(@test_object.inner_object.profile).to eq(@profiles['test'])
58
+ expect(@foo_object.inner_object.profile).to eq(@profiles['foo'])
59
+ expect(@foo_object.datastreams['descMetadata'].profile).to eq(@profiles['foo_descMetadata'])
60
+ expect(@foo_object.datastreams['descMetadata'].content).to be_equivalent_to(@foo_content)
61
61
  end
62
62
  end
63
63
 
64
64
  it 'should instantiate all datastreams in the solr doc, even ones undeclared by the class' do
65
65
  obj = ActiveFedora::Base.load_instance_from_solr @foo_object.pid
66
- obj.datastreams.keys.should include('descMetadata')
66
+ expect(obj.datastreams.keys).to include('descMetadata')
67
67
  end
68
68
 
69
69
  it 'should #reify a lightweight object as a new instance' do
@@ -72,10 +72,10 @@ describe ActiveFedora::SolrService do
72
72
  result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
73
73
  solr_foo = result.first
74
74
  real_foo = solr_foo.reify
75
- solr_foo.inner_object.should be_a(ActiveFedora::SolrDigitalObject)
76
- real_foo.inner_object.should be_a(ActiveFedora::DigitalObject)
77
- solr_foo.label.should == 'foo_object'
78
- real_foo.label.should == 'foo_object'
75
+ expect(solr_foo.inner_object).to be_a(ActiveFedora::SolrDigitalObject)
76
+ expect(real_foo.inner_object).to be_a(ActiveFedora::DigitalObject)
77
+ expect(solr_foo.label).to eq('foo_object')
78
+ expect(real_foo.label).to eq('foo_object')
79
79
  end
80
80
 
81
81
  it 'should #reify! a lightweight object within the same instance' do
@@ -83,10 +83,10 @@ describe ActiveFedora::SolrService do
83
83
  solr_result = ActiveFedora::SolrService.query(query)
84
84
  result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
85
85
  solr_foo = result.first
86
- solr_foo.inner_object.should be_a(ActiveFedora::SolrDigitalObject)
86
+ expect(solr_foo.inner_object).to be_a(ActiveFedora::SolrDigitalObject)
87
87
  solr_foo.reify!
88
- solr_foo.inner_object.should be_a(ActiveFedora::DigitalObject)
89
- solr_foo.label.should == 'foo_object'
88
+ expect(solr_foo.inner_object).to be_a(ActiveFedora::DigitalObject)
89
+ expect(solr_foo.label).to eq('foo_object')
90
90
  end
91
91
 
92
92
  it 'should raise an exception when attempting to reify a first-class object' do
@@ -94,17 +94,17 @@ describe ActiveFedora::SolrService do
94
94
  solr_result = ActiveFedora::SolrService.query(query)
95
95
  result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
96
96
  solr_foo = result.first
97
- lambda {solr_foo.reify}.should_not raise_exception
98
- lambda {solr_foo.reify!}.should_not raise_exception
99
- lambda {solr_foo.reify!}.should raise_exception(/already a full/)
100
- lambda {solr_foo.reify}.should raise_exception(/already a full/)
97
+ expect {solr_foo.reify}.not_to raise_exception
98
+ expect {solr_foo.reify!}.not_to raise_exception
99
+ expect {solr_foo.reify!}.to raise_exception(/already a full/)
100
+ expect {solr_foo.reify}.to raise_exception(/already a full/)
101
101
  end
102
102
 
103
103
  it 'should call load_instance_from_solr if :load_from_solr option passed in' do
104
104
  query = "id\:#{RSolr.solr_escape(@test_object.pid)} OR id\:#{RSolr.solr_escape(@foo_object.pid)}"
105
105
  solr_result = ActiveFedora::SolrService.query(query)
106
- ActiveFedora::Base.should_receive(:load_instance_from_solr).once
107
- FooObject.should_receive(:load_instance_from_solr).once
106
+ expect(ActiveFedora::Base).to receive(:load_instance_from_solr).once
107
+ expect(FooObject).to receive(:load_instance_from_solr).once
108
108
  result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
109
109
  end
110
110
 
@@ -2,34 +2,34 @@ def mock_client
2
2
  return @mock_client if @mock_client
3
3
  @mock_client = double("client")
4
4
  @getter = double("getter")
5
- @getter.stub(:get).and_return('')
6
- @mock_client.stub(:[]).with("describe?xml=true").and_return('')
5
+ allow(@getter).to receive(:get).and_return('')
6
+ allow(@mock_client).to receive(:[]).with("describe?xml=true").and_return('')
7
7
  @mock_client
8
8
  end
9
9
 
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(double('get getter', :get=>'foobar'))
13
+ allow(mock_client).to receive(:[]).with("objects/#{pid}?format=xml").and_return(double('get getter', :get=>'foobar'))
14
14
  else
15
- mock_client.stub(:[]).with("objects/#{pid}?format=xml").and_raise(RestClient::ResourceNotFound)
15
+ allow(mock_client).to receive(:[]).with("objects/#{pid}?format=xml").and_raise(RestClient::ResourceNotFound)
16
16
  end
17
- mock_client.stub(:[]).with("objects/#{pid}/datastreams?format=xml").and_return(@getter)
17
+ allow(mock_client).to receive(:[]).with("objects/#{pid}/datastreams?format=xml").and_return(@getter)
18
18
  datastreams ||= ['someData', 'withText', 'withText2', 'RELS-EXT']
19
19
  datastreams.each do |dsid|
20
- mock_client.stub(:[]).with("objects/#{pid}/datastreams/#{dsid}?format=xml").and_return(@getter)
20
+ allow(mock_client).to receive(:[]).with("objects/#{pid}/datastreams/#{dsid}?format=xml").and_return(@getter)
21
21
  end
22
22
  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(double("ingester", :post=>pid))
26
+ expect(mock_client).to receive(:[]).with("objects/#{n || 'new'}").and_return(double("ingester", :post=>pid))
27
27
  end
28
28
 
29
29
  def stub_add_ds(pid, dsids)
30
30
  pid.gsub!(/:/, '%3A')
31
31
  dsids.each do |dsid|
32
- client = mock_client.stub(:[]).with do |params|
32
+ client = allow(mock_client).to receive(:[]) do |params|
33
33
  /objects\/#{pid}\/datastreams\/#{dsid}/.match(params)
34
34
  end
35
35
  client.and_return(double("ds_adder", :post=>pid, :get=>''))
@@ -39,7 +39,6 @@ end
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(double("content_accessor", :post=>pid, :get=>''))
42
+ allow(mock_client).to receive(:[]) { |params| /objects\/#{pid}\/datastreams\/#{dsid}\/content/.match(params)}.and_return(double("content_accessor", :post=>pid, :get=>''))
43
43
  end
44
44
  end
45
-
@@ -14,36 +14,36 @@ describe ActiveFedora do
14
14
  describe "initialization methods" do
15
15
  describe "environment" do
16
16
  it "should use config_options[:environment] if set" do
17
- ActiveFedora.stub(:config_options => {:environment=>"ballyhoo"})
18
- ActiveFedora.environment.should eql("ballyhoo")
17
+ allow(ActiveFedora).to receive_messages(:config_options => {:environment=>"ballyhoo"})
18
+ expect(ActiveFedora.environment).to eql("ballyhoo")
19
19
  end
20
20
 
21
21
  it "should use Rails.env if no config_options and Rails.env is set" do
22
22
  stub_rails(:env => "bedbugs")
23
- ActiveFedora.stub(:config_options => {})
24
- ActiveFedora.environment.should eql("bedbugs")
23
+ allow(ActiveFedora).to receive_messages(:config_options => {})
24
+ expect(ActiveFedora.environment).to eql("bedbugs")
25
25
  unstub_rails
26
26
  end
27
27
 
28
28
  it "should use ENV['environment'] if neither config_options nor Rails.env are set" do
29
29
  ENV['environment'] = "wichita"
30
- ActiveFedora.stub(:config_options => {})
31
- ActiveFedora.environment.should eql("wichita")
30
+ allow(ActiveFedora).to receive_messages(:config_options => {})
31
+ expect(ActiveFedora.environment).to eql("wichita")
32
32
  ENV['environment']='test'
33
33
  end
34
34
 
35
35
  it "should use ENV['RAILS_ENV'] and log a warning if none of the above are set" do
36
36
  ENV['environment']=nil
37
37
  ENV['RAILS_ENV'] = "rails_env"
38
- lambda {ActiveFedora.environment}.should raise_error(RuntimeError, "You're depending on RAILS_ENV for setting your environment. Please use ENV['environment'] for non-rails environment setting: 'rake foo:bar environment=test'")
38
+ expect {ActiveFedora.environment}.to raise_error(RuntimeError, "You're depending on RAILS_ENV for setting your environment. Please use ENV['environment'] for non-rails environment setting: 'rake foo:bar environment=test'")
39
39
  ENV['environment']='test'
40
40
  end
41
41
 
42
42
  it "should be development if none of the above are present" do
43
43
  ENV['environment']=nil
44
44
  ENV['RAILS_ENV'] = nil
45
- ActiveFedora.stub(:config_options => {})
46
- ActiveFedora.environment.should == 'development'
45
+ allow(ActiveFedora).to receive_messages(:config_options => {})
46
+ expect(ActiveFedora.environment).to eq('development')
47
47
  ENV['environment']="test"
48
48
  end
49
49
  end
@@ -59,7 +59,7 @@ describe ActiveFedora do
59
59
  describe "outside of rails" do
60
60
  it "should load the passed config if explicit config passed in as a string" do
61
61
  ActiveFedora.init(:fedora_config_path=>'./spec/fixtures/rails_root/config/fedora.yml', :environment => 'test')
62
- ActiveFedora.config.credentials.should == {:url=> "http://testhost.com:8983/fedora", :user=>'fedoraAdmin', :password=>'fedoraAdmin'}
62
+ expect(ActiveFedora.config.credentials).to eq({:url=> "http://testhost.com:8983/fedora", :user=>'fedoraAdmin', :password=>'fedoraAdmin'})
63
63
  end
64
64
  end
65
65
 
@@ -79,22 +79,22 @@ describe ActiveFedora do
79
79
  solr_config_path = File.expand_path(File.join(File.dirname(__FILE__),"../fixtures/rails_root/config/solr.yml"))
80
80
  pred_config_path = File.expand_path(File.join(File.dirname(__FILE__),"../fixtures/rails_root/config/predicate_mappings.yml"))
81
81
 
82
- File.stub(:open).with(fedora_config_path).and_return(fedora_config)
83
- File.stub(:open).with(solr_config_path).and_return(solr_config)
84
- ActiveFedora::SolrService.stub(:load_mappings) #For the solrizer solr_mappings.yml
82
+ allow(File).to receive(:open).with(fedora_config_path).and_return(fedora_config)
83
+ allow(File).to receive(:open).with(solr_config_path).and_return(solr_config)
84
+ allow(ActiveFedora::SolrService).to receive(:load_mappings) #For the solrizer solr_mappings.yml
85
85
 
86
86
  ActiveFedora.init(:fedora_config_path=>fedora_config_path,:solr_config_path=>solr_config_path)
87
- ActiveFedora.solr.class.should == ActiveFedora::SolrService
87
+ expect(ActiveFedora.solr.class).to eq(ActiveFedora::SolrService)
88
88
  end
89
89
  end
90
90
 
91
91
  describe "with no explicit config path" do
92
92
  it "should look for the file in the path defined at Rails.root" do
93
- ActiveFedora::SolrService.stub(:load_mappings) #necessary or else it will load the solrizer config and it breaks other tests in the suite.
93
+ allow(ActiveFedora::SolrService).to receive(:load_mappings) #necessary or else it will load the solrizer config and it breaks other tests in the suite.
94
94
 
95
95
  stub_rails(:root=>File.join(File.dirname(__FILE__),"../fixtures/rails_root"))
96
96
  ActiveFedora.init()
97
- ActiveFedora.config.credentials[:url].should == "http://testhost.com:8983/fedora"
97
+ expect(ActiveFedora.config.credentials[:url]).to eq("http://testhost.com:8983/fedora")
98
98
  end
99
99
  end
100
100
  end
@@ -111,13 +111,13 @@ describe ActiveFedora do
111
111
  end
112
112
  end
113
113
  it "should return class constants based on strings" do
114
- ActiveFedora.class_from_string("Om").should == Om
115
- ActiveFedora.class_from_string("ActiveFedora::RDF::Indexing").should == ActiveFedora::RDF::Indexing
116
- ActiveFedora.class_from_string("Indexing", ActiveFedora::RDF).should == ActiveFedora::RDF::Indexing
114
+ expect(ActiveFedora.class_from_string("Om")).to eq(Om)
115
+ expect(ActiveFedora.class_from_string("ActiveFedora::RDF::Indexing")).to eq(ActiveFedora::RDF::Indexing)
116
+ expect(ActiveFedora.class_from_string("Indexing", ActiveFedora::RDF)).to eq(ActiveFedora::RDF::Indexing)
117
117
  end
118
118
 
119
119
  it "should find sibling classes" do
120
- ActiveFedora.class_from_string("SiblingClass", ParentClass::OtherSiblingClass).should == ParentClass::SiblingClass
120
+ expect(ActiveFedora.class_from_string("SiblingClass", ParentClass::OtherSiblingClass)).to eq(ParentClass::SiblingClass)
121
121
  end
122
122
 
123
123
  it "should raise a NameError if the class isn't found" do