active-fedora 8.2.1 → 8.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/active-fedora.gemspec +1 -2
  3. data/lib/active_fedora/datastream_collections.rb +4 -8
  4. data/lib/active_fedora/datastreams.rb +7 -9
  5. data/lib/active_fedora/version.rb +1 -1
  6. data/spec/config_helper.rb +3 -3
  7. data/spec/integration/associations_spec.rb +76 -76
  8. data/spec/integration/auditable_spec.rb +7 -7
  9. data/spec/integration/autosave_association_spec.rb +3 -3
  10. data/spec/integration/base_spec.rb +51 -51
  11. data/spec/integration/belongs_to_association_spec.rb +27 -27
  12. data/spec/integration/bug_spec.rb +1 -1
  13. data/spec/integration/collection_association_spec.rb +2 -2
  14. data/spec/integration/complex_rdf_datastream_spec.rb +32 -32
  15. data/spec/integration/datastream_collections_spec.rb +42 -42
  16. data/spec/integration/datastream_spec.rb +19 -19
  17. data/spec/integration/datastreams_spec.rb +25 -25
  18. data/spec/integration/delete_all_spec.rb +5 -5
  19. data/spec/integration/fedora_solr_sync_spec.rb +1 -1
  20. data/spec/integration/full_featured_model_spec.rb +9 -9
  21. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +46 -47
  22. data/spec/integration/has_many_associations_spec.rb +17 -17
  23. data/spec/integration/json_serialization_spec.rb +2 -2
  24. data/spec/integration/load_from_solr_spec.rb +1 -1
  25. data/spec/integration/model_spec.rb +9 -9
  26. data/spec/integration/nested_attribute_spec.rb +17 -17
  27. data/spec/integration/ntriples_datastream_spec.rb +43 -43
  28. data/spec/integration/om_datastream_spec.rb +37 -37
  29. data/spec/integration/persistence_spec.rb +1 -1
  30. data/spec/integration/rdf_nested_attributes_spec.rb +9 -9
  31. data/spec/integration/relation_delegation_spec.rb +7 -7
  32. data/spec/integration/relation_spec.rb +2 -2
  33. data/spec/integration/rels_ext_datastream_spec.rb +3 -3
  34. data/spec/integration/scoped_query_spec.rb +14 -14
  35. data/spec/integration/solr_service_spec.rb +24 -24
  36. data/spec/support/mock_fedora.rb +9 -10
  37. data/spec/unit/active_fedora_spec.rb +20 -20
  38. data/spec/unit/attributes_spec.rb +24 -24
  39. data/spec/unit/base_active_model_spec.rb +6 -6
  40. data/spec/unit/base_cma_spec.rb +2 -2
  41. data/spec/unit/base_datastream_management_spec.rb +7 -7
  42. data/spec/unit/base_extra_spec.rb +20 -20
  43. data/spec/unit/base_spec.rb +141 -141
  44. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
  45. data/spec/unit/callback_spec.rb +12 -12
  46. data/spec/unit/code_configurator_spec.rb +7 -7
  47. data/spec/unit/config_spec.rb +2 -2
  48. data/spec/unit/content_model_spec.rb +19 -20
  49. data/spec/unit/core_spec.rb +1 -1
  50. data/spec/unit/datastream_collections_spec.rb +101 -101
  51. data/spec/unit/datastream_spec.rb +12 -12
  52. data/spec/unit/datastreams_spec.rb +39 -39
  53. data/spec/unit/file_configurator_spec.rb +117 -117
  54. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +16 -16
  55. data/spec/unit/has_many_collection_spec.rb +5 -5
  56. data/spec/unit/inheritance_spec.rb +5 -5
  57. data/spec/unit/model_spec.rb +5 -5
  58. data/spec/unit/nom_datastream_spec.rb +5 -5
  59. data/spec/unit/ntriples_datastream_spec.rb +56 -56
  60. data/spec/unit/om_datastream_spec.rb +99 -99
  61. data/spec/unit/persistence_spec.rb +2 -2
  62. data/spec/unit/predicates_spec.rb +28 -28
  63. data/spec/unit/property_spec.rb +5 -5
  64. data/spec/unit/qualified_dublin_core_datastream_spec.rb +10 -10
  65. data/spec/unit/query_spec.rb +66 -66
  66. data/spec/unit/rdf_datastream_spec.rb +10 -10
  67. data/spec/unit/rdf_resource_datastream_spec.rb +2 -2
  68. data/spec/unit/rdf_xml_writer_spec.rb +3 -3
  69. data/spec/unit/rdfxml_rdf_datastream_spec.rb +9 -9
  70. data/spec/unit/relationship_graph_spec.rb +31 -31
  71. data/spec/unit/reload_on_save_spec.rb +3 -3
  72. data/spec/unit/rels_ext_datastream_spec.rb +28 -28
  73. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +11 -11
  74. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +11 -11
  75. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +11 -11
  76. data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +7 -7
  77. data/spec/unit/rubydora_connection_spec.rb +3 -3
  78. data/spec/unit/semantic_node_spec.rb +17 -17
  79. data/spec/unit/serializers_spec.rb +1 -1
  80. data/spec/unit/service_definitions_spec.rb +11 -11
  81. data/spec/unit/simple_datastream_spec.rb +6 -6
  82. data/spec/unit/solr_config_options_spec.rb +10 -10
  83. data/spec/unit/solr_digital_object_spec.rb +4 -4
  84. data/spec/unit/solr_service_spec.rb +41 -41
  85. data/spec/unit/unsaved_digital_object_spec.rb +8 -8
  86. data/spec/unit/validations_spec.rb +6 -6
  87. metadata +4 -4
