active-fedora 6.7.8 → 6.8.0

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 (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,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::RdfNode do
4
- describe "inheritance" do
4
+ describe 'inheritance' do
5
5
  before do
6
6
  class Parent
7
7
  include ActiveFedora::RdfObject
@@ -22,14 +22,14 @@ describe ActiveFedora::RdfNode do
22
22
  Object.send(:remove_const, :Parent)
23
23
  end
24
24
 
25
- describe "child class" do
26
- it "should inherit the terms" do
27
- Child.config.keys.should == ['title', 'description']
25
+ describe 'child class' do
26
+ it 'should inherit the terms' do
27
+ expect(Child.config.keys).to eq(['title', 'description'])
28
28
  end
29
29
  end
30
- describe "parent class" do
31
- it "should not be infected with the child terms" do
32
- Parent.config.keys.should == ['title']
30
+ describe 'parent class' do
31
+ it 'should not be infected with the child terms' do
32
+ expect(Parent.config.keys).to eq(['title'])
33
33
  end
34
34
  end
35
35
  end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require File.join( File.dirname(__FILE__), "../../lib/active_fedora/rdf_xml_writer" )
2
+ require File.join( File.dirname(__FILE__), '../../lib/active_fedora/rdf_xml_writer' )
3
3
 
4
4
  describe ActiveFedora::RDFXMLWriter do
5
5
  before(:all) do
@@ -25,9 +25,9 @@ describe ActiveFedora::RDFXMLWriter do
25
25
  EOS
26
26
 
27
27
  end
28
- it "should serialize graphs using the rdf:Description element despite the presence of rdf:type statements" do
28
+ it 'should serialize graphs using the rdf:Description element despite the presence of rdf:type statements' do
29
29
  graph = RDF::Graph.new
30
- subject = RDF::URI.new "info:fedora/test:sample_pid"
30
+ subject = RDF::URI.new 'info:fedora/test:sample_pid'
31
31
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_member_of), RDF::URI.new('demo:10'))
32
32
  graph.insert RDF::Statement.new(subject, RDF::URI('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), RDF::URI.new('http://purl.org/dc/dcmitype/Collection'))
33
33
  content = ActiveFedora::RDFXMLWriter.buffer do |writer|
@@ -35,17 +35,17 @@ describe ActiveFedora::RDFXMLWriter do
35
35
  writer << statement
36
36
  end
37
37
  end
38
- content.should be_equivalent_to @rdf_xml_with_type
38
+ expect(content).to be_equivalent_to @rdf_xml_with_type
39
39
  end
40
-
40
+
41
41
  it 'should serialize graphs without rdf:type equivalently to RDF::RDFXML::Writer' do
42
42
  graph = RDF::Graph.new
43
- subject = RDF::URI.new "info:fedora/test:sample_pid"
43
+ subject = RDF::URI.new 'info:fedora/test:sample_pid'
44
44
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_member_of), RDF::URI.new('info:fedora/demo:10'))
45
45
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_part_of), RDF::URI.new('info:fedora/demo:11'))
46
46
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_part), RDF::URI.new('info:fedora/demo:12'))
47
- graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:OtherModel"))
48
- graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:SampleModel"))
47
+ graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new('info:fedora/afmodel:OtherModel'))
48
+ graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new('info:fedora/afmodel:SampleModel'))
49
49
 
50
50
  local_content = ActiveFedora::RDFXMLWriter.buffer do |writer|
51
51
  graph.each_statement do |statement|
@@ -57,7 +57,7 @@ describe ActiveFedora::RDFXMLWriter do
57
57
  writer << statement
58
58
  end
59
59
  end
60
- EquivalentXml.equivalent?(local_content, @rdf_xml).should be_true
61
- EquivalentXml.equivalent?(local_content, generic_content).should be_true
60
+ expect(EquivalentXml.equivalent?(local_content, @rdf_xml)).to be_truthy
61
+ expect(EquivalentXml.equivalent?(local_content, generic_content)).to be_truthy
62
62
  end
63
63
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::RdfxmlRDFDatastream do
4
- describe "a new instance" do
4
+ describe 'a new instance' do
5
5
  before(:each) do
6
6
  class MyRdfxmlDatastream < ActiveFedora::RdfxmlRDFDatastream
7
7
  map_predicates do |map|
