active-fedora 6.8.0 → 7.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +15 -5
  4. data/CONTRIBUTING.md +2 -0
  5. data/Gemfile +0 -2
  6. data/History.txt +2 -32
  7. data/README.md +143 -0
  8. data/Rakefile +5 -7
  9. data/active-fedora.gemspec +9 -9
  10. data/gemfiles/rails3.gemfile +11 -0
  11. data/gemfiles/rails4.gemfile +10 -0
  12. data/lib/active_fedora.rb +31 -4
  13. data/lib/active_fedora/association_relation.rb +18 -0
  14. data/lib/active_fedora/associations.rb +38 -171
  15. data/lib/active_fedora/associations/association.rb +163 -0
  16. data/lib/active_fedora/associations/association_scope.rb +39 -0
  17. data/lib/active_fedora/associations/belongs_to_association.rb +47 -25
  18. data/lib/active_fedora/associations/builder/association.rb +55 -0
  19. data/lib/active_fedora/associations/builder/belongs_to.rb +100 -0
  20. data/lib/active_fedora/associations/builder/collection_association.rb +56 -0
  21. data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +30 -0
  22. data/lib/active_fedora/associations/builder/has_many.rb +63 -0
  23. data/lib/active_fedora/associations/builder/singular_association.rb +32 -0
  24. data/lib/active_fedora/associations/{association_collection.rb → collection_association.rb} +203 -53
  25. data/lib/active_fedora/associations/collection_proxy.rb +862 -0
  26. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +35 -25
  27. data/lib/active_fedora/associations/has_many_association.rb +36 -11
  28. data/lib/active_fedora/associations/singular_association.rb +62 -0
  29. data/lib/active_fedora/attributes.rb +43 -139
  30. data/lib/active_fedora/autosave_association.rb +317 -0
  31. data/lib/active_fedora/base.rb +10 -327
  32. data/lib/active_fedora/callbacks.rb +1 -3
  33. data/lib/active_fedora/content_model.rb +16 -0
  34. data/lib/active_fedora/core.rb +151 -0
  35. data/lib/active_fedora/datastream_attribute.rb +76 -0
  36. data/lib/active_fedora/datastream_hash.rb +8 -13
  37. data/lib/active_fedora/datastreams.rb +39 -26
  38. data/lib/active_fedora/digital_object.rb +2 -2
  39. data/lib/active_fedora/fedora_attributes.rb +45 -0
  40. data/lib/active_fedora/fixture_loader.rb +1 -1
  41. data/lib/active_fedora/indexing.rb +6 -1
  42. data/lib/active_fedora/model.rb +0 -17
  43. data/lib/active_fedora/nested_attributes.rb +2 -2
  44. data/lib/active_fedora/null_relation.rb +7 -0
  45. data/lib/active_fedora/om_datastream.rb +3 -4
  46. data/lib/active_fedora/persistence.rb +41 -29
  47. data/lib/active_fedora/querying.rb +2 -163
  48. data/lib/active_fedora/rdf.rb +1 -0
  49. data/lib/active_fedora/rdf/indexing.rb +67 -0
  50. data/lib/active_fedora/rdf_datastream.rb +2 -50
  51. data/lib/active_fedora/rdf_node.rb +12 -7
  52. data/lib/active_fedora/rdf_node/term_proxy.rb +30 -21
  53. data/lib/active_fedora/rdfxml_rdf_datastream.rb +1 -1
  54. data/lib/active_fedora/reflection.rb +163 -20
  55. data/lib/active_fedora/relation.rb +33 -130
  56. data/lib/active_fedora/relation/calculations.rb +19 -0
  57. data/lib/active_fedora/relation/delegation.rb +22 -0
  58. data/lib/active_fedora/relation/finder_methods.rb +247 -0
  59. data/lib/active_fedora/relation/merger.rb +22 -0
  60. data/lib/active_fedora/relation/query_methods.rb +58 -0
  61. data/lib/active_fedora/relation/spawn_methods.rb +46 -0
  62. data/lib/active_fedora/relationship_graph.rb +0 -2
  63. data/lib/active_fedora/rels_ext_datastream.rb +1 -4
  64. data/lib/active_fedora/rubydora_connection.rb +1 -1
  65. data/lib/active_fedora/scoping.rb +20 -0
  66. data/lib/active_fedora/scoping/default.rb +38 -0
  67. data/lib/active_fedora/scoping/named.rb +32 -0
  68. data/lib/active_fedora/semantic_node.rb +54 -106
  69. data/lib/active_fedora/serialization.rb +19 -0
  70. data/lib/active_fedora/sharding.rb +58 -0
  71. data/lib/active_fedora/solr_digital_object.rb +15 -5
  72. data/lib/active_fedora/solr_instance_loader.rb +1 -1
  73. data/lib/active_fedora/solr_service.rb +1 -1
  74. data/lib/active_fedora/unsaved_digital_object.rb +6 -4
  75. data/lib/active_fedora/version.rb +1 -1
  76. data/lib/tasks/active_fedora.rake +3 -0
  77. data/lib/tasks/active_fedora_dev.rake +6 -5
  78. data/spec/config_helper.rb +14 -14
  79. data/spec/integration/associations_spec.rb +168 -455
  80. data/spec/integration/attributes_spec.rb +12 -11
  81. data/spec/integration/auditable_spec.rb +11 -11
  82. data/spec/integration/autosave_association_spec.rb +25 -0
  83. data/spec/integration/base_spec.rb +163 -163
  84. data/spec/integration/belongs_to_association_spec.rb +166 -0
  85. data/spec/integration/bug_spec.rb +7 -7
  86. data/spec/integration/collection_association_spec.rb +58 -0
  87. data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
  88. data/spec/integration/datastream_collections_spec.rb +69 -69
  89. data/spec/integration/datastream_spec.rb +43 -43
  90. data/spec/integration/datastreams_spec.rb +63 -63
  91. data/spec/integration/delete_all_spec.rb +46 -39
  92. data/spec/integration/fedora_solr_sync_spec.rb +5 -5
  93. data/spec/integration/field_to_solr_name_spec.rb +34 -0
  94. data/spec/integration/full_featured_model_spec.rb +100 -101
  95. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +341 -0
  96. data/spec/integration/has_many_associations_spec.rb +172 -24
  97. data/spec/integration/json_serialization_spec.rb +31 -0
  98. data/spec/integration/load_from_solr_spec.rb +48 -0
  99. data/spec/integration/model_spec.rb +35 -40
  100. data/spec/integration/nested_attribute_spec.rb +42 -43
  101. data/spec/integration/ntriples_datastream_spec.rb +131 -113
  102. data/spec/integration/om_datastream_spec.rb +67 -67
  103. data/spec/integration/persistence_spec.rb +7 -7
  104. data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
  105. data/spec/integration/relation_delegation_spec.rb +26 -25
  106. data/spec/integration/relation_spec.rb +42 -0
  107. data/spec/integration/rels_ext_datastream_spec.rb +20 -20
  108. data/spec/integration/scoped_query_spec.rb +61 -51
  109. data/spec/integration/solr_instance_loader_spec.rb +5 -5
  110. data/spec/integration/solr_service_spec.rb +46 -46
  111. data/spec/samples/hydra-mods_article_datastream.rb +334 -334
  112. data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
  113. data/spec/samples/marpa-dc_datastream.rb +17 -17
  114. data/spec/samples/models/audio_record.rb +16 -16
  115. data/spec/samples/models/image.rb +2 -2
  116. data/spec/samples/models/mods_article.rb +5 -5
  117. data/spec/samples/models/oral_history.rb +18 -18
  118. data/spec/samples/models/seminar.rb +24 -24
  119. data/spec/samples/models/seminar_audio_file.rb +17 -17
  120. data/spec/samples/oral_history_sample_model.rb +21 -21
  121. data/spec/samples/special_thing.rb +14 -14
  122. data/spec/spec_helper.rb +11 -7
  123. data/spec/support/an_active_model.rb +2 -8
  124. data/spec/support/freeze_mocks.rb +12 -0
  125. data/spec/support/mock_fedora.rb +17 -16
  126. data/spec/unit/active_fedora_spec.rb +58 -60
  127. data/spec/unit/attributes_spec.rb +314 -0
  128. data/spec/unit/base_active_model_spec.rb +28 -27
  129. data/spec/unit/base_cma_spec.rb +5 -5
  130. data/spec/unit/base_datastream_management_spec.rb +27 -27
  131. data/spec/unit/base_extra_spec.rb +76 -48
  132. data/spec/unit/base_spec.rb +277 -348
  133. data/spec/unit/callback_spec.rb +18 -19
  134. data/spec/unit/code_configurator_spec.rb +17 -17
  135. data/spec/unit/config_spec.rb +8 -16
  136. data/spec/unit/content_model_spec.rb +79 -60
  137. data/spec/unit/datastream_collections_spec.rb +229 -229
  138. data/spec/unit/datastream_spec.rb +51 -63
  139. data/spec/unit/datastreams_spec.rb +87 -87
  140. data/spec/unit/file_configurator_spec.rb +217 -217
  141. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +44 -25
  142. data/spec/unit/has_many_collection_spec.rb +26 -8
  143. data/spec/unit/inheritance_spec.rb +13 -12
  144. data/spec/unit/model_spec.rb +39 -45
  145. data/spec/unit/nom_datastream_spec.rb +15 -15
  146. data/spec/unit/ntriples_datastream_spec.rb +123 -118
  147. data/spec/unit/om_datastream_spec.rb +227 -233
  148. data/spec/unit/persistence_spec.rb +34 -15
  149. data/spec/unit/predicates_spec.rb +73 -73
  150. data/spec/unit/property_spec.rb +17 -9
  151. data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
  152. data/spec/unit/query_spec.rb +222 -198
  153. data/spec/unit/rdf_datastream_spec.rb +21 -28
  154. data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
  155. data/spec/unit/rdf_list_spec.rb +65 -64
  156. data/spec/unit/rdf_node_spec.rb +7 -7
  157. data/spec/unit/rdf_xml_writer_spec.rb +10 -10
  158. data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
  159. data/spec/unit/relationship_graph_spec.rb +51 -51
  160. data/spec/unit/rels_ext_datastream_spec.rb +68 -74
  161. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
  162. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
  163. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
  164. data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
  165. data/spec/unit/rubydora_connection_spec.rb +5 -5
  166. data/spec/unit/semantic_node_spec.rb +48 -107
  167. data/spec/unit/serializers_spec.rb +4 -4
  168. data/spec/unit/service_definitions_spec.rb +26 -26
  169. data/spec/unit/simple_datastream_spec.rb +17 -17
  170. data/spec/unit/solr_config_options_spec.rb +29 -28
  171. data/spec/unit/solr_digital_object_spec.rb +17 -25
  172. data/spec/unit/solr_service_spec.rb +95 -82
  173. data/spec/unit/unsaved_digital_object_spec.rb +24 -23
  174. data/spec/unit/validations_spec.rb +21 -21
  175. metadata +110 -159
  176. data/.rspec +0 -1
  177. data/.rubocop.yml +0 -1
  178. data/.rubocop_todo.yml +0 -938
  179. data/CONSOLE_GETTING_STARTED.textile +0 -1
  180. data/NOKOGIRI_DATASTREAMS.textile +0 -1
  181. data/README.textile +0 -116
  182. data/lib/active_fedora/associations/association_proxy.rb +0 -178
  183. data/lib/active_fedora/delegating.rb +0 -72
  184. data/lib/active_fedora/nokogiri_datastream.rb +0 -11
  185. data/spec/integration/delegating_spec.rb +0 -59
  186. data/spec/rails3_test_app/.gitignore +0 -4
  187. data/spec/rails3_test_app/.rspec +0 -1
  188. data/spec/rails3_test_app/Gemfile +0 -40
  189. data/spec/rails3_test_app/Rakefile +0 -7
  190. data/spec/rails3_test_app/app/controllers/application_controller.rb +0 -3
  191. data/spec/rails3_test_app/app/helpers/application_helper.rb +0 -2
  192. data/spec/rails3_test_app/app/views/layouts/application.html.erb +0 -14
  193. data/spec/rails3_test_app/config.ru +0 -4
  194. data/spec/rails3_test_app/config/application.rb +0 -42
  195. data/spec/rails3_test_app/config/boot.rb +0 -6
  196. data/spec/rails3_test_app/config/database.yml +0 -22
  197. data/spec/rails3_test_app/config/environment.rb +0 -5
  198. data/spec/rails3_test_app/config/environments/development.rb +0 -25
  199. data/spec/rails3_test_app/config/environments/production.rb +0 -49
  200. data/spec/rails3_test_app/config/environments/test.rb +0 -35
  201. data/spec/rails3_test_app/config/initializers/backtrace_silencers.rb +0 -7
  202. data/spec/rails3_test_app/config/initializers/inflections.rb +0 -10
  203. data/spec/rails3_test_app/config/initializers/mime_types.rb +0 -5
  204. data/spec/rails3_test_app/config/initializers/secret_token.rb +0 -7
  205. data/spec/rails3_test_app/config/initializers/session_store.rb +0 -8
  206. data/spec/rails3_test_app/config/locales/en.yml +0 -5
  207. data/spec/rails3_test_app/config/routes.rb +0 -58
  208. data/spec/rails3_test_app/db/seeds.rb +0 -7
  209. data/spec/rails3_test_app/run_tests +0 -3
  210. data/spec/rails3_test_app/script/rails +0 -6
  211. data/spec/rails3_test_app/spec/spec_helper.rb +0 -27
  212. data/spec/rails3_test_app/spec/unit/rails_3_init.rb +0 -15
  213. data/spec/unit/association_proxy_spec.rb +0 -12
  214. data/spec/unit/base_delegate_spec.rb +0 -197
  215. data/spec/unit/base_delegate_to_spec.rb +0 -73
