active-fedora 6.7.8 → 6.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.rubocop.yml +1 -0
  4. data/.rubocop_todo.yml +938 -0
  5. data/.travis.yml +5 -6
  6. data/Gemfile +3 -1
  7. data/Rakefile +7 -5
  8. data/active-fedora.gemspec +7 -8
  9. data/lib/active_fedora/om_datastream.rb +1 -0
  10. data/lib/active_fedora/rdf_xml_writer.rb +31 -62
  11. data/lib/active_fedora/version.rb +1 -1
  12. data/spec/config_helper.rb +14 -14
  13. data/spec/integration/associations_spec.rb +232 -232
  14. data/spec/integration/attributes_spec.rb +11 -12
  15. data/spec/integration/auditable_spec.rb +10 -10
  16. data/spec/integration/base_spec.rb +163 -163
  17. data/spec/integration/bug_spec.rb +7 -7
  18. data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
  19. data/spec/integration/datastream_collections_spec.rb +69 -69
  20. data/spec/integration/datastream_spec.rb +43 -43
  21. data/spec/integration/datastreams_spec.rb +63 -63
  22. data/spec/integration/delegating_spec.rb +14 -14
  23. data/spec/integration/delete_all_spec.rb +38 -42
  24. data/spec/integration/fedora_solr_sync_spec.rb +5 -5
  25. data/spec/integration/full_featured_model_spec.rb +101 -101
  26. data/spec/integration/has_many_associations_spec.rb +24 -24
  27. data/spec/integration/model_spec.rb +30 -30
  28. data/spec/integration/nested_attribute_spec.rb +41 -41
  29. data/spec/integration/ntriples_datastream_spec.rb +107 -107
  30. data/spec/integration/om_datastream_spec.rb +67 -67
  31. data/spec/integration/persistence_spec.rb +6 -6
  32. data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
  33. data/spec/integration/relation_delegation_spec.rb +24 -26
  34. data/spec/integration/rels_ext_datastream_spec.rb +20 -20
  35. data/spec/integration/scoped_query_spec.rb +40 -41
  36. data/spec/integration/solr_instance_loader_spec.rb +4 -4
  37. data/spec/integration/solr_service_spec.rb +46 -46
  38. data/spec/rails3_test_app/config/application.rb +1 -1
  39. data/spec/rails3_test_app/config/environments/development.rb +0 -1
  40. data/spec/rails3_test_app/config/environments/production.rb +1 -1
  41. data/spec/rails3_test_app/spec/spec_helper.rb +3 -3
  42. data/spec/rails3_test_app/spec/unit/rails_3_init.rb +4 -4
  43. data/spec/samples/hydra-mods_article_datastream.rb +334 -334
  44. data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
  45. data/spec/samples/marpa-dc_datastream.rb +17 -17
  46. data/spec/samples/models/audio_record.rb +16 -16
  47. data/spec/samples/models/image.rb +2 -2
  48. data/spec/samples/models/mods_article.rb +5 -5
  49. data/spec/samples/models/oral_history.rb +18 -18
  50. data/spec/samples/models/seminar.rb +24 -24
  51. data/spec/samples/models/seminar_audio_file.rb +17 -17
  52. data/spec/samples/oral_history_sample_model.rb +21 -21
  53. data/spec/samples/special_thing.rb +14 -14
  54. data/spec/spec_helper.rb +7 -11
  55. data/spec/support/an_active_model.rb +2 -2
  56. data/spec/support/mock_fedora.rb +16 -17
  57. data/spec/unit/active_fedora_spec.rb +58 -58
  58. data/spec/unit/association_proxy_spec.rb +5 -7
  59. data/spec/unit/base_active_model_spec.rb +25 -26
  60. data/spec/unit/base_cma_spec.rb +5 -5
  61. data/spec/unit/base_datastream_management_spec.rb +27 -27
  62. data/spec/unit/base_delegate_spec.rb +80 -82
  63. data/spec/unit/base_delegate_to_spec.rb +37 -39
  64. data/spec/unit/base_extra_spec.rb +48 -48
  65. data/spec/unit/base_spec.rb +300 -300
  66. data/spec/unit/callback_spec.rb +19 -19
  67. data/spec/unit/code_configurator_spec.rb +17 -17
  68. data/spec/unit/config_spec.rb +16 -8
  69. data/spec/unit/content_model_spec.rb +60 -60
  70. data/spec/unit/datastream_collections_spec.rb +229 -229
  71. data/spec/unit/datastream_spec.rb +57 -54
  72. data/spec/unit/datastreams_spec.rb +77 -77
  73. data/spec/unit/file_configurator_spec.rb +217 -217
  74. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +26 -26
  75. data/spec/unit/has_many_collection_spec.rb +9 -9
  76. data/spec/unit/inheritance_spec.rb +12 -13
  77. data/spec/unit/model_spec.rb +41 -51
  78. data/spec/unit/nom_datastream_spec.rb +15 -15
  79. data/spec/unit/ntriples_datastream_spec.rb +112 -112
  80. data/spec/unit/om_datastream_spec.rb +233 -227
  81. data/spec/unit/persistence_spec.rb +6 -6
  82. data/spec/unit/predicates_spec.rb +73 -73
  83. data/spec/unit/property_spec.rb +9 -17
  84. data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
  85. data/spec/unit/query_spec.rb +188 -217
  86. data/spec/unit/rdf_datastream_spec.rb +28 -21
  87. data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
  88. data/spec/unit/rdf_list_spec.rb +80 -104
  89. data/spec/unit/rdf_node_spec.rb +7 -7
  90. data/spec/unit/rdf_xml_writer_spec.rb +10 -10
  91. data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
  92. data/spec/unit/relationship_graph_spec.rb +51 -51
  93. data/spec/unit/rels_ext_datastream_spec.rb +75 -69
  94. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
  95. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
  96. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
  97. data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
  98. data/spec/unit/rubydora_connection_spec.rb +5 -5
  99. data/spec/unit/semantic_node_spec.rb +59 -59
  100. data/spec/unit/serializers_spec.rb +4 -4
  101. data/spec/unit/service_definitions_spec.rb +26 -26
  102. data/spec/unit/simple_datastream_spec.rb +17 -17
  103. data/spec/unit/solr_config_options_spec.rb +27 -28
  104. data/spec/unit/solr_digital_object_spec.rb +21 -21
  105. data/spec/unit/solr_service_spec.rb +81 -81
  106. data/spec/unit/unsaved_digital_object_spec.rb +20 -20
  107. data/spec/unit/validations_spec.rb +21 -21
  108. metadata +70 -58
  109. data/gemfiles/gemfile.rails3 +0 -11
  110. data/gemfiles/gemfile.rails4 +0 -10