@@ -14,15 +14,15 @@ describe ActiveFedora::RdfxmlRDFDatastream do
14
14
  after(:each) do
15
15
  Object.send(:remove_const, :MyRdfxmlDatastream)
16
16
  end
17
- it "should save and reload" do
17
+ it 'should save and reload' do
18
18
  @subject.publisher = ["St. Martin's Press"]
19
- @subject.serialize.should =~ /<rdf:RDF/
19
+ expect(@subject.serialize).to match(/<rdf:RDF/)
20
20
  end
21
21
  end
22
22
 
23
- describe "a complex data model" do
24
- before do
25
- class DAMS < RDF::Vocabulary("http://library.ucsd.edu/ontology/dams#")
23
+ describe 'a complex data model' do
24
+ before do
25
+ class DAMS < RDF::Vocabulary('http://library.ucsd.edu/ontology/dams#')
26
26
  property :title
27
27
  property :relatedTitle
28
28
  property :type
@@ -46,7 +46,7 @@ describe ActiveFedora::RdfxmlRDFDatastream do
46
46
 
47
47
  module RDF
48
48
  # This enables RDF to respond_to? :value
49
- def self.value
49
+ def self.value
50
50
  self[:value]
51
51
  end
52
52
  end
@@ -61,7 +61,7 @@ describe ActiveFedora::RdfxmlRDFDatastream do
61
61
 
62
62
  attr_reader :about
63
63
 
64
- def initialize(digital_object=nil, dsid=nil, options={})
64
+ def initialize(digital_object = nil, dsid = nil, options = {})
65
65
  @about = options.delete(:about)
66
66
  super
67
67
  end
@@ -79,7 +79,7 @@ describe ActiveFedora::RdfxmlRDFDatastream do
79
79
  include ActiveFedora::RdfObject
80
80
  map_predicates do |map|
81
81
  rdf_type DAMS.Description
82
- map.value(:in=> RDF) do |index|
82
+ map.value(:in => RDF) do |index|
83
83
  index.as :searchable
84
84
  end
85
85
  end
@@ -92,35 +92,35 @@ describe ActiveFedora::RdfxmlRDFDatastream do
92
92
  Object.send(:remove_const, :DAMS)
93
93
  end
94
94
 
95
- describe "a new instance" do
96
- subject { MyDatastream.new(double('inner object', :pid=>'test:1', :new_record? =>true), 'descMetadata', about:"http://library.ucsd.edu/ark:/20775/") }
97
- it "should have a subject" do
98
- subject.rdf_subject.to_s.should == "http://library.ucsd.edu/ark:/20775/"
95
+ describe 'a new instance' do
96
+ subject { MyDatastream.new(double('inner object', :pid => 'test:1', :new_record? => true), 'descMetadata', about: 'http://library.ucsd.edu/ark:/20775/') }
97
+ it 'should have a subject' do
98
+ expect(subject.rdf_subject.to_s).to eq('http://library.ucsd.edu/ark:/20775/')
99
99
  end
100
-
100
+
101
101
  end
102
102
 
103
- describe "an instance with content" do
103
+ describe 'an instance with content' do
104
104
  subject do
105
- subject = MyDatastream.new(double('inner object', :pid=>'test:1', :new_record? =>true), 'descMetadata')
105
+ subject = MyDatastream.new(double('inner object', :pid => 'test:1', :new_record? => true), 'descMetadata')
106
106
  subject.content = File.new('spec/fixtures/damsObjectModel.xml').read
107
107
  subject
108
108
  end
109
- it "should have a subject" do
110
- subject.rdf_subject.to_s.should == "http://library.ucsd.edu/ark:/20775/"
109
+ it 'should have a subject' do
110
+ expect(subject.rdf_subject.to_s).to eq('http://library.ucsd.edu/ark:/20775/')
111
111
  end
112
- it "should have controlGroup" do
113
- subject.controlGroup.should == 'X'
112
+ it 'should have controlGroup' do
113
+ expect(subject.controlGroup).to eq('X')
114
114
  end
115
- it "should have mimeType" do
116
- subject.mimeType.should == 'text/xml'
115
+ it 'should have mimeType' do
116
+ expect(subject.mimeType).to eq('text/xml')
117
117
  end
118
- it "should have dsid" do
119
- subject.dsid.should == 'descMetadata'
118
+ it 'should have dsid' do
119
+ expect(subject.dsid).to eq('descMetadata')
120
120
  end