@@ -2,24 +2,33 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::NtriplesRDFDatastream do
4
4
  before do
5
+
6
+ class FileVocabulary < RDF::Vocabulary("http://downlode.org/Code/RDF/File_Properties/schema#")
7
+ property :size
8
+ end
9
+
5
10
  class MyDatastream < ActiveFedora::NtriplesRDFDatastream
6
11
  map_predicates do |map|
7
- map.title(:in => RDF::DC) do |index|
12
+ map.title(in: RDF::DC) do |index|
8
13
  index.as :stored_searchable, :facetable
9
14
  end
10
- map.date_uploaded(:to => 'dateSubmitted', :in => RDF::DC) do |index|
15
+ map.date_uploaded(to: "dateSubmitted", in: RDF::DC) do |index|
11
16
  index.type :date
12
17
  index.as :stored_searchable, :sortable
13
18
  end
14
- map.part(:to => 'hasPart', :in => RDF::DC)
15
- map.based_near(:in => RDF::FOAF)
16
- map.related_url(:to => 'seeAlso', :in => RDF::RDFS)
19
+ map.size(in: FileVocabulary) do |index|
20
+ index.type :integer
21
+ index.as :stored_sortable
22
+ end
23
+ map.part(to: "hasPart", in: RDF::DC)
24
+ map.based_near(in: RDF::FOAF)
25
+ map.related_url(to: "seeAlso", in: RDF::RDFS)
17
26
  end
