active-fedora 8.2.1 → 8.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/active-fedora.gemspec +1 -2
  3. data/lib/active_fedora/datastream_collections.rb +4 -8
  4. data/lib/active_fedora/datastreams.rb +7 -9
  5. data/lib/active_fedora/version.rb +1 -1
  6. data/spec/config_helper.rb +3 -3
  7. data/spec/integration/associations_spec.rb +76 -76
  8. data/spec/integration/auditable_spec.rb +7 -7
  9. data/spec/integration/autosave_association_spec.rb +3 -3
  10. data/spec/integration/base_spec.rb +51 -51
  11. data/spec/integration/belongs_to_association_spec.rb +27 -27
  12. data/spec/integration/bug_spec.rb +1 -1
  13. data/spec/integration/collection_association_spec.rb +2 -2
  14. data/spec/integration/complex_rdf_datastream_spec.rb +32 -32
  15. data/spec/integration/datastream_collections_spec.rb +42 -42
  16. data/spec/integration/datastream_spec.rb +19 -19
  17. data/spec/integration/datastreams_spec.rb +25 -25
  18. data/spec/integration/delete_all_spec.rb +5 -5
  19. data/spec/integration/fedora_solr_sync_spec.rb +1 -1
  20. data/spec/integration/full_featured_model_spec.rb +9 -9
  21. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +46 -47
  22. data/spec/integration/has_many_associations_spec.rb +17 -17
  23. data/spec/integration/json_serialization_spec.rb +2 -2
  24. data/spec/integration/load_from_solr_spec.rb +1 -1
  25. data/spec/integration/model_spec.rb +9 -9
  26. data/spec/integration/nested_attribute_spec.rb +17 -17
  27. data/spec/integration/ntriples_datastream_spec.rb +43 -43
  28. data/spec/integration/om_datastream_spec.rb +37 -37
  29. data/spec/integration/persistence_spec.rb +1 -1
  30. data/spec/integration/rdf_nested_attributes_spec.rb +9 -9
  31. data/spec/integration/relation_delegation_spec.rb +7 -7
  32. data/spec/integration/relation_spec.rb +2 -2
  33. data/spec/integration/rels_ext_datastream_spec.rb +3 -3
  34. data/spec/integration/scoped_query_spec.rb +14 -14
  35. data/spec/integration/solr_service_spec.rb +24 -24
  36. data/spec/support/mock_fedora.rb +9 -10
  37. data/spec/unit/active_fedora_spec.rb +20 -20
  38. data/spec/unit/attributes_spec.rb +24 -24
  39. data/spec/unit/base_active_model_spec.rb +6 -6
  40. data/spec/unit/base_cma_spec.rb +2 -2
  41. data/spec/unit/base_datastream_management_spec.rb +7 -7
  42. data/spec/unit/base_extra_spec.rb +20 -20
  43. data/spec/unit/base_spec.rb +141 -141
  44. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
  45. data/spec/unit/callback_spec.rb +12 -12
  46. data/spec/unit/code_configurator_spec.rb +7 -7
  47. data/spec/unit/config_spec.rb +2 -2
  48. data/spec/unit/content_model_spec.rb +19 -20
  49. data/spec/unit/core_spec.rb +1 -1
  50. data/spec/unit/datastream_collections_spec.rb +101 -101
  51. data/spec/unit/datastream_spec.rb +12 -12
  52. data/spec/unit/datastreams_spec.rb +39 -39
  53. data/spec/unit/file_configurator_spec.rb +117 -117
  54. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +16 -16
  55. data/spec/unit/has_many_collection_spec.rb +5 -5
  56. data/spec/unit/inheritance_spec.rb +5 -5
  57. data/spec/unit/model_spec.rb +5 -5
  58. data/spec/unit/nom_datastream_spec.rb +5 -5
  59. data/spec/unit/ntriples_datastream_spec.rb +56 -56
  60. data/spec/unit/om_datastream_spec.rb +99 -99
  61. data/spec/unit/persistence_spec.rb +2 -2
  62. data/spec/unit/predicates_spec.rb +28 -28
  63. data/spec/unit/property_spec.rb +5 -5
  64. data/spec/unit/qualified_dublin_core_datastream_spec.rb +10 -10
  65. data/spec/unit/query_spec.rb +66 -66
  66. data/spec/unit/rdf_datastream_spec.rb +10 -10
  67. data/spec/unit/rdf_resource_datastream_spec.rb +2 -2
  68. data/spec/unit/rdf_xml_writer_spec.rb +3 -3
  69. data/spec/unit/rdfxml_rdf_datastream_spec.rb +9 -9
  70. data/spec/unit/relationship_graph_spec.rb +31 -31
  71. data/spec/unit/reload_on_save_spec.rb +3 -3
  72. data/spec/unit/rels_ext_datastream_spec.rb +28 -28
  73. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +11 -11
  74. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +11 -11
  75. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +11 -11
  76. data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +7 -7
  77. data/spec/unit/rubydora_connection_spec.rb +3 -3
  78. data/spec/unit/semantic_node_spec.rb +17 -17
  79. data/spec/unit/serializers_spec.rb +1 -1
  80. data/spec/unit/service_definitions_spec.rb +11 -11
  81. data/spec/unit/simple_datastream_spec.rb +6 -6
  82. data/spec/unit/solr_config_options_spec.rb +10 -10
  83. data/spec/unit/solr_digital_object_spec.rb +4 -4
  84. data/spec/unit/solr_service_spec.rb +41 -41
  85. data/spec/unit/unsaved_digital_object_spec.rb +8 -8
  86. data/spec/unit/validations_spec.rb +6 -6
  87. metadata +4 -4
@@ -15,15 +15,15 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
15
15
 
16
16
  it "should call add_relationship" do
17
17
  subject = Book.new(pid: 'subject:a')
18
- subject.stub(:new_record? => false, save: true)
18
+ allow(subject).to receive_messages(:new_record? => false, save: true)
19
19
  predicate = Book.create_reflection(:has_and_belongs_to_many, 'pages', {:property=>'predicate'}, nil)
20
- ActiveFedora::SolrService.stub(:query).and_return([])
20
+ allow(ActiveFedora::SolrService).to receive(:query).and_return([])
21
21
  ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
22
- ac.should_receive(:callback).twice
22
+ expect(ac).to receive(:callback).twice
23
23
  object = Page.new(:pid => 'object:b')
24
- object.stub(:new_record? => false, save: true)
24
+ allow(object).to receive_messages(:new_record? => false, save: true)
25
25
 
26
- subject.should_receive(:add_relationship).with('predicate', object)
26
+ expect(subject).to receive(:add_relationship).with('predicate', object)
27
27
 
28
28
  ac << object
29
29
 
@@ -31,17 +31,17 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
31
31
 
32
32
  it "should call add_relationship on subject and object when inverse_of given" do
33
33
  subject = Book.new(pid: 'subject:a')
34
- subject.stub(:new_record? => false, save: true)
34
+ allow(subject).to receive_messages(:new_record? => false, save: true)
35
35
  predicate = Book.create_reflection(:has_and_belongs_to_many, 'pages', {:property=>'predicate', :inverse_of => 'inverse_predicate'}, nil)
