active-fedora 6.7.8 → 6.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.rubocop.yml +1 -0
  4. data/.rubocop_todo.yml +938 -0
  5. data/.travis.yml +5 -6
  6. data/Gemfile +3 -1
  7. data/Rakefile +7 -5
  8. data/active-fedora.gemspec +7 -8
  9. data/lib/active_fedora/om_datastream.rb +1 -0
  10. data/lib/active_fedora/rdf_xml_writer.rb +31 -62
  11. data/lib/active_fedora/version.rb +1 -1
  12. data/spec/config_helper.rb +14 -14
  13. data/spec/integration/associations_spec.rb +232 -232
  14. data/spec/integration/attributes_spec.rb +11 -12
  15. data/spec/integration/auditable_spec.rb +10 -10
  16. data/spec/integration/base_spec.rb +163 -163
  17. data/spec/integration/bug_spec.rb +7 -7
  18. data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
  19. data/spec/integration/datastream_collections_spec.rb +69 -69
  20. data/spec/integration/datastream_spec.rb +43 -43
  21. data/spec/integration/datastreams_spec.rb +63 -63
  22. data/spec/integration/delegating_spec.rb +14 -14
  23. data/spec/integration/delete_all_spec.rb +38 -42
  24. data/spec/integration/fedora_solr_sync_spec.rb +5 -5
  25. data/spec/integration/full_featured_model_spec.rb +101 -101
  26. data/spec/integration/has_many_associations_spec.rb +24 -24
  27. data/spec/integration/model_spec.rb +30 -30
  28. data/spec/integration/nested_attribute_spec.rb +41 -41
  29. data/spec/integration/ntriples_datastream_spec.rb +107 -107
  30. data/spec/integration/om_datastream_spec.rb +67 -67
  31. data/spec/integration/persistence_spec.rb +6 -6
  32. data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
  33. data/spec/integration/relation_delegation_spec.rb +24 -26
  34. data/spec/integration/rels_ext_datastream_spec.rb +20 -20
  35. data/spec/integration/scoped_query_spec.rb +40 -41
  36. data/spec/integration/solr_instance_loader_spec.rb +4 -4
  37. data/spec/integration/solr_service_spec.rb +46 -46
  38. data/spec/rails3_test_app/config/application.rb +1 -1
  39. data/spec/rails3_test_app/config/environments/development.rb +0 -1
  40. data/spec/rails3_test_app/config/environments/production.rb +1 -1
  41. data/spec/rails3_test_app/spec/spec_helper.rb +3 -3
  42. data/spec/rails3_test_app/spec/unit/rails_3_init.rb +4 -4
  43. data/spec/samples/hydra-mods_article_datastream.rb +334 -334
  44. data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
  45. data/spec/samples/marpa-dc_datastream.rb +17 -17
  46. data/spec/samples/models/audio_record.rb +16 -16
  47. data/spec/samples/models/image.rb +2 -2
  48. data/spec/samples/models/mods_article.rb +5 -5
  49. data/spec/samples/models/oral_history.rb +18 -18
  50. data/spec/samples/models/seminar.rb +24 -24
  51. data/spec/samples/models/seminar_audio_file.rb +17 -17
  52. data/spec/samples/oral_history_sample_model.rb +21 -21
  53. data/spec/samples/special_thing.rb +14 -14
  54. data/spec/spec_helper.rb +7 -11
  55. data/spec/support/an_active_model.rb +2 -2
  56. data/spec/support/mock_fedora.rb +16 -17
  57. data/spec/unit/active_fedora_spec.rb +58 -58
  58. data/spec/unit/association_proxy_spec.rb +5 -7
  59. data/spec/unit/base_active_model_spec.rb +25 -26
  60. data/spec/unit/base_cma_spec.rb +5 -5
  61. data/spec/unit/base_datastream_management_spec.rb +27 -27
  62. data/spec/unit/base_delegate_spec.rb +80 -82
  63. data/spec/unit/base_delegate_to_spec.rb +37 -39
  64. data/spec/unit/base_extra_spec.rb +48 -48
  65. data/spec/unit/base_spec.rb +300 -300
  66. data/spec/unit/callback_spec.rb +19 -19
  67. data/spec/unit/code_configurator_spec.rb +17 -17
  68. data/spec/unit/config_spec.rb +16 -8
  69. data/spec/unit/content_model_spec.rb +60 -60
  70. data/spec/unit/datastream_collections_spec.rb +229 -229
  71. data/spec/unit/datastream_spec.rb +57 -54
  72. data/spec/unit/datastreams_spec.rb +77 -77
  73. data/spec/unit/file_configurator_spec.rb +217 -217
  74. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +26 -26
  75. data/spec/unit/has_many_collection_spec.rb +9 -9
  76. data/spec/unit/inheritance_spec.rb +12 -13
  77. data/spec/unit/model_spec.rb +41 -51
  78. data/spec/unit/nom_datastream_spec.rb +15 -15
  79. data/spec/unit/ntriples_datastream_spec.rb +112 -112
  80. data/spec/unit/om_datastream_spec.rb +233 -227
  81. data/spec/unit/persistence_spec.rb +6 -6
  82. data/spec/unit/predicates_spec.rb +73 -73
  83. data/spec/unit/property_spec.rb +9 -17
  84. data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
  85. data/spec/unit/query_spec.rb +188 -217
  86. data/spec/unit/rdf_datastream_spec.rb +28 -21
  87. data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
  88. data/spec/unit/rdf_list_spec.rb +80 -104
  89. data/spec/unit/rdf_node_spec.rb +7 -7
  90. data/spec/unit/rdf_xml_writer_spec.rb +10 -10
  91. data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
  92. data/spec/unit/relationship_graph_spec.rb +51 -51
  93. data/spec/unit/rels_ext_datastream_spec.rb +75 -69
  94. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
  95. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
  96. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
  97. data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
  98. data/spec/unit/rubydora_connection_spec.rb +5 -5
  99. data/spec/unit/semantic_node_spec.rb +59 -59
  100. data/spec/unit/serializers_spec.rb +4 -4
  101. data/spec/unit/service_definitions_spec.rb +26 -26
  102. data/spec/unit/simple_datastream_spec.rb +17 -17
  103. data/spec/unit/solr_config_options_spec.rb +27 -28
  104. data/spec/unit/solr_digital_object_spec.rb +21 -21
  105. data/spec/unit/solr_service_spec.rb +81 -81
  106. data/spec/unit/unsaved_digital_object_spec.rb +20 -20
  107. data/spec/unit/validations_spec.rb +21 -21
  108. metadata +70 -58
  109. data/gemfiles/gemfile.rails3 +0 -11
  110. data/gemfiles/gemfile.rails4 +0 -10
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::Model do
4
-
5
- before(:all) do
4
+
5
+ before(:all) do
6
6
  module ModelIntegrationSpec