18
27
  end
19
- class RdfTest < ActiveFedora::Base
20
- has_metadata :name => 'rdf', :type => MyDatastream
21
- delegate_to 'rdf', [:based_near, :related_url, :part, :date_uploaded], multiple: true
22
- delegate :title, to: 'rdf', multiple: false
28
+ class RdfTest < ActiveFedora::Base
29
+ has_metadata :name=>'rdf', :type=>MyDatastream
30
+ has_attributes :based_near, :related_url, :part, :date_uploaded, datastream: 'rdf', multiple: true
31
+ has_attributes :title, :size, datastream: 'rdf', multiple: false
23
32
  end
24
33
  @subject = RdfTest.new
25
34
  end
@@ -31,107 +40,116 @@ describe ActiveFedora::NtriplesRDFDatastream do
31
40
  after do
32
41
  Object.send(:remove_const, :RdfTest)
33
42
  Object.send(:remove_const, :MyDatastream)
43
+ Object.send(:remove_const, :FileVocabulary)
34
44
  end
35
45
 
36
- it 'should not try to send an empty datastream' do
46
+ it "should not try to send an empty datastream" do
37
47
  @subject.save
38
48
  end
39
49
 
40
- it 'should save content properly upon save' do
41
- foo = RdfTest.new(:pid => 'test:1') #Pid needs to match the subject in the loaded file
50
+ it "should save content properly upon save" do
51
+ foo = RdfTest.new(:pid=>'test:1') #Pid needs to match the subject in the loaded file
42
52
  foo.title = 'Hamlet'