@@ -1,29 +1,29 @@
1
1
  require 'active-fedora'
2
2
 
3
- class Seminar
4
-
3
+ class Seminar
4
+
5
5
  include ActiveFedora::Model
6
-
6
+
7
7
  # Imitating DataMapper ...
8
-
9
- relationship "parts", :is_part_of, [:seminar_audio_file], :inbound => true
10
- #has n, :parts, {:predicate => :is_part_of, :likely_types => [:seminar_audio_file], :inbound => true}
8
+
9
+ relationship 'parts', :is_part_of, [:seminar_audio_file], :inbound => true
10
+ #has n, :parts, {:predicate => :is_part_of, :likely_types => [:seminar_audio_file], :inbound => true}
11
11
  # OR
12
- # has_parts [:seminar_audio_file]
13
-
14
- property "title_wylie", :text # Note: reserving title_tibetan for actual UTF-8 tibetan text
15
- property "title_english", :text
16
- property "original_media_format", :text
17
- property "original_media_number_of_units", :integer
18
- property "author_name_wylie", :text
19
- property "author_name_english", :text
20
- property "location", :string
21
- property "date_recorded", :date
22
- property "file_name", :string
23
- property "duration", :string
24
- property "file_size", :integer
25
- property "restriction", :text
26
- property "uri", :string
27
- property "notes", :text
28
-
29
- end
12
+ # has_parts [:seminar_audio_file]
13
+
14
+ property 'title_wylie', :text # Note: reserving title_tibetan for actual UTF-8 tibetan text
15
+ property 'title_english', :text
16
+ property 'original_media_format', :text
17
+ property 'original_media_number_of_units', :integer
18
+ property 'author_name_wylie', :text
19
+ property 'author_name_english', :text
20
+ property 'location', :string
21
+ property 'date_recorded', :date
22
+ property 'file_name', :string
23
+ property 'duration', :string
24
+ property 'file_size', :integer
25
+ property 'restriction', :text
26
+ property 'uri', :string
27
+ property 'notes', :text
28
+
29
+ end
@@ -1,32 +1,32 @@
1
1
  require 'active-fedora'