7
7
  class Basic < ActiveFedora::Base
8
- has_metadata :name => "properties", :type => ActiveFedora::SimpleDatastream do |m|
9
- m.field "foo", :string
10
- m.field "bar", :string
11
- m.field "baz", :string
8
+ has_metadata :name => 'properties', :type => ActiveFedora::SimpleDatastream do |m|
9
+ m.field 'foo', :string
10
+ m.field 'bar', :string
11
+ m.field 'baz', :string
12
12
  end
13
13
 
14
14
  delegate_to :properties, [:foo, :bar, :baz], multiple: true
@@ -18,50 +18,48 @@ describe ActiveFedora::Model do
18
18
  doc[ActiveFedora::SolrService.solr_name('foo', :sortable)] = doc[ActiveFedora::SolrService.solr_name('foo', type: :string)]
19
19
  doc
20
20
  end
21
-
21
+
22
22
  end
23
23
  end
24
24
 
25
25
  end
26
-
26
+
27
27
  after(:all) do
28
28
  Object.send(:remove_const, :ModelIntegrationSpec)
29
29
  end
30
30
 
31
31
 
32
- describe "with multiple objects" do
33
- let!(:instance1){ ModelIntegrationSpec::Basic.create!(:foo=>'Beta', :bar=>'Chips')}
34
- let!(:instance2){ ModelIntegrationSpec::Basic.create!(:foo=>'Alpha', :bar=>'Peanuts')}
35
- let!(:instance3){ ModelIntegrationSpec::Basic.create!(:foo=>'Sigma', :bar=>'Peanuts')}
32
+ describe 'with multiple objects' do
33
+ let!(:instance1){ ModelIntegrationSpec::Basic.create!(:foo => 'Beta', :bar => 'Chips')}
34
+ let!(:instance2){ ModelIntegrationSpec::Basic.create!(:foo => 'Alpha', :bar => 'Peanuts')}
35
+ let!(:instance3){ ModelIntegrationSpec::Basic.create!(:foo => 'Sigma', :bar => 'Peanuts')}
36
36
 