43
53
  foo.save
44
- expect(foo.title).to eq('Hamlet')
54
+ foo.title.should == 'Hamlet'
45
55
  foo.rdf.content = File.new('spec/fixtures/mixed_rdf_descMetadata.nt').read
46
56
  foo.save
47
- expect(foo.title).to eq('Title of work')
57
+ foo.title.should == 'Title of work'
48
58
  end
49
59
 
50
- it 'should delegate as_json to the fields' do
51
- @subject = RdfTest.new(title: 'Title of work')
52
- expect(@subject.rdf.title.as_json).to eq(['Title of work'])
53
- expect(@subject.rdf.title.to_json).to eq("\[\"Title of work\"\]")
60
+ it "should delegate as_json to the fields" do
61
+ @subject = RdfTest.new(title: "Title of work")
62
+ @subject.rdf.title.as_json.should == ["Title of work"]
63
+ @subject.rdf.title.to_json.should == "\[\"Title of work\"\]"
54
64
  end
55
65
 
56
- it 'should solrize even when the object is not new' do
66
+ it "should solrize even when the object is not new" do
57
67
  foo = RdfTest.new
58
- expect(foo).to receive(:update_index).once
59
- foo.title = 'title1'
68
+ foo.should_receive(:update_index).once
69
+ foo.title = "title1"
60
70
  foo.save
61
71
  foo = RdfTest.find(foo.pid)
62
- expect(foo).to receive(:update_index).once
63
- foo.title = 'The Work2'
64
- foo.save
72
+ foo.should_receive(:update_index).once
73
+ foo.title = "The Work2"
74
+ foo.save
65
75
  end
66
76
 
67
- it 'should serialize dates' do
68
- subject.date_uploaded = Date.parse('2012-11-02')
69
- expect(subject.date_uploaded.first).to be_kind_of Date
70
- solr_document = subject.to_solr
71
- expect(solr_document[ActiveFedora::SolrService.solr_name('rdf__date_uploaded', type: :date)]).to eq(['2012-11-02T00:00:00Z'])
77
+ describe "serializing" do
78
+ it "should handle dates" do
79
+ subject.date_uploaded = Date.parse('2012-11-02')
80
+ subject.date_uploaded.first.should be_kind_of Date
81
+ solr_document = subject.to_solr
82
+ solr_document[ActiveFedora::SolrService.solr_name('rdf__date_uploaded', type: :date)].should == ['2012-11-02T00:00:00Z']
83
+ end
84
+ it "should handle integers" do
85
+ subject.size = 12345
86
+ subject.size.should be_kind_of Fixnum
87
+ solr_document = subject.to_solr
88
+ solr_document[ActiveFedora::SolrService.solr_name('rdf__size', :stored_sortable, type: :integer)].should == '12345'
89
+ end
72
90
  end
73
91
 
74
- it 'should produce a solr document' do
75
- @subject = RdfTest.new(title: 'War and Peace')
92
+ it "should produce a solr document" do
93
+ @subject = RdfTest.new(title: "War and Peace")
76
94
  solr_document = @subject.to_solr
77
- expect(solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :facetable)]).to eq(['War and Peace'])
78
- expect(solr_document[ActiveFedora::SolrService.solr_name('rdf__title', type: :string)]).to eq(['War and Peace'])
95
+ solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :facetable)].should == ["War and Peace"]
96
+ solr_document[ActiveFedora::SolrService.solr_name('rdf__title', type: :string)].should == ["War and Peace"]
79
97
  end
80
98
 
81
- it 'should set and recall values' do
99
+ it "should set and recall values" do
82
100
  @subject.title = 'War and Peace'
83
- expect(@subject.rdf).to be_changed
84
- @subject.based_near = 'Moscow, Russia'
85
- @subject.related_url = 'http://en.wikipedia.org/wiki/War_and_Peace'
86
- @subject.part = 'this is a part'
101
+ @subject.rdf.should be_changed
102
+ @subject.based_near = "Moscow, Russia"
103
+ @subject.related_url = "http://en.wikipedia.org/wiki/War_and_Peace"
104
+ @subject.part = "this is a part"
87
105
  @subject.save