2
2
 
3
3
  class SeminarAudioFile
4
-
4
+
5
5
  include ActiveFedora::Model
6
-
6
+
7
7
  # Imitating DataMapper ...
8
-
9
- relationship "parent", :is_part_of, :seminar
8
+
9
+ relationship 'parent', :is_part_of, :seminar
10
10
  #has n, :parents, {:predicate => :is_part_of, :likely_types => [:seminar]}
11
11
  # OR
12
12
  # is_part_of :seminar
13
-
14
- property "date_recorded", :date
15
- property "file_name", :string
16
- property "duration", :string
17
- property "uri", :string
18
- property "notes", :text
13
+
14
+ property 'date_recorded', :date
15
+ property 'file_name', :string
16
+ property 'duration', :string
17
+ property 'uri', :string
18
+ property 'notes', :text
19
19
 
20
20
  # TODO: Figure out how to declare access restrictions
21
21
  #property "restriction", :text
22
- set_restrictions ["public", "private"]
23
-
22
+ set_restrictions ['public', 'private']
23
+
24
24
  # A file_size property doesn't make sense when you have both compressed and uncompressed in the same object!
25
- # Probably better to rely on the file size in datastreamVersion "SIZE" attribute from Fedora anyway
25
+ # Probably better to rely on the file size in datastreamVersion "SIZE" attribute from Fedora anyway
26
26
  #property "file_size", :integer
27
27
 
28
- datastream "compressed", ["audio/mpeg"], :multiple => true
29
- datastream "uncompressed", ["audio/wav", "audio/aiff"], :multiple => true
30
-
31
-
28
+ datastream 'compressed', ['audio/mpeg'], :multiple => true
29
+ datastream 'uncompressed', ['audio/wav', 'audio/aiff'], :multiple => true
30
+
31
+
32
32
  end
@@ -1,30 +1,30 @@
1
- require "active_fedora"
1
+ require 'active_fedora'
2
2
  class OralHistorySampleModel < ActiveFedora::Base
3
3
 
4
4
  #has_relationship "parts", :is_part_of, :inbound => true
5
-
6
- has_metadata :name => "properties", :type => ActiveFedora::SimpleDatastream do |m|
7
- m.field "narrator", :string
8
- m.field "interviewer", :string
9
- m.field "transcript_editor", :text
10
- m.field "bio", :string
11
- m.field "notes", :text
12
- m.field "hard_copy_availability", :text
13
- m.field "hard_copy_location", :text
14
- m.field "other_contributor", :string
15
- m.field "restrictions", :text
16
- m.field "series", :string
17
- m.field "location", :string
5
+
6
+ has_metadata :name => 'properties', :type => ActiveFedora::SimpleDatastream do |m|
7
+ m.field 'narrator', :string
8
+ m.field 'interviewer', :string
9
+ m.field 'transcript_editor', :text
10
+ m.field 'bio', :string
11
+ m.field 'notes', :text
12
+ m.field 'hard_copy_availability', :text
13
+ m.field 'hard_copy_location', :text
14
+ m.field 'other_contributor', :string
15
+ m.field 'restrictions', :text
16
+ m.field 'series', :string
17
+ m.field 'location', :string
18
18
  end
19
-
20
- has_metadata :name => "dublin_core", :type => ActiveFedora::QualifiedDublinCoreDatastream
21
19
 
22
- has_metadata :name => "significant_passages", :type => ActiveFedora::SimpleDatastream do |m|
23
- m.field "significant_passage", :text
20
+ has_metadata :name => 'dublin_core', :type => ActiveFedora::QualifiedDublinCoreDatastream
21
+
22
+ has_metadata :name => 'significant_passages', :type => ActiveFedora::SimpleDatastream do |m|
23
+ m.field 'significant_passage', :text
24
24
  end