121
- it "should have fields" do
122
- subject.resource_type.should == ["image"]
123
- subject.title.first.value.should == ["example title"]
121
+ it 'should have fields' do
122
+ expect(subject.resource_type).to eq(['image'])
123
+ expect(subject.title.first.value).to eq(['example title'])
124
124
  end
125
125
  end
126
126
  end
@@ -1,115 +1,115 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::RelationshipGraph do
4
- before do
4
+ before do
5
5
  @graph = ActiveFedora::RelationshipGraph.new
6
6
  @n1 = ActiveFedora::Base.new()
7
7
  @n1.stub(:pid => 'foo:777')
8
8
  end
9
9
 
10
- describe "#relationships" do
11
- it "should have hash accessors" do
12
- @graph.should respond_to(:[])
10
+ describe '#relationships' do
11
+ it 'should have hash accessors' do
12
+ expect(@graph).to respond_to(:[])
13
13
  end
14
14
 
15
- it "should initialize new relation keys" do
16
- @graph[:has_description].should be_empty
17
- @graph[:has_description].should respond_to(:<<)
15
+ it 'should initialize new relation keys' do
16
+ expect(@graph[:has_description]).to be_empty
17
+ expect(@graph[:has_description]).to respond_to(:<<)
18
18
  end
19
19
 
20
20
  end
21
21
 
22
- it "should add relationships" do
22
+ it 'should add relationships' do
23
23
  @n2 = ActiveFedora::Base.new
24
24
  @graph.add(:has_part, @n1)
25
- @graph[:has_part].should == [@n1]
25
+ expect(@graph[:has_part]).to eq([@n1])
26
26
  @graph.add(:has_part, @n2)
27
- @graph[:has_part].should == [@n1, @n2]
27
+ expect(@graph[:has_part]).to eq([@n1, @n2])
28
28
  @graph.add(:has_part, @n2)
29
- @graph[:has_part].should == [@n1, @n2]
30
- @graph.dirty.should be_true
29
+ expect(@graph[:has_part]).to eq([@n1, @n2])
30
+ expect(@graph.dirty).to be_truthy
31
31
  end
32
32
 
33
- it "should create a rdf graph" do
33
+ it 'should create a rdf graph' do
34
34
  graph = @graph.to_graph('info:fedora/foo:1')
35
- graph.should be_kind_of RDF::Graph
36
- graph.statements.to_a.should == []
35
+ expect(graph).to be_kind_of RDF::Graph
36
+ expect(graph.statements.to_a).to eq([])
37
37
 
38
38
  @graph.add(:has_part, @n1)
39
39
  graph = @graph.to_graph('info:fedora/foo:1')
40
40
  stmts = graph.statements.to_a
41
- stmts.size.should == 1
41
+ expect(stmts.size).to eq(1)
42
42
  stmt = stmts.first
43
- stmt.subject.to_s.should == 'info:fedora/foo:1'
44
- stmt.predicate.to_s.should == 'info:fedora/fedora-system:def/relations-external#hasPart'
45
- stmt.object.to_s.should == 'info:fedora/foo:777'
46
-
43
+ expect(stmt.subject.to_s).to eq('info:fedora/foo:1')
44
+ expect(stmt.predicate.to_s).to eq('info:fedora/fedora-system:def/relations-external#hasPart')
45
+ expect(stmt.object.to_s).to eq('info:fedora/foo:777')
46
+
47
47
  end
48
48
 
49
- it "should have array accessor" do
49
+ it 'should have array accessor' do
50
50
  @graph.add(:has_part, @n1)
51
- @graph[:has_part].should == [@n1]
51
+ expect(@graph[:has_part]).to eq([@n1])
52
52
  end
53
53
 
54
- describe "has_predicate?" do
55
- it "should return true when it has it" do
56
- @graph.has_predicate?(:has_part).should be_false
54
+ describe 'has_predicate?' do
55
+ it 'should return true when it has it' do
56
+ expect(@graph.has_predicate?(:has_part)).to be_falsey
57
57
  @graph.add(:has_part, @n1)
58
- @graph.has_predicate?(:has_part).should be_true
58
+ expect(@graph.has_predicate?(:has_part)).to be_truthy
59
59
  end
60
60
  end
61
61
 