37
37
  after { ModelIntegrationSpec::Basic.delete_all }
38
38
 
39
39
  subject { ModelIntegrationSpec::Basic.where(bar: 'Peanuts') }
40
40
 
41
- it "should map" do
42
- subject.map(&:id).should == [instance2.id, instance3.id]
41
+ it 'should map' do
42
+ expect(subject.map(&:id)).to eq([instance2.id, instance3.id])
43
43
  end
44
44
 
45
- it "should collect" do
46
- subject.collect(&:id).should == [instance2.id, instance3.id]
45
+ it 'should collect' do
46
+ expect(subject.collect(&:id)).to eq([instance2.id, instance3.id])
47
47
  end
48
48
 
49
- it "should have each" do
49
+ it 'should have each' do
50
50
  t = double
51
- t.should_receive(:foo).twice
51
+ expect(t).to receive(:foo).twice
52
52
  subject.each { t.foo }
53
53
  end
54
54
 
55
- it "should have all?" do
56
- expect(subject.all? { |t| t.foo == ['Alpha']}).to be_false
57
- expect(subject.all? { |t| t.bar == ['Peanuts']}).to be_true
55
+ it 'should have all?' do
56
+ expect(subject.all? { |t| t.foo == ['Alpha']}).to be_falsey
57
+ expect(subject.all? { |t| t.bar == ['Peanuts']}).to be_truthy
58
58
  end
59
59
 
60
- it "should have include?" do
61
- expect(subject.include?(instance1)).to be_false
62
- expect(subject.include?(instance2)).to be_true
60
+ it 'should have include?' do
61
+ expect(subject.include?(instance1)).to be_falsey
62
+ expect(subject.include?(instance2)).to be_truthy
63
63
  end
64
64
  end
65
65
  end
66
-
67
-
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  require 'active_fedora'
4
- require "rexml/document"
4
+ require 'rexml/document'
5
5
 
6
6
 
7
7
  describe ActiveFedora::RelsExtDatastream do
8
-
8
+
9
9
  before(:all) do
10
- @sample_relationships_hash = Hash.new(:is_member_of => ["info:fedora/demo:5", "info:fedora/demo:10"])
10
+ @sample_relationships_hash = Hash.new(:is_member_of => ['info:fedora/demo:5', 'info:fedora/demo:10'])
11
11
  @sample_xml_string = <<-EOS
12
12
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
13
13
  <rdf:Description rdf:about="info:fedora/changeme:475">
@@ -16,17 +16,17 @@ describe ActiveFedora::RelsExtDatastream do
16
16
  </rdf:Description>
17
17
  </rdf:RDF>
18
18
  EOS
19
-
19
+
20
20
  @sample_xml = REXML::Document.new(@sample_xml_string)
21
21
  end
22
-
22
+
23
23
  before(:each) do
24
24
  @test_object = ActiveFedora::Base.new
25
25
  @test_datastream = ActiveFedora::RelsExtDatastream.new(@test_object.inner_object, 'RELS-EXT')
26
26
  @test_datastream.model = @test_object
27
27
  @test_object.save
28
28
  end
29
-
29
+
30
30
  after(:each) do
31
31
  begin
32
32
  @test_object.delete
@@ -49,34 +49,34 @@ describe ActiveFedora::RelsExtDatastream do
49
49
  rescue
50
50
  end
51
51
  end
52
-
53
-
52
+
53
+
54
54
  describe '#serialize!' do
55
-
56
- it "should generate new rdf/xml as the datastream content" do
55
+
56
+ it 'should generate new rdf/xml as the datastream content' do
57
57
  @test_object.add_datastream(@test_datastream)
