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,370 +2,370 @@ require 'spec_helper'
2
2
  require 'config_helper'
3
3
 
4
4
  describe ActiveFedora::FileConfigurator do
5
-
5
+
6
6
  subject {ActiveFedora.configurator }
7
-
7
+
8
8
  after :all do
9
9
  unstub_rails
10
10
  # Restore to default fedora configs
11
11
  restore_spec_configuration
12
12
  end
13
13
 
14
- describe '#initialize' do
15
- it 'should trigger configuration reset (to empty defaults)' do
16
- expect_any_instance_of(ActiveFedora::FileConfigurator).to receive(:reset!)
14
+ describe "#initialize" do
15
+ it "should trigger configuration reset (to empty defaults)" do
16
+ ActiveFedora::FileConfigurator.any_instance.should_receive(:reset!)
17
17
  ActiveFedora::FileConfigurator.new
18
- end
18
+ end
19
19
  end
20
20
 
21
- describe '#config_options' do
21
+ describe "#config_options" do
22
22
  before do
23
23
  subject.reset!
24
24
  end
25
- it 'should be an empty hash' do
26
- expect(subject.config_options).to eq({})
25
+ it "should be an empty hash" do
26
+ subject.config_options.should == {}
27
27
  end
28
28
  end
29
29
 
30
- describe '#fedora_config' do
30
+ describe "#fedora_config" do
31
31
  before do
32
32
  subject.reset!
33
33
  end
34
- it 'should trigger configuration to load' do
35
- expect(subject).to receive(:load_fedora_config)
34
+ it "should trigger configuration to load" do
35
+ subject.should_receive(:load_fedora_config)
36
36
  subject.fedora_config
37
- end
37
+ end
38
38
  end
39
- describe '#solr_config' do
39
+ describe "#solr_config" do
40
40
  before do
41
41
  subject.reset!
42
42
  end
43
- it 'should trigger configuration to load' do
44
- expect(subject).to receive(:load_solr_config)
43
+ it "should trigger configuration to load" do
44
+ subject.should_receive(:load_solr_config)
45
45
  subject.solr_config
46
- end
46
+ end
47
47
  end
48
48
 
49
- describe '#reset!' do
49
+ describe "#reset!" do
50
50
  before { subject.reset! }
51
- it 'should clear @fedora_config' do
52
- expect(subject.instance_variable_get(:@fedora_config)).to eq({})
51
+ it "should clear @fedora_config" do
52
+ subject.instance_variable_get(:@fedora_config).should == {}
53
53
  end
54
- it 'should clear @solr_config' do
55
- expect(subject.instance_variable_get(:@solr_config)).to eq({})
54
+ it "should clear @solr_config" do
55
+ subject.instance_variable_get(:@solr_config).should == {}
56
56
  end
57
- it 'should clear @config_options' do
58
- expect(subject.instance_variable_get(:@config_options)).to eq({})
57
+ it "should clear @config_options" do
58
+ subject.instance_variable_get(:@config_options).should == {}
59
59
  end
60
60
  end
61
61
 
62
- describe 'initialization methods' do
63
-
64
- describe 'get_config_path(:fedora)' do
65
- it 'should use the config_options[:config_path] if it exists' do
66
- expect(subject).to receive(:config_options).and_return({:fedora_config_path => '/path/to/fedora.yml'})
67
- expect(File).to receive(:file?).with('/path/to/fedora.yml').and_return(true)
68
- expect(subject.get_config_path(:fedora)).to eql('/path/to/fedora.yml')
62
+ describe "initialization methods" do
63
+
64
+ describe "get_config_path(:fedora)" do
65
+ it "should use the config_options[:config_path] if it exists" do
66
+ subject.should_receive(:config_options).and_return({:fedora_config_path => "/path/to/fedora.yml"})
67
+ File.should_receive(:file?).with("/path/to/fedora.yml").and_return(true)
68
+ subject.get_config_path(:fedora).should eql("/path/to/fedora.yml")
69
69
  end
70
70
 
71
- it 'should look in Rails.root/config/fedora.yml if it exists and no fedora_config_path passed in' do
72
- expect(subject).to receive(:config_options).and_return({})
73
- stub_rails(:root => '/rails/root')
74
- expect(File).to receive(:file?).with('/rails/root/config/fedora.yml').and_return(true)
75
- expect(subject.get_config_path(:fedora)).to eql('/rails/root/config/fedora.yml')
71
+ it "should look in Rails.root/config/fedora.yml if it exists and no fedora_config_path passed in" do
72
+ subject.should_receive(:config_options).and_return({})
73
+ stub_rails(:root => "/rails/root")
74
+ File.should_receive(:file?).with("/rails/root/config/fedora.yml").and_return(true)
75
+ subject.get_config_path(:fedora).should eql("/rails/root/config/fedora.yml")
76
76
  unstub_rails