62
- describe "delete" do
63
- it "should delete an object when an object is passed" do
62
+ describe 'delete' do
63
+ it 'should delete an object when an object is passed' do
64
64
  @graph.add(:has_part, @n1)
65
- @graph[:has_part].should == [@n1]
65
+ expect(@graph[:has_part]).to eq([@n1])
66
66
  @graph.delete(:has_part, @n1)
67
- @graph[:has_part].should == []
67
+ expect(@graph[:has_part]).to eq([])
68
68
  end
69
- it "should delete an pid when an object is passed" do
69
+ it 'should delete an pid when an object is passed' do
70
70
  #a reloaded rels-ext is just a list of uris, not inflated.
71
71
  @graph.add(:has_part, 'info:fedora/foo:777')
72
- @graph[:has_part].should == ['info:fedora/foo:777']
72
+ expect(@graph[:has_part]).to eq(['info:fedora/foo:777'])
73
73
  @graph.delete(:has_part, @n1)
74
- @graph[:has_part].should == []
74
+ expect(@graph[:has_part]).to eq([])
75
75
  end
76
- it "should delete an pid when a string is passed" do
76
+ it 'should delete an pid when a string is passed' do
77
77
  #a reloaded rels-ext is just a list of uris, not inflated.
78
78
  @graph.add(:has_part, 'info:fedora/foo:777')
79
- @graph[:has_part].should == ['info:fedora/foo:777']
79
+ expect(@graph[:has_part]).to eq(['info:fedora/foo:777'])
80
80
  @graph.delete(:has_part, 'info:fedora/foo:777')
81
- @graph[:has_part].should == []
81
+ expect(@graph[:has_part]).to eq([])
82
82
  end
83
- it "should delete an object when a pid is passed" do
83
+ it 'should delete an object when a pid is passed' do
84
84
  #a reloaded rels-ext is just a list of uris, not inflated.
85
85
  @graph.add(:has_part, @n1)
86
- @graph[:has_part].should == [@n1]
86
+ expect(@graph[:has_part]).to eq([@n1])
87
87
  @graph.delete(:has_part, 'info:fedora/foo:777')
88
- @graph[:has_part].should == []
88
+ expect(@graph[:has_part]).to eq([])
89
89
  end
90
90
 
91
- it "should delete all the predicates if only one arg is passed" do
91
+ it 'should delete all the predicates if only one arg is passed' do
92
92
  @graph.add(:has_part, @n1)
93
- @graph[:has_part].should == [@n1]
93
+ expect(@graph[:has_part]).to eq([@n1])
94
94
  @graph.delete(:has_part)
95
- @graph.has_predicate?(:has_part).should_not be_true
95
+ expect(@graph.has_predicate?(:has_part)).not_to be_truthy
96
96
  end
97
97
  end
98
- describe "build_statement" do
99
- it "should raise an error when the target is a pid, not a uri" do
100
- lambda { @graph.build_statement('info:fedora/spec:9', :is_part_of, 'spec:7') }.should raise_error ArgumentError
98
+ describe 'build_statement' do
99
+ it 'should raise an error when the target is a pid, not a uri' do
100
+ expect { @graph.build_statement('info:fedora/spec:9', :is_part_of, 'spec:7') }.to raise_error ArgumentError
101
101
  end
102
- it "should run the happy path" do
102
+ it 'should run the happy path' do
103
103
  stm = @graph.build_statement('info:fedora/spec:9', :is_part_of, 'info:fedora/spec:7')
104
- stm.object.to_s.should == "info:fedora/spec:7"
104
+ expect(stm.object.to_s).to eq('info:fedora/spec:7')
105
105
  end
106
- it "should also be happy with non-info URIs" do
106
+ it 'should also be happy with non-info URIs' do
107
107
  stm = @graph.build_statement('info:fedora/spec:9', :is_annotation_of, 'http://www.w3.org/standards/techs/rdf')
108
- stm.object.to_s.should == "http://www.w3.org/standards/techs/rdf"
108
+ expect(stm.object.to_s).to eq('http://www.w3.org/standards/techs/rdf')
109
109
  end
110
- it "should also be happy with targets that are URI::Generics" do
110
+ it 'should also be happy with targets that are URI::Generics' do
111
111
  stm = @graph.build_statement('info:fedora/spec:9', :is_annotation_of, URI.parse('http://www.w3.org/standards/techs/rdf'))