88
- expect(@subject.title).to eq('War and Peace')
89
- expect(@subject.based_near).to eq(['Moscow, Russia'])
90
- expect(@subject.related_url).to eq(['http://en.wikipedia.org/wiki/War_and_Peace'])
91
- expect(@subject.part).to eq(['this is a part'])
106
+ @subject.title.should == 'War and Peace'
107
+ @subject.based_near.should == ["Moscow, Russia"]
108
+ @subject.related_url.should == ["http://en.wikipedia.org/wiki/War_and_Peace"]
109
+ @subject.part.should == ["this is a part"]
92
110
  end
93
- it 'should set, persist, and recall values' do
111
+ it "should set, persist, and recall values" do
94
112
  @subject.title = 'War and Peace'
95
- @subject.based_near = 'Moscow, Russia'
96
- @subject.related_url = 'http://en.wikipedia.org/wiki/War_and_Peace'
97
- @subject.part = 'this is a part'
113
+ @subject.based_near = "Moscow, Russia"
114
+ @subject.related_url = "http://en.wikipedia.org/wiki/War_and_Peace"
115
+ @subject.part = "this is a part"
98
116
  @subject.save
99
117
 
100
118
  loaded = RdfTest.find(@subject.pid)
101
- expect(loaded.title).to eq('War and Peace')
102
- expect(loaded.based_near).to eq(['Moscow, Russia'])
103
- expect(loaded.related_url).to eq(['http://en.wikipedia.org/wiki/War_and_Peace'])
104
- expect(loaded.part).to eq(['this is a part'])
119
+ loaded.title.should == 'War and Peace'
120
+ loaded.based_near.should == ['Moscow, Russia']
121
+ loaded.related_url.should == ['http://en.wikipedia.org/wiki/War_and_Peace']
122
+ loaded.part.should == ['this is a part']
105
123
  end
106
- it 'should set multiple values' do
107
- @subject.part = ['part 1', 'part 2']
124
+ it "should set multiple values" do
125
+ @subject.part = ["part 1", "part 2"]
108
126
  @subject.save
109
127
 
110
128
  loaded = RdfTest.find(@subject.pid)
111
- expect(loaded.part).to eq(['part 1', 'part 2'])
129
+ loaded.part.should == ['part 1', 'part 2']
112
130
  end
113
- it 'should append values' do
114
- @subject.part = 'thing 1'
131
+ it "should append values" do
132
+ @subject.part = "thing 1"
115
133
  @subject.save
116
134
 
117
- @subject.part << 'thing 2'
118
- expect(@subject.part).to eq(['thing 1', 'thing 2'])
135
+ @subject.part << "thing 2"
136
+ @subject.part.should == ["thing 1", "thing 2"]
119
137
  end
120
138
 
121
- it 'should be able to save a blank document' do
122
- @subject.title = ''
139
+ it "should be able to save a blank document" do
140
+ @subject.title = ""
123
141
  @subject.save
124
142
  end
125
143
 
126
- it 'should load n-triples into the graph' do
144
+ it "should load n-triples into the graph" do
127
145
  ntrip = '<http://oregondigital.org/ns/62> <http://purl.org/dc/terms/type> "Image" .
128
146
  <http://oregondigital.org/ns/62> <http://purl.org/dc/terms/spatial> "Benton County (Ore.)" .
129
147
  '
130
148
  @subject.rdf.content = ntrip
131
- expect(@subject.rdf.graph.dump(:ntriples)).to eq(ntrip)
149
+ @subject.rdf.graph.dump(:ntriples).should == ntrip
132
150
  end
133
151
 
134
- describe 'using rdf_subject' do
152
+ describe "using rdf_subject" do
135
153
  before do
136
154
  # reopening existing class
137
155
  class MyDatastream < ActiveFedora::NtriplesRDFDatastream
@@ -146,12 +164,12 @@ describe ActiveFedora::NtriplesRDFDatastream do
146
164
  @subject.destroy
147
165
  end
148
166
 
149
- it 'should write rdf with proper subjects' do
167
+ it "should write rdf with proper subjects" do
150
168
  @subject.inner_object.pid = 'test:99'
151
- @subject.rdf.type = 'Frog'
169
+ @subject.rdf.type = "Frog"
152
170
  @subject.save!
153
171
  @subject.reload
154
- expect(@subject.rdf.graph.dump(:ntriples)).to eq("<http://oregondigital.org/ns/99> <http://purl.org/dc/terms/type> \"Frog\" .\n")
172
+ @subject.rdf.graph.dump(:ntriples).should == "<http://oregondigital.org/ns/99> <http://purl.org/dc/terms/type> \"Frog\" .\n"
155
173
  @subject.rdf.type == ['Frog']
156
174
 
157
175
  end
@@ -159,49 +177,49 @@ describe ActiveFedora::NtriplesRDFDatastream do
159
177
  end
160
178
 
161
179
 
162
- it 'should delete values' do
163
- @subject.title = 'Hamlet'
164
- @subject.related_url = 'http://psu.edu/'
165
- @subject.related_url << 'http://projecthydra.org/'
180
+ it "should delete values" do
181
+ @subject.title = "Hamlet"
182
+ @subject.related_url = "http://psu.edu/"
183
+ @subject.related_url << "http://projecthydra.org/"
166
184
 
167
- expect(@subject.title).to eq('Hamlet')
168
- expect(@subject.related_url).to include('http://psu.edu/')
169
- expect(@subject.related_url).to include('http://projecthydra.org/')
185
+ @subject.title.should == "Hamlet"
186
+ @subject.related_url.should include("http://psu.edu/")
187
+ @subject.related_url.should include("http://projecthydra.org/")
170
188
 