77
77
  end
78
78
 
79
- it 'should look in ./config/fedora.yml if neither rails.root nor :fedora_config_path are set' do
80
- expect(subject).to receive(:config_options).and_return({})
81
- Dir.stub(:getwd => '/current/working/directory')
82
- expect(File).to receive(:file?).with('/current/working/directory/config/fedora.yml').and_return(true)
83
- expect(subject.get_config_path(:fedora)).to eql('/current/working/directory/config/fedora.yml')
79
+ it "should look in ./config/fedora.yml if neither rails.root nor :fedora_config_path are set" do
80
+ subject.should_receive(:config_options).and_return({})
81
+ Dir.stub(:getwd => "/current/working/directory")
82
+ File.should_receive(:file?).with("/current/working/directory/config/fedora.yml").and_return(true)
83
+ subject.get_config_path(:fedora).should eql("/current/working/directory/config/fedora.yml")
84
84
  end
85
85
 
86
- it 'should return default fedora.yml that ships with active-fedora if none of the above' do
87
- expect(subject).to receive(:config_options).and_return({})
88
- expect(Dir).to receive(:getwd).and_return('/current/working/directory')
89
- expect(File).to receive(:file?).with('/current/working/directory/config/fedora.yml').and_return(false)
90
- expect(File).to receive(:file?).with(File.expand_path(File.join(File.dirname('__FILE__'), 'config', 'fedora.yml'))).and_return(true)
91
- expect(logger).to receive(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml') - or set Rails.root and put fedora.yml into \#{Rails.root}/config.")
92
- expect(subject.get_config_path(:fedora)).to eql(File.expand_path(File.join(File.dirname('__FILE__'), 'config', 'fedora.yml')))
86
+ it "should return default fedora.yml that ships with active-fedora if none of the above" do
87
+ subject.should_receive(:config_options).and_return({})
88
+ Dir.should_receive(:getwd).and_return("/current/working/directory")
89
+ File.should_receive(:file?).with("/current/working/directory/config/fedora.yml").and_return(false)
90
+ File.should_receive(:file?).with(File.expand_path(File.join(File.dirname("__FILE__"),'config','fedora.yml'))).and_return(true)
91
+ logger.should_receive(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml') - or set Rails.root and put fedora.yml into \#{Rails.root}/config.")
92
+ subject.get_config_path(:fedora).should eql(File.expand_path(File.join(File.dirname("__FILE__"),'config','fedora.yml')))
93
93
  end
94
94
  end
95
95
 
96
- describe 'get_config_path(:predicate_mappings)' do
97
- it 'should use the config_options[:config_path] if it exists' do
98
- expect(subject).to receive(:config_options).and_return({:predicate_mappings_config_path => '/path/to/predicate_mappings.yml'})
99
- expect(File).to receive(:file?).with('/path/to/predicate_mappings.yml').and_return(true)
100
- expect(subject.get_config_path(:predicate_mappings)).to eql('/path/to/predicate_mappings.yml')
96
+ describe "get_config_path(:predicate_mappings)" do
97
+ it "should use the config_options[:config_path] if it exists" do
98
+ subject.should_receive(:config_options).and_return({:predicate_mappings_config_path => "/path/to/predicate_mappings.yml"})
99
+ File.should_receive(:file?).with("/path/to/predicate_mappings.yml").and_return(true)
100
+ subject.get_config_path(:predicate_mappings).should eql("/path/to/predicate_mappings.yml")
101
101
  end
102
102
 
103
- it 'should look in Rails.root/config/predicate_mappings.yml if it exists and no predicate_mappings_config_path passed in' do
104
- expect(subject).to receive(:config_options).and_return({})
105
- stub_rails(:root => '/rails/root')
106
- expect(File).to receive(:file?).with('/rails/root/config/predicate_mappings.yml').and_return(true)
107
- expect(subject.get_config_path(:predicate_mappings)).to eql('/rails/root/config/predicate_mappings.yml')
103
+ it "should look in Rails.root/config/predicate_mappings.yml if it exists and no predicate_mappings_config_path passed in" do
104
+ subject.should_receive(:config_options).and_return({})
105
+ stub_rails(:root => "/rails/root")
106
+ File.should_receive(:file?).with("/rails/root/config/predicate_mappings.yml").and_return(true)
107
+ subject.get_config_path(:predicate_mappings).should eql("/rails/root/config/predicate_mappings.yml")
108
108
  unstub_rails
109
109
  end
110
110
 
111
- it 'should look in ./config/predicate_mappings.yml if neither rails.root nor :predicate_mappings_config_path are set' do
112
- expect(subject).to receive(:config_options).and_return({})
113
- Dir.stub(:getwd => '/current/working/directory')
114
- expect(File).to receive(:file?).with('/current/working/directory/config/predicate_mappings.yml').and_return(true)
115
- expect(subject.get_config_path(:predicate_mappings)).to eql('/current/working/directory/config/predicate_mappings.yml')
111
+ it "should look in ./config/predicate_mappings.yml if neither rails.root nor :predicate_mappings_config_path are set" do
112
+ subject.should_receive(:config_options).and_return({})
113
+ Dir.stub(:getwd => "/current/working/directory")
114
+ File.should_receive(:file?).with("/current/working/directory/config/predicate_mappings.yml").and_return(true)
115
+ subject.get_config_path(:predicate_mappings).should eql("/current/working/directory/config/predicate_mappings.yml")
116
116
  end
117
117
 
118
- it 'should return default predicate_mappings.yml that ships with active-fedora if none of the above' do
119
- expect(subject).to receive(:config_options).and_return({})
120
- expect(Dir).to receive(:getwd).and_return('/current/working/directory')
121
- expect(File).to receive(:file?).with('/current/working/directory/config/predicate_mappings.yml').and_return(false)
122
- expect(File).to receive(:file?).with(File.expand_path(File.join(File.dirname('__FILE__'), 'config', 'predicate_mappings.yml'))).and_return(true)
123
- expect(logger).to receive(:warn).with("Using the default predicate_mappings.yml that comes with active-fedora. If you want to override this, pass the path to predicate_mappings.yml to ActiveFedora - ie. ActiveFedora.init(:predicate_mappings_config_path => '/path/to/predicate_mappings.yml') - or set Rails.root and put predicate_mappings.yml into \#{Rails.root}/config.")
124
- expect(subject.get_config_path(:predicate_mappings)).to eql(File.expand_path(File.join(File.dirname('__FILE__'), 'config', 'predicate_mappings.yml')))
118
+ it "should return default predicate_mappings.yml that ships with active-fedora if none of the above" do
119
+ subject.should_receive(:config_options).and_return({})
120
+ Dir.should_receive(:getwd).and_return("/current/working/directory")
121
+ File.should_receive(:file?).with("/current/working/directory/config/predicate_mappings.yml").and_return(false)
122
+ File.should_receive(:file?).with(File.expand_path(File.join(File.dirname("__FILE__"),'config','predicate_mappings.yml'))).and_return(true)
123
+ logger.should_receive(:warn).with("Using the default predicate_mappings.yml that comes with active-fedora. If you want to override this, pass the path to predicate_mappings.yml to ActiveFedora - ie. ActiveFedora.init(:predicate_mappings_config_path => '/path/to/predicate_mappings.yml') - or set Rails.root and put predicate_mappings.yml into \#{Rails.root}/config.")
124
+ subject.get_config_path(:predicate_mappings).should eql(File.expand_path(File.join(File.dirname("__FILE__"),'config','predicate_mappings.yml')))
125
125
  end
126
126
  end
127
127
 
128
- describe 'get_config_path(:solr)' do
129
- it 'should return the solr_config_path if set in config_options hash' do
130
- subject.stub(:config_options => {:solr_config_path => '/path/to/solr.yml'})
131
- expect(File).to receive(:file?).with('/path/to/solr.yml').and_return(true)
132
- expect(subject.get_config_path(:solr)).to eql('/path/to/solr.yml')
128
+ describe "get_config_path(:solr)" do
129
+ it "should return the solr_config_path if set in config_options hash" do
130
+ subject.stub(:config_options => {:solr_config_path => "/path/to/solr.yml"})
131
+ File.should_receive(:file?).with("/path/to/solr.yml").and_return(true)
132
+ subject.get_config_path(:solr).should eql("/path/to/solr.yml")
133
133
  end
134
-
135
- it 'should return the solr.yml file in the same directory as the fedora.yml if it exists' do
136
- expect(subject).to receive(:path).and_return('/path/to/fedora/config/fedora.yml')
137
- expect(File).to receive(:file?).with('/path/to/fedora/config/solr.yml').and_return(true)
138
- expect(subject.get_config_path(:solr)).to eql('/path/to/fedora/config/solr.yml')
134
+
135
+ it "should return the solr.yml file in the same directory as the fedora.yml if it exists" do
136
+ subject.should_receive(:path).and_return("/path/to/fedora/config/fedora.yml")
137
+ File.should_receive(:file?).with("/path/to/fedora/config/solr.yml").and_return(true)
138
+ subject.get_config_path(:solr).should eql("/path/to/fedora/config/solr.yml")
139
139
  end
140
-
141
- context 'no solr.yml in same directory as fedora.yml and fedora.yml does not contain solr url' do
140
+
141
+ context "no solr.yml in same directory as fedora.yml and fedora.yml does not contain solr url" do
142
142
 
143
143
  before :each do
144
144
  subject.stub(:config_options => {})
145
- expect(subject).to receive(:path).and_return('/path/to/fedora/config/fedora.yml')
146
- expect(File).to receive(:file?).with('/path/to/fedora/config/solr.yml').and_return(false)
145
+ subject.should_receive(:path).and_return("/path/to/fedora/config/fedora.yml")
146
+ File.should_receive(:file?).with("/path/to/fedora/config/solr.yml").and_return(false)
147
147
  end
148
148
  after :each do
149
149
  unstub_rails
150
150
  end
151
151
 
152
- it 'should not raise an error if there is not a solr.yml in the same directory as the fedora.yml and the fedora.yml has a solr url defined and look in rails.root' do
153
- stub_rails(:root => '/rails/root')
154
- expect(File).to receive(:file?).with('/rails/root/config/solr.yml').and_return(true)
155
- expect(subject.get_config_path(:solr)).to eql('/rails/root/config/solr.yml')
152
+ it "should not raise an error if there is not a solr.yml in the same directory as the fedora.yml and the fedora.yml has a solr url defined and look in rails.root" do
153
+ stub_rails(:root=>"/rails/root")
154
+ File.should_receive(:file?).with("/rails/root/config/solr.yml").and_return(true)
155
+ subject.get_config_path(:solr).should eql("/rails/root/config/solr.yml")
156
156
  end
157
157
 
158
- it 'should look in ./config/solr.yml if no rails root' do
159
- Dir.stub(:getwd => '/current/working/directory')
160
- expect(File).to receive(:file?).with('/current/working/directory/config/solr.yml').and_return(true)
161
- expect(subject.get_config_path(:solr)).to eql('/current/working/directory/config/solr.yml')
158
+ it "should look in ./config/solr.yml if no rails root" do
159
+ Dir.stub(:getwd => "/current/working/directory")
160
+ File.should_receive(:file?).with("/current/working/directory/config/solr.yml").and_return(true)
161
+ subject.get_config_path(:solr).should eql("/current/working/directory/config/solr.yml")
162
162
  end
163
163
 
164
- it 'should return the default solr.yml file that ships with active-fedora if no other option is set' do
165
- Dir.stub(:getwd => '/current/working/directory')
166
- expect(File).to receive(:file?).with('/current/working/directory/config/solr.yml').and_return(false)
167
- expect(File).to receive(:file?).with(File.expand_path(File.join(File.dirname('__FILE__'), 'config', 'solr.yml'))).and_return(true)
168
- expect(logger).to receive(:warn).with("Using the default solr.yml that comes with active-fedora. If you want to override this, pass the path to solr.yml to ActiveFedora - ie. ActiveFedora.init(:solr_config_path => '/path/to/solr.yml') - or set Rails.root and put solr.yml into \#{Rails.root}/config.")
169
- expect(subject.get_config_path(:solr)).to eql(File.expand_path(File.join(File.dirname('__FILE__'), 'config', 'solr.yml')))
164
+ it "should return the default solr.yml file that ships with active-fedora if no other option is set" do
165
+ Dir.stub(:getwd => "/current/working/directory")
166
+ File.should_receive(:file?).with("/current/working/directory/config/solr.yml").and_return(false)
167
+ File.should_receive(:file?).with(File.expand_path(File.join(File.dirname("__FILE__"),'config','solr.yml'))).and_return(true)
168
+ logger.should_receive(:warn).with("Using the default solr.yml that comes with active-fedora. If you want to override this, pass the path to solr.yml to ActiveFedora - ie. ActiveFedora.init(:solr_config_path => '/path/to/solr.yml') - or set Rails.root and put solr.yml into \#{Rails.root}/config.")
169
+ subject.get_config_path(:solr).should eql(File.expand_path(File.join(File.dirname("__FILE__"),'config','solr.yml')))
170
170
  end
171
171
  end
172
172
 
173
173
  end
174
174
 
175
- describe 'load_fedora_config' do
175
+ describe "load_fedora_config" do
176
176
  before(:each) do
177
177
  subject.reset!
178
178
  end
179
- it 'should load the file specified in fedora_config_path' do
180
- allow(subject).to receive(:load_solrizer_config)
181
- expect(subject).to receive(:get_config_path).with(:fedora).and_return('/path/to/fedora.yml')
182
- expect(subject).to receive(:load_solr_config)
183
- expect(IO).to receive(:read).with('/path/to/fedora.yml').and_return("development:\n url: http://devfedora:8983\ntest:\n url: http://myfedora:8080")
184
- expect(subject.load_fedora_config).to eq({:url => 'http://myfedora:8080'})
185
- expect(subject.fedora_config).to eq({:url => 'http://myfedora:8080'})
179
+ it "should load the file specified in fedora_config_path" do
180
+ subject.stub(:load_solrizer_config)
181
+ subject.should_receive(:get_config_path).with(:fedora).and_return("/path/to/fedora.yml")
182
+ subject.should_receive(:load_solr_config)
183
+ IO.should_receive(:read).with("/path/to/fedora.yml").and_return("development:\n url: http://devfedora:8983\ntest:\n url: http://myfedora:8080")
184
+ subject.load_fedora_config.should == {:url=>"http://myfedora:8080"}
185
+ subject.fedora_config.should == {:url=>"http://myfedora:8080"}
186
186
  end
187
187
 
188
- it 'should allow sharding' do
189
- allow(subject).to receive(:load_solrizer_config)
190
- expect(subject).to receive(:get_config_path).with(:fedora).and_return('/path/to/fedora.yml')
191
- expect(subject).to receive(:load_solr_config)
192
- expect(IO).to receive(:read).with('/path/to/fedora.yml').and_return("development:\n url: http://devfedora:8983\ntest:\n- url: http://myfedora:8080\n- url: http://myfedora:8081")
193
- expect(subject.load_fedora_config).to eq([{:url => 'http://myfedora:8080'}, {:url => 'http://myfedora:8081'}])
194
- expect(subject.fedora_config).to eq([{:url => 'http://myfedora:8080'}, {:url => 'http://myfedora:8081'}])
188
+ it "should allow sharding" do
189
+ subject.stub(:load_solrizer_config)
190
+ subject.should_receive(:get_config_path).with(:fedora).and_return("/path/to/fedora.yml")
191
+ subject.should_receive(:load_solr_config)
192
+ IO.should_receive(:read).with("/path/to/fedora.yml").and_return("development:\n url: http://devfedora:8983\ntest:\n- url: http://myfedora:8080\n- url: http://myfedora:8081")
193
+ subject.load_fedora_config.should == [{:url=>"http://myfedora:8080"}, {:url=>"http://myfedora:8081"}]
194
+ subject.fedora_config.should == [{:url=>"http://myfedora:8080"}, {:url=>"http://myfedora:8081"}]
195
195
  end
196
196
 
197
- it 'should parse the file using ERb' do
198
- allow(subject).to receive(:load_solrizer_config)
199
- expect(subject).to receive(:get_config_path).with(:fedora).and_return('/path/to/fedora.yml')
200
- expect(subject).to receive(:load_solr_config)
201
- expect(IO).to receive(:read).with('/path/to/fedora.yml').and_return("development:\n url: http://devfedora:<%= 8983 %>\ntest:\n url: http://myfedora:<%= 8081 %>")
202
- expect(subject.load_fedora_config).to eq({:url => 'http://myfedora:8081'})
203
- expect(subject.fedora_config).to eq({:url => 'http://myfedora:8081'})
197
+ it "should parse the file using ERb" do
198
+ subject.stub(:load_solrizer_config)
199
+ subject.should_receive(:get_config_path).with(:fedora).and_return("/path/to/fedora.yml")
200
+ subject.should_receive(:load_solr_config)
201
+ IO.should_receive(:read).with("/path/to/fedora.yml").and_return("development:\n url: http://devfedora:<%= 8983 %>\ntest:\n url: http://myfedora:<%= 8081 %>")
202
+ subject.load_fedora_config.should == {:url=>"http://myfedora:8081"}
203
+ subject.fedora_config.should == {:url=>"http://myfedora:8081"}
204
204
  end
205
205
  end
206
206
 
207
- describe 'load_solr_config' do
207
+ describe "load_solr_config" do
208
208
  before(:each) do
209
209
  subject.reset!
210
210
  end
211
- it 'should load the file specified in solr_config_path' do
212
- allow(subject).to receive(:load_solrizer_config)
213
- expect(subject).to receive(:get_config_path).with(:solr).and_return('/path/to/solr.yml')
214
- expect(subject).to receive(:load_fedora_config)
215
- expect(IO).to receive(:read).with('/path/to/solr.yml').and_return("development:\n default:\n url: http://devsolr:8983\ntest:\n default:\n url: http://mysolr:8080")
216
- expect(subject.load_solr_config).to eq({:url => 'http://mysolr:8080'})
217
- expect(subject.solr_config).to eq({:url => 'http://mysolr:8080'})
211
+ it "should load the file specified in solr_config_path" do
212
+ subject.stub(:load_solrizer_config)
213
+ subject.should_receive(:get_config_path).with(:solr).and_return("/path/to/solr.yml")
214
+ subject.should_receive(:load_fedora_config)
215
+ IO.should_receive(:read).with("/path/to/solr.yml").and_return("development:\n default:\n url: http://devsolr:8983\ntest:\n default:\n url: http://mysolr:8080")
216
+ subject.load_solr_config.should == {:url=>"http://mysolr:8080"}
217
+ subject.solr_config.should == {:url=>"http://mysolr:8080"}
218
218
  end
219
219
 
220
- it 'should parse the file using ERb' do
221
- allow(subject).to receive(:load_solrizer_config)
222
- expect(subject).to receive(:get_config_path).with(:solr).and_return('/path/to/solr.yml')
223
- expect(subject).to receive(:load_fedora_config)
224
- expect(IO).to receive(:read).with('/path/to/solr.yml').and_return("development:\n default:\n url: http://devsolr:<%= 8983 %>\ntest:\n default:\n url: http://mysolr:<%= 8081 %>")
225
- expect(subject.load_solr_config).to eq({:url => 'http://mysolr:8081'})
226
- expect(subject.solr_config).to eq({:url => 'http://mysolr:8081'})
220
+ it "should parse the file using ERb" do
221
+ subject.stub(:load_solrizer_config)
222
+ subject.should_receive(:get_config_path).with(:solr).and_return("/path/to/solr.yml")
223
+ subject.should_receive(:load_fedora_config)
224
+ IO.should_receive(:read).with("/path/to/solr.yml").and_return("development:\n default:\n url: http://devsolr:<%= 8983 %>\ntest:\n default:\n url: http://mysolr:<%= 8081 %>")
225
+ subject.load_solr_config.should == {:url=>"http://mysolr:8081"}
226
+ subject.solr_config.should == {:url=>"http://mysolr:8081"}
227
227
  end
228
228
  end
229
229
 
230
- describe 'load_configs' do
231
- describe 'when config is not loaded' do
230
+ describe "load_configs" do
231
+ describe "when config is not loaded" do
232
232
  before do
233
233
  subject.instance_variable_set :@config_loaded, nil
234
234
  end
235
- it 'should load the fedora and solr configs' do
236
- expect(subject.config_loaded?).to be_falsey
235
+ it "should load the fedora and solr configs" do
236
+ subject.config_loaded?.should be_false
237
237
  subject.load_configs
238
- expect(subject.config_loaded?).to be_truthy
238
+ subject.config_loaded?.should be_true
239
239
  end
240
240
  end
241
- describe 'when config is loaded' do
241
+ describe "when config is loaded" do
242
242
  before do
243
243
  subject.instance_variable_set :@config_loaded, true
244
244
  end
245
- it 'should load the fedora and solr configs' do
246
- expect(subject).to receive(:load_config).never
247
- expect(subject.config_loaded?).to be_truthy
245
+ it "should load the fedora and solr configs" do
246
+ subject.should_receive(:load_config).never
247
+ subject.config_loaded?.should be_true
248
248
  subject.load_configs
249
- expect(subject.config_loaded?).to be_truthy
249
+ subject.config_loaded?.should be_true
250
250
  end
251
251
  end
252
252
  end
253
253
 
254
- describe 'check_fedora_path_for_solr' do
255
- it 'should find the solr.yml file and return it if it exists' do
256
- expect(subject).to receive(:path).and_return('/path/to/fedora/fedora.yml')
257
- expect(File).to receive(:file?).with('/path/to/fedora/solr.yml').and_return(true)
258
- expect(subject.check_fedora_path_for_solr).to eq('/path/to/fedora/solr.yml')
254
+ describe "check_fedora_path_for_solr" do
255
+ it "should find the solr.yml file and return it if it exists" do
256
+ subject.should_receive(:path).and_return("/path/to/fedora/fedora.yml")
257
+ File.should_receive(:file?).with("/path/to/fedora/solr.yml").and_return(true)
258
+ subject.check_fedora_path_for_solr.should == "/path/to/fedora/solr.yml"
259
259
  end
260
- it 'should return nil if the solr.yml file is not there' do
261
- expect(subject).to receive(:path).and_return('/path/to/fedora/fedora.yml')
262
- expect(File).to receive(:file?).with('/path/to/fedora/solr.yml').and_return(false)
263
- expect(subject.check_fedora_path_for_solr).to be_nil
260
+ it "should return nil if the solr.yml file is not there" do
261
+ subject.should_receive(:path).and_return("/path/to/fedora/fedora.yml")
262
+ File.should_receive(:file?).with("/path/to/fedora/solr.yml").and_return(false)
263
+ subject.check_fedora_path_for_solr.should be_nil
264
264
  end
265
265
  end
266
266
  end
267
-
268
- describe 'setting the environment and loading configuration' do
269
-
267
+
268
+ describe "setting the environment and loading configuration" do
269
+
270
270
  before(:all) do
271
271
  @fake_rails_root = File.expand_path(File.dirname(__FILE__) + '/../fixtures/rails_root')
272
272
  end
273
273
 
274
-
274
+
275
275
  after(:all) do
276
- config_file = File.join(File.dirname(__FILE__), '..', '..', 'config', 'fedora.yml')
277
- environment = 'test'
278
- ActiveFedora.init(:environment => environment, :fedora_config_path => config_file)
276
+ config_file = File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml")
277
+ environment = "test"
278
+ ActiveFedora.init(:environment=>environment, :fedora_config_path=>config_file)
279
279
  end
280
-
281
- it 'can tell its config paths' do
280
+
281
+ it "can tell its config paths" do
282
282
  subject.init
283
- expect(subject).to respond_to(:solr_config_path)
283
+ subject.should respond_to(:solr_config_path)
284
284
  end
285
- it 'loads a config from the current working directory as a second choice' do
286
- allow(subject).to receive(:load_solrizer_config)
287
- allow(Dir).to receive(:getwd).and_return(@fake_rails_root)
285
+ it "loads a config from the current working directory as a second choice" do
286
+ subject.stub(:load_solrizer_config)
287
+ Dir.stub(:getwd).and_return(@fake_rails_root)
288
288
  subject.init
289
- expect(subject.get_config_path(:fedora)).to eql("#{@fake_rails_root}/config/fedora.yml")
290
- expect(subject.solr_config_path).to eql("#{@fake_rails_root}/config/solr.yml")
289
+ subject.get_config_path(:fedora).should eql("#{@fake_rails_root}/config/fedora.yml")
290
+ subject.solr_config_path.should eql("#{@fake_rails_root}/config/solr.yml")
291
291
  end
292
- it 'loads the config that ships with this gem as a last choice' do
293
- allow(Dir).to receive(:getwd).and_return('/fake/path')
294
- allow(subject).to receive(:load_solrizer_config)
295
- expect(logger).to receive(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml') - or set Rails.root and put fedora.yml into \#{Rails.root}/config.").exactly(3).times
292
+ it "loads the config that ships with this gem as a last choice" do
293
+ Dir.stub(:getwd).and_return("/fake/path")
294
+ subject.stub(:load_solrizer_config)
295
+ logger.should_receive(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml') - or set Rails.root and put fedora.yml into \#{Rails.root}/config.").exactly(3).times
296
296
  subject.init
297
- expected_config = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config'))
298
- expect(subject.get_config_path(:fedora)).to eql(expected_config + '/fedora.yml')
299
- expect(subject.solr_config_path).to eql(expected_config + '/solr.yml')
297
+ expected_config = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "config"))
298
+ subject.get_config_path(:fedora).should eql(expected_config+'/fedora.yml')
299
+ subject.solr_config_path.should eql(expected_config+'/solr.yml')
300
300
  end
301
- it 'raises an error if you pass in a string' do
302
- expect{ subject.init("#{@fake_rails_root}/config/fake_fedora.yml") }.to raise_exception(ArgumentError)
301
+ it "raises an error if you pass in a string" do
302
+ lambda{ subject.init("#{@fake_rails_root}/config/fake_fedora.yml") }.should raise_exception(ArgumentError)
303
303
  end
304
- it 'raises an error if you pass in a non-existant config file' do
305
- expect{ subject.init(:fedora_config_path => 'really_fake_fedora.yml') }.to raise_exception(ActiveFedora::ConfigurationError)
304
+ it "raises an error if you pass in a non-existant config file" do
305
+ lambda{ subject.init(:fedora_config_path=>"really_fake_fedora.yml") }.should raise_exception(ActiveFedora::ConfigurationError)
306
306
  end
307
-
308
- describe 'within Rails' do
309
- before(:all) do
310
- stub_rails(:root => File.dirname(__FILE__) + '/../fixtures/rails_root')
307
+
308
+ describe "within Rails" do
309
+ before(:all) do
310
+ stub_rails(:root=>File.dirname(__FILE__) + '/../fixtures/rails_root')
311
311
  end
312
312
 
313
313
  after(:all) do
314
314
  unstub_rails
315
315
  end
316
-
317
- it 'loads a config from Rails.root as a first choice' do
318
- allow(subject).to receive(:load_solrizer_config)
316
+
317
+ it "loads a config from Rails.root as a first choice" do
318
+ subject.stub(:load_solrizer_config)
319
319
  subject.init
320
- expect(subject.get_config_path(:fedora)).to eql("#{Rails.root}/config/fedora.yml")
321
- expect(subject.solr_config_path).to eql("#{Rails.root}/config/solr.yml")
320
+ subject.get_config_path(:fedora).should eql("#{Rails.root}/config/fedora.yml")
321
+ subject.solr_config_path.should eql("#{Rails.root}/config/solr.yml")
322
322
  end
323
-
324
- it 'can tell what environment it is set to run in' do
325
- stub_rails(:env => 'development')
323
+
324
+ it "can tell what environment it is set to run in" do
325
+ stub_rails(:env=>"development")
326
326
  subject.init
327
- expect(ActiveFedora.environment).to eql('development')
327
+ ActiveFedora.environment.should eql("development")
328
328
  end
329
-
329
+
330
330
  end
331
331
  end
332
-
332
+
333
333
  ##########################
334
-
335
- describe '.build_predicate_config_path' do
336
- it 'should return the path to the default config/predicate_mappings.yml if no valid path is given' do
337
- expect(subject.send(:build_predicate_config_path)).to eq(default_predicate_mapping_file)
334
+
335
+ describe ".build_predicate_config_path" do
336
+ it "should return the path to the default config/predicate_mappings.yml if no valid path is given" do
337
+ subject.send(:build_predicate_config_path).should == default_predicate_mapping_file
338
338
  end
339
339
  end
340
340
 
341
- describe '.predicate_config' do
341
+ describe ".predicate_config" do
342
342
  before do
343
343
  subject.instance_variable_set :@config_loaded, nil
344
344
  end
345
- it 'should return the default mapping if it has not been initialized' do
346
- expect(subject.predicate_config()).to eq(YAMLAdaptor.load(File.read(default_predicate_mapping_file)))
345
+ it "should return the default mapping if it has not been initialized" do
346
+ subject.predicate_config().should == YAMLAdaptor.load(File.read(default_predicate_mapping_file))
347
347
  end
348
348
  end
349
349
 
350
- describe '.valid_predicate_mapping' do
351
- it 'should return true if the predicate mapping has the appropriate keys and value types' do
352
- expect(subject.send(:valid_predicate_mapping?, default_predicate_mapping_file)).to be_truthy
350
+ describe ".valid_predicate_mapping" do
351
+ it "should return true if the predicate mapping has the appropriate keys and value types" do
352
+ subject.send(:valid_predicate_mapping?,default_predicate_mapping_file).should be_true
353
353
  end
354
- it 'should return false if the mapping is missing the :default_namespace' do
355
- mock_yaml({:default_namespace0 => 'my_namespace', :predicate_mapping => {:key0 => 'value0', :key1 => 'value1'}}, '/path/to/predicate_mappings.yml')
356
- expect(subject.send(:valid_predicate_mapping?, '/path/to/predicate_mappings.yml')).to be_falsey
354
+ it "should return false if the mapping is missing the :default_namespace" do
355
+ mock_yaml({:default_namespace0=>"my_namespace",:predicate_mapping=>{:key0=>"value0", :key1=>"value1"}},"/path/to/predicate_mappings.yml")
356
+ subject.send(:valid_predicate_mapping?,"/path/to/predicate_mappings.yml").should be_false
357
357
  end
358
- it 'should return false if the :default_namespace is not a string' do
359
- mock_yaml({:default_namespace => {:foo => 'bar'}, :predicate_mapping => {:key0 => 'value0', :key1 => 'value1'}}, '/path/to/predicate_mappings.yml')
360
- expect(subject.send(:valid_predicate_mapping?, '/path/to/predicate_mappings.yml')).to be_falsey
358
+ it "should return false if the :default_namespace is not a string" do
359
+ mock_yaml({:default_namespace=>{:foo=>"bar"}, :predicate_mapping=>{:key0=>"value0", :key1=>"value1"}},"/path/to/predicate_mappings.yml")
360
+ subject.send(:valid_predicate_mapping?,"/path/to/predicate_mappings.yml").should be_false
361
361
  end
362
- it 'should return false if the :predicate_mappings key is missing' do
363
- mock_yaml({:default_namespace => 'a string'}, '/path/to/predicate_mappings.yml')
364
- expect(subject.send(:valid_predicate_mapping?, '/path/to/predicate_mappings.yml')).to be_falsey
362
+ it "should return false if the :predicate_mappings key is missing" do
363
+ mock_yaml({:default_namespace=>"a string"},"/path/to/predicate_mappings.yml")
364
+ subject.send(:valid_predicate_mapping?,"/path/to/predicate_mappings.yml").should be_false
365
365
  end
366
- it 'should return false if the :predicate_mappings key is not a hash' do
367
- mock_yaml({:default_namespace => 'a string', :predicate_mapping => 'another string'}, '/path/to/predicate_mappings.yml')
368
- expect(subject.send(:valid_predicate_mapping?, '/path/to/predicate_mappings.yml')).to be_falsey
366
+ it "should return false if the :predicate_mappings key is not a hash" do
367
+ mock_yaml({:default_namespace=>"a string",:predicate_mapping=>"another string"},"/path/to/predicate_mappings.yml")
368
+ subject.send(:valid_predicate_mapping?,"/path/to/predicate_mappings.yml").should be_false
369
369
  end
370
370
 
371
371
  end