36
- ActiveFedora::SolrService.stub(:query).and_return([])
36
+ allow(ActiveFedora::SolrService).to receive(:query).and_return([])
37
37
  ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
38
- ac.should_receive(:callback).twice
38
+ expect(ac).to receive(:callback).twice
39
39
  object = Page.new(:pid => 'object:b')
40
- object.stub(:new_record? => false, save: true)
40
+ allow(object).to receive_messages(:new_record? => false, save: true)
41
41
 
42
- subject.should_receive(:add_relationship).with('predicate', object)
42
+ expect(subject).to receive(:add_relationship).with('predicate', object)
43
43
 
44
- object.should_receive(:add_relationship).with('inverse_predicate', subject)
44
+ expect(object).to receive(:add_relationship).with('inverse_predicate', subject)
45
45
 
46
46
  ac << object
47
47
 
@@ -50,15 +50,15 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
50
50
  it "should call solr query multiple times" do
51
51
 
52
52
  subject = Book.new(pid: 'subject:a')
53
- subject.stub(:new_record? => false, save: true)
53
+ allow(subject).to receive_messages(:new_record? => false, save: true)
54
54
  predicate = Book.create_reflection(:has_and_belongs_to_many, 'pages', {:property=>'predicate', :solr_page_size => 10}, nil)
55
55
  ids = []
56
56
  0.upto(15) {|i| ids << i.to_s}
57
57
  query1 = ids.slice(0,10).map {|i| "_query_:\"{!raw f=id}#{i}\""}.join(" OR ")
58
58
  query2 = ids.slice(10,10).map {|i| "_query_:\"{!raw f=id}#{i}\""}.join(" OR ")
59
- subject.should_receive(:ids_for_outbound).and_return(ids)
60
- ActiveFedora::SolrService.should_receive(:query).with(query1, {:rows=>10}).and_return([])
61
- ActiveFedora::SolrService.should_receive(:query).with(query2, {:rows=>10}).and_return([])
59
+ expect(subject).to receive(:ids_for_outbound).and_return(ids)
60
+ expect(ActiveFedora::SolrService).to receive(:query).with(query1, {:rows=>10}).and_return([])
61
+ expect(ActiveFedora::SolrService).to receive(:query).with(query2, {:rows=>10}).and_return([])
62
62
 
63
63
  ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
64
64
  ac.find_target
@@ -88,7 +88,7 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
88
88
  let(:collection) {Collection.create().tap {|c| c.members << thing}}
89
89
 
90
90
  it "should call destroy" do
91
- expect(collection.destroy).to_not raise_error
91
+ expect { collection.destroy }.to_not raise_error
92
92
  end
93
93
 
94
94
  end
@@ -15,18 +15,18 @@ describe ActiveFedora::Associations::HasManyAssociation do
15
15
 
16
16
  subject { Book.new(pid: 'subject:a') }
17
17
  before {
18
- subject.stub(:new_record? => false, save: true)
18
+ allow(subject).to receive_messages(:new_record? => false, save: true)
19
19
  }
20
20
 
21
21
  it "should call add_relationship" do
22
22
  reflection = Book.create_reflection(:has_many, 'pages', {:property=>'predicate'}, Book)
23
- ActiveFedora::SolrService.stub(:query).and_return([])
23
+ allow(ActiveFedora::SolrService).to receive(:query).and_return([])
24
24
  ac = ActiveFedora::Associations::HasManyAssociation.new(subject, reflection)
25
- ac.should_receive(:callback).twice
25
+ expect(ac).to receive(:callback).twice
26
26
  object = Page.new(:pid => 'object:b')
27
- object.stub(:new_record? => false, save: true)
27
+ allow(object).to receive_messages(:new_record? => false, save: true)
28
28
 
29
- object.should_receive(:add_relationship).with('predicate', subject)
29
+ expect(object).to receive(:add_relationship).with('predicate', subject)
30
30
 
31
31
  ac << object
32
32
 
@@ -17,17 +17,17 @@ describe ActiveFedora::Base do
17
17
 
18
18
  it "doesn't overwrite stream specs" do
19
19
  f = Foo.new
20
- f.datastreams.size.should == 3
20
+ expect(f.datastreams.size).to eq(3)
21
21
  streams = f.datastreams.values.map{|x| x.class.to_s}.sort
22
- streams.pop.should == "ActiveFedora::SimpleDatastream"
23
- streams.pop.should == "ActiveFedora::RelsExtDatastream"
24
- streams.pop.should == "ActiveFedora::QualifiedDublinCoreDatastream"
22
+ expect(streams.pop).to eq("ActiveFedora::SimpleDatastream")
23
+ expect(streams.pop).to eq("ActiveFedora::RelsExtDatastream")
24
+ expect(streams.pop).to eq("ActiveFedora::QualifiedDublinCoreDatastream")
25
25
  end
26
26
 
27
27
  it "should work for multiple types" do
28
28
  b = Foo.new
29
29
  f = Bar.new
30
- b.class.ds_specs.should_not == f.class.ds_specs
30
+ expect(b.class.ds_specs).not_to eq(f.class.ds_specs)
31
31
  end
32
32
  after do
33
33
  Object.send(:remove_const, :Bar)
@@ -20,11 +20,11 @@ describe ActiveFedora::Model do
20
20
  SpecModel::Basic.solr_query_handler = 'standard'
21
21
  end
22
22
  it "should have a default" do
23
- SpecModel::Basic.solr_query_handler.should == 'standard'
23
+ expect(SpecModel::Basic.solr_query_handler).to eq('standard')
24
24
  end
25
25
  it "should be settable" do
26
26
  SpecModel::Basic.solr_query_handler = 'search'
27
- SpecModel::Basic.solr_query_handler.should == 'search'
27
+ expect(SpecModel::Basic.solr_query_handler).to eq('search')
28
28
  end
29
29
  end
30
30
 
@@ -44,13 +44,13 @@ describe ActiveFedora::Model do
44
44
 
45
45
  describe ".classname_from_uri" do
46
46
  it "should turn an afmodel URI into a Model class name" do