171
- @subject.title = '' #empty string can be meaningful, don't assume delete.
172
- expect(@subject.title).to eq('')
189
+ @subject.title = "" #empty string can be meaningful, don't assume delete.
190
+ @subject.title.should == ''
173
191
 
174
192
  @subject.title = nil
175
- @subject.related_url.delete('http://projecthydra.org/')
176
-
177
- expect(@subject.title).to be_nil
178
- expect(@subject.related_url).to eq(['http://psu.edu/'])
179
- end
180
- it 'should delete multiple values at once' do
181
- @subject.part = 'MacBeth'
182
- @subject.part << 'Hamlet'
183
- @subject.part << 'Romeo & Juliet'
184
- expect(@subject.part.first).to eq('MacBeth')
185
- @subject.part.delete('MacBeth', 'Romeo & Juliet')
186
- expect(@subject.part).to eq(['Hamlet'])
187
- expect(@subject.part.first).to eq('Hamlet')
188
- end
189
- it 'should ignore values to be deleted that do not exist' do
190
- @subject.part = ['title1', 'title2', 'title3']
191
- @subject.part.delete('title2', 'title4', 'title6')
192
- expect(@subject.part).to eq(['title1', 'title3'])
193
- end
194
- describe 'term proxy methods' do
193
+ @subject.related_url.delete("http://projecthydra.org/")
194
+
195
+ @subject.title.should be_nil
196
+ @subject.related_url.should == ["http://psu.edu/"]
197
+ end
198
+ it "should delete multiple values at once" do
199
+ @subject.part = "MacBeth"
200
+ @subject.part << "Hamlet"
201
+ @subject.part << "Romeo & Juliet"
202
+ @subject.part.first.should == "MacBeth"
203
+ @subject.part.delete("MacBeth", "Romeo & Juliet")
204
+ @subject.part.should == ["Hamlet"]
205
+ @subject.part.first.should == "Hamlet"
206
+ end
207
+ it "should ignore values to be deleted that do not exist" do
208
+ @subject.part = ["title1", "title2", "title3"]
209
+ @subject.part.delete("title2", "title4", "title6")
210
+ @subject.part.should == ["title1", "title3"]
211
+ end
212
+ describe "term proxy methods" do
195
213
  before(:each) do
196
214
  class TitleDatastream < ActiveFedora::NtriplesRDFDatastream
197
215
  map_predicates { |map| map.title(:in => RDF::DC) }
198
216
  end
199
- class Foobar < ActiveFedora::Base
200
- has_metadata :name => 'rdf', :type => TitleDatastream
201
- delegate :title, :to => 'rdf', multiple: true
217
+ class Foobar < ActiveFedora::Base
218
+ has_metadata :name=>'rdf', :type=>TitleDatastream
219
+ has_attributes :title, datastream: 'rdf', multiple: true
202
220
  end
203
221
  @subject = Foobar.new
204
- @subject.title = ['title1', 'title2', 'title3']
222
+ @subject.title = ["title1", "title2", "title3"]
205
223
  end
206
224
 
207
225
  after(:each) do
@@ -209,26 +227,26 @@ describe ActiveFedora::NtriplesRDFDatastream do
209
227
  Object.send(:remove_const, :TitleDatastream)
210
228
  end
211
229
 
212
- it 'should support the count method to determine # of values' do
213
- expect(@subject.title.count).to eq(3)
230
+ it "should support the count method to determine # of values" do
231
+ @subject.title.count.should == 3
214
232
  end
215
- it 'should iterate over multiple values' do
216
- expect(@subject.title).to respond_to(:each)
233
+ it "should iterate over multiple values" do
234
+ @subject.title.should respond_to(:each)
217
235
  end
218
- it 'should get the first value' do
219
- expect(@subject.title.first).to eq('title1')
236
+ it "should get the first value" do
237
+ @subject.title.first.should == "title1"
220
238
  end
221
- it 'should evaluate equality predictably' do
222
- expect(@subject.title).to eq(['title1', 'title2', 'title3'])
239
+ it "should evaluate equality predictably" do
240
+ @subject.title.should == ["title1", "title2", "title3"]
223
241
  end
224
- it 'should support the empty? method' do
225
- expect(@subject.title).to respond_to(:empty?)
226
- expect(@subject.title.empty?).to be_falsey
227
- @subject.title.delete('title1', 'title2', 'title3')
228
- expect(@subject.title.empty?).to be_truthy
242
+ it "should support the empty? method" do
243
+ @subject.title.should respond_to(:empty?)
244
+ @subject.title.empty?.should be_false
245
+ @subject.title.delete("title1", "title2", "title3")
246
+ @subject.title.empty?.should be_true
229
247
  end
230
- it 'should support the is_a? method' do
231
- expect(@subject.title.is_a?(Array)).to eq(true)
248
+ it "should support the is_a? method" do
249
+ @subject.title.is_a?(Array).should == true
232
250
  end
233
251
  end
234
252
  end
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
- require 'solrizer'
2
+ require "solrizer"
3
3
 
4
4
  describe ActiveFedora::OmDatastream do
5
-
6
- describe 'a new instance with an inline datastream' do
7
- before(:all) do
5
+
6
+ describe "a new instance with an inline datastream" do
7
+ before(:all) do
8
8
  class ModsArticle3 < ActiveFedora::Base
9
9
  # Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