58
- @test_object.add_relationship(:is_member_of, "info:fedora/demo:5")
59
- @test_object.add_relationship(:is_member_of, "info:fedora/demo:10")
58
+ @test_object.add_relationship(:is_member_of, 'info:fedora/demo:5')
59
+ @test_object.add_relationship(:is_member_of, 'info:fedora/demo:10')
60
60
  rexml1 = REXML::Document.new(@test_datastream.to_rels_ext())
61
61
  @test_datastream.serialize!
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)
62
+ rexml2 = REXML::Document.new(@test_object.datastreams['RELS-EXT'].content)
63
+ expect(rexml1.root.elements['rdf:Description'].inspect).to eql(rexml2.root.elements['rdf:Description'].inspect)
64
64
  end
65
-
65
+
66
66
  end
67
-
68
- it "should load relationships from fedora into parent object" do
67
+
68
+ it 'should load relationships from fedora into parent object' do
69
69
  class SpecNode; include ActiveFedora::SemanticNode; end
70
- ActiveFedora::Predicates.predicate_mappings[ActiveFedora::Predicates.default_predicate_namespace].each_key do |p|
70
+ ActiveFedora::Predicates.predicate_mappings[ActiveFedora::Predicates.default_predicate_namespace].each_key do |p|
71
71
  @test_object.add_relationship(p, "info:fedora/demo:#{rand(100)}")
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
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "scoped queries" do
4
-
5
- before(:each) do
3
+ describe 'scoped queries' do
4
+
5
+ before(:each) do
6
6
  module ModelIntegrationSpec
7
7
  class Basic < ActiveFedora::Base
8
- has_metadata :name => "properties", :type => ActiveFedora::SimpleDatastream do |m|
9
- m.field "foo", :string
10
- m.field "bar", :string
11
- m.field "baz", :string
8
+ has_metadata :name => 'properties', :type => ActiveFedora::SimpleDatastream do |m|
9
+ m.field 'foo', :string
10
+ m.field 'bar', :string
11
+ m.field 'baz', :string
12
12
  end
13
13
 
14
14
  delegate_to :properties, [:foo, :bar, :baz], multiple: true
@@ -18,81 +18,80 @@ describe "scoped queries" do
18
18
  doc[ActiveFedora::SolrService.solr_name('foo', :sortable)] = doc[ActiveFedora::SolrService.solr_name('foo', type: :string)]
19
19
  doc
20
20
  end
21
-
21
+
22
22
  end
23
23
  end
24
24
 
25
25
  end
26
-
26
+
27
27
  after(:each) do
28
28
  Object.send(:remove_const, :ModelIntegrationSpec)
29
29
  end
30
30
 
31
31
 
32
- describe "When there is one object in the store" do
32
+ describe 'When there is one object in the store' do
33
33
  let!(:test_instance) { ModelIntegrationSpec::Basic.create!()}
34
34
 
35
35
  after do
36
36
  test_instance.delete
37
37
  end
38
-
39
- describe ".all" do
40
- it "should return an array of instances of the calling Class" do
38
+
39
+ describe '.all' do
40
+ it 'should return an array of instances of the calling Class' do
41
41
  result = ModelIntegrationSpec::Basic.all
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
- describe ".first" do
52
- it "should return one instance of the calling class" do
53
- ModelIntegrationSpec::Basic.first.should == test_instance
51
+ describe '.first' do
52
+ it 'should return one instance of the calling class' do
53
+ expect(ModelIntegrationSpec::Basic.first).to eq(test_instance)
54
54
  end
55
55
  end
56
56
  end
57
57
 
58
- describe "with multiple objects" do
59
- let!(:test_instance1) { ModelIntegrationSpec::Basic.create!(:foo=>'Beta', :bar=>'Chips')}
60
- let!(:test_instance2) { ModelIntegrationSpec::Basic.create!(:foo=>'Alpha', :bar=>'Peanuts')}
61
- let!(:test_instance3) { ModelIntegrationSpec::Basic.create!(:foo=>'Sigma', :bar=>'Peanuts')}
58
+ describe 'with multiple objects' do
59
+ let!(:test_instance1) { ModelIntegrationSpec::Basic.create!(:foo => 'Beta', :bar => 'Chips')}
60
+ let!(:test_instance2) { ModelIntegrationSpec::Basic.create!(:foo => 'Alpha', :bar => 'Peanuts')}
61
+ let!(:test_instance3) { ModelIntegrationSpec::Basic.create!(:foo => 'Sigma', :bar => 'Peanuts')}
62
62
 