47
- ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:SpecModel_CamelCased').should == ['SpecModel::CamelCased', 'afmodel']
47
+ expect(ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:SpecModel_CamelCased')).to eq(['SpecModel::CamelCased', 'afmodel'])
48
48
  end
49
49
  it "should not change plurality" do
50
- ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:MyMetadata').should == ['MyMetadata', 'afmodel']
50
+ expect(ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:MyMetadata')).to eq(['MyMetadata', 'afmodel'])
51
51
  end
52
52
  it "should capitalize the first letter" do
53
- ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:image').should == ['Image', 'afmodel']
53
+ expect(ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:image')).to eq(['Image', 'afmodel'])
54
54
  end
55
55
  end
56
56
  end
@@ -15,16 +15,16 @@ describe ActiveFedora::NomDatastream do
15
15
  }
16
16
 
17
17
  it "should work" do
18
- subject.a.should include("123")
18
+ expect(subject.a).to include("123")
19
19
  end
20
20
 
21
21
  it "should to_solr" do
22
- subject.to_solr['a_s'].should include('123')
23
- subject.to_solr['b_s'].should include('asdf')
22
+ expect(subject.to_solr['a_s']).to include('123')
23
+ expect(subject.to_solr['b_s']).to include('asdf')
24
24
  end
25
25
 
26
26
  it "should be a managed datastream" do
27
- subject.controlGroup.should == 'M'
27
+ expect(subject.controlGroup).to eq('M')
28
28
  end
29
29
  end
30
30
 
@@ -54,7 +54,7 @@ describe ActiveFedora::NomDatastream do
54
54
  }
55
55
 
56
56
  it "should scope #a attribute to only the dc namespace" do
57
- subject.a.should == ["123"]
57
+ expect(subject.a).to eq(["123"])
58
58
  end
59
59
 
60
60
  end
@@ -19,59 +19,59 @@ describe ActiveFedora::NtriplesRDFDatastream do
19
19
  Object.send(:remove_const, :MyDatastream)
20
20
  end
21
21
  it "should have a subject" do
22
- @subject.rdf_subject.should == "info:fedora/test:1"
22
+ expect(@subject.rdf_subject).to eq("info:fedora/test:1")
23
23
  end
24
24
  it "should have controlGroup" do
25
- @subject.controlGroup.should == 'M'
25
+ expect(@subject.controlGroup).to eq('M')
26
26
  end
27
27
  it "should have mimeType" do
28
- @subject.mimeType.should == 'application/n-triples'
28
+ expect(@subject.mimeType).to eq('application/n-triples')
29
29
  end
30
30
  it "should have dsid" do
31
- @subject.dsid.should == 'descMetadata'
31
+ expect(@subject.dsid).to eq('descMetadata')
32
32
  end
33
33
  it "should have fields" do
34
- @subject.created.should == [Date.parse('2010-12-31')]
35
- @subject.title.should == ["Title of work"]
36
- @subject.publisher.should == ["Penn State"]
37
- @subject.based_near.should == ["New York, NY, US"]
38
- @subject.related_url.length.should == 1
39
- @subject.related_url.first.rdf_subject.should == "http://google.com/"
34
+ expect(@subject.created).to eq([Date.parse('2010-12-31')])
35
+ expect(@subject.title).to eq(["Title of work"])
36
+ expect(@subject.publisher).to eq(["Penn State"])
37
+ expect(@subject.based_near).to eq(["New York, NY, US"])
38
+ expect(@subject.related_url.length).to eq(1)
39
+ expect(@subject.related_url.first.rdf_subject).to eq("http://google.com/")
40
40
  end
41
41
 
42
42
  it "should be able to call enumerable methods on the fields" do
43
- @subject.title.join(', ').should == "Title of work"
44
- @subject.title.count.should == 1
45
- @subject.title.size.should == 1
46
- @subject.title[0].should == "Title of work"
47
- @subject.title.to_a.should == ["Title of work"]
43
+ expect(@subject.title.join(', ')).to eq("Title of work")
44
+ expect(@subject.title.count).to eq(1)
45
+ expect(@subject.title.size).to eq(1)
46
+ expect(@subject.title[0]).to eq("Title of work")
47
+ expect(@subject.title.to_a).to eq(["Title of work"])
48
48
  val = []
49
49
  @subject.title.each_with_index {|v, i| val << "#{i}. #{v}"}
50
- val.should == ["0. Title of work"]
50
+ expect(val).to eq(["0. Title of work"])
51
51
  end
52
52
 
53
53
  it "should return fields that are not TermProxies" do
54
- @subject.created.should be_kind_of Array
54
+ expect(@subject.created).to be_kind_of Array
55
55
  end
56
56
  it "should have method missing" do
57
- lambda{@subject.frank}.should raise_exception NoMethodError
57
+ expect{@subject.frank}.to raise_exception NoMethodError
58
58
  end
59
59
 
60
60
  it "should set fields" do
61
61
  @subject.publisher = "St. Martin's Press"
62
- @subject.publisher.should == ["St. Martin's Press"]
62
+ expect(@subject.publisher).to eq(["St. Martin's Press"])
63
63
  end
64
64
  it "should set rdf literal fields" do
65
65
  @subject.creator = RDF.Literal("Geoff Ryman")
66
- @subject.creator.should == ["Geoff Ryman"]
66
+ expect(@subject.creator).to eq(["Geoff Ryman"])
67
67
  end
68
68
  it "should append fields" do
69
69
  @subject.publisher << "St. Martin's Press"
70
- @subject.publisher.should == ["Penn State", "St. Martin's Press"]
70
+ expect(@subject.publisher).to eq(["Penn State", "St. Martin's Press"])
71
71
  end
72
72
  it "should delete fields" do
73
73
  @subject.related_url.delete(RDF::URI("http://google.com/"))
74
- @subject.related_url.should == []
74
+ expect(@subject.related_url).to eq([])
75
75
  end
76
76
  end
77
77
 
@@ -81,8 +81,8 @@ describe ActiveFedora::NtriplesRDFDatastream do
81
81
  @two = ActiveFedora::RDFDatastream.new('fakepid', 'myQuix')
82
82
  end
83
83
  it "should generate predictable prexies" do
84
- @one.apply_prefix("baz").should == 'my_foobar__baz'
85
- @two.apply_prefix("baz").should == 'my_quix__baz'
84
+ expect(@one.apply_prefix("baz")).to eq('my_foobar__baz')
85
+ expect(@two.apply_prefix("baz")).to eq('my_quix__baz')
86
86
  end
87
87
  end
88
88
 
@@ -98,8 +98,8 @@ describe ActiveFedora::NtriplesRDFDatastream do
98
98
  end
99
99
  @inner_object = double('inner object', pid: 'test:1', :new_record? => true)
100
100
  @subject = MyDatastream.new(@inner_object, 'mixed_rdf')
101
- @subject.stub(pid: 'test:1')
102
- @subject.stub(:new_record? => false)
101
+ allow(@subject).to receive_messages(pid: 'test:1')
102
+ allow(@subject).to receive_messages(:new_record? => false)
103
103
  @subject.content = File.new('spec/fixtures/mixed_rdf_descMetadata.nt').read
104
104
  end
105
105
 
@@ -108,11 +108,11 @@ describe ActiveFedora::NtriplesRDFDatastream do
108
108
  end
109
109
 
110
110
  it "should have fields" do
111
- @subject.title.should == ["Title of datastream"]
111
+ expect(@subject.title).to eq(["Title of datastream"])
112
112
  end
113
113
 
114
114
  it "should have a custom subject" do
115
- @subject.rdf_subject.should == 'info:fedora/test:1/content'
115
+ expect(@subject.rdf_subject).to eq('info:fedora/test:1/content')
116
116
  end
117
117
  end
118
118
 
@@ -122,17 +122,17 @@ describe ActiveFedora::NtriplesRDFDatastream do
122
122
  property :publisher, predicate: RDF::DC.publisher
123
123
  end
124
124
  @subject = MyDatastream.new(@inner_object, 'mixed_rdf')
125
- @subject.stub(pid: 'test:1', repository: ActiveFedora::Base.connection_for_pid(0))
125
+ allow(@subject).to receive_messages(pid: 'test:1', repository: ActiveFedora::Base.connection_for_pid(0))
126
126
  end
127
127
  after(:each) do
128
128
  Object.send(:remove_const, :MyDatastream)
129
129
  end
130
130
  it "should support to_s method" do
131
- @subject.publisher.to_s.should == [].to_s
131
+ expect(@subject.publisher.to_s).to eq([].to_s)
132
132
  @subject.publisher = "Bob"
133
- @subject.publisher.to_s.should == ["Bob"].to_s
133
+ expect(@subject.publisher.to_s).to eq(["Bob"].to_s)
134
134
  @subject.publisher << "Jim"
135
- @subject.publisher.to_s.should == ["Bob", "Jim"].to_s
135
+ expect(@subject.publisher.to_s).to eq(["Bob", "Jim"].to_s)
136
136
  end
137
137
  end
138
138
 
@@ -166,12 +166,12 @@ describe ActiveFedora::NtriplesRDFDatastream do
166
166
  Object.send(:remove_const, :MyDatastream)
167
167
  end
168
168
  before(:each) do
169
- @subject.stub(pid: 'test:1')
169
+ allow(@subject).to receive_messages(pid: 'test:1')
170
170
  @subject.serialize
171
171
  end
172
172
  it "should provide .to_solr and return a SolrDocument" do
173
- @subject.should respond_to(:to_solr)
174
- @subject.to_solr.should be_kind_of(Hash)
173
+ expect(@subject).to respond_to(:to_solr)
174
+ expect(@subject.to_solr).to be_kind_of(Hash)
175
175
  end
176
176
 
177
177
  it "should have a solr_name method" do
@@ -181,20 +181,20 @@ describe ActiveFedora::NtriplesRDFDatastream do
181
181
 
182
182
  it "should optionally allow you to provide the Solr::Document to add fields to and return that document when done" do
183
183
  doc = Hash.new
184
- @subject.to_solr(doc).should == doc
184
+ expect(@subject.to_solr(doc)).to eq(doc)
185
185
  end
186
186
  it "should iterate through @fields hash" do
187
187
  solr_doc = @subject.to_solr
188
- solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", type: :string)].should == ["publisher1"]
189
- solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :sortable)].should == "publisher1"
190
- solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :facetable)].should == ["publisher1"]
191
- solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", type: :string)].should == ["coverage1", "coverage2"]
192
- solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :facetable)].should == ["coverage1", "coverage2"]
193
- solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__created", :sortable, type: :date)].should == "2009-10-10T00:00:00Z"
194
- solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__created", :displayable)].should == ["2009-10-10"]
195
- solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", type: :string)].should == ["fake-title"]
196
- solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", :sortable)].should == "fake-title"
197
- solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__related_url", type: :string)].should == ["http://example.org/"]
188
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", type: :string)]).to eq(["publisher1"])
189
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :sortable)]).to eq("publisher1")
190
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :facetable)]).to eq(["publisher1"])
191
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", type: :string)]).to eq(["coverage1", "coverage2"])
192
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :facetable)]).to eq(["coverage1", "coverage2"])
193
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__created", :sortable, type: :date)]).to eq("2009-10-10T00:00:00Z")
194
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__created", :displayable)]).to eq(["2009-10-10"])
195
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", type: :string)]).to eq(["fake-title"])
196
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", :sortable)]).to eq("fake-title")
197
+ expect(solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__related_url", type: :string)]).to eq(["http://example.org/"])
198
198
  end
199
199
 
200
200
  describe "with an actual object" do
@@ -205,9 +205,9 @@ describe ActiveFedora::NtriplesRDFDatastream do
205
205
  end
206
206
  @obj = MyDatastream.new(@inner_object, 'solr_rdf')
207
207
  repository = double()
208
- @obj.stub(repository: repository, pid: 'test:1')
209
- repository.stub(:modify_datastream)
210
- repository.stub(:add_datastream)
208
+ allow(@obj).to receive_messages(repository: repository, pid: 'test:1')
209
+ allow(repository).to receive(:modify_datastream)
210
+ allow(repository).to receive(:add_datastream)
211
211
  @obj.created = Date.parse("2012-03-04")
212
212
  @obj.title = "Of Mice and Men, The Sequel"
213
213
  @obj.publisher = "Bob's Blogtastic Publishing"
@@ -223,21 +223,21 @@ describe ActiveFedora::NtriplesRDFDatastream do
223
223
 
224
224
  describe ".fields()" do
225
225
  it "should return the right fields" do
226
- @obj.send(:fields).keys.should == ["created", "title", "publisher", "based_near", "related_url"]
226
+ expect(@obj.send(:fields).keys).to eq(["created", "title", "publisher", "based_near", "related_url"])
227
227
  end
228
228
  it "should return the right values" do
229
229
  fields = @obj.send(:fields)
230
- fields[:related_url][:values].should == ["http://example.org/blogtastic/"]
231
- fields[:based_near][:values].should == ["Tacoma, WA", "Renton, WA"]
230
+ expect(fields[:related_url][:values]).to eq(["http://example.org/blogtastic/"])
231
+ expect(fields[:based_near][:values]).to eq(["Tacoma, WA", "Renton, WA"])
232
232
  end
233
233
  it "should return the right type information" do
234
234
  fields = @obj.send(:fields)
235
- fields[:created][:type].should == :date
235
+ expect(fields[:created][:type]).to eq(:date)
236
236
  end
237
237
  end
238
238
  describe ".to_solr()" do
239
239
  it "should return the right fields" do
240
- @obj.to_solr.keys.should include(ActiveFedora::SolrService.solr_name("solr_rdf__related_url", type: :string),
240
+ expect(@obj.to_solr.keys).to include(ActiveFedora::SolrService.solr_name("solr_rdf__related_url", type: :string),
241
241
  ActiveFedora::SolrService.solr_name("solr_rdf__publisher", type: :string),
242
242
  ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :sortable),
243
243
  ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :facetable),
@@ -251,8 +251,8 @@ describe ActiveFedora::NtriplesRDFDatastream do
251
251
  end
252
252
 
253
253
  it "should return the right values" do
254
- @obj.to_solr[ActiveFedora::SolrService.solr_name("solr_rdf__related_url", type: :string)].should == ["http://example.org/blogtastic/"]
255
- @obj.to_solr[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", type: :string)].should == ["Tacoma, WA","Renton, WA"]
254
+ expect(@obj.to_solr[ActiveFedora::SolrService.solr_name("solr_rdf__related_url", type: :string)]).to eq(["http://example.org/blogtastic/"])
255
+ expect(@obj.to_solr[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", type: :string)]).to eq(["Tacoma, WA","Renton, WA"])
256
256
  end
257
257
  end
258
258
  end
@@ -21,14 +21,14 @@ describe ActiveFedora::OmDatastream do
21
21
  before(:each) do
22
22
  @mock_inner = double('inner object')
23
23
  @mock_repo = double('repository')
24
- @mock_repo.stub(:datastream_dissemination=>'My Content', :config=>{}, :datastream_profile=>{})
25
- @mock_inner.stub(:repository).and_return(@mock_repo)
26
- @mock_inner.stub(:pid)
27
- @mock_inner.stub(:new_record? => false)
24
+ allow(@mock_repo).to receive_messages(:datastream_dissemination=>'My Content', :config=>{}, :datastream_profile=>{})
25
+ allow(@mock_inner).to receive(:repository).and_return(@mock_repo)
26
+ allow(@mock_inner).to receive(:pid)
27
+ allow(@mock_inner).to receive_messages(:new_record? => false)
28
28
  @test_ds = ActiveFedora::OmDatastream.new(@mock_inner, "descMetadata")
29
- @test_ds.stub(:new? => false, :profile => {}, :datastream_content => '<test_xml/>')
29
+ allow(@test_ds).to receive_messages(:new? => false, :profile => {}, :datastream_content => '<test_xml/>')
30
30
  @test_ds.content="<test_xml/>"
31
- @test_ds.stub(:new? => false)
31
+ allow(@test_ds).to receive_messages(:new? => false)
32
32
  end
33
33
 
34
34
  its(:metadata?) { should be true}
@@ -36,36 +36,36 @@ describe ActiveFedora::OmDatastream do
36
36
  its(:controlGroup) { should == "M"}
37
37
 
38
38
  it "should include the Solrizer::XML::TerminologyBasedSolrizer for .to_solr support" do
39
- ActiveFedora::OmDatastream.included_modules.should include(OM::XML::TerminologyBasedSolrizer)
39
+ expect(ActiveFedora::OmDatastream.included_modules).to include(OM::XML::TerminologyBasedSolrizer)
40
40
  end
41
41
 
42
42
  describe '#new' do
43
43
  it 'should provide #new' do
44
- ActiveFedora::OmDatastream.should respond_to(:new)
45
- @test_ds.ng_xml.should be_instance_of(Nokogiri::XML::Document)
44
+ expect(ActiveFedora::OmDatastream).to respond_to(:new)
45
+ expect(@test_ds.ng_xml).to be_instance_of(Nokogiri::XML::Document)
46
46
  end
47
47
  it 'should load xml from blob if provided' do
48
48
  test_ds1 = ActiveFedora::OmDatastream.new(nil, 'ds1')
49
49
  test_ds1.content="<xml><foo/></xml>"
50
- test_ds1.ng_xml.to_xml.should be_equivalent_to("<?xml version=\"1.0\"?>\n<xml>\n <foo/>\n</xml>\n")
50
+ expect(test_ds1.ng_xml.to_xml).to be_equivalent_to("<?xml version=\"1.0\"?>\n<xml>\n <foo/>\n</xml>\n")
51
51
  end
52
52
  it "should initialize from #xml_template if no xml is provided" do
53
- ActiveFedora::OmDatastream.should_receive(:xml_template).and_return("<fake template/>")
53
+ expect(ActiveFedora::OmDatastream).to receive(:xml_template).and_return("<fake template/>")
54
54
  n = ActiveFedora::OmDatastream.new
55
- n.ng_xml.should be_equivalent_to("<fake template/>")
55
+ expect(n.ng_xml).to be_equivalent_to("<fake template/>")
56
56
  end
57
57
  end
58
58
 
59
59
  describe "#prefix" do
60
60
  subject { ActiveFedora::OmDatastream.new(nil, 'descMetadata') }
61
61
  it "should be \"\#{dsid.underscore}__\"" do
62
- subject.send(:prefix).should == "desc_metadata__"
62
+ expect(subject.send(:prefix)).to eq("desc_metadata__")
63
63
  end
64
64
  end
65
65
 
66
66
  describe '#xml_template' do
67
67
  it "should return an empty xml document" do
68
- ActiveFedora::OmDatastream.xml_template.to_xml.should be_equivalent_to("<?xml version=\"1.0\"?>\n<xml/>\n")
68
+ expect(ActiveFedora::OmDatastream.xml_template.to_xml).to be_equivalent_to("<?xml version=\"1.0\"?>\n<xml/>\n")
69
69
  end
70
70
  end
71
71
 
@@ -116,25 +116,25 @@ describe ActiveFedora::OmDatastream do
116
116
 
117
117
  it "should apply submitted hash to corresponding datastream field values" do
118
118
  result = @mods_ds.update_indexed_attributes( {[{":person"=>"0"}, "role"]=>{"0"=>"role1", "1"=>"role2", "2"=>"role3"} })
119
- result.should == {"person_0_role"=>["role1", "role2", "role3"]}
120
- @mods_ds.property_values('//oxns:name[@type="personal"][1]/oxns:role').should == ["role1","role2","role3"]
119
+ expect(result).to eq({"person_0_role"=>["role1", "role2", "role3"]})
120
+ expect(@mods_ds.property_values('//oxns:name[@type="personal"][1]/oxns:role')).to eq(["role1","role2","role3"])
121
121
  end
122
122
  it "should support single-value arguments (as opposed to a hash of values with array indexes as keys)" do
123
123
  # In other words, { "fubar"=>"dork" } should have the same effect as { "fubar"=>{"0"=>"dork"} }
124
124
  result = @mods_ds.update_indexed_attributes( { [{":person"=>"0"}, "role"]=>"the role" } )
125
- result.should == {"person_0_role"=>["the role"]}
126
- @mods_ds.term_values('//oxns:name[@type="personal"][1]/oxns:role').first.should == "the role"
125
+ expect(result).to eq({"person_0_role"=>["the role"]})
126
+ expect(@mods_ds.term_values('//oxns:name[@type="personal"][1]/oxns:role').first).to eq("the role")
127
127
  end
128
128
  it "should do nothing if field key is a string (must be an array or symbol). Will not accept xpath queries!" do
129
129
  xml_before = @mods_ds.to_xml
130
130
  expect(ActiveFedora::Base.logger).to receive(:warn).with "WARNING: descMetadata ignoring {\"fubar\" => \"the role\"} because \"fubar\" is a String (only valid OM Term Pointers will be used). Make sure your html has the correct field_selector tags in it."
131
- @mods_ds.update_indexed_attributes( { "fubar"=>"the role" } ).should == {}
132
- @mods_ds.to_xml.should == xml_before
131
+ expect(@mods_ds.update_indexed_attributes( { "fubar"=>"the role" } )).to eq({})
132
+ expect(@mods_ds.to_xml).to eq(xml_before)
133
133
  end
134
134
  it "should do nothing if there is no accessor corresponding to the given field key" do
135
135
  xml_before = @mods_ds.to_xml
136
- @mods_ds.update_indexed_attributes( { [{"fubar"=>"0"}]=>"the role" } ).should == {}
137
- @mods_ds.to_xml.should == xml_before
136
+ expect(@mods_ds.update_indexed_attributes( { [{"fubar"=>"0"}]=>"the role" } )).to eq({})
137
+ expect(@mods_ds.to_xml).to eq(xml_before)
138
138
  end
139
139
 
140
140
  ### Examples copied over form metadata_datastream_spec
@@ -142,30 +142,30 @@ describe ActiveFedora::OmDatastream do
142
142
  it "should work for text fields" do
143
143
  att= {[{"person"=>"0"},"description"]=>{"-1"=>"mork", "1"=>"york"}}
144
144
  result = @mods_ds.update_indexed_attributes(att)
145
- result.should == {"person_0_description"=>["mork","york"]}
146
- @mods_ds.get_values([{:person=>0},:description]).should == ['mork', 'york']
145
+ expect(result).to eq({"person_0_description"=>["mork","york"]})
146
+ expect(@mods_ds.get_values([{:person=>0},:description])).to eq(['mork', 'york'])
147
147
  att= {[{"person"=>"0"},"description"]=>{"-1"=>"dork"}}
148
148
  result2 = @mods_ds.update_indexed_attributes(att)
149
- result2.should == {"person_0_description"=>["dork"]}
150
- @mods_ds.get_values([{:person=>0},:description]).should == ['dork']
149
+ expect(result2).to eq({"person_0_description"=>["dork"]})
150
+ expect(@mods_ds.get_values([{:person=>0},:description])).to eq(['dork'])
151
151
  end
152
152
 
153
153
  it "should allow deleting of values and should delete values so that to_xml does not return emtpy nodes" do
154
154
  att= {[{"person"=>"0"},"description"]=>{"0"=>"york", "1"=>"mangle","2"=>"mork"}}
155
155
  @mods_ds.update_indexed_attributes(att)
156
- @mods_ds.get_values([{"person"=>"0"},"description"]).should == ['york', 'mangle', 'mork']
156
+ expect(@mods_ds.get_values([{"person"=>"0"},"description"])).to eq(['york', 'mangle', 'mork'])
157
157
 
158
158
  @mods_ds.update_indexed_attributes({[{"person"=>"0"},{"description" => '1'} ]=> nil})
159
- @mods_ds.get_values([{"person"=>"0"},"description"]).should == ['york', 'mork']
159
+ expect(@mods_ds.get_values([{"person"=>"0"},"description"])).to eq(['york', 'mork'])
160
160
 
161
161
  @mods_ds.update_indexed_attributes({[{"person"=>"0"},{"description" => '0'}]=>:delete})
162
- @mods_ds.get_values([{"person"=>"0"},"description"]).should == ['mork']
162
+ expect(@mods_ds.get_values([{"person"=>"0"},"description"])).to eq(['mork'])
163
163
  end
164
164
 
165
165
  it "should set changed to true" do
166
- @mods_ds.get_values([{:title_info=>0},:main_title]).should == ["ARTICLE TITLE", "TITLE OF HOST JOURNAL"]
166
+ expect(@mods_ds.get_values([{:title_info=>0},:main_title])).to eq(["ARTICLE TITLE", "TITLE OF HOST JOURNAL"])
167
167
  @mods_ds.update_indexed_attributes [{"title_info"=>"0"},"main_title"]=>{"-1"=>"mork"}
168
- @mods_ds.should be_changed
168
+ expect(@mods_ds).to be_changed
169
169
  end
170
170
  end
171
171
 
@@ -177,92 +177,92 @@ describe ActiveFedora::OmDatastream do
177
177
  end
178
178
 
179
179
  it "should call lookup with field_name and return the text values from each resulting node" do
180
- @mods_ds.should_receive(:term_values).with("--my xpath--").and_return(["value1", "value2"])
181
- @mods_ds.get_values("--my xpath--").should == ["value1", "value2"]
180
+ expect(@mods_ds).to receive(:term_values).with("--my xpath--").and_return(["value1", "value2"])
181
+ expect(@mods_ds.get_values("--my xpath--")).to eq(["value1", "value2"])
182
182
  end
183
183
  it "should assume that field_names that are strings are xpath queries" do
184
- ActiveFedora::OmDatastream.should_receive(:accessor_xpath).never
185
- @mods_ds.should_receive(:term_values).with("--my xpath--").and_return(["abstract1", "abstract2"])
186
- @mods_ds.get_values("--my xpath--").should == ["abstract1", "abstract2"]
184
+ expect(ActiveFedora::OmDatastream).to receive(:accessor_xpath).never
185
+ expect(@mods_ds).to receive(:term_values).with("--my xpath--").and_return(["abstract1", "abstract2"])
186
+ expect(@mods_ds.get_values("--my xpath--")).to eq(["abstract1", "abstract2"])
187
187
  end
188
188
  end
189
189
 
190
190
  describe '.save' do
191
191
  it "should provide .save" do
192
- @test_ds.should respond_to(:save)
192
+ expect(@test_ds).to respond_to(:save)
193
193
  end
194
194
  it "should persist the product of .to_xml in fedora" do
195
- @mock_repo.stub(:datastream).and_return('')
196
- @test_ds.stub(:new? => true)
197
- @test_ds.stub(:ng_xml_changed? => true)
198
- @test_ds.stub(:to_xml => "fake xml")
199
- @mock_repo.should_receive(:add_datastream).with(:pid => nil, :dsid => 'descMetadata', :versionable => true, :content => 'fake xml', :controlGroup => 'M', :dsState => 'A', :mimeType=>'text/xml')
195
+ allow(@mock_repo).to receive(:datastream).and_return('')
196
+ allow(@test_ds).to receive_messages(:new? => true)
197
+ allow(@test_ds).to receive_messages(:ng_xml_changed? => true)
198
+ allow(@test_ds).to receive_messages(:to_xml => "fake xml")
199
+ expect(@mock_repo).to receive(:add_datastream).with(:pid => nil, :dsid => 'descMetadata', :versionable => true, :content => 'fake xml', :controlGroup => 'M', :dsState => 'A', :mimeType=>'text/xml')
200
200
 
201
201
  @test_ds.serialize!
202
202
  @test_ds.save
203
- @test_ds.mimeType.should == 'text/xml'
203
+ expect(@test_ds.mimeType).to eq('text/xml')
204
204
  end
205
205
  end
206
206
 
207
207
  describe 'setting content' do
208
208
  subject { ActiveFedora::OmDatastream.new(@mock_inner, "descMetadata") }
209
209
  it "should update the content" do
210
- subject.stub(:new? => false )
210
+ allow(subject).to receive_messages(:new? => false )
211
211
  subject.content = "<a />"
212
- subject.content.should == '<a/>'
212
+ expect(subject.content).to eq('<a/>')
213
213
  end
214
214
 
215
215
  it "should mark the object as changed" do
216
- subject.stub(:new? => false, :controlGroup => 'M')
216
+ allow(subject).to receive_messages(:new? => false, :controlGroup => 'M')
217
217
  subject.content = "<a />"
218
- subject.should be_changed
218
+ expect(subject).to be_changed
219
219
  end
220
220
 
221
221
  it "update ngxml and mark the xml as loaded" do
222
- subject.stub(:new? => false )
222
+ allow(subject).to receive_messages(:new? => false )
223
223
  subject.content = "<a />"
224
- subject.ng_xml.to_xml.should =~ /<a\/>/
225
- subject.xml_loaded.should be true
224
+ expect(subject.ng_xml.to_xml).to match(/<a\/>/)
225
+ expect(subject.xml_loaded).to be true
226
226
  end
227
227
  end
228
228
 
229
229
  describe 'ng_xml=' do
230
230
  before do
231
- @mock_inner.stub(:new_record? => true)
231
+ allow(@mock_inner).to receive_messages(:new_record? => true)
232
232
  @test_ds2 = ActiveFedora::OmDatastream.new(@mock_inner, "descMetadata")
233
233
  end
234
234
  it "should parse raw xml for you" do
235
235
  @test_ds2.ng_xml = @sample_raw_xml
236
- @test_ds2.ng_xml.class.should == Nokogiri::XML::Document
237
- @test_ds2.ng_xml.to_xml.should be_equivalent_to(@sample_raw_xml)
236
+ expect(@test_ds2.ng_xml.class).to eq(Nokogiri::XML::Document)
237
+ expect(@test_ds2.ng_xml.to_xml).to be_equivalent_to(@sample_raw_xml)
238
238
  end
239
239
 
240
240
  it "Should always set a document when an Element is passed" do
241
241
  @test_ds2.ng_xml = Nokogiri::XML(@sample_raw_xml).xpath('//xmlelement').first
242
- @test_ds2.ng_xml.should be_kind_of Nokogiri::XML::Document
243
- @test_ds2.ng_xml.to_xml.should be_equivalent_to("<xmlelement/>")
242
+ expect(@test_ds2.ng_xml).to be_kind_of Nokogiri::XML::Document
243
+ expect(@test_ds2.ng_xml.to_xml).to be_equivalent_to("<xmlelement/>")
244
244
  end
245
245
  it "should mark the datastream as changed" do
246
- @test_ds2.stub(:new? => false, :controlGroup => 'M')
247
- @test_ds2.should_not be_changed
246
+ allow(@test_ds2).to receive_messages(:new? => false, :controlGroup => 'M')
247
+ expect(@test_ds2).not_to be_changed
248
248
  @test_ds2.ng_xml = @sample_raw_xml
249
- @test_ds2.should be_changed
249
+ expect(@test_ds2).to be_changed
250
250
  end
251
251
  end
252
252
 
253
253
  describe '.to_xml' do
254
254
  it "should provide .to_xml" do
255
- @test_ds.should respond_to(:to_xml)
255
+ expect(@test_ds).to respond_to(:to_xml)
256
256
  end
257
257
 
258
258
  it "should ng_xml.to_xml" do
259
- @test_ds.stub(:ng_xml => Nokogiri::XML::Document.parse("<text_document/>"))
260
- @test_ds.to_xml.should == "<text_document/>"
259
+ allow(@test_ds).to receive_messages(:ng_xml => Nokogiri::XML::Document.parse("<text_document/>"))
260
+ expect(@test_ds.to_xml).to eq("<text_document/>")
261
261
  end
262
262
 
263
263
  it 'should accept an optional Nokogiri::XML Document as an argument and insert its fields into that (mocked test)' do
264
264
  doc = Nokogiri::XML::Document.parse("<test_document/>")
265
- doc.root.should_receive(:add_child)#.with(@test_ds.ng_xml.root)
265
+ expect(doc.root).to receive(:add_child)#.with(@test_ds.ng_xml.root)
266
266
  @test_ds.to_xml(doc)
267
267
  end
268
268
 
@@ -270,15 +270,15 @@ describe ActiveFedora::OmDatastream do
270
270
  expected_result = "<test_document><foo/><test_xml/></test_document>"
271
271
  doc = Nokogiri::XML::Document.parse("<test_document><foo/></test_document>")
272
272
  result = @test_ds.to_xml(doc)
273
- doc.should be_equivalent_to expected_result
274
- result.should be_equivalent_to expected_result
273
+ expect(doc).to be_equivalent_to expected_result
274
+ expect(result).to be_equivalent_to expected_result
275
275
  end
276
276
 
277
277
  it 'should add to root of Nokogiri::XML::Documents, but add directly to the elements if a Nokogiri::XML::Node is passed in' do
278
278
  doc = Nokogiri::XML::Document.parse("<test_document/>")
279
279
  el = Nokogiri::XML::Node.new("test_element", Nokogiri::XML::Document.new)
280
- @test_ds.to_xml(doc).should be_equivalent_to "<test_document><test_xml/></test_document>"
281
- @test_ds.to_xml(el).should be_equivalent_to "<test_element/>"
280
+ expect(@test_ds.to_xml(doc)).to be_equivalent_to "<test_document><test_xml/></test_document>"
281
+ expect(@test_ds.to_xml(el)).to be_equivalent_to "<test_element/>"
282
282
  end
283
283
 
284
284
  end
@@ -286,7 +286,7 @@ describe ActiveFedora::OmDatastream do
286
286
  describe '.from_solr' do
287
287
  it "should set the internal_solr_doc attribute to the solr document passed in" do
288
288
  @test_ds.from_solr(@solr_doc)
289
- @test_ds.internal_solr_doc.should == @solr_doc
289
+ expect(@test_ds.internal_solr_doc).to eq(@solr_doc)
290
290
  end
291
291
  end
292
292
 
@@ -302,47 +302,47 @@ describe ActiveFedora::OmDatastream do
302
302
 
303
303
  it "should return correct values from solr_doc given different term pointers" do
304
304
  mock_term = double("OM::XML::Term")
305
- mock_term.stub(:type).and_return(:text)
305
+ allow(mock_term).to receive(:type).and_return(:text)
306
306
  mock_terminology = double("OM::XML::Terminology")
307
- mock_terminology.stub(:retrieve_term).and_return(mock_term)
308
- ActiveFedora::OmDatastream.stub(:terminology).and_return(mock_terminology)
307
+ allow(mock_terminology).to receive(:retrieve_term).and_return(mock_term)
308
+ allow(ActiveFedora::OmDatastream).to receive(:terminology).and_return(mock_terminology)
309
309
  @mods_ds.from_solr(@solr_doc)
310
310
  term_pointer = [:name,:role,:roleTerm]
311
- @mods_ds.get_values_from_solr(:name,:role,:roleTerm).should == ["creator","submitter","teacher"]
311
+ expect(@mods_ds.get_values_from_solr(:name,:role,:roleTerm)).to eq(["creator","submitter","teacher"])
312
312
  ar = @mods_ds.get_values_from_solr({:name=>0},:role,:roleTerm)
313
- ar.length.should == 2
314
- ar.include?("creator").should == true
315
- ar.include?("submitter").should == true
316
- @mods_ds.get_values_from_solr({:name=>1},:role,:roleTerm).should == ["teacher"]
317
- @mods_ds.get_values_from_solr({:name=>0},{:role=>0},:roleTerm).should == ["creator"]
318
- @mods_ds.get_values_from_solr({:name=>0},{:role=>1},:roleTerm).should == ["submitter"]
319
- @mods_ds.get_values_from_solr({:name=>0},{:role=>2},:roleTerm).should == []
320
- @mods_ds.get_values_from_solr({:name=>1},{:role=>0},:roleTerm).should == ["teacher"]
321
- @mods_ds.get_values_from_solr({:name=>1},{:role=>1},:roleTerm).should == []
313
+ expect(ar.length).to eq(2)
314
+ expect(ar.include?("creator")).to eq(true)
315
+ expect(ar.include?("submitter")).to eq(true)
316
+ expect(@mods_ds.get_values_from_solr({:name=>1},:role,:roleTerm)).to eq(["teacher"])
317
+ expect(@mods_ds.get_values_from_solr({:name=>0},{:role=>0},:roleTerm)).to eq(["creator"])
318
+ expect(@mods_ds.get_values_from_solr({:name=>0},{:role=>1},:roleTerm)).to eq(["submitter"])
319
+ expect(@mods_ds.get_values_from_solr({:name=>0},{:role=>2},:roleTerm)).to eq([])
320
+ expect(@mods_ds.get_values_from_solr({:name=>1},{:role=>0},:roleTerm)).to eq(["teacher"])
321
+ expect(@mods_ds.get_values_from_solr({:name=>1},{:role=>1},:roleTerm)).to eq([])
322
322
  ar = @mods_ds.get_values_from_solr(:name,{:role=>0},:roleTerm)
323
- ar.length.should == 2
324
- ar.include?("creator").should == true
325
- ar.include?("teacher").should == true
326
- @mods_ds.get_values_from_solr(:name,{:role=>1},:roleTerm).should == ["submitter"]
323
+ expect(ar.length).to eq(2)
324
+ expect(ar.include?("creator")).to eq(true)
325
+ expect(ar.include?("teacher")).to eq(true)
326
+ expect(@mods_ds.get_values_from_solr(:name,{:role=>1},:roleTerm)).to eq(["submitter"])
327
327
  end
328
328
  end
329
329
 
330
330
  describe '.has_solr_name?' do
331
331
  it "should return true if the given key exists in the solr document passed in" do
332
- @test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("test_ds__name_0_role_0_roleTerm", type: :string),@solr_doc).should == true
333
- @test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("test_ds__name_0_role_0_roleTerm", type: :string).to_sym,@solr_doc).should == true
334
- @test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("test_ds__name_1_role_1_roleTerm", type: :string),@solr_doc).should == false
332
+ expect(@test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("test_ds__name_0_role_0_roleTerm", type: :string),@solr_doc)).to eq(true)
333
+ expect(@test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("test_ds__name_0_role_0_roleTerm", type: :string).to_sym,@solr_doc)).to eq(true)
334
+ expect(@test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("test_ds__name_1_role_1_roleTerm", type: :string),@solr_doc)).to eq(false)
335
335
  #if not doc passed in should be new empty solr doc and always return false