10
- has_metadata 'descMetadata', type: Hydra::ModsArticleDatastream, control_group: 'X', autocreate: true
10
+ has_metadata :name => "descMetadata", :type => Hydra::ModsArticleDatastream, :control_group => 'X', :autocreate => true
11
11
  end
12
12
  end
13
13
 
@@ -25,38 +25,38 @@ describe ActiveFedora::OmDatastream do
25
25
  @obj.destroy
26
26
  end
27
27
 
28
- it 'should report being inline' do
29
- expect(@obj.descMetadata).to be_inline
28
+ it "should report being inline" do
29
+ @obj.descMetadata.should be_inline
30
30
  end
31
31
 
32
- it 'should not be changed when no fields have been set' do
33
- expect(@obj.descMetadata).not_to be_content_changed
32
+ it "should not be changed when no fields have been set" do
33
+ @obj.descMetadata.should_not be_content_changed
34
34
  end
35
- it 'should be changed when a field has been set' do
35
+ it "should be changed when a field has been set" do
36
36
  @obj.descMetadata.title = 'Foobar'
37
- expect(@obj.descMetadata).to be_content_changed
37
+ @obj.descMetadata.should be_content_changed
38
38
  end
39
- describe '#changed?' do
40
- it 'should not be changed if the new xml matches the old xml' do
39
+ describe "#changed?" do
40
+ it "should not be changed if the new xml matches the old xml" do
41
41
  @obj.descMetadata.content = @obj.descMetadata.content
42
- expect(@obj.descMetadata).not_to be_changed
42
+ @obj.descMetadata.should_not be_changed
43
43
  end
44
44
 
45
- it 'should not be changed if there are minor differences in whitespace' do
46
- @obj.descMetadata.content = '<a><b>1</b></a>'
45
+ it "should not be changed if there are minor differences in whitespace" do
46
+ @obj.descMetadata.content = "<a><b>1</b></a>"
47
47
  @obj.save
48
- expect(@obj.descMetadata).not_to be_changed
48
+ @obj.descMetadata.should_not be_changed
49
49
  @obj.descMetadata.content = "<a>\n<b>1</b>\n</a>"
50
- expect(@obj.descMetadata).not_to be_changed
50
+ @obj.descMetadata.should_not be_changed
51
51
  end
52
52
  end
53
53
  end
54
54
 
55
- describe 'an instance that is a managed datastream' do
55
+ describe "an instance that is a managed datastream" do
56
56
  before(:all) do
57
57
  class ModsArticle2 < ActiveFedora::Base
58
58
  # Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
59
- has_metadata 'descMetadata', type: Hydra::ModsArticleDatastream, autocreate: true
59
+ has_metadata :name => "descMetadata", :type => Hydra::ModsArticleDatastream, :autocreate => true
60
60
  end
61
61
  end
62
62
 
@@ -74,28 +74,28 @@ describe ActiveFedora::OmDatastream do
74
74
  @obj.destroy
75
75
  end
76
76
 
77
- it 'should not report being inline' do
78
- expect(@obj.descMetadata).to be_managed
77
+ it "should not report being inline" do
78
+ @obj.descMetadata.should be_managed
79
79
  end
80
80
 
81
- describe '#changed?' do
82
- it 'should not be changed if the new xml matches the old xml' do
81
+ describe "#changed?" do
82
+ it "should not be changed if the new xml matches the old xml" do
83
83
  @obj.descMetadata.content = @obj.descMetadata.content
84
- expect(@obj.descMetadata).not_to be_changed
84
+ @obj.descMetadata.should_not be_changed
85
85
  end
86
86
 
87
- it 'should be changed if there are minor differences in whitespace' do
88
- @obj.descMetadata.content = '<a><b>1</b></a>'
87
+ it "should be changed if there are minor differences in whitespace" do
88
+ @obj.descMetadata.content = "<a><b>1</b></a>"
89
89
  @obj.save
90
- expect(@obj.descMetadata).not_to be_changed
90
+ @obj.descMetadata.should_not be_changed
91
91
  @obj.descMetadata.content = "<a>\n<b>1</b>\n</a>"
92
- expect(@obj.descMetadata).to be_changed
92
+ @obj.descMetadata.should be_changed
93
93
  end
94
94
  end
95
95
 
96
- describe 'empty datastream content' do
97
- it 'should not break when there is empty datastream content' do
98
- @obj.descMetadata.content = ''
96
+ describe "empty datastream content" do
97
+ it "should not break when there is empty datastream content" do
98
+ @obj.descMetadata.content = ""
99
99
  @obj.save
100
100
  end
101
101
  end
@@ -108,35 +108,35 @@ describe ActiveFedora::OmDatastream do
108
108
  @solr_obj = ActiveFedora::Base.load_instance_from_solr(@obj.pid)
109
109
  end
110
110
 