25
-
26
- has_metadata :name => "sensitive_passages", :type => ActiveFedora::SimpleDatastream do |m|
27
- m.field "sensitive_passage", :text
25
+
26
+ has_metadata :name => 'sensitive_passages', :type => ActiveFedora::SimpleDatastream do |m|
27
+ m.field 'sensitive_passage', :text
28
28
  end
29
29
 
30
30
  end
@@ -1,11 +1,11 @@
1
- require "samples/marpa-dc_datastream.rb"
1
+ require 'samples/marpa-dc_datastream.rb'
2
2
 
3
3
  # This is an example of an ActiveFedora Model
4
4
  #
5
- # Some of the datastream ids were chosen based on the Hydra modeling conventions. You don't have to follow them in your work.
5
+ # Some of the datastream ids were chosen based on the Hydra modeling conventions. You don't have to follow them in your work.
6
6
  # ActiveFedora itself has no notion of those conventions, but we do encourage you to use them.
7
7
  #
8
- # The Hydra conventions encourage you to have a datastream with this dsid whose contents are descriptive metadata like MODS or Dublin Core. They especially encourage MODS.
8
+ # The Hydra conventions encourage you to have a datastream with this dsid whose contents are descriptive metadata like MODS or Dublin Core. They especially encourage MODS.
9
9
  # The descMetadata dsid is a Hydra convention for a datastream with descriptive metadata contents, like MODS or Dublin Core. They especially encourage MODS.
10
10
  # The rightsMetadata dsid is also a convention provided by the Hydra Common Metadata "content model"
11
11
  #
@@ -13,32 +13,32 @@ require "samples/marpa-dc_datastream.rb"
13
13
  # Note that on the wiki, "content model" is often used to refer to Fedora CModels and/or abstract/notional models. The Common Metadata content model is an example of this.
14
14
  # The wiki includes a page that attempts to shed some light on the question of "What is a content model?" https://wiki.duraspace.org/display/hydra/Don't+call+it+a+'content+model'!
15
15
  class SpecialThing < ActiveFedora::Base
16
-
16
+
17
17
  #
18
18
  # DATASTREAMS
19
19
  #
20
-
20
+
21
21
  # This declares a datastream with Datastream ID (dsid) of "descMetadata"
22
22
  # The descMetadata datastream is bound to the Hydra::ModsArticleDatastream class that's defined in lib/active_fedora/samples
23
23
  # Any time you load a Fedora object using an instance of SampleModel, the instance will assume its descMetadata datastream conforms to the assumptions in Hydra::ModsArticleDatastream class
24
- has_metadata :name => "descMetadata", :type=> Hydra::ModsArticleDatastream
25
-
24
+ has_metadata :name => 'descMetadata', :type => Hydra::ModsArticleDatastream
25
+
26
26
  # This declares a datastream with Datastream ID (dsid) of "rightsMetadata"
27
27
  # Like the descMetadata datastream, any time you load a Fedora object using an instance of SampleModel, the instance will assume its descMetadata datastream conforms to the assumptions in Hydra::RightsMetadataDatastream class
28
- has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadataDatastream
29
-
28
+ has_metadata :name => 'rightsMetadata', :type => Hydra::RightsMetadataDatastream
29
+
30
30
  # This is not part of the Hydra conventions
31
31
  # Adding an extra datastream called "extraMetadataForFun" that is bound to the Marpa::DcDatastream class
32
- has_metadata :name => "extraMetadataForFun", :type => Marpa::DcDatastream
33
-
32
+ has_metadata :name => 'extraMetadataForFun', :type => Marpa::DcDatastream
33
+
34
34
  #
35
35
  # RELATIONSHIPS
36
36
  #
37
-
37
+
38
38
  # This is an example of how you can add a custom relationship to a model
39
39
  # This will allow you to call .derivation on instances of the model to get the _outbound_ "hasDerivation" relationship in the RELS-EXT datastream
40
- belongs_to :derivation, :property=>:has_derivation
40
+ belongs_to :derivation, :property => :has_derivation
41
41
 
42
42
  # This will allow you to call .inspirations on instances of the model to get a list of all of the objects that assert "hasDerivation" relationships pointing at this object
