revolutionhealth-config_loader 2.0.40655071 → 2.0.118251957

Sign up to get free protection for your applications and to get access to all the features.
data/lib/config_loader.rb CHANGED
@@ -49,8 +49,8 @@ class ConfigurationLoader
49
49
  @caching = (cache_option == :force_cache)
50
50
  @base_path = base_path
51
51
  # defer caching until rails has finished initializing and thus all gems are loaded
52
- if cache_option == :defer_cache && Object.const_defined?(:Rails)
53
- Rails::configuration.after_initialize do
52
+ if cache_option == :defer_cache && Object.const_defined?(:Rails) && Rails.respond_to?(:configuration)
53
+ Rails.configuration.after_initialize do
54
54
  self.instance_eval { @caching = true }
55
55
  end
56
56
  end
@@ -27,6 +27,7 @@ end
27
27
  class TestConfigReload < Test::Unit::TestCase
28
28
 
29
29
  def test_config_reload
30
+ ConfigLoader.instance_eval { @caching = true } # enable caching
30
31
  loaded = ConfigLoader.load_file('test_reload.yml')
31
32
  assert_not_nil loaded
32
33
  assert ConfigLoader.loader_called
@@ -94,6 +95,8 @@ class TestConfigReload < Test::Unit::TestCase
94
95
  File.open( test_reload_file, 'w' ) do |out|
95
96
  YAML.dump(loaded, out )
96
97
  end
98
+ ensure
99
+ ConfigLoader.instance_eval { @caching = false } # disable caching
97
100
  end
98
101
 
99
102
  def test_check_only
@@ -103,13 +106,18 @@ class TestConfigReload < Test::Unit::TestCase
103
106
  end
104
107
 
105
108
  def test_use_alternate_base_path
109
+ orig_rails_root = RAILS_ROOT
106
110
  Object.send(:remove_const, "RAILS_ROOT")
107
- assert_raise(RuntimeError) {
108
- ConfigurationLoader.new(false).send(:app_root)
109
- }
110
- top_dir = File.join(File.dirname(__FILE__), '..')
111
- conf = ConfigurationLoader.new(false, top_dir)
112
- assert conf.send(:app_root).first == File.expand_path(top_dir)
111
+ begin
112
+ assert_raise(RuntimeError) {
113
+ ConfigurationLoader.new(false).send(:app_root)
114
+ }
115
+ top_dir = File.join(File.dirname(__FILE__), '..')
116
+ conf = ConfigurationLoader.new(false, top_dir)
117
+ assert conf.send(:app_root).first == File.expand_path(top_dir)
118
+ ensure
119
+ Object.const_set(:RAILS_ROOT, orig_rails_root)
120
+ end
113
121
  end
114
122
 
115
123
  end
data/test/test_helper.rb CHANGED
@@ -2,6 +2,9 @@ require 'test/unit'
2
2
  require File.join(File.dirname(__FILE__), '..', 'lib', 'config_loader')
3
3
 
4
4
  unless defined?(RAILS_ENV)
5
- RAILS_ROOT = File.dirname(__FILE__)
6
5
  RAILS_ENV = 'test'
6
+ end
7
+
8
+ unless defined?(RAILS_ROOT)
9
+ RAILS_ROOT = File.dirname(__FILE__)
7
10
  end
@@ -14,8 +14,7 @@ class TestServiceConfig < Test::Unit::TestCase
14
14
  else
15
15
  k
16
16
  end
17
-
18
- assert ServiceConfig.send(real_key.to_sym, 'search') == v
17
+ assert_equal v, ServiceConfig.send(real_key.to_sym, 'search')
19
18
  end
20
19
  end
21
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revolutionhealth-config_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.40655071
4
+ version: 2.0.118251957
5
5
  platform: ruby
6
6
  authors:
7
7
  - Revolution Health