112
- stm.object.to_s.should == "http://www.w3.org/standards/techs/rdf"
112
+ expect(stm.object.to_s).to eq('http://www.w3.org/standards/techs/rdf')
113
113
  end
114
114
  end
115
115
  end
@@ -2,57 +2,64 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::RelsExtDatastream do
4
4
  before(:all) do
5
- @pid = "test:sample_pid"
6
-
5
+ @pid = 'test:sample_pid'
6
+
7
7
  @sample_xml = Nokogiri::XML::Document.parse(@sample_xml_string)
8
8
  end
9
-
9
+
10
10
  before(:each) do
11
11
  mock_inner = double('inner object')
12
12
  @mock_repo = double('repository')
13
- @mock_repo.stub(:datastream_dissemination=>'My Content', :config=>{})
14
- mock_inner.stub(:repository).and_return(@mock_repo)
15
- mock_inner.stub(:pid).and_return(@pid)
16
- @test_ds = ActiveFedora::RelsExtDatastream.new(mock_inner, "RELS-EXT")
17
- @test_ds.stub(:profile).and_return({})
13
+ @mock_repo.stub(:datastream_dissemination => 'My Content', :config => {})
14
+ allow(mock_inner).to receive(:repository).and_return(@mock_repo)
15
+ allow(mock_inner).to receive(:pid).and_return(@pid)
16
+ @test_ds = ActiveFedora::RelsExtDatastream.new(mock_inner, 'RELS-EXT')
17
+ allow(@test_ds).to receive(:profile).and_return({})
18
18
  end
19
19
 
20
- its(:metadata?) { should be_true}
21
- its(:controlGroup) { should == "X"}
20
+ describe '#metadata?' do
21
+ subject { super().metadata? }
22
+ it { is_expected.to be_truthy}
23
+ end
24
+
25
+ describe '#controlGroup' do
26
+ subject { super().controlGroup }
27
+ it { is_expected.to eq('X')}
28
+ end
22
29
 
23
- describe "#mimeType" do
30
+ describe '#mimeType' do
24
31
  it 'should use the application/rdf+xml mime type' do
25
- @test_ds.mimeType.should == 'application/rdf+xml'
32
+ expect(@test_ds.mimeType).to eq('application/rdf+xml')
26
33
  end
27
34
  end
28
35
 
29
- describe "#changed?" do
30
- it "should be false when no changes have been made" do
31
- subject.changed?.should == false
36
+ describe '#changed?' do
37
+ it 'should be false when no changes have been made' do
38
+ expect(subject.changed?).to eq(false)
32
39
  end
33
- it "should be true when the model has changes" do
34
- subject.model = double(:relationships_are_dirty=>true)
35
- subject.changed?.should == true
40
+ it 'should be true when the model has changes' do
41
+ subject.model = double(:relationships_are_dirty => true)
42
+ expect(subject.changed?).to eq(true)
36
43
  end
37
44
  end
38
-
39
-
45
+
46
+
40
47
  describe '#serialize!' do
41
-
42
- it "should generate new rdf/xml as the datastream content if the object has been changed" do
48
+
49
+ it 'should generate new rdf/xml as the datastream content if the object has been changed' do
43
50
  graph = RDF::Graph.new
44
- subject = RDF::URI.new "info:fedora/test:sample_pid"
51
+ subject = RDF::URI.new 'info:fedora/test:sample_pid'
45
52
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_member_of), RDF::URI.new('demo:10'))
46
-
47
- @test_ds.stub(:new? => true, :relationships_are_dirty? =>true, :relationships => graph, :model => double(:relationships_are_dirty= => true))
53
+
54
+ @test_ds.stub(:new? => true, :relationships_are_dirty? => true, :relationships => graph, :model => double(:relationships_are_dirty= => true))
48
55
  @test_ds.serialize!
49
- EquivalentXml.equivalent?(@test_ds.content, "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n <rdf:Description rdf:about='info:fedora/test:sample_pid'>\n <isMemberOf rdf:resource='demo:10' xmlns='info:fedora/fedora-system:def/relations-external#'/></rdf:Description>\n </rdf:RDF>").should be_true
56
+ expect(EquivalentXml.equivalent?(@test_ds.content, "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n <rdf:Description rdf:about='info:fedora/test:sample_pid'>\n <isMemberOf rdf:resource='demo:10' xmlns='info:fedora/fedora-system:def/relations-external#'/></rdf:Description>\n </rdf:RDF>")).to be_truthy
50
57
  end
