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
@@ -15,13 +15,13 @@ describe ActiveFedora::Persistence do
15
15
 
16
16
  describe "#create_needs_index?" do
17
17
  it "should be true" do
18
- subject.send(:create_needs_index?).should be_true
18
+ expect(subject.send(:create_needs_index?)).to be_truthy
19
19
  end
20
20
  end
21
21
 
22
22
  describe "#update_needs_index?" do
23
23
  it "should be true" do
24
- subject.send(:update_needs_index?).should be_true
24
+ expect(subject.send(:update_needs_index?)).to be_truthy
25
25
  end
26
26
  end
27
27
  end
@@ -3,11 +3,11 @@ require 'spec_helper'
3
3
  describe ActiveFedora::Predicates do
4
4
  describe "#short_predicate" do
5
5
  it 'should parse strings' do
6
- ActiveFedora::Predicates.short_predicate('http://www.openarchives.org/OAI/2.0/itemID').should == :oai_item_id
6
+ expect(ActiveFedora::Predicates.short_predicate('http://www.openarchives.org/OAI/2.0/itemID')).to eq(:oai_item_id)
7
7
  end
8
8
  it 'should parse uris' do
9
- ActiveFedora::Predicates.short_predicate(RDF::DC.creator).should == 'dc_terms_creator'
10
- ActiveFedora::Predicates.short_predicate(RDF::SKOS.hasTopConcept).should == '2004_02_skos_core_has_top_concept'
9
+ expect(ActiveFedora::Predicates.short_predicate(RDF::DC.creator)).to eq('dc_terms_creator')
10
+ expect(ActiveFedora::Predicates.short_predicate(RDF::SKOS.hasTopConcept)).to eq('2004_02_skos_core_has_top_concept')
11
11
  end
12
12
  before(:all) do
13
13
  @original_mapping = ActiveFedora::Predicates.predicate_config[:predicate_mapping]
@@ -21,25 +21,25 @@ describe ActiveFedora::Predicates do
21
21
  "http://example.org/zoo/wolves/"=>{:alpha => 'Manager'},
22
22
  "http://example.org/zoo/"=>{:keeper => 'Manager'}
23
23
  }
24
- ActiveFedora::Predicates.short_predicate("http://example.org/zoo/Manager").should == :keeper
25
- ActiveFedora::Predicates.short_predicate("http://example.org/zoo/wolves/Manager").should == :alpha
26
- ActiveFedora::Predicates.short_predicate("http://example.org/Manager").should == :ceo
24
+ expect(ActiveFedora::Predicates.short_predicate("http://example.org/zoo/Manager")).to eq(:keeper)
25
+ expect(ActiveFedora::Predicates.short_predicate("http://example.org/zoo/wolves/Manager")).to eq(:alpha)
26
+ expect(ActiveFedora::Predicates.short_predicate("http://example.org/Manager")).to eq(:ceo)
27
27
  end
28
28
  end
29
29
 
30
30
  it 'should provide .default_predicate_namespace' do
31
- ActiveFedora::Predicates.default_predicate_namespace.should == 'info:fedora/fedora-system:def/relations-external#'
31
+ expect(ActiveFedora::Predicates.default_predicate_namespace).to eq('info:fedora/fedora-system:def/relations-external#')
32
32
  end
33
33
 
34
34
  describe "#predicate_mappings" do
35
35
 
36
36
  it 'should return a hash' do
37
- ActiveFedora::Predicates.predicate_mappings.should be_kind_of Hash
37
+ expect(ActiveFedora::Predicates.predicate_mappings).to be_kind_of Hash
38
38
  end
39
39
 
40
40
  it "should provide mappings to the fedora ontology via the info:fedora/fedora-system:def/relations-external default namespace mapping" do
41
- ActiveFedora::Predicates.predicate_mappings.keys.include?(ActiveFedora::Predicates.default_predicate_namespace).should be_true
42
- ActiveFedora::Predicates.predicate_mappings[ActiveFedora::Predicates.default_predicate_namespace].should be_kind_of Hash
41
+ expect(ActiveFedora::Predicates.predicate_mappings.keys.include?(ActiveFedora::Predicates.default_predicate_namespace)).to be_truthy
42
+ expect(ActiveFedora::Predicates.predicate_mappings[ActiveFedora::Predicates.default_predicate_namespace]).to be_kind_of Hash
43
43
  end
44
44
 
45
45
  it 'should provide predicate mappings for entire Fedora Relationship Ontology' do
@@ -67,21 +67,21 @@ describe ActiveFedora::Predicates do
67
67
  :conforms_to => "conformsTo",
68
68
  :has_model => "hasModel"]