63
63
  after do
64
64
  test_instance1.delete
65
65
  test_instance2.delete
66
66
  test_instance3.delete
67
67
  end
68
- it "should query" do
69
- ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', type: :string)=> 'Beta').should == [test_instance1]
70
- ModelIntegrationSpec::Basic.where('foo' => 'Beta').should == [test_instance1]
68
+ it 'should query' do
69
+ expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', type: :string) => 'Beta')).to eq([test_instance1])
70
+ expect(ModelIntegrationSpec::Basic.where('foo' => 'Beta')).to eq([test_instance1])
71
71
  end
72
- it "should order" do
73
- ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').should == [test_instance2, test_instance1, test_instance3]
72
+ it 'should order' do
73
+ expect(ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc')).to eq([test_instance2, test_instance1, test_instance3])
74
74
  end
75
- it "should limit" do
76
- ModelIntegrationSpec::Basic.limit(1).should == [test_instance1]
75
+ it 'should limit' do
76
+ expect(ModelIntegrationSpec::Basic.limit(1)).to eq([test_instance1])
77
77
  end
78
78
 
79
- it "should chain queries" do
80
- ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').limit(1).should == [test_instance2]
79
+ it 'should chain queries' do
80
+ 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])
81
81
  end
82
82
 
83
- it "should chain count" do
84
- ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').count.should == 2
83
+ it 'should chain count' do
84
+ expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').count).to eq(2)
85
85
  end
86
86
 
87
87
  describe "when one of the objects in solr isn't in fedora" do
88
- it "should log an error" do
89
- ModelIntegrationSpec::Basic.should_receive(:find_one).with(test_instance1.pid, nil).and_call_original
90
- ModelIntegrationSpec::Basic.should_receive(:find_one).with(test_instance2.pid, nil).and_raise(ActiveFedora::ObjectNotFoundError)
91
- ModelIntegrationSpec::Basic.should_receive(:find_one).with(test_instance3.pid, nil).and_call_original
92
- ActiveFedora::Relation.logger.should_receive(:error).with("When trying to find_each #{test_instance2.pid}, encountered an ObjectNotFoundError. Solr may be out of sync with Fedora")
93
- ModelIntegrationSpec::Basic.all.should == [test_instance1, test_instance3]
88
+ it 'should log an error' do
89
+ expect(ModelIntegrationSpec::Basic).to receive(:find_one).with(test_instance1.pid, nil).and_call_original
90
+ expect(ModelIntegrationSpec::Basic).to receive(:find_one).with(test_instance2.pid, nil).and_raise(ActiveFedora::ObjectNotFoundError)
91
+ expect(ModelIntegrationSpec::Basic).to receive(:find_one).with(test_instance3.pid, nil).and_call_original
92
+ expect(ActiveFedora::Relation.logger).to receive(:error).with("When trying to find_each #{test_instance2.pid}, encountered an ObjectNotFoundError. Solr may be out of sync with Fedora")
93
+ expect(ModelIntegrationSpec::Basic.all).to eq([test_instance1, test_instance3])
94
94
  end
95
95
  end
96
96
  end
97
97
  end
98
-
@@ -22,14 +22,14 @@ describe ActiveFedora::SolrInstanceLoader do
22
22
  end
23
23
  end
24
24
  describe 'with matching solr document' do
25
- let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>pid).first }
25
+ let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id => pid).first }
26
26
  it 'it casts the SOLR document and casts into an AF::Base object' do
27
27
  expect(subject.object).to eq(active_fedora_object)
28
28
  end
29
29
  end
30
30
  describe 'with a mismatching solr document' do
31
31
  let(:mismatching_pid) { @test_object2.pid }
32
- let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>mismatching_pid).first }
32
+ let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id => mismatching_pid).first }
33
33
  it 'it raise ObjectNotFoundError' do