51
-
58
+
52
59
  end
53
60
 
54
61
  describe '#to_rels_ext' do
55
-
62
+
56
63
  before(:all) do
57
64
  @sample_rels_ext_xml = <<-EOS
58
65
  <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
@@ -65,69 +72,69 @@ describe ActiveFedora::RelsExtDatastream do
65
72
  </rdf:Description>
66
73
  </rdf:RDF>
67
74
  EOS
68
- @pid = "test:sample_pid"
75
+ @pid = 'test:sample_pid'
69
76
  end
70
-
77
+
71
78
  it 'should serialize the relationships array to Fedora RELS-EXT rdf/xml' do
72
79
  graph = RDF::Graph.new
73
- subject = RDF::URI.new "info:fedora/test:sample_pid"
80
+ subject = RDF::URI.new 'info:fedora/test:sample_pid'
74
81
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_member_of), RDF::URI.new('info:fedora/demo:10'))
75
82
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_part_of), RDF::URI.new('info:fedora/demo:11'))
76
83
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_part), RDF::URI.new('info:fedora/demo:12'))
77
- graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:OtherModel"))
78
- graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:SampleModel"))
84
+ graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new('info:fedora/afmodel:OtherModel'))
85
+ graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new('info:fedora/afmodel:SampleModel'))
79
86
 
80
- @test_ds.should_receive(:model).and_return(double("model", :relationships=>graph, :relationships_are_dirty= => true))
81
- EquivalentXml.equivalent?(@test_ds.to_rels_ext(), @sample_rels_ext_xml).should be_true
87
+ expect(@test_ds).to receive(:model).and_return(double('model', :relationships => graph, :relationships_are_dirty= => true))
88
+ expect(EquivalentXml.equivalent?(@test_ds.to_rels_ext(), @sample_rels_ext_xml)).to be_truthy
82
89
  end
83
-
90
+
84
91
  it 'should use mapped namespace prefixes when given' do
85
92
  graph = RDF::Graph.new
86
- subject = RDF::URI.new "info:fedora/test:sample_pid"
93
+ subject = RDF::URI.new 'info:fedora/test:sample_pid'
87
94
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_member_of), RDF::URI.new('info:fedora/demo:10'))
88
95
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_part_of), RDF::URI.new('info:fedora/demo:11'))
89
96
  graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_part), RDF::URI.new('info:fedora/demo:12'))
90
- graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:OtherModel"))
91
- graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:SampleModel"))
97
+ graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new('info:fedora/afmodel:OtherModel'))
98
+ graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new('info:fedora/afmodel:SampleModel'))
92
99
 
93
- @test_ds.stub(:model).and_return(double("model", :relationships=>graph, :relationships_are_dirty= => true))
100
+ allow(@test_ds).to receive(:model).and_return(double('model', :relationships => graph, :relationships_are_dirty= => true))
94
101
  rels = @test_ds.to_rels_ext()
95
- EquivalentXml.equivalent?(rels, @sample_rels_ext_xml).should be_true
96
- rels.should_not =~ /fedora:isMemberOf/
97
- rels.should_not =~ /fedora-model:hasModel/
98
- rels.should =~ /ns\d:isMemberOf/
99
- rels.should =~ /ns\d:hasModel/
100
-
101
- ActiveFedora::Predicates.predicate_config[:predicate_namespaces] = {:"fedora-model"=>"info:fedora/fedora-system:def/model#", :fedora=>"info:fedora/fedora-system:def/relations-external#"}
102
+ expect(EquivalentXml.equivalent?(rels, @sample_rels_ext_xml)).to be_truthy
103
+ expect(rels).not_to match(/fedora:isMemberOf/)
104
+ expect(rels).not_to match(/fedora-model:hasModel/)
105
+ expect(rels).to match(/ns\d:isMemberOf/)
106
+ expect(rels).to match(/ns\d:hasModel/)
107
+
108
+ ActiveFedora::Predicates.predicate_config[:predicate_namespaces] = {:"fedora-model" => 'info:fedora/fedora-system:def/model#', :fedora => 'info:fedora/fedora-system:def/relations-external#'}
102
109
  rels = @test_ds.to_rels_ext()