336
- @test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("test_ds__name_0_role_0_roleTerm", type: :string)).should == false
336
+ expect(@test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("test_ds__name_0_role_0_roleTerm", type: :string))).to eq(false)
337
337
  end
338
338
  end
339
339
 
340
340
  describe '.is_hierarchical_term_pointer?' do
341
341
  it "should return true only if the pointer passed in is an array that contains a hash" do
342
- @test_ds.is_hierarchical_term_pointer?(*[:image,{:tag1=>1},:tag2]).should == true
343
- @test_ds.is_hierarchical_term_pointer?(*[:image,:tag1,{:tag2=>1}]).should == true
344
- @test_ds.is_hierarchical_term_pointer?(*[:image,:tag1,:tag2]).should == false
345
- @test_ds.is_hierarchical_term_pointer?(nil).should == false
342
+ expect(@test_ds.is_hierarchical_term_pointer?(*[:image,{:tag1=>1},:tag2])).to eq(true)
343
+ expect(@test_ds.is_hierarchical_term_pointer?(*[:image,:tag1,{:tag2=>1}])).to eq(true)
344
+ expect(@test_ds.is_hierarchical_term_pointer?(*[:image,:tag1,:tag2])).to eq(false)
345
+ expect(@test_ds.is_hierarchical_term_pointer?(nil)).to eq(false)
346
346
  end