43
- has_many :inspirations, :property=>:has_derivation
43
+ has_many :inspirations, :property => :has_derivation
44
44
  end
@@ -1,5 +1,5 @@
1
- ENV["environment"] ||= 'test'
2
- require "bundler/setup"
1
+ ENV['environment'] ||= 'test'
2
+ require 'bundler/setup'
3
3
 
4
4
 
5
5
  begin
@@ -17,31 +17,27 @@ require 'active-fedora'
17
17
  require 'rspec'
18
18
  require 'equivalent-xml/rspec_matchers'
19
19
 
20
- Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f }
20
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each {|f| require f }
21
21
  require 'samples/samples'
22
22
 
23
23
 
24
24
  logger.level = Logger::WARN if logger.respond_to? :level ###MediaShelf StubLogger doesn't have a level= method
25
- $VERBOSE=nil
25
+ $VERBOSE = nil
26
26
 
27
27
  # This loads the Fedora and Solr config info from /config/fedora.yml
28
28
  # You can load it from a different location by passing a file path as an argument.
29
29
  def restore_spec_configuration
30
- ActiveFedora.init(:fedora_config_path=>File.join(File.dirname(__FILE__), "..", "config", "fedora.yml"))
30
+ ActiveFedora.init(:fedora_config_path => File.join(File.dirname(__FILE__), '..', 'config', 'fedora.yml'))
31
31
  end
32
32
  restore_spec_configuration
33
33
 
34
34
  # Shut those Rails deprecation warnings up
35
- ActiveSupport::Deprecation.behavior= Proc.new { |message, callstack| }
36
-
37
- RSpec.configure do |config|
38
- config.color_enabled = true
39
- end
35
+ ActiveSupport::Deprecation.behavior = Proc.new { |message, callstack| }
40
36
 
41
37
  def fixture(file)
42
38
  File.open(File.join(File.dirname(__FILE__), 'fixtures', file), 'rb')
43
39
  end
44
40
 
45
41
  def solr_uri(uri)
46
- uri.gsub(/(:)/, "\\:").gsub(/(\/)/,"\\/")
42
+ uri.gsub(/(:)/, '\\:').gsub(/(\/)/, '\\/')
47
43
  end
@@ -1,4 +1,4 @@
1
- shared_examples_for "An ActiveModel" do
1
+ shared_examples_for 'An ActiveModel' do
2
2
  begin
3
3
  require 'minitest/unit'
4
4
  include Minitest::Assertions
@@ -16,7 +16,7 @@ shared_examples_for "An ActiveModel" do
16
16
  include ActiveModel::Lint::Tests
17
17
 
18
18
  ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m|
19
- example m.gsub('_',' ') do
19
+ example m.tr('_', ' ') do
20
20
  send m
21
21
  end
22
22
  end
@@ -1,45 +1,44 @@
1
1
  def mock_client
2
2
  return @mock_client if @mock_client
3
- @mock_client = double("client")
4
- @getter = double("getter")
5
- @getter.stub(:get).and_return('')
6
- @mock_client.stub(:[]).with("describe?xml=true").and_return('')
7
- @mock_client
3
+ @mock_client = double('client')
4
+ @getter = double('getter')
5
+ allow(@getter).to receive(:get).and_return('')
6
+ allow(@mock_client).to receive(:[]).with('describe?xml=true').and_return('')
7
+ @mock_client
8
8
  end
9
-
10
- def stub_get(pid, datastreams=nil, record_exists=false)
9
+
10
+ def stub_get(pid, datastreams = nil, record_exists = false)
11
11
  pid.gsub!(/:/, '%3A')
12
12
  if record_exists
13
- mock_client.stub(:[]).with("objects/#{pid}?format=xml").and_return(double('get getter', :get=>'foobar'))
13
+ allow(mock_client).to receive(:[]).with("objects/#{pid}?format=xml").and_return(double('get getter', :get => 'foobar'))
14
14
  else
15
- mock_client.stub(:[]).with("objects/#{pid}?format=xml").and_raise(RestClient::ResourceNotFound)
15
+ allow(mock_client).to receive(:[]).with("objects/#{pid}?format=xml").and_raise(RestClient::ResourceNotFound)
16
16
  end