111
- it 'should return the same values whether getting from solr or Fedora' do
112
- expect(@solr_obj.datastreams['descMetadata'].term_values(:name, :role, :text)).to eq(['Creator', 'Contributor', 'Funder', 'Host'])
113
- expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 0}, :role, :text)).to eq(['Creator'])
114
- expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 1}, :role, :text)).to eq(['Contributor'])
115
- expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 0}, {:role => 0}, :text)).to eq(['Creator'])
116
- expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 0}, :text)).to eq(['Contributor'])
117
- expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 1}, :text)).to eq([])
118
- ar = @solr_obj.datastreams['descMetadata'].term_values(:name, {:role => 0}, :text)
119
- expect(ar.length).to eq(4)
120
- expect(ar.include?('Creator')).to eq(true)
121
- expect(ar.include?('Contributor')).to eq(true)
122
- expect(ar.include?('Funder')).to eq(true)
123
- expect(ar.include?('Host')).to eq(true)
124
-
125
- expect(@obj.datastreams['descMetadata'].term_values(:name, :role, :text)).to eq(['Creator', 'Contributor', 'Funder', 'Host'])
126
- expect(@obj.datastreams['descMetadata'].term_values({:name => 0}, :role, :text)).to eq(['Creator'])
127
- expect(@obj.datastreams['descMetadata'].term_values({:name => 1}, :role, :text)).to eq(['Contributor'])
128
- expect(@obj.datastreams['descMetadata'].term_values({:name => 0}, {:role => 0}, :text)).to eq(['Creator'])
129
- expect(@obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 0}, :text)).to eq(['Contributor'])
130
- expect(@obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 1}, :text)).to eq([])
131
- ar = @obj.datastreams['descMetadata'].term_values(:name, {:role => 0}, :text)
132
- expect(ar.length).to eq(4)
133
- expect(ar.include?('Creator')).to eq(true)
134
- expect(ar.include?('Contributor')).to eq(true)
135
- expect(ar.include?('Funder')).to eq(true)
136
- expect(ar.include?('Host')).to eq(true)
111
+ it "should return the same values whether getting from solr or Fedora" do
112
+ @solr_obj.datastreams["descMetadata"].term_values(:name,:role,:text).should == ["Creator","Contributor","Funder","Host"]
113
+ @solr_obj.datastreams["descMetadata"].term_values({:name=>0},:role,:text).should == ["Creator"]
114
+ @solr_obj.datastreams["descMetadata"].term_values({:name=>1},:role,:text).should == ["Contributor"]
115
+ @solr_obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).should == ["Creator"]
116
+ @solr_obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>0},:text).should == ["Contributor"]
117
+ @solr_obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>1},:text).should == []
118
+ ar = @solr_obj.datastreams["descMetadata"].term_values(:name,{:role=>0},:text)
119
+ ar.length.should == 4
120
+ ar.include?("Creator").should == true
121
+ ar.include?("Contributor").should == true
122
+ ar.include?("Funder").should == true
123
+ ar.include?("Host").should == true
124
+
125
+ @obj.datastreams["descMetadata"].term_values(:name,:role,:text).should == ["Creator","Contributor","Funder","Host"]
126
+ @obj.datastreams["descMetadata"].term_values({:name=>0},:role,:text).should == ["Creator"]
127
+ @obj.datastreams["descMetadata"].term_values({:name=>1},:role,:text).should == ["Contributor"]
128
+ @obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).should == ["Creator"]
129
+ @obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>0},:text).should == ["Contributor"]
130
+ @obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>1},:text).should == []
131
+ ar = @obj.datastreams["descMetadata"].term_values(:name,{:role=>0},:text)
132
+ ar.length.should == 4
133
+ ar.include?("Creator").should == true
134
+ ar.include?("Contributor").should == true
135
+ ar.include?("Funder").should == true
136
+ ar.include?("Host").should == true
137
137
  end
138
138
  end
139
-
139
+
140
140
  describe '.update_values' do
141
141
  before do
142
142
  @obj.descMetadata.content = File.read(fixture('mods_articles/mods_article1.xml'))
@@ -144,24 +144,24 @@ describe ActiveFedora::OmDatastream do
144
144
  @obj.reload
145
145
  end
146
146
 
147
- it 'should not be dirty after .update_values is saved' do
148
- @obj.datastreams['descMetadata'].update_values([{:name => 0}, {:role => 0}, :text] => 'Funder')
149
- expect(@obj.datastreams['descMetadata']).to be_changed
147
+ it "should not be dirty after .update_values is saved" do
148
+ @obj.datastreams["descMetadata"].update_values([{:name=>0},{:role=>0},:text] =>"Funder")
149
+ @obj.datastreams["descMetadata"].should be_changed
150
150
  @obj.save
151
- expect(@obj.datastreams['descMetadata']).not_to be_changed
152
- expect(@obj.datastreams['descMetadata'].term_values({:name => 0}, {:role => 0}, :text)).to eq(['Funder'])
153
- end
151
+ @obj.datastreams["descMetadata"].should_not be_changed
152
+ @obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).should == ["Funder"]
153
+ end
154
154
  end
155
155
 
156
156
 
157
- describe '.to_solr' do
157
+ describe ".to_solr" do
158
158
  before do
159
159
  @obj.descMetadata.journal.issue.publication_date = Date.parse('2012-11-02')
160
160
  @obj.save!
161
161
  @obj.reload
162
162
  end
163
163
  it "should solrize terms with :type=>'date' to *_dt solr terms" do
164
- expect(@obj.to_solr[ActiveFedora::SolrService.solr_name('journal_issue_publication_date', type: :date)]).to eq(['2012-11-02T00:00:00Z'])
164
+ @obj.to_solr[ActiveFedora::SolrService.solr_name('journal_issue_publication_date', type: :date)].should == ['2012-11-02T00:00:00Z']
165
165
  end
166
166
  end
167
167
  end