69
69
  desired_mappings.each_pair do |k,v|
70
- ActiveFedora::Predicates.predicate_mappings[ActiveFedora::Predicates.default_predicate_namespace].should have_key(k)
71
- ActiveFedora::Predicates.predicate_mappings[ActiveFedora::Predicates.default_predicate_namespace][k].should == v
70
+ expect(ActiveFedora::Predicates.predicate_mappings[ActiveFedora::Predicates.default_predicate_namespace]).to have_key(k)
71
+ expect(ActiveFedora::Predicates.predicate_mappings[ActiveFedora::Predicates.default_predicate_namespace][k]).to eq(v)
72
72
  end
73
73
  end
74
74
  end
75
75
 
76
76
  it 'should provide #predicate_lookup that maps symbols to common RELS-EXT predicates' do
77
- ActiveFedora::Predicates.should respond_to(:predicate_lookup)
78
- ActiveFedora::Predicates.predicate_lookup(:is_part_of).should == "isPartOf"
79
- ActiveFedora::Predicates.predicate_lookup(:is_member_of).should == "isMemberOf"
80
- ActiveFedora::Predicates.predicate_lookup("isPartOfCollection").should == "isPartOfCollection"
77
+ expect(ActiveFedora::Predicates).to respond_to(:predicate_lookup)
78
+ expect(ActiveFedora::Predicates.predicate_lookup(:is_part_of)).to eq("isPartOf")
79
+ expect(ActiveFedora::Predicates.predicate_lookup(:is_member_of)).to eq("isMemberOf")
80
+ expect(ActiveFedora::Predicates.predicate_lookup("isPartOfCollection")).to eq("isPartOfCollection")
81
81
  ActiveFedora::Predicates.predicate_config[:predicate_mapping].merge!({"some_namespace"=>{:has_foo=>"hasFOO"}})
82
- ActiveFedora::Predicates.find_predicate(:has_foo).should == ["hasFOO","some_namespace"]
83
- ActiveFedora::Predicates.predicate_lookup(:has_foo,"some_namespace").should == "hasFOO"
84
- lambda { ActiveFedora::Predicates.predicate_lookup(:has_foo) }.should raise_error ActiveFedora::UnregisteredPredicateError
82
+ expect(ActiveFedora::Predicates.find_predicate(:has_foo)).to eq(["hasFOO","some_namespace"])
83
+ expect(ActiveFedora::Predicates.predicate_lookup(:has_foo,"some_namespace")).to eq("hasFOO")
84
+ expect { ActiveFedora::Predicates.predicate_lookup(:has_foo) }.to raise_error ActiveFedora::UnregisteredPredicateError
85
85
  end
86
86
 
87
87
  context 'initialization' do
@@ -94,19 +94,19 @@ describe ActiveFedora::Predicates do
94
94
  end
95
95
 
96
96
  it 'should allow explicit initialization of predicates' do
97
- ActiveFedora::Predicates.find_predicate(:is_part_of).should == ["isPartOf", "info:fedora/fedora-system:def/relations-external#"]
97
+ expect(ActiveFedora::Predicates.find_predicate(:is_part_of)).to eq(["isPartOf", "info:fedora/fedora-system:def/relations-external#"])
98
98
  ActiveFedora::Predicates.predicate_config = {
99
99
  :default_namespace => 'http://example.com/foo',
100
100
  :predicate_mapping => {
101
101
  'http://example.com/foo' => { :has_bar => 'hasBAR' }
102
102
  }
103
103
  }
104
- ActiveFedora::Predicates.find_predicate(:has_bar).should == ["hasBAR", "http://example.com/foo"]
105
- lambda { ActiveFedora::Predicates.find_predicate(:is_part_of) }.should raise_error ActiveFedora::UnregisteredPredicateError
104
+ expect(ActiveFedora::Predicates.find_predicate(:has_bar)).to eq(["hasBAR", "http://example.com/foo"])
105
+ expect { ActiveFedora::Predicates.find_predicate(:is_part_of) }.to raise_error ActiveFedora::UnregisteredPredicateError
106
106
  end
107
107
 
108
108
  it 'should ensure that the configuration has the correct keys' do
109
- lambda { ActiveFedora::Predicates.predicate_config = { :foo => 'invalid!' } }.should raise_error TypeError
109
+ expect { ActiveFedora::Predicates.predicate_config = { :foo => 'invalid!' } }.to raise_error TypeError
110
110
  end
111
111
 
112
112
  it "should allow adding predicates without wiping out existing predicates" do
@@ -118,12 +118,12 @@ describe ActiveFedora::Predicates do
118
118
  },
119
119
  })