17
- mock_client.stub(:[]).with("objects/#{pid}/datastreams?format=xml").and_return(@getter)
17
+ allow(mock_client).to receive(:[]).with("objects/#{pid}/datastreams?format=xml").and_return(@getter)
18
18
  datastreams ||= ['someData', 'withText', 'withText2', 'RELS-EXT']
19
19
  datastreams.each do |dsid|
20
- mock_client.stub(:[]).with("objects/#{pid}/datastreams/#{dsid}?format=xml").and_return(@getter)
20
+ allow(mock_client).to receive(:[]).with("objects/#{pid}/datastreams/#{dsid}?format=xml").and_return(@getter)
21
21
  end
22
22
  end
23
23
 
24
- def stub_ingest(pid=nil)
24
+ def stub_ingest(pid = nil)
25
25
  n = pid ? pid.gsub(/:/, '%3A') : nil
26
- mock_client.should_receive(:[]).with("objects/#{n || 'new'}").and_return(double("ingester", :post=>pid))
26
+ expect(mock_client).to receive(:[]).with("objects/#{n || 'new'}").and_return(double('ingester', :post => pid))
27
27
  end
28
28
 
29
29
  def stub_add_ds(pid, dsids)
30
30
  pid.gsub!(/:/, '%3A')
31
31
  dsids.each do |dsid|
32
- client = mock_client.stub(:[]).with do |params|
32
+ client = allow(mock_client).to receive(:[]).with(no_args) do |params|
33
33
  /objects\/#{pid}\/datastreams\/#{dsid}/.match(params)
34
34
  end
35
- client.and_return(double("ds_adder", :post=>pid, :get=>''))
35
+ client.and_return(double('ds_adder', :post => pid, :get => ''))
36
36
  end
37
37
  end
38
38
 
39
39
  def stub_get_content(pid, dsids)
40
40
  pid.gsub!(/:/, '%3A')
41
41
  dsids.each do |dsid|