347
347
  end
348
348
 
@@ -360,11 +360,11 @@ describe ActiveFedora::OmDatastream do
360
360
  rescue
361
361
  found_exception = true
362
362
  end
363
- found_exception.should == true
363
+ expect(found_exception).to eq(true)
364
364
  end
365
365
 
366
366
  it "should update a value internally call OM::XML::TermValueOperators::update_values if internal_solr_doc is not set" do
367
- @mods_ds.stub(:om_update_values).once()
367
+ allow(@mods_ds).to receive(:om_update_values).once()
368
368
  term_pointer = [:name,:role,:roleTerm]
369
369
  @mods_ds.update_values([{":person"=>"0"}, "role", "text"]=>{"0"=>"role1", "1"=>"role2", "2"=>"role3"})
370
370
  end
@@ -373,7 +373,7 @@ describe ActiveFedora::OmDatastream do
373
373
  mods_ds = Hydra::ModsArticleDatastream.new
374
374
  mods_ds.content=fixture(File.join("mods_articles","mods_article1.xml")).read
375
375
  mods_ds.update_values([{":person"=>"0"}, "role", "text"]=>{"0"=>"role1", "1"=>"role2", "2"=>"role3"})
376
- mods_ds.should be_changed
376
+ expect(mods_ds).to be_changed
377
377
  end