120
120
  # New & Modified Predicates
121
- ActiveFedora::Predicates.find_predicate(:has_profile).should == ["hasProfile", "http://projecthydra.org/ns/relations#"]
122
- ActiveFedora::Predicates.find_predicate(:references).should == ["references", "info:fedora/fedora-system:def/relations-external#"]
123
- ActiveFedora::Predicates.find_predicate(:has_derivation).should == ["cameFrom", "info:fedora/fedora-system:def/relations-external#"]
121
+ expect(ActiveFedora::Predicates.find_predicate(:has_profile)).to eq(["hasProfile", "http://projecthydra.org/ns/relations#"])
122
+ expect(ActiveFedora::Predicates.find_predicate(:references)).to eq(["references", "info:fedora/fedora-system:def/relations-external#"])
123
+ expect(ActiveFedora::Predicates.find_predicate(:has_derivation)).to eq(["cameFrom", "info:fedora/fedora-system:def/relations-external#"])
124
124
  # Pre-Existing predicates should be unharmed
125
- ActiveFedora::Predicates.find_predicate(:is_part_of).should == ["isPartOf", "info:fedora/fedora-system:def/relations-external#"]
126
- ActiveFedora::Predicates.find_predicate(:is_governed_by).should == ["isGovernedBy", "http://projecthydra.org/ns/relations#"]
125
+ expect(ActiveFedora::Predicates.find_predicate(:is_part_of)).to eq(["isPartOf", "info:fedora/fedora-system:def/relations-external#"])
126
+ expect(ActiveFedora::Predicates.find_predicate(:is_governed_by)).to eq(["isGovernedBy", "http://projecthydra.org/ns/relations#"])
127
127
  end
128
128
 
129
129
  end
@@ -6,27 +6,27 @@ require 'active_fedora/model'
6
6
  describe ActiveFedora::Property do
7
7
 
8
8
  before(:all) do
9
- @test_property = ActiveFedora::Property.new(stub("model_stub"),"file_name", :string)
9
+ @test_property = ActiveFedora::Property.new(double("model_stub"),"file_name", :string)
10
10
  end
11
11
 
12
12
  it 'should provide .new' do
13
- ActiveFedora::Property.should respond_to(:new)
13
+ expect(ActiveFedora::Property).to respond_to(:new)
14
14
  end
15
15
 
16
16
  it 'should provide .name' do
17
- ActiveFedora::Property.should respond_to(:name)
17
+ expect(ActiveFedora::Property).to respond_to(:name)
18
18
  end
19
19
 
20
20
 
21
21
  it 'should provide .instance_variable_name' do
22
22
  #ActiveFedora::Property.should respond_to(:instance_variable_name)
23
23
 
24
- @test_property.should respond_to(:instance_variable_name)
24
+ expect(@test_property).to respond_to(:instance_variable_name)
25
25
  end
26
26
 
27
27
  describe '.instance_variable_name' do
28
28
  it 'should return the value of the name attribute with an @ appended' do
29
- @test_property.instance_variable_name.should eql("@#{@test_property.name}")
29
+ expect(@test_property.instance_variable_name).to eql("@#{@test_property.name}")
30
30
  end
31
31
  end
32
32
 
@@ -41,21 +41,21 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
41
41
 
42
42
  end
43
43
  it "from_xml should parse everything correctly" do
44
- @test_ds.ng_xml.should be_equivalent_to @sample_xml
44
+ expect(@test_ds.ng_xml).to be_equivalent_to @sample_xml
45
45
  end
46
46
 
47
47
  it "should create the right number of fields" do
48
- ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS.size.should == 54
48
+ expect(ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS.size).to eq(54)
49
49
  end
50
50
 
51
51
  it "should have unmodifiable constants" do
52
- proc {ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS<<:foo}.should raise_error((TypeError if RUBY_VERSION < "1.9.0") || RuntimeError, /can't modify frozen array/i)
52
+ expect {ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS<<:foo}.to raise_error((TypeError if RUBY_VERSION < "1.9.0") || RuntimeError, /can't modify frozen array/i)
53
53
 
54
54
  end
55
55
 
56
56
  it "should default dc elements to :multiple=>true" do
57
57
  @test_ds.fields.values.each do |s|
58
- s.has_key?(:multiple).should == true
58
+ expect(s.has_key?(:multiple)).to eq(true)
59
59
  end
60
60
  end
61
61
 
@@ -64,7 +64,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
64
64
 
65
65
  describe '#new' do
66
66
  it 'should provide #new' do
67
- ActiveFedora::QualifiedDublinCoreDatastream.should respond_to(:new)
67
+ expect(ActiveFedora::QualifiedDublinCoreDatastream).to respond_to(:new)
68
68
  end
69
69
 
70
70
 
@@ -75,7 +75,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
75
75
  pending if el == :type
76
76
  value = "Hey #{el}"
77
77
  @test_ds.send("#{el.to_s}=", value)
78
- @test_ds.send(el).first.should == value #Looking at first because creator has 2 nodes
78
+ expect(@test_ds.send(el).first).to eq(value) #Looking at first because creator has 2 nodes
79
79
  end
80
80
  end
81
81
  end
@@ -95,7 +95,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
95
95
  @test_ds.creator= ["creator1", "creator2"]
96
96
  @test_ds.title= ["title1"]
97
97
 
98
- @test_ds.to_xml.should be_equivalent_to('
98
+ expect(@test_ds.to_xml).to be_equivalent_to('
99
99
  <dc xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
100
100
  <dcterms:publisher>publisher1</dcterms:publisher>
101
101
  <dcterms:creator>creator1</dcterms:creator>
@@ -110,7 +110,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
110
110
  @test_ds = ActiveFedora::QualifiedDublinCoreDatastream.new(nil, 'qdc' )
111
111
  @test_ds.title = "War and Peace"
112
112
  solr = @test_ds.to_solr
113
- solr[ActiveFedora::SolrService.solr_name('title', type: :string)].should == "War and Peace"
113
+ expect(solr[ActiveFedora::SolrService.solr_name('title', type: :string)]).to eq("War and Peace")
114
114
  end
115
115
 
116
116
  end
@@ -120,7 +120,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
120
120
  sample_xml = "<dc xmlns:dcterms='http://purl.org/dc/terms/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><dcterms:cust>custom</dcterms:cust></dc>"
121
121
  test_ds = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(sample_xml )
122
122
  test_ds.field :cust
123
- test_ds.cust.should == ['custom']
123
+ expect(test_ds.cust).to eq(['custom'])
124
124
  end
125
125
  end
126
126
 
@@ -128,7 +128,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
128
128
  it "should be able to map :dc_type to the path 'type'" do
129
129
  test_ds = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(@sample_xml)
130
130
  test_ds.field :dc_type, :string, path: "type", multiple: true
131
- test_ds.dc_type.should == ['sound']
131
+ expect(test_ds.dc_type).to eq(['sound'])
132
132
  end
133
133
  end
134
134
 
@@ -16,27 +16,27 @@ describe ActiveFedora::Base do
16
16
  end
17
17
 
18
18
  describe ":all" do
19
- before { ActiveFedora::Base.stub(:relation => relation) }
19
+ before { allow(ActiveFedora::Base).to receive_messages(:relation => relation) }
20
20
  describe "called on a concrete class" do
21
21
  let(:relation) { ActiveFedora::Relation.new(SpecModel::Basic) }
22
22
  it "should query solr for all objects with :has_model_s of self.class" do
23
- relation.should_receive(:load_from_fedora).with("changeme:30", nil).and_return("Fake Object1")
24
- relation.should_receive(:load_from_fedora).with("changeme:22", nil).and_return("Fake Object2")
23
+ expect(relation).to receive(:load_from_fedora).with("changeme:30", nil).and_return("Fake Object1")
24
+ expect(relation).to receive(:load_from_fedora).with("changeme:22", nil).and_return("Fake Object2")
25
25
  mock_docs = [{"id" => "changeme:30"}, {"id" => "changeme:22"}]
26
- mock_docs.should_receive(:has_next?).and_return(false)
27
- ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with(1, 1000, 'select', :params=>{:q=>@model_query, :qt => 'standard', :sort => [@sort_query], :fl=> 'id', }).and_return('response'=>{'docs'=>mock_docs})
28
- SpecModel::Basic.all.should == ["Fake Object1", "Fake Object2"]
26
+ expect(mock_docs).to receive(:has_next?).and_return(false)
27
+ expect(ActiveFedora::SolrService.instance.conn).to receive(:paginate).with(1, 1000, 'select', :params=>{:q=>@model_query, :qt => 'standard', :sort => [@sort_query], :fl=> 'id', }).and_return('response'=>{'docs'=>mock_docs})
28
+ expect(SpecModel::Basic.all).to eq(["Fake Object1", "Fake Object2"])
29
29
  end
30
30
  end
31
31
  describe "called without a specific class" do
32
32
  let(:relation) { ActiveFedora::Relation.new(ActiveFedora::Base) }
33
33
  it "should specify a q parameter" do
34
- relation.should_receive(:load_from_fedora).with("changeme:30", true).and_return("Fake Object1")
35
- relation.should_receive(:load_from_fedora).with("changeme:22", true).and_return("Fake Object2")
34
+ expect(relation).to receive(:load_from_fedora).with("changeme:30", true).and_return("Fake Object1")
35
+ expect(relation).to receive(:load_from_fedora).with("changeme:22", true).and_return("Fake Object2")
36
36
  mock_docs = [{"id" => "changeme:30"},{"id" => "changeme:22"}]
37
- mock_docs.should_receive(:has_next?).and_return(false)
38
- ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with(1, 1000, 'select', :params=>{:q=>'*:*', :qt => 'standard', :sort => [@sort_query], :fl=> 'id', }).and_return('response'=>{'docs'=>mock_docs})
39
- ActiveFedora::Base.all.should == ["Fake Object1", "Fake Object2"]
37
+ expect(mock_docs).to receive(:has_next?).and_return(false)
38
+ expect(ActiveFedora::SolrService.instance.conn).to receive(:paginate).with(1, 1000, 'select', :params=>{:q=>'*:*', :qt => 'standard', :sort => [@sort_query], :fl=> 'id', }).and_return('response'=>{'docs'=>mock_docs})
39
+ expect(ActiveFedora::Base.all).to eq(["Fake Object1", "Fake Object2"])
40
40
  end
41
41
  end
42
42
  end
@@ -46,37 +46,37 @@ describe ActiveFedora::Base do
46
46
  describe "and a pid is specified" do
47
47
  it "should use SpecModel::Basic.allocate.init_with_object to instantiate an object" do
48
48
  allow_any_instance_of(SpecModel::Basic).to receive(:init_with_object).and_return(SpecModel::Basic.new )
49
- ActiveFedora::DigitalObject.should_receive(:find).and_return(double("inner obj", :'new?'=>false))
50
- SpecModel::Basic.find("_PID_", cast: false).should be_a SpecModel::Basic
49
+ expect(ActiveFedora::DigitalObject).to receive(:find).and_return(double("inner obj", :'new?'=>false))
50
+ expect(SpecModel::Basic.find("_PID_", cast: false)).to be_a SpecModel::Basic
51
51
  end
52
52
  it "should raise an exception if it is not found" do
53
53
  allow_any_instance_of(Rubydora::Fc3Service).to receive(:object).and_raise(RestClient::ResourceNotFound)
54
- SpecModel::Basic.should_receive(:connection_for_pid).with("_PID_")
55
- lambda {SpecModel::Basic.find("_PID_")}.should raise_error ActiveFedora::ObjectNotFoundError
54
+ expect(SpecModel::Basic).to receive(:connection_for_pid).with("_PID_")
55
+ expect {SpecModel::Basic.find("_PID_")}.to raise_error ActiveFedora::ObjectNotFoundError
56
56
  end
57
57
  end
58
58
  end
59
59
  describe "with default :cast of true" do
60
60
  it "should use SpecModel::Basic.allocate.init_with_object to instantiate an object" do
61
61
  allow_any_instance_of(SpecModel::Basic).to receive(:init_with_object).and_return(double("Model", :adapt_to_cmodel=>SpecModel::Basic.new ))
62
- ActiveFedora::DigitalObject.should_receive(:find).and_return(double("inner obj", :'new?'=>false))
62
+ expect(ActiveFedora::DigitalObject).to receive(:find).and_return(double("inner obj", :'new?'=>false))
63
63
  SpecModel::Basic.find("_PID_")
64
64
  end
65
65
  end
66
66
 
67
67
  describe "with conditions" do
68
68
  before do
69
- ActiveFedora::Base.stub(:relation => relation)
70
- relation.stub(clone: relation)
69
+ allow(ActiveFedora::Base).to receive_messages(:relation => relation)
70
+ allow(relation).to receive_messages(clone: relation)
71
71
  end
72
72
  let(:relation) { ActiveFedora::Relation.new(SpecModel::Basic) }
73
73
  it "should filter by the provided fields" do
74
- relation.should_receive(:load_from_fedora).with("changeme:30", nil).and_return("Fake Object1")
75
- relation.should_receive(:load_from_fedora).with("changeme:22", nil).and_return("Fake Object2")
74
+ expect(relation).to receive(:load_from_fedora).with("changeme:30", nil).and_return("Fake Object1")
75
+ expect(relation).to receive(:load_from_fedora).with("changeme:22", nil).and_return("Fake Object2")
76
76
 
77
77
  mock_docs = [{"id" => "changeme:30"},{"id" => "changeme:22"}]
78
- mock_docs.should_receive(:has_next?).and_return(false)
79
- ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with() { |page, rows, method, hash|
78
+ expect(mock_docs).to receive(:has_next?).and_return(false)
79
+ expect(ActiveFedora::SolrService.instance.conn).to receive(:paginate) { |page, rows, method, hash|
80
80
  page == 1 &&
81
81
  rows == 1000 &&
82
82
  method == 'select' &&
@@ -88,24 +88,24 @@ describe ActiveFedora::Base do
88
88
  hash[:params][:q].split(" AND ").include?("baz:quix") &&
89
89
  hash[:params][:q].split(" AND ").include?("baz:quack")
90
90
  }.and_return('response'=>{'docs'=>mock_docs})
91
- SpecModel::Basic.find({:foo=>'bar', :baz=>['quix','quack']}).should == ["Fake Object1", "Fake Object2"]
91
+ expect(SpecModel::Basic.find({:foo=>'bar', :baz=>['quix','quack']})).to eq(["Fake Object1", "Fake Object2"])
92
92
  end
93
93
 
94
94
  it "should correctly query for empty strings" do
95
- SpecModel::Basic.find( :active_fedora_model_ssi => '').count.should == 0
95
+ expect(SpecModel::Basic.find( :active_fedora_model_ssi => '').count).to eq(0)
96
96
  end
97
97
 
98
98
  it 'should correctly query for empty arrays' do
99
- SpecModel::Basic.find( :active_fedora_model_ssi => []).count.should == 0
99
+ expect(SpecModel::Basic.find( :active_fedora_model_ssi => []).count).to eq(0)
100
100
  end
101
101
 
102
102
  it "should add options" do
103
- relation.should_receive(:load_from_fedora).with("changeme:30", nil).and_return("Fake Object1")
104
- relation.should_receive(:load_from_fedora).with("changeme:22", nil).and_return("Fake Object2")
103
+ expect(relation).to receive(:load_from_fedora).with("changeme:30", nil).and_return("Fake Object1")
104
+ expect(relation).to receive(:load_from_fedora).with("changeme:22", nil).and_return("Fake Object2")
105
105
 
106
106
  mock_docs = [{"id" => "changeme:30"},{"id" => "changeme:22"}]
107
- mock_docs.should_receive(:has_next?).and_return(false)
108
- ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with() { |page, rows, method, hash|
107
+ expect(mock_docs).to receive(:has_next?).and_return(false)
108
+ expect(ActiveFedora::SolrService.instance.conn).to receive(:paginate) { |page, rows, method, hash|
109
109
  page == 1 &&
110
110
  rows == 1000 &&
111
111
  method == 'select' &&
@@ -117,34 +117,34 @@ describe ActiveFedora::Base do
117
117
  hash[:params][:q].split(" AND ").include?("baz:quix") &&
118
118
  hash[:params][:q].split(" AND ").include?("baz:quack")
119
119
  }.and_return('response'=>{'docs'=>mock_docs})
120
- SpecModel::Basic.find({:foo=>'bar', :baz=>['quix','quack']}, :sort=>'title_t desc').should == ["Fake Object1", "Fake Object2"]
120
+ expect(SpecModel::Basic.find({:foo=>'bar', :baz=>['quix','quack']}, :sort=>'title_t desc')).to eq(["Fake Object1", "Fake Object2"])
121
121
  end
122
122
  end
123
123
  end
124
124
 
125
125
 
126
126
  describe '#find_each' do
127
- before { ActiveFedora::Base.stub(:relation => relation) }
127
+ before { allow(ActiveFedora::Base).to receive_messages(:relation => relation) }
128
128
  let(:relation) { ActiveFedora::Relation.new(SpecModel::Basic) }
129
129
  it "should query solr for all objects with :active_fedora_model_s of self.class" do
130
130
  mock_docs = [{"id" => "changeme:30"},{"id" => "changeme:22"}]
131
- mock_docs.should_receive(:has_next?).and_return(false)
132
- ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with(1, 1000, 'select', :params=>{:q=>@model_query, :qt => 'standard', :sort => [@sort_query], :fl=> 'id', }).and_return('response'=>{'docs'=>mock_docs})
131
+ expect(mock_docs).to receive(:has_next?).and_return(false)
132
+ expect(ActiveFedora::SolrService.instance.conn).to receive(:paginate).with(1, 1000, 'select', :params=>{:q=>@model_query, :qt => 'standard', :sort => [@sort_query], :fl=> 'id', }).and_return('response'=>{'docs'=>mock_docs})
133
133
 
134
- relation.should_receive(:load_from_fedora).with("changeme:30", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:30'))
135
- relation.should_receive(:load_from_fedora).with("changeme:22", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:22'))
134
+ expect(relation).to receive(:load_from_fedora).with("changeme:30", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:30'))
135
+ expect(relation).to receive(:load_from_fedora).with("changeme:22", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:22'))
136
136
  yielded = double("yielded method")
137
- yielded.should_receive(:run).with { |obj| obj.class == SpecModel::Basic}.twice
137
+ expect(yielded).to receive(:run).twice { |obj| obj.class == SpecModel::Basic}
138
138
  SpecModel::Basic.find_each(){|obj| yielded.run(obj) }
139
139
  end
140
140
  describe "with conditions" do
141
141
  it "should filter by the provided fields" do
142
- relation.should_receive(:load_from_fedora).with("changeme:30", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:30'))
143
- relation.should_receive(:load_from_fedora).with("changeme:22", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:22'))
142
+ expect(relation).to receive(:load_from_fedora).with("changeme:30", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:30'))
143
+ expect(relation).to receive(:load_from_fedora).with("changeme:22", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:22'))
144
144
 
145
145
  mock_docs = [{"id" => "changeme:30"},{"id" => "changeme:22"}]
146
- mock_docs.should_receive(:has_next?).and_return(false)
147
- ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with() { |page, rows, method, hash|
146
+ expect(mock_docs).to receive(:has_next?).and_return(false)
147
+ expect(ActiveFedora::SolrService.instance.conn).to receive(:paginate) { |page, rows, method, hash|
148
148
  page == 1 &&
149
149
  rows == 1000 &&
150
150
  method == 'select' &&
@@ -157,7 +157,7 @@ describe ActiveFedora::Base do
157
157
  hash[:params][:q].split(" AND ").include?("baz:quack")
158
158
  }.and_return('response'=>{'docs'=>mock_docs})
159
159
  yielded = double("yielded method")
160
- yielded.should_receive(:run).with { |obj| obj.class == SpecModel::Basic}.twice
160
+ expect(yielded).to receive(:run).twice { |obj| obj.class == SpecModel::Basic}
161
161
  SpecModel::Basic.find_each({:foo=>'bar', :baz=>['quix','quack']}){|obj| yielded.run(obj) }
162
162
  end
163
163
  end
@@ -167,8 +167,8 @@ describe ActiveFedora::Base do
167
167
  describe "with conditions hash" do
168
168
  it "should filter by the provided fields" do
169
169
  mock_docs = double('docs')
170
- mock_docs.should_receive(:has_next?).and_return(false)
171
- ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with() { |page, rows, method, hash|
170
+ expect(mock_docs).to receive(:has_next?).and_return(false)
171
+ expect(ActiveFedora::SolrService.instance.conn).to receive(:paginate) { |page, rows, method, hash|
172
172
  page == 1 &&
173
173
  rows == 1002 &&
174
174
  method == 'select' &&
@@ -181,8 +181,8 @@ describe ActiveFedora::Base do
181
181
  hash[:params][:q].split(" AND ").include?("baz:quack")
182
182
  }.and_return('response'=>{'docs'=>mock_docs})
183
183
  yielded = double("yielded method")
184
- yielded.should_receive(:run).with(mock_docs)
185
- SpecModel::Basic.find_in_batches({:foo=>'bar', :baz=>['quix','quack']}, {:batch_size=>1002, :fl=>'id'}){|group| yielded.run group }.should
184
+ expect(yielded).to receive(:run).with(mock_docs)
185
+ SpecModel::Basic.find_in_batches({:foo=>'bar', :baz=>['quix','quack']}, {:batch_size=>1002, :fl=>'id'}) {|group| yielded.run group }
186
186
  end
187
187
  end
188
188
  end
@@ -191,19 +191,19 @@ describe ActiveFedora::Base do
191
191
 
192
192
  it "should return a count" do
193
193
  mock_result = {'response'=>{'numFound'=>7}}
194
- ActiveFedora::SolrService.should_receive(:query).with(@model_query, :rows=>0, :raw=>true).and_return(mock_result)
195
- SpecModel::Basic.count.should == 7
194
+ expect(ActiveFedora::SolrService).to receive(:query).with(@model_query, :rows=>0, :raw=>true).and_return(mock_result)
195
+ expect(SpecModel::Basic.count).to eq(7)
196
196
  end
197
197
  it "should allow conditions" do
198
198
  mock_result = {'response'=>{'numFound'=>7}}
199
- ActiveFedora::SolrService.should_receive(:query).with("#{@model_query} AND (foo:bar)", :rows=>0, :raw=>true).and_return(mock_result)
200
- SpecModel::Basic.count(:conditions=>'foo:bar').should == 7
199
+ expect(ActiveFedora::SolrService).to receive(:query).with("#{@model_query} AND (foo:bar)", :rows=>0, :raw=>true).and_return(mock_result)
200
+ expect(SpecModel::Basic.count(:conditions=>'foo:bar')).to eq(7)
201
201
  end
202
202
 
203
203
  it "should count without a class specified" do
204
204
  mock_result = {'response'=>{'numFound'=>7}}
205
- ActiveFedora::SolrService.should_receive(:query).with("(foo:bar)", :rows=>0, :raw=>true).and_return(mock_result)
206
- ActiveFedora::Base.count(:conditions=>'foo:bar').should == 7
205
+ expect(ActiveFedora::SolrService).to receive(:query).with("(foo:bar)", :rows=>0, :raw=>true).and_return(mock_result)
206
+ expect(ActiveFedora::Base.count(:conditions=>'foo:bar')).to eq(7)
207
207
  end
208
208
  end
209
209
 
@@ -252,7 +252,7 @@ describe ActiveFedora::Base do
252
252
  describe '#find_with_conditions' do
253
253
  it "should make a query to solr and return the results" do
254
254
  mock_result = double('Result')
255
- ActiveFedora::SolrService.should_receive(:query).with() { |args|
255
+ expect(ActiveFedora::SolrService).to receive(:query) { |args|
256
256
  q = args.first if args.is_a? Array
257
257
  q ||= args
258
258
  q.split(" AND ").include?(@model_query) &&
@@ -260,32 +260,32 @@ describe ActiveFedora::Base do
260
260
  q.split(" AND ").include?("baz:quix") &&
261
261
  q.split(" AND ").include?("baz:quack")
262
262
  }.and_return(mock_result)
263
- SpecModel::Basic.find_with_conditions(:foo=>'bar', :baz=>['quix','quack']).should == mock_result
263
+ expect(SpecModel::Basic.find_with_conditions(:foo=>'bar', :baz=>['quix','quack'])).to eq(mock_result)
264
264
  end
265
265
 
266
266
  it "should escape quotes" do
267
267
  mock_result = double('Result')
268
- ActiveFedora::SolrService.should_receive(:query).with() { |args|
269
- q = args.first if args.is_a? Array
270
- q ||= args
271
- q.split(" AND ").include?(@model_query) &&
272
- q.split(" AND ").include?(@model_query) &&
273
- q.split(" AND ").include?('foo:9\\"\\ Nails') &&
274
- q.split(" AND ").include?('baz:7\\"\\ version') &&
275
- q.split(" AND ").include?('baz:quack')
268
+ expect(ActiveFedora::SolrService).to receive(:query) { |args|
269
+ q = args.first if args.is_a? Array
270
+ q ||= args
271
+ q.split(" AND ").include?(@model_query) &&
272
+ q.split(" AND ").include?(@model_query) &&
273
+ q.split(" AND ").include?('foo:9\\"\\ Nails') &&
274
+ q.split(" AND ").include?('baz:7\\"\\ version') &&
275
+ q.split(" AND ").include?('baz:quack')
276
276
  }.and_return(mock_result)
277
- SpecModel::Basic.find_with_conditions(:foo=>'9" Nails', :baz=>['7" version','quack']).should == mock_result
277
+ expect(SpecModel::Basic.find_with_conditions(:foo=>'9" Nails', :baz=>['7" version','quack'])).to eq(mock_result)
278
278
  end
279
279
 
280
280
  it "shouldn't use the class if it's called on AF:Base " do
281
281
  mock_result = double('Result')
282
- ActiveFedora::SolrService.should_receive(:query).with('baz:quack', {:sort => [@sort_query]}).and_return(mock_result)
283
- ActiveFedora::Base.find_with_conditions(:baz=>'quack').should == mock_result
282
+ expect(ActiveFedora::SolrService).to receive(:query).with('baz:quack', {:sort => [@sort_query]}).and_return(mock_result)
283
+ expect(ActiveFedora::Base.find_with_conditions(:baz=>'quack')).to eq(mock_result)
284
284
  end
285
285
  it "should use the query string if it's provided and wrap it in parentheses" do
286
286
  mock_result = double('Result')
287
- ActiveFedora::SolrService.should_receive(:query).with('(chunky:monkey)', {:sort => [@sort_query]}).and_return(mock_result)
288
- ActiveFedora::Base.find_with_conditions('chunky:monkey').should == mock_result
287
+ expect(ActiveFedora::SolrService).to receive(:query).with('(chunky:monkey)', {:sort => [@sort_query]}).and_return(mock_result)
288
+ expect(ActiveFedora::Base.find_with_conditions('chunky:monkey')).to eq(mock_result)
289
289
  end
290
290
  end
291
291