42
- mock_client.stub(:[]).with { |params| /objects\/#{pid}\/datastreams\/#{dsid}\/content/.match(params)}.and_return(double("content_accessor", :post=>pid, :get=>''))
42
+ allow(mock_client).to receive(:[]).with(no_args) { |params| /objects\/#{pid}\/datastreams\/#{dsid}\/content/.match(params)}.and_return(double('content_accessor', :post => pid, :get => ''))
43
43
  end
44
44
  end
45
-
@@ -4,106 +4,106 @@ require 'config_helper'
4
4
  # For testing Module-level methods like ActiveFedora.init
5
5
 
6
6
  describe ActiveFedora do
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 "initialization methods" do
15
- describe "environment" do
16
- it "should use config_options[:environment] if set" do
17
- ActiveFedora.stub(:config_options => {:environment=>"ballyhoo"})
18
- ActiveFedora.environment.should eql("ballyhoo")
14
+ describe 'initialization methods' do
15
+ describe 'environment' do
16
+ it 'should use config_options[:environment] if set' do
17
+ ActiveFedora.stub(:config_options => {:environment => 'ballyhoo'})
18
+ expect(ActiveFedora.environment).to eql('ballyhoo')
19
19
  end
20
20
 
21
- it "should use Rails.env if no config_options and Rails.env is set" do
22
- stub_rails(:env => "bedbugs")
21
+ it 'should use Rails.env if no config_options and Rails.env is set' do
22
+ stub_rails(:env => 'bedbugs')
23
23
  ActiveFedora.stub(:config_options => {})
24
- ActiveFedora.environment.should eql("bedbugs")
24
+ expect(ActiveFedora.environment).to eql('bedbugs')
25
25
  unstub_rails
26
26
  end
27
27
 
28
28
  it "should use ENV['environment'] if neither config_options nor Rails.env are set" do
29
- ENV['environment'] = "wichita"
29
+ ENV['environment'] = 'wichita'
30
30
  ActiveFedora.stub(:config_options => {})
31
- ActiveFedora.environment.should eql("wichita")
32
- ENV['environment']='test'
31
+ expect(ActiveFedora.environment).to eql('wichita')
32
+ ENV['environment'] = 'test'
33
33
  end
34
34
 
35
35
  it "should use ENV['RAILS_ENV'] and log a warning if none of the above are set" do
36
- ENV['environment']=nil
37
- ENV['RAILS_ENV'] = "rails_env"
38
- lambda {ActiveFedora.environment}.should raise_error(RuntimeError, "You're depending on RAILS_ENV for setting your environment. Please use ENV['environment'] for non-rails environment setting: 'rake foo:bar environment=test'")
39
- ENV['environment']='test'
36
+ ENV['environment'] = nil
37
+ ENV['RAILS_ENV'] = 'rails_env'
38
+ expect {ActiveFedora.environment}.to raise_error(RuntimeError, "You're depending on RAILS_ENV for setting your environment. Please use ENV['environment'] for non-rails environment setting: 'rake foo:bar environment=test'")
39
+ ENV['environment'] = 'test'
40
40
  end
41
41
 
42
- it "should be development if none of the above are present" do
43
- ENV['environment']=nil
42
+ it 'should be development if none of the above are present' do
43
+ ENV['environment'] = nil
44
44
  ENV['RAILS_ENV'] = nil
45
45
  ActiveFedora.stub(:config_options => {})
46
- ActiveFedora.environment.should == 'development'
47
- ENV['environment']="test"
46
+ expect(ActiveFedora.environment).to eq('development')
47
+ ENV['environment'] = 'test'
48
48
  end
49
49
  end
50
50
  end
51
-
52
- describe ".init" do
53
-
51
+
52
+ describe '.init' do
53
+
54
54
  after(:all) do
55
55
  # Restore to default fedora configs
56
- ActiveFedora.init(:environment => "test", :fedora_config_path => File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml"))
56
+ ActiveFedora.init(:environment => 'test', :fedora_config_path => File.join(File.dirname(__FILE__), '..', '..', 'config', 'fedora.yml'))
57
57
  end
58
58
 
59
- describe "outside of rails" do
60
- it "should load the passed config if explicit config passed in as a string" do
61
- ActiveFedora.init(:fedora_config_path=>'./spec/fixtures/rails_root/config/fedora.yml', :environment => 'test')
62
- ActiveFedora.config.credentials.should == {:url=> "http://testhost.com:8983/fedora", :user=>'fedoraAdmin', :password=>'fedoraAdmin'}
59
+ describe 'outside of rails' do
60
+ it 'should load the passed config if explicit config passed in as a string' do
61
+ ActiveFedora.init(:fedora_config_path => './spec/fixtures/rails_root/config/fedora.yml', :environment => 'test')
62
+ expect(ActiveFedora.config.credentials).to eq({:url => 'http://testhost.com:8983/fedora', :user => 'fedoraAdmin', :password => 'fedoraAdmin'})
63
63
  end
64
64
  end
65
65
 
66
- describe "within rails" do
66
+ describe 'within rails' do
67
67
 
68
68
  after(:all) do
69
69
  unstub_rails
70
70
  end
71
71
 
72
- describe "versions prior to 3.0" do
73
- describe "with explicit config path passed in" do
74
- it "should load the specified config path" do
75
- fedora_config="test:\n url: http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora"
72
+ describe 'versions prior to 3.0' do
73
+ describe 'with explicit config path passed in' do
74
+ it 'should load the specified config path' do
75
+ fedora_config = "test:\n url: http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora"
76
76
  solr_config = "test:\n default:\n url: http://foosolr:8983"
77
77
 
78
- fedora_config_path = File.expand_path(File.join(File.dirname(__FILE__),"../fixtures/rails_root/config/fedora.yml"))
79
- solr_config_path = File.expand_path(File.join(File.dirname(__FILE__),"../fixtures/rails_root/config/solr.yml"))
80
- pred_config_path = File.expand_path(File.join(File.dirname(__FILE__),"../fixtures/rails_root/config/predicate_mappings.yml"))
81
-
82
- File.stub(:open).with(fedora_config_path).and_return(fedora_config)
83
- File.stub(:open).with(solr_config_path).and_return(solr_config)
84
- ActiveFedora::SolrService.stub(:load_mappings) #For the solrizer solr_mappings.yml
78
+ fedora_config_path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/rails_root/config/fedora.yml'))
79
+ solr_config_path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/rails_root/config/solr.yml'))
80
+ pred_config_path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/rails_root/config/predicate_mappings.yml'))
81
+
82
+ allow(File).to receive(:open).with(fedora_config_path).and_return(fedora_config)
83
+ allow(File).to receive(:open).with(solr_config_path).and_return(solr_config)
84
+ allow(ActiveFedora::SolrService).to receive(:load_mappings) #For the solrizer solr_mappings.yml
85
85
 
86
86
 
87
87
  # ActiveSupport::Deprecation.should_receive(:warn).with("Configuring fedora with \":url\" without :user and :password is no longer supported.")
88
- ActiveFedora.init(:fedora_config_path=>fedora_config_path,:solr_config_path=>solr_config_path)
89
- ActiveFedora.solr.class.should == ActiveFedora::SolrService
88
+ ActiveFedora.init(:fedora_config_path => fedora_config_path, :solr_config_path => solr_config_path)
89
+ expect(ActiveFedora.solr.class).to eq(ActiveFedora::SolrService)
90
90
  end
91
91
  end
92
92
 
93
- describe "with no explicit config path" do
94
- it "should look for the file in the path defined at Rails.root" do
95
- ActiveFedora::SolrService.stub(:load_mappings) #necessary or else it will load the solrizer config and it breaks other tests in the suite.
96
-
97
- stub_rails(:root=>File.join(File.dirname(__FILE__),"../fixtures/rails_root"))
93
+ describe 'with no explicit config path' do
94
+ it 'should look for the file in the path defined at Rails.root' do
95
+ allow(ActiveFedora::SolrService).to receive(:load_mappings) #necessary or else it will load the solrizer config and it breaks other tests in the suite.
96
+
97
+ stub_rails(:root => File.join(File.dirname(__FILE__), '../fixtures/rails_root'))
98
98
  ActiveFedora.init()
99
- ActiveFedora.config.credentials[:url].should == "http://testhost.com:8983/fedora"
99
+ expect(ActiveFedora.config.credentials[:url]).to eq('http://testhost.com:8983/fedora')
100
100
  end
101
101
  end
102
102
  end
103
103
  end
104
104
  end
105
-
106
- describe "#class_from_string" do
105
+
106
+ describe '#class_from_string' do
107
107
  before do
108
108
  module ParentClass
109
109
  class SiblingClass
@@ -112,20 +112,20 @@ describe ActiveFedora do
112
112
  end
113
113
  end
114
114
  end
115
- it "should return class constants based on strings" do
116
- ActiveFedora.class_from_string("Om").should == Om
117
- ActiveFedora.class_from_string("ActiveFedora::RdfNode::TermProxy").should == ActiveFedora::RdfNode::TermProxy
118
- ActiveFedora.class_from_string("TermProxy", ActiveFedora::RdfNode).should == ActiveFedora::RdfNode::TermProxy
115
+ it 'should return class constants based on strings' do
116
+ expect(ActiveFedora.class_from_string('Om')).to eq(Om)
117
+ expect(ActiveFedora.class_from_string('ActiveFedora::RdfNode::TermProxy')).to eq(ActiveFedora::RdfNode::TermProxy)
118
+ expect(ActiveFedora.class_from_string('TermProxy', ActiveFedora::RdfNode)).to eq(ActiveFedora::RdfNode::TermProxy)
119
119
  end
120
120
 
121
- it "should find sibling classes" do
122
- ActiveFedora.class_from_string("SiblingClass", ParentClass::OtherSiblingClass).should == ParentClass::SiblingClass
121
+ it 'should find sibling classes' do
122
+ expect(ActiveFedora.class_from_string('SiblingClass', ParentClass::OtherSiblingClass)).to eq(ParentClass::SiblingClass)
123
123
  end
124
124
 
125
125
  it "should raise a NameError if the class isn't found" do
126
126
  expect {
127
- ActiveFedora.class_from_string("FooClass", ParentClass::OtherSiblingClass)
128
- }.to raise_error NameError, "uninitialized constant FooClass"
127
+ ActiveFedora.class_from_string('FooClass', ParentClass::OtherSiblingClass)
128
+ }.to raise_error NameError, /uninitialized constant FooClass/
129
129
  end
130
130
  end
131
131
  end