378
378
  end
379
379
 
@@ -385,7 +385,7 @@ describe ActiveFedora::OmDatastream do
385
385
  end
386
386
 
387
387
  it "should call OM::XML::term_values if internal_solr_doc is not set and return values from xml" do
388
- @mods_ds.stub(:om_term_values).once()
388
+ allow(@mods_ds).to receive(:om_term_values).once()
389
389
  term_pointer = [:name,:role,:roleTerm]
390
390
  @mods_ds.term_values(*term_pointer)
391
391
  end
@@ -394,7 +394,7 @@ describe ActiveFedora::OmDatastream do
394
394
  it "should call get_values_from_solr if internal_solr_doc is set" do
395
395
  @mods_ds.from_solr(@solr_doc)
396
396
  term_pointer = [:name,:role,:roleTerm]
397
- @mods_ds.stub(:get_values_from_solr).once()
397
+ allow(@mods_ds).to receive(:get_values_from_solr).once()
398
398
  @mods_ds.term_values(*term_pointer)
399
399
  end
400
400
  end
@@ -414,8 +414,8 @@ describe ActiveFedora::OmDatastream do
414
414
  Object.send(:remove_const, :MyObj)
415
415
  end
416
416
  it "should not load the descMetadata datastream when calling content_changed?" do
417
- @obj.inner_object.repository.should_not_receive(:datastream_dissemination).with(hash_including(:dsid=>'descMetadata'))
418
- @obj.descMetadata.should_not be_content_changed
417
+ expect(@obj.inner_object.repository).not_to receive(:datastream_dissemination).with(hash_including(:dsid=>'descMetadata'))
418
+ expect(@obj.descMetadata).not_to be_content_changed
419
419
  end
420
420
  end
421
421
  end