34
34
  expect {
35
35
  subject
@@ -47,7 +47,7 @@ describe ActiveFedora::SolrInstanceLoader do
47
47
  end
48
48
  end
49
49
  describe 'with matching solr document' do
50
- let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>pid).first }
50
+ let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id => pid).first }
51
51
  it 'it raise ObjectNotFoundError' do
52
52
  expect {
53
53
  subject.object
@@ -56,7 +56,7 @@ describe ActiveFedora::SolrInstanceLoader do
56
56
  end
57
57
  describe 'with a mismatching solr document' do
58
58
  let(:mismatching_pid) { @test_object2.pid }
59
- let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>mismatching_pid).first }
59
+ let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id => mismatching_pid).first }
60
60
  it 'it raise ObjectNotFoundError' do
61
61
  expect {
62
62
  subject
@@ -3,23 +3,23 @@ require 'spec_helper'
3
3
  require 'active_fedora'
4
4
 
5
5
  describe ActiveFedora::SolrService do
6
- describe "#reify_solr_results" do
6
+ describe '#reify_solr_results' do
7
7
  before(:all) do
8
8
  class FooObject < ActiveFedora::Base
9
9
  def self.pid_namespace
10
- "foo"
10
+ 'foo'
11
11
  end
12
-
13
- has_metadata :name => "descMetadata", :type => ActiveFedora::QualifiedDublinCoreDatastream
12
+
13
+ has_metadata :name => 'descMetadata', :type => ActiveFedora::QualifiedDublinCoreDatastream
14
14
  end
15
15
  @test_object = ActiveFedora::Base.new
16
16
  @test_object.label = 'test_object'
17
17
  @foo_object = FooObject.new
18
18
  @foo_object.label = 'foo_object'
19
- attributes = {"language"=>{0=>"Italian"},
20
- "creator"=>{0=>"Linguist, A."},
21
- "geography"=>{0=>"Italy"},
22
- "title"=>{0=>"Italian and Spanish: A Comparison of Common Phrases"}}
19
+ attributes = {'language' => {0 => 'Italian'},
20
+ 'creator' => {0 => 'Linguist, A.'},
21
+ 'geography' => {0 => 'Italy'},
22
+ 'title' => {0 => 'Italian and Spanish: A Comparison of Common Phrases'}}
23
23
  @foo_object.descMetadata.update_indexed_attributes(attributes)
24
24
  @test_object.save
25
25
  @foo_object.save
@@ -35,78 +35,78 @@ describe ActiveFedora::SolrService do
35
35
  @foo_object.delete
36
36
  Object.send(:remove_const, :FooObject)
37
37
  end
38
- it "should return an array of objects that are of the class stored in active_fedora_model_s" do
38
+ it 'should return an array of objects that are of the class stored in active_fedora_model_s' do
39
39
  query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@test_object.pid)} OR id\:#{ActiveFedora::SolrService.escape_uri_for_query(@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
+
48
48
  it 'should load objects from solr data if a :load_from_solr option is passed in' do
49
49
  query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@test_object.pid)} OR id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
50
50
  solr_result = ActiveFedora::SolrService.query(query)
51
- result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
52
- result.length.should == 2
51
+ result = ActiveFedora::SolrService.reify_solr_results(solr_result, {:load_from_solr => true})
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
- obj = ActiveFedora::Base.load_instance_from_solr @foo_object.pid
66
- obj.datastreams.keys.should include('descMetadata')
65
+ obj = ActiveFedora::Base.load_instance_from_solr @foo_object.pid
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
70
70
  query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
71
71
  solr_result = ActiveFedora::SolrService.query(query)
72
- result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
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
82
82
  query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
83
83
  solr_result = ActiveFedora::SolrService.query(query)
84
- result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
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
93
93
  query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
94
94
  solr_result = ActiveFedora::SolrService.query(query)
95
- result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
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\:#{ActiveFedora::SolrService.escape_uri_for_query(@test_object.pid)} OR id\:#{ActiveFedora::SolrService.escape_uri_for_query(@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
108
- result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
106
+ expect(ActiveFedora::Base).to receive(:load_instance_from_solr).once
107
+ expect(FooObject).to receive(:load_instance_from_solr).once
108
+ result = ActiveFedora::SolrService.reify_solr_results(solr_result, {:load_from_solr => true})
109
109
  end
110
-
110
+
111
111
  end
112
112
  end