103
- EquivalentXml.equivalent?(rels, @sample_rels_ext_xml).should be_true
104
- rels.should =~ /fedora:isMemberOf/
105
- rels.should =~ /fedora-model:hasModel/
106
- rels.should_not =~ /ns\d:isMemberOf/
107
- rels.should_not =~ /ns\d:hasModel/
110
+ expect(EquivalentXml.equivalent?(rels, @sample_rels_ext_xml)).to be_truthy
111
+ expect(rels).to match(/fedora:isMemberOf/)
112
+ expect(rels).to match(/fedora-model:hasModel/)
113
+ expect(rels).not_to match(/ns\d:isMemberOf/)
114
+ expect(rels).not_to match(/ns\d:hasModel/)
108
115
  ActiveFedora::Predicates.predicate_config[:predicate_namespaces] = nil
109
116
  end
110
-
117
+
111
118
  end
112
-
113
- describe "#from_xml" do
119
+
120
+ describe '#from_xml' do
114
121
  before(:all) do
115
122
  @test_obj = ActiveFedora::Base.new
116
- @test_obj.add_relationship(:is_member_of, "info:fedora/demo:10")
117
- @test_obj.add_relationship(:is_part_of, "info:fedora/demo:11")
118
- @test_obj.add_relationship(:conforms_to, "AnInterface", true)
123
+ @test_obj.add_relationship(:is_member_of, 'info:fedora/demo:10')
124
+ @test_obj.add_relationship(:is_part_of, 'info:fedora/demo:11')
125
+ @test_obj.add_relationship(:conforms_to, 'AnInterface', true)
119
126
  @test_obj.save
120
127
  end
121
128
  after(:all) do
122
129
  @test_obj.delete
123
130
  end
124
- it "should handle un-mapped predicates gracefully" do
125
- @test_obj.add_relationship("foo", "info:fedora/foo:bar")
131
+ it 'should handle un-mapped predicates gracefully' do
132
+ @test_obj.add_relationship('foo', 'info:fedora/foo:bar')
126
133
  @test_obj.save
127
- @test_obj.relationships.size.should == 5
128
- @test_obj.ids_for_outbound("foo").should == ["foo:bar"]
134
+ expect(@test_obj.relationships.size).to eq(5)
135
+ expect(@test_obj.ids_for_outbound('foo')).to eq(['foo:bar'])
129
136
  end
130
- it "should automatically map un-mapped predicates" do
137
+ it 'should automatically map un-mapped predicates' do
131
138
  xml = <<-EOS
132
139
  <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
133
140
  <rdf:Description rdf:about='info:fedora/test:sample_pid'>
@@ -143,10 +150,10 @@ describe ActiveFedora::RelsExtDatastream do
143
150
  model = ActiveFedora::Base.new
144
151
  new_ds = ActiveFedora::RelsExtDatastream.new
145
152
  new_ds.model = model
146
- lambda { ActiveFedora::RelsExtDatastream.from_xml(xml, new_ds) }.should_not raise_exception
147
- new_ds.to_rels_ext.should =~ /missing:hasOtherRelationship/
153
+ expect { ActiveFedora::RelsExtDatastream.from_xml(xml, new_ds) }.not_to raise_exception
154
+ expect(new_ds.to_rels_ext).to match(/missing:hasOtherRelationship/)
148
155
  end
149
- it "should handle un-mapped literals" do
156
+ it 'should handle un-mapped literals' do
150
157
  xml = "
151
158
  <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:oai=\"http://www.openarchives.org/OAI/2.0/\">
152
159
  <rdf:Description rdf:about=\"info:fedora/changeme:3489\">
@@ -161,9 +168,8 @@ describe ActiveFedora::RelsExtDatastream do
161
168
  new_ds.model = model
162
169
  ActiveFedora::RelsExtDatastream.from_xml(xml, new_ds)
163
170
  new_ext = new_ds.to_rels_ext()
164
- new_ext.should match "<ns0:itemID>oai:hull.ac.uk:hull:2708</ns0:itemID>"
165
-
171
+ new_ext.should match "<ns2:itemID>oai:hull.ac.uk:hull:2708</ns2:itemID>"
166
172
  end
167
173
  end
168
-
174
+
169
175
  end