@@ -11,17 +11,17 @@ describe RSpec::Matchers, "have_many_associated_active_fedora_objects_matcher" d
11
11
  let(:association) { :association }
12
12
 
13
13
  it 'should match when association is properly stored in fedora' do
14
- subject.class.should_receive(:find).with(pid).and_return(subject)
15
- subject.should_receive(association).and_return([object1,object2])
16
- subject.should have_many_associated_active_fedora_objects(association).with_objects([object1, object2])
14
+ expect(subject.class).to receive(:find).with(pid).and_return(subject)
15
+ expect(subject).to receive(association).and_return([object1,object2])
16
+ expect(subject).to have_many_associated_active_fedora_objects(association).with_objects([object1, object2])
17
17
  end
18
18
 
19
19
  it 'should not match when association is different' do
20
- subject.class.should_receive(:find).with(pid).and_return(subject)
21
- subject.should_receive(association).and_return([object1,object3])
22
- lambda {
23
- subject.should have_many_associated_active_fedora_objects(association).with_objects([object1, object2])
24
- }.should (
20
+ expect(subject.class).to receive(:find).with(pid).and_return(subject)
21
+ expect(subject).to receive(association).and_return([object1,object3])
22
+ expect {
23
+ expect(subject).to have_many_associated_active_fedora_objects(association).with_objects([object1, object2])
24
+ }.to (
25
25
  raise_error(
26
26
  RSpec::Expectations::ExpectationNotMetError,
27
27
  /expected #{subject.class} PID=#{pid} association: #{association.inspect}/
@@ -30,9 +30,9 @@ describe RSpec::Matchers, "have_many_associated_active_fedora_objects_matcher" d
30
30
  end
31
31
 
32
32
  it 'should require :with_objects option' do
33
- lambda {
34
- subject.should have_many_associated_active_fedora_objects(association)
35
- }.should(
33
+ expect {
34
+ expect(subject).to have_many_associated_active_fedora_objects(association)
35
+ }.to(
36
36
  raise_error(
37
37
  ArgumentError,
38
38
  "subject.should have_many_associated_active_fedora_objects(<association_name>).with_objects(<objects[]>)"
@@ -11,17 +11,17 @@ describe RSpec::Matchers, "have_predicate_matcher" do
11
11
  let(:predicate) { :predicate }
12
12
 
13
13
  it 'should match when relationship is "what we have in Fedora"' do
14
- subject.class.should_receive(:find).with(pid).and_return(subject)
15
- subject.should_receive(:relationships).with(predicate).and_return([object1,object2])
16
- subject.should have_predicate(predicate).with_objects([object1, object2])
14
+ expect(subject.class).to receive(:find).with(pid).and_return(subject)
15
+ expect(subject).to receive(:relationships).with(predicate).and_return([object1,object2])
16
+ expect(subject).to have_predicate(predicate).with_objects([object1, object2])
17
17
  end
18
18
 
19
19
  it 'should not match when relationship is different' do
20
- subject.class.should_receive(:find).with(pid).and_return(subject)
21
- subject.should_receive(:relationships).with(predicate).and_return([object1,object3])
22
- lambda {
23
- subject.should have_predicate(predicate).with_objects([object1, object2])
24
- }.should (
20
+ expect(subject.class).to receive(:find).with(pid).and_return(subject)
21
+ expect(subject).to receive(:relationships).with(predicate).and_return([object1,object3])
22
+ expect {
23
+ expect(subject).to have_predicate(predicate).with_objects([object1, object2])
24
+ }.to (
25
25
  raise_error(
26
26
  RSpec::Expectations::ExpectationNotMetError,
27
27
  /expected #{subject.class} PID=#{pid} relationship: #{predicate.inspect}/
@@ -30,9 +30,9 @@ describe RSpec::Matchers, "have_predicate_matcher" do
30
30
  end
31
31
 
32
32
  it 'should require :with_objects option' do
33
- lambda {
34
- subject.should have_predicate(predicate)
35
- }.should(
33
+ expect {
34
+ expect(subject).to have_predicate(predicate)
35
+ }.to(
36
36
  raise_error(
37
37
  ArgumentError,
38
38
  "subject.should have_predicate(<predicate>).with_objects(<objects[]>)"
@@ -15,14 +15,14 @@ describe RSpec::Matchers, "match_fedora_datastream" do
15
15
 
16
16
  it 'should match based on request' do
17
17
  stub_request(:get, datastream_url).to_return(:body => expected_xml, :status => 200)
18
- subject.should match_fedora_datastream(datastream_name).with(expected_xml)
18
+ expect(subject).to match_fedora_datastream(datastream_name).with(expected_xml)
19
19
  end
20
20
 
21
21
  it 'should handle non-matching requests' do
22
22
  stub_request(:get, datastream_url).to_return(:body => "<parent>#{expected_xml}</parent>", :status => 200)
23
- lambda {
24
- subject.should match_fedora_datastream(datastream_name).with(expected_xml)
25
- }.should(
23
+ expect {
24
+ expect(subject).to match_fedora_datastream(datastream_name).with(expected_xml)
25
+ }.to(
26
26
  raise_error(
27
27
  RSpec::Expectations::ExpectationNotMetError,
28
28
  /expected #{subject.class} PID=#{pid} datastream: #{datastream_name.inspect} to match Fedora/
@@ -32,9 +32,9 @@ describe RSpec::Matchers, "match_fedora_datastream" do
32
32
 
33
33
  it 'should require :with option' do
34
34
  stub_request(:get, datastream_url).to_return(:body => "<parent>#{expected_xml}</parent>", :status => 200)
35
- lambda {
36
- subject.should match_fedora_datastream(datastream_name)
37
- }.should(
35
+ expect {
36
+ expect(subject).to match_fedora_datastream(datastream_name)
37
+ }.to(
38
38
  raise_error(
39
39
  ArgumentError,
40
40
  "match_fedora_datastream(<datastream_name>).with(<expected_xml>)"
@@ -5,9 +5,9 @@ describe ActiveFedora::RubydoraConnection do
5
5
  describe 'initialize' do
6
6
  it "should pass through valid options" do
7
7
  @instance = ActiveFedora::RubydoraConnection.new :timeout => 3600, :fake_option => :missing, :force => true, :validateChecksum=>true
8
- @instance.connection.client.options[:timeout].should == 3600
9
- @instance.connection.config[:validateChecksum].should == true
10
- @instance.connection.client.options.has_key?(:fake_option).should be_false
8
+ expect(@instance.connection.client.options[:timeout]).to eq(3600)
9
+ expect(@instance.connection.config[:validateChecksum]).to eq(true)
10
+ expect(@instance.connection.client.options.has_key?(:fake_option)).to be_falsey
11
11
  end
12
12
  end
13
13
  end
@@ -22,7 +22,7 @@ describe ActiveFedora::SemanticNode do
22
22
  end
23
23
 
24
24
  @node = SpecNode.new
25
- @node.stub(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
25
+ allow(@node).to receive(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
26
26
  @node.pid = increment_pid
27
27
  end
28
28
 
@@ -32,37 +32,37 @@ describe ActiveFedora::SemanticNode do
32
32
 
33
33
  describe "pid_from_uri" do
34
34
  it "should strip the info:fedora/ out of a given string" do
35
- SpecNode.pid_from_uri("info:fedora/FOO:BAR").should == "FOO:BAR"
35
+ expect(SpecNode.pid_from_uri("info:fedora/FOO:BAR")).to eq("FOO:BAR")
36
36
  end
37
37
  end
38
38
 
39
39
  describe ".add_relationship" do
40
40
  it "should add relationship to the relationships graph" do
41
41
  @node.add_relationship("isMemberOf", 'demo:9')
42
- @node.ids_for_outbound("isMemberOf").should == ['demo:9']
42
+ expect(@node.ids_for_outbound("isMemberOf")).to eq(['demo:9'])
43
43
  end
44
44
  it "should not be written into the graph until it is saved" do
45
45
  @n1 = ActiveFedora::Base.new
46
46
  @node.add_relationship(:has_part, @n1)
47
- @node.relationships.statements.to_a.first.object.to_s.should == 'info:fedora/'
47
+ expect(@node.relationships.statements.to_a.first.object.to_s).to eq('info:fedora/')
48
48
  @n1.save
49
- @node.relationships.statements.to_a.first.object.to_s.should == @n1.internal_uri
49
+ expect(@node.relationships.statements.to_a.first.object.to_s).to eq(@n1.internal_uri)
50
50
  end
51
51
 
52
52
  it "should add a literal relationship to the relationships graph" do
53
53
  @node.add_relationship("isMemberOf", 'demo:9', true)
54
- @node.relationships("isMemberOf").should == ['demo:9']
54
+ expect(@node.relationships("isMemberOf")).to eq(['demo:9'])
55
55
  end
56
56
 
57
57
  it "adding relationship to an instance should not affect class-level relationships hash" do
58
58
  local_test_node1 = SpecNode.new
59
59
  local_test_node2 = SpecNode.new
60
- local_test_node1.stub(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
60
+ allow(local_test_node1).to receive(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
61
61
  local_test_node1.add_relationship(:is_member_of, 'demo:10')
62
- local_test_node2.stub(:rels_ext).and_return(double('rels-ext', :content=>''))
62
+ allow(local_test_node2).to receive(:rels_ext).and_return(double('rels-ext', :content=>''))
63
63
 
64
- local_test_node1.relationships(:is_member_of).should == ["demo:10"]
65
- local_test_node2.relationships(:is_member_of).should == []
64
+ expect(local_test_node1.relationships(:is_member_of)).to eq(["demo:10"])
65
+ expect(local_test_node2.relationships(:is_member_of)).to eq([])
66
66
  end
67
67
 
68
68
  end
@@ -75,28 +75,28 @@ describe ActiveFedora::SemanticNode do
75
75
  end
76
76
  it "should clear the specified relationship" do
77
77
  @node.clear_relationship(:is_member_of)
78
- @node.relationships(:is_member_of).should == []
79
- @node.relationships(:has_description).should == ['demo:9']
78
+ expect(@node.relationships(:is_member_of)).to eq([])
79
+ expect(@node.relationships(:has_description)).to eq(['demo:9'])
80
80
  end
81
81
  end
82
82
 
83
83
  describe '#remove_relationship' do
84
84
  it 'should remove a relationship from the relationships hash' do
85
- @node.stub(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
85
+ allow(@node).to receive(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
86
86
  @node.add_relationship(:has_part, "info:fedora/3")
87
87
  @node.add_relationship(:has_part, "info:fedora/4")
88
88
  #check both are there
89
- @node.ids_for_outbound(:has_part).should include "3", "4"
89
+ expect(@node.ids_for_outbound(:has_part)).to include "3", "4"
90
90
  @node.remove_relationship(:has_part, "info:fedora/3")
91
91
  #check returns false if relationship does not exist and does nothing with different predicate
92
92
  @node.remove_relationship(:has_member,"info:fedora/4")
93
93
  #check only one item removed
94
- @node.ids_for_outbound(:has_part).should == ['4']
94
+ expect(@node.ids_for_outbound(:has_part)).to eq(['4'])
95
95
  @node.remove_relationship(:has_part,"info:fedora/4")
96
96
  #check last item removed and predicate removed since now emtpy
97
- @node.ids_for_outbound(:has_part).should == []
97
+ expect(@node.ids_for_outbound(:has_part)).to eq([])
98
98
 
99
- @node.relationships_are_dirty.should == true
99
+ expect(@node.relationships_are_dirty).to eq(true)
100
100
 
101
101
  end
102
102
  end
@@ -14,7 +14,7 @@ describe ActiveFedora::Attributes::Serializers do
14
14
  subject { Foo.new }
15
15
  it "should deserialize dates" do
16
16
  subject.attributes = {'birthday(1i)' =>'2012', 'birthday(2i)' =>'10', 'birthday(3i)' => '31'}
17
- subject.birthday.should == '2012-10-31'
17
+ expect(subject.birthday).to eq('2012-10-31')
18
18
  end
19
19
  end
20
20
 
@@ -14,50 +14,50 @@ describe ActiveFedora::ServiceDefinitions do
14
14
  </fmm:MethodMap>
15
15
  MMAP
16
16
  @repository = ActiveFedora::Base.connection_for_pid(0)
17
- @repository.stub(:datastream_dissemination).with({:pid=>'test:12',:dsid=>'METHODMAP'}).and_return mmap
17
+ allow(@repository).to receive(:datastream_dissemination).with({:pid=>'test:12',:dsid=>'METHODMAP'}).and_return mmap
18
18
  Test.has_service_definition "test:12"
19
19
  end
20
20
 
21
21
  subject {
22
22
  obj = Test.new()
23
- obj.stub(:pid).and_return('monkey:99')
23
+ allow(obj).to receive(:pid).and_return('monkey:99')
24
24
  obj
25
25
  }
26
26
  describe "method lookup" do
27
27
  it "should find method keys in the YAML config" do
28
- ActiveFedora::ServiceDefinitions.lookup_method("fedora-system:3", "viewObjectProfile").should == :object_profile
28
+ expect(ActiveFedora::ServiceDefinitions.lookup_method("fedora-system:3", "viewObjectProfile")).to eq(:object_profile)
29
29
  end
30
30
  end
31
31
  describe "method creation" do
32
32
  it "should create the system sdef methods" do
33
- subject.should respond_to(:object_profile)
33
+ expect(subject).to respond_to(:object_profile)
34
34
  end
35
35
  it "should create the declared sdef methods" do
36
- subject.should respond_to(:document_style_1)
36
+ expect(subject).to respond_to(:document_style_1)
37
37
  end
38
38
  end
39
39
  describe "generated method" do
40
40
  it "should call the appropriate rubydora rest api method" do
41
- @repository.should_receive(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1'})
41
+ expect(@repository).to receive(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1'})
42
42
  #@mock_client.stub(:[]).with('objects/monkey%3A99/methods/test%3A12/getDocumentStyle1')
43
43
 
44
44
  subject.document_style_1
45
45
  end
46
46
  it "should call the appropriate rubydora rest api method with parameters" do
47
- @repository.should_receive(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1', :format=>'xml'})
47
+ expect(@repository).to receive(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1', :format=>'xml'})
48
48
  obj = Test.new()
49
- obj.stub(:pid).and_return('monkey:99')
49
+ allow(obj).to receive(:pid).and_return('monkey:99')
50
50
  obj.document_style_1({:format=>'xml'})
51
51
  end
52
52
  it "should call the appropriate rubydora rest api method with a block" do
53
- @repository.stub(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1'}).and_yield "ping!","pang!"
53
+ allow(@repository).to receive(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1'}).and_yield "ping!","pang!"
54
54
  obj = Test.new()
55
- obj.stub(:pid).and_return('monkey:99')
55
+ allow(obj).to receive(:pid).and_return('monkey:99')
56
56
  block_response = ""
57
57
  obj.document_style_1 {|res,req|
58
58
  block_response += 'pong!' if res == "ping!" and req == "pang!"
59
59
  }
60
- block_response.should == "pong!"
60
+ expect(block_response).to eq("pong!")
61
61
  end
62
62
  end
63
63
  end
@@ -12,7 +12,7 @@ describe ActiveFedora::SimpleDatastream do
12
12
 
13
13
  end
14
14
  it "from_xml should parse everything correctly" do
15
- @test_ds.ng_xml.should be_equivalent_to @sample_xml
15
+ expect(@test_ds.ng_xml).to be_equivalent_to @sample_xml
16
16
  end
17
17
 
18
18
 
@@ -23,14 +23,14 @@ describe ActiveFedora::SimpleDatastream do
23
23
  it "should respond to getters and setters for the string typed #{el} element" do
24
24
  value = "Hey #{el}"
25
25
  @test_ds.send("#{el.to_s}=", value)
26
- @test_ds.send(el).first.should == value #Looking at first because creator has 2 nodes
26
+ expect(@test_ds.send(el).first).to eq(value) #Looking at first because creator has 2 nodes
27
27
  end
28
28
  end
29
29
 
30
30
  it "should set date elements" do
31
31
  d = Date.parse('1939-05-23')
32
32
  @test_ds.creation_date = d
33
- @test_ds.creation_date.first.should == d
33
+ expect(@test_ds.creation_date.first).to eq(d)
34
34
  end
35
35
  end
36
36
  end
@@ -40,7 +40,7 @@ describe ActiveFedora::SimpleDatastream do
40
40
  @test_ds.publisher= "charlie"
41
41
  @test_ds.coverage= ["80%", "20%"]
42
42
 
43
- @test_ds.to_xml.should be_equivalent_to('
43
+ expect(@test_ds.to_xml).to be_equivalent_to('
44
44
  <fields>
45
45
  <coverage>80%</coverage>
46
46
  <coverage>20%</coverage>
@@ -54,8 +54,8 @@ describe ActiveFedora::SimpleDatastream do
54
54
  describe "#to_solr" do
55
55
  it "should have title" do
56
56
  solr = @test_ds.to_solr
57
- solr[ActiveFedora::SolrService.solr_name('publisher', type: :string)].should == "publisher1"
58
- solr[ActiveFedora::SolrService.solr_name('creation_date', type: :date)].should == "2012-01-15"
57
+ expect(solr[ActiveFedora::SolrService.solr_name('publisher', type: :string)]).to eq("publisher1")
58
+ expect(solr[ActiveFedora::SolrService.solr_name('creation_date', type: :date)]).to eq("2012-01-15")
59
59
  end
60
60
  end
61
61
 
@@ -24,17 +24,17 @@ describe ActiveFedora do
24
24
  SOLR_DOCUMENT_ID = "id"
25
25
  end
26
26
  it "should be used by ActiveFedora::Base.to_solr" do
27
- @test_object.stub(pid: 'changeme:123')
27
+ allow(@test_object).to receive_messages(pid: 'changeme:123')
28
28
  SOLR_DOCUMENT_ID = "MY_SAMPLE_ID"
29
- @test_object.to_solr[SOLR_DOCUMENT_ID.to_sym].should == 'changeme:123'
30
- @test_object.to_solr[:id].should be_nil
29
+ expect(@test_object.to_solr[SOLR_DOCUMENT_ID.to_sym]).to eq('changeme:123')
30
+ expect(@test_object.to_solr[:id]).to be_nil
31
31
  end
32
32
 
33
33
  it "should be used by ActiveFedora::Base#find_with_conditions" do
34
34
  mock_response = double("SolrResponse")
35
- ActiveFedora::SolrService.should_receive(:query).with("_query_:\"{!raw f=#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}}info:fedora/afmodel:SolrSpecModel_Basic\" AND " + SOLR_DOCUMENT_ID + ':changeme\\:30', {:sort => ["#{ActiveFedora::SolrService.solr_name("system_create", :stored_sortable, type: :date)} asc"]}).and_return(mock_response)
35
+ expect(ActiveFedora::SolrService).to receive(:query).with("_query_:\"{!raw f=#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}}info:fedora/afmodel:SolrSpecModel_Basic\" AND " + SOLR_DOCUMENT_ID + ':changeme\\:30', {:sort => ["#{ActiveFedora::SolrService.solr_name("system_create", :stored_sortable, type: :date)} asc"]}).and_return(mock_response)
36
36
 
37
- SolrSpecModel::Basic.find_with_conditions(:id=>"changeme:30").should equal(mock_response)
37
+ expect(SolrSpecModel::Basic.find_with_conditions(:id=>"changeme:30")).to equal(mock_response)
38
38
  end
39
39
  end
40
40
 
@@ -50,14 +50,14 @@ describe ActiveFedora do
50
50
  it "should prevent Base.save from calling update_index if false" do
51
51
  dirty_ds = ActiveFedora::SimpleDatastream.new(@test_object.inner_object, 'ds1')
52
52
  @test_object.datastreams['ds1'] = dirty_ds
53
- @test_object.stub(:datastreams).and_return({:ds1 => dirty_ds})
54
- @test_object.should_receive(:update_index).never
55
- @test_object.should_receive(:refresh)
53
+ allow(@test_object).to receive(:datastreams).and_return({:ds1 => dirty_ds})
54
+ expect(@test_object).to receive(:update_index).never
55
+ expect(@test_object).to receive(:refresh)
56
56
  @test_object.save
57
57
  end
58
58
  it "should prevent Base.delete from deleting the corresponding Solr document if false" do
59
- ActiveFedora::SolrService.instance.conn.should_receive(:delete).with(@test_object.pid).never
60
- @test_object.inner_object.should_receive(:delete)
59
+ expect(ActiveFedora::SolrService.instance.conn).to receive(:delete).with(@test_object.pid).never
60
+ expect(@test_object.inner_object).to receive(:delete)
61
61
  @test_object.delete
62
62
  end
63
63
  end
@@ -5,7 +5,7 @@ describe ActiveFedora::SolrDigitalObject do
5
5
  subject { ActiveFedora::SolrDigitalObject.new({},{'datastreams'=>{}}) }
6
6
  describe "when not finished" do
7
7
  it "should not respond_to? :repository" do
8
- subject.should_not respond_to :repository
8
+ expect(subject).not_to respond_to :repository
9
9
  end
10
10
  end
11
11
  describe "when finished" do
@@ -13,7 +13,7 @@ describe ActiveFedora::SolrDigitalObject do
13
13
  subject.freeze
14
14
  end
15
15
  it "should respond_to? :repository" do
16
- subject.should respond_to :repository
16
+ expect(subject).to respond_to :repository
17
17
  end
18
18
  end
19
19
  end
@@ -71,10 +71,10 @@ describe ActiveFedora::SolrDigitalObject do
71
71
  end
72
72
  subject { ActiveFedora::SolrDigitalObject.new({}, {'datastreams'=>{'properties'=>{'dsMIME'=>'text/xml'}}},WithoutMetadataDs) }
73
73
  it "should create an xml datastream" do
74
- subject.datastreams['properties'].should be_kind_of ActiveFedora::OmDatastream
74
+ expect(subject.datastreams['properties']).to be_kind_of ActiveFedora::OmDatastream
75
75
  end
76
76
 
77
- its(:new_record?) { should be_false }
77
+ its(:new_record?) { should be_falsey }
78
78
  end
79
79
 
80
80
  describe "with a ds spec that's not part of the solrized object" do
@@ -10,28 +10,28 @@ describe ActiveFedora::SolrService do
10
10
  end
11
11
 
12
12
  it "should take a narg constructor and configure for localhost" do
13
- RSolr.should_receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://localhost:8080/solr')
13
+ expect(RSolr).to receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://localhost:8080/solr')
14
14
  ActiveFedora::SolrService.register
15
15
  end
16
16
  it "should accept host arg into constructor" do
17
- RSolr.should_receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://fubar')
17
+ expect(RSolr).to receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://fubar')
18
18
  ActiveFedora::SolrService.register('http://fubar')
19
19
  end
20
20
  it "should clobber options" do
21
- RSolr.should_receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://localhost:8080/solr', :autocommit=>:off, :foo=>:bar)
21
+ expect(RSolr).to receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://localhost:8080/solr', :autocommit=>:off, :foo=>:bar)
22
22
  ActiveFedora::SolrService.register(nil, {:autocommit=>:off, :foo=>:bar})
23
23
  end
24
24
 
25
25
  it "should set the threadlocal solr service" do
26
- RSolr.should_receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://localhost:8080/solr', :autocommit=>:off, :foo=>:bar)
26
+ expect(RSolr).to receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://localhost:8080/solr', :autocommit=>:off, :foo=>:bar)
27
27
  ss = ActiveFedora::SolrService.register(nil, {:autocommit=>:off, :foo=>:bar})
28
- Thread.current[:solr_service].should == ss
29
- ActiveFedora::SolrService.instance.should == ss
28
+ expect(Thread.current[:solr_service]).to eq(ss)
29
+ expect(ActiveFedora::SolrService.instance).to eq(ss)
30
30
  end
31
31
  it "should try to initialize if the service not initialized, and fail if it does not succeed" do
32
- Thread.current[:solr_service].should be_nil
33
- ActiveFedora::SolrService.should_receive(:register)
34
- proc{ActiveFedora::SolrService.instance}.should raise_error(ActiveFedora::SolrNotInitialized)
32
+ expect(Thread.current[:solr_service]).to be_nil
33
+ expect(ActiveFedora::SolrService).to receive(:register)
34
+ expect{ActiveFedora::SolrService.instance}.to raise_error(ActiveFedora::SolrNotInitialized)
35
35
  end
36
36
 
37
37
  describe "reify solr results" do
@@ -51,42 +51,42 @@ describe ActiveFedora::SolrService do
51
51
  end
52
52
  describe ".reify_solr_result" do
53
53
  it "should use .find to instantiate objects" do
54
- AudioRecord.should_receive(:find).with("my:_PID1_", cast: true)
54
+ expect(AudioRecord).to receive(:find).with("my:_PID1_", cast: true)
55
55
  ActiveFedora::SolrService.reify_solr_result(@sample_solr_hits.first)
56
56
  end
57
57
  it "should use .load_instance_from_solr when called with :load_from_solr option" do
58
- AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID1_", @sample_solr_hits.first)
59
- ActiveFedora::SolrService.should_not_receive(:query)
58
+ expect(AudioRecord).to receive(:load_instance_from_solr).with("my:_PID1_", @sample_solr_hits.first)
59
+ expect(ActiveFedora::SolrService).not_to receive(:query)
60
60
  ActiveFedora::SolrService.reify_solr_result(@sample_solr_hits.first, load_from_solr: true)
61
61
  end
62
62
  end
63
63
  describe ".reify_solr_results" do
64
64
  it "should use AudioRecord.find to instantiate objects" do
65
- AudioRecord.should_receive(:find).with("my:_PID1_", cast: true)
66
- AudioRecord.should_receive(:find).with("my:_PID2_", cast: true)
67
- AudioRecord.should_receive(:find).with("my:_PID3_", cast: true)
65
+ expect(AudioRecord).to receive(:find).with("my:_PID1_", cast: true)
66
+ expect(AudioRecord).to receive(:find).with("my:_PID2_", cast: true)
67
+ expect(AudioRecord).to receive(:find).with("my:_PID3_", cast: true)
68
68
  ActiveFedora::SolrService.reify_solr_results(@sample_solr_hits)
69
69
  end
70
70
  it "should use AudioRecord.load_instance_from_solr when called with :load_from_solr option" do
71
- AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID1_", @sample_solr_hits[0])
72
- AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID2_", @sample_solr_hits[1])
73
- AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID3_", @sample_solr_hits[2])
74
- ActiveFedora::SolrService.should_not_receive(:query)
71
+ expect(AudioRecord).to receive(:load_instance_from_solr).with("my:_PID1_", @sample_solr_hits[0])
72
+ expect(AudioRecord).to receive(:load_instance_from_solr).with("my:_PID2_", @sample_solr_hits[1])
73
+ expect(AudioRecord).to receive(:load_instance_from_solr).with("my:_PID3_", @sample_solr_hits[2])
74
+ expect(ActiveFedora::SolrService).not_to receive(:query)
75
75
  ActiveFedora::SolrService.reify_solr_results(@sample_solr_hits, load_from_solr: true)
76
76
  end
77
77
  end
78
78
  describe ".lazy_reify_solr_results" do
79
79
  it "should lazily reify solr results" do
80
- AudioRecord.should_receive(:find).with("my:_PID1_", cast: true)
81
- AudioRecord.should_receive(:find).with("my:_PID2_", cast: true)
82
- AudioRecord.should_receive(:find).with("my:_PID3_", cast: true)
80
+ expect(AudioRecord).to receive(:find).with("my:_PID1_", cast: true)
81
+ expect(AudioRecord).to receive(:find).with("my:_PID2_", cast: true)
82
+ expect(AudioRecord).to receive(:find).with("my:_PID3_", cast: true)
83
83
  ActiveFedora::SolrService.lazy_reify_solr_results(@sample_solr_hits).each {|r| r}
84
84
  end
85
85
  it "should use AudioRecord.load_instance_from_solr when called with :load_from_solr option" do
86
- AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID1_", @sample_solr_hits[0])
87
- AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID2_", @sample_solr_hits[1])
88
- AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID3_", @sample_solr_hits[2])
89
- ActiveFedora::SolrService.should_not_receive(:query)
86
+ expect(AudioRecord).to receive(:load_instance_from_solr).with("my:_PID1_", @sample_solr_hits[0])
87
+ expect(AudioRecord).to receive(:load_instance_from_solr).with("my:_PID2_", @sample_solr_hits[1])
88
+ expect(AudioRecord).to receive(:load_instance_from_solr).with("my:_PID3_", @sample_solr_hits[2])
89
+ expect(ActiveFedora::SolrService).not_to receive(:query)
90
90
  ActiveFedora::SolrService.lazy_reify_solr_results(@sample_solr_hits, load_from_solr: true).each {|r| r}
91
91
  end
92
92
  end
@@ -100,11 +100,11 @@ describe ActiveFedora::SolrService do
100
100
 
101
101
  describe '#construct_query_for_pids' do
102
102
  it "should generate a useable solr query from an array of Fedora pids" do
103
- ActiveFedora::SolrService.construct_query_for_pids(["my:_PID1_", "my:_PID2_", "my:_PID3_"]).should == '_query_:"{!raw f=id}my:_PID1_" OR _query_:"{!raw f=id}my:_PID2_" OR _query_:"{!raw f=id}my:_PID3_"'
103
+ expect(ActiveFedora::SolrService.construct_query_for_pids(["my:_PID1_", "my:_PID2_", "my:_PID3_"])).to eq('_query_:"{!raw f=id}my:_PID1_" OR _query_:"{!raw f=id}my:_PID2_" OR _query_:"{!raw f=id}my:_PID3_"')
104
104
 
105
105
  end
106
106
  it "should return a valid solr query even if given an empty array as input" do
107
- ActiveFedora::SolrService.construct_query_for_pids([""]).should == "id:NEVER_USE_THIS_ID"
107
+ expect(ActiveFedora::SolrService.construct_query_for_pids([""])).to eq("id:NEVER_USE_THIS_ID")
108
108
 
109
109
  end
110
110
  end
@@ -113,33 +113,33 @@ describe ActiveFedora::SolrService do
113
113
  it "should call solr" do
114
114
  mock_conn = double("Connection")
115
115
  stub_result = double("Result")
116
- mock_conn.should_receive(:get).with('select', :params=>{:q=>'querytext', :qt=>'standard'}).and_return(stub_result)
117
- ActiveFedora::SolrService.stub(:instance =>double("instance", :conn=>mock_conn))
118
- ActiveFedora::SolrService.query('querytext', :raw=>true).should == stub_result
116
+ expect(mock_conn).to receive(:get).with('select', :params=>{:q=>'querytext', :qt=>'standard'}).and_return(stub_result)
117
+ allow(ActiveFedora::SolrService).to receive_messages(:instance =>double("instance", :conn=>mock_conn))
118
+ expect(ActiveFedora::SolrService.query('querytext', :raw=>true)).to eq(stub_result)
119
119
  end
120
120
  end
121
121
  describe ".count" do
122
122
  it "should return a count of matching records" do
123
123
  mock_conn = double("Connection")
124
124
  stub_result = {'response' => {'numFound'=>'7'}}
125
- mock_conn.should_receive(:get).with('select', :params=>{:rows=>0, :q=>'querytext', :qt=>'standard'}).and_return(stub_result)
126
- ActiveFedora::SolrService.stub(:instance =>double("instance", :conn=>mock_conn))
127
- ActiveFedora::SolrService.count('querytext').should == 7
125
+ expect(mock_conn).to receive(:get).with('select', :params=>{:rows=>0, :q=>'querytext', :qt=>'standard'}).and_return(stub_result)
126
+ allow(ActiveFedora::SolrService).to receive_messages(:instance =>double("instance", :conn=>mock_conn))
127
+ expect(ActiveFedora::SolrService.count('querytext')).to eq(7)
128
128
  end
129
129
  it "should accept query args" do
130
130
  mock_conn = double("Connection")
131
131
  stub_result = {'response' => {'numFound'=>'7'}}
132
- mock_conn.should_receive(:get).with('select', :params=>{:rows=>0, :q=>'querytext', :qt=>'standard', :fq=>'filter'}).and_return(stub_result)
133
- ActiveFedora::SolrService.stub(:instance =>double("instance", :conn=>mock_conn))
134
- ActiveFedora::SolrService.count('querytext', :fq=>'filter', :rows=>10).should == 7
132
+ expect(mock_conn).to receive(:get).with('select', :params=>{:rows=>0, :q=>'querytext', :qt=>'standard', :fq=>'filter'}).and_return(stub_result)
133
+ allow(ActiveFedora::SolrService).to receive_messages(:instance =>double("instance", :conn=>mock_conn))
134
+ expect(ActiveFedora::SolrService.count('querytext', :fq=>'filter', :rows=>10)).to eq(7)
135
135
  end
136
136
  end
137
137
  describe ".add" do
138
138
  it "should call solr" do
139
139
  mock_conn = double("Connection")
140
140
  doc = {'id' => '1234'}
141
- mock_conn.should_receive(:add).with(doc, {:params=>{}})
142
- ActiveFedora::SolrService.stub(:instance =>double("instance", :conn=>mock_conn))
141
+ expect(mock_conn).to receive(:add).with(doc, {:params=>{}})
142
+ allow(ActiveFedora::SolrService).to receive_messages(:instance =>double("instance", :conn=>mock_conn))
143
143
  ActiveFedora::SolrService.add(doc)
144
144
  end
145
145
  end
@@ -147,8 +147,8 @@ describe ActiveFedora::SolrService do
147
147
  it "should call solr" do
148
148
  mock_conn = double("Connection")
149
149
  doc = {'id' => '1234'}
150
- mock_conn.should_receive(:commit)
151
- ActiveFedora::SolrService.stub(:instance =>double("instance", :conn=>mock_conn))
150
+ expect(mock_conn).to receive(:commit)
151
+ allow(ActiveFedora::SolrService).to receive_messages(:instance =>double("instance", :conn=>mock_conn))
152
152
  ActiveFedora::SolrService.commit()
153
153
  end
154
154
  end