configy 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/HISTORY.md +4 -0
- data/README.md +2 -0
- data/Rakefile +2 -2
- data/configy.gemspec +2 -2
- data/lib/configy.rb +2 -0
- data/{test/base_test.rb → spec/base_spec.rb} +21 -21
- data/{test/config_file_test.rb → spec/config_file_spec.rb} +10 -9
- data/{test/config_store_test.rb → spec/config_store_spec.rb} +17 -16
- data/spec/configy_spec.rb +48 -0
- data/spec/load_path_spec.rb +32 -0
- data/spec/nested_config_spec.rb +30 -0
- data/{test → spec}/scratch/.gitkeep +0 -0
- data/spec/section_spec.rb +43 -0
- data/{test/test_helper.rb → spec/spec_helper.rb} +0 -0
- metadata +21 -18
- data/test/configy_test.rb +0 -49
- data/test/load_path_test.rb +0 -32
- data/test/nested_config_test.rb +0 -23
- data/test/section_test.rb +0 -37
data/Gemfile.lock
CHANGED
data/HISTORY.md
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -3,8 +3,8 @@ Bundler::GemHelper.install_tasks
|
|
3
3
|
|
4
4
|
require 'rake/testtask'
|
5
5
|
Rake::TestTask.new(:test) do |test|
|
6
|
-
test.libs << 'lib' << '
|
7
|
-
test.pattern = '
|
6
|
+
test.libs << 'lib' << 'spec'
|
7
|
+
test.pattern = 'spec/**/*_spec.rb'
|
8
8
|
test.verbose = true
|
9
9
|
end
|
10
10
|
|
data/configy.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "configy"
|
3
|
-
s.version = "1.1.
|
3
|
+
s.version = "1.1.2"
|
4
4
|
|
5
|
-
s.authors = [ "Gabe Varela", "Ben Marini", "Chip Miller" ]
|
5
|
+
s.authors = [ "Gabe Varela", "Ben Marini", "Chip Miller", "Bram Swenson", "Jeremy Ruppel" ]
|
6
6
|
s.date = "2012-03-18"
|
7
7
|
s.email = "bmarini@gmail.com"
|
8
8
|
s.summary = "Simple yaml driven configuration gem"
|
data/lib/configy.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'erb'
|
3
3
|
|
4
|
-
|
4
|
+
describe Configy::Base do
|
5
5
|
MAIN_CONFIG = <<-EOS
|
6
6
|
common:
|
7
7
|
a: 1
|
@@ -23,40 +23,40 @@ special:
|
|
23
23
|
e: <%= 6 * 7 %>
|
24
24
|
EOS
|
25
25
|
|
26
|
-
|
26
|
+
it "test top level configs should be accesssible as methods" do
|
27
27
|
with_config_file(MAIN_CONFIG, 'config') do
|
28
28
|
config = Configy::Base.new('config', 'special', scratch_dir)
|
29
|
-
|
29
|
+
config.a.must_equal 1
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
it "test method missing" do
|
34
34
|
config = Configy::Base.new('config', 'special', scratch_dir)
|
35
35
|
assert_raises NoMethodError do
|
36
36
|
config.nope = "oops"
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
it "test should override params with another file and use proper section" do
|
41
41
|
with_config_file(MAIN_CONFIG, 'config') do
|
42
42
|
with_config_file(LOCAL_CONFIG, 'config.local') do
|
43
43
|
config = Configy::Base.new('config', 'special', scratch_dir)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
config.a.must_equal '2'
|
45
|
+
config.b.must_equal 8
|
46
|
+
config.c.must_equal 2
|
47
|
+
config.d.must_equal 6
|
48
|
+
config.e.must_equal 42
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
|
53
|
+
it "test should reload a config file if changed" do
|
54
54
|
with_config_file({ 'common' => {'a' => 'foo'} }, 'config') do |file1, hash1|
|
55
55
|
with_config_file({ 'special' => {'b' => 'bar'} }, 'config.local') do |file2, hash2|
|
56
56
|
|
57
57
|
config = Configy::Base.new('config', 'special', scratch_dir)
|
58
|
-
|
59
|
-
|
58
|
+
config.a.must_equal 'foo'
|
59
|
+
config.b.must_equal 'bar'
|
60
60
|
|
61
61
|
# Simulate 1 second going by
|
62
62
|
config.send(:config).mtime -= 1
|
@@ -65,7 +65,7 @@ special:
|
|
65
65
|
f.puts( {'common' => {'a' => 'foo*'} }.to_yaml )
|
66
66
|
end
|
67
67
|
|
68
|
-
|
68
|
+
config.a.must_equal 'foo*'
|
69
69
|
|
70
70
|
# Simulate 1 second going by
|
71
71
|
config.send(:config).mtime -= 1
|
@@ -74,19 +74,19 @@ special:
|
|
74
74
|
f.puts( {'special' => {'b' => 'bar*'} }.to_yaml )
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
config.b.must_equal 'bar*'
|
78
78
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
|
83
|
+
it "test should not reload a config file if changed and cache config is true" do
|
84
84
|
with_config_file({ 'common' => {'a' => 'foo'} }, 'config') do |file1, hash1|
|
85
85
|
with_config_file({ 'special' => {'b' => 'bar'} }, 'config.local') do |file2, hash2|
|
86
86
|
|
87
87
|
config = Configy::Base.new('config', 'special', scratch_dir, true)
|
88
|
-
|
89
|
-
|
88
|
+
config.a.must_equal 'foo'
|
89
|
+
config.b.must_equal 'bar'
|
90
90
|
|
91
91
|
# Simulate 1 second going by
|
92
92
|
config.send(:config).mtime -= 1
|
@@ -95,7 +95,7 @@ special:
|
|
95
95
|
f.puts( {'common' => {'a' => 'foo*'} }.to_yaml )
|
96
96
|
end
|
97
97
|
|
98
|
-
|
98
|
+
config.a.must_equal 'foo'
|
99
99
|
|
100
100
|
# Simulate 1 second going by
|
101
101
|
config.send(:config).mtime -= 1
|
@@ -104,7 +104,7 @@ special:
|
|
104
104
|
f.puts( {'special' => {'b' => 'bar*'} }.to_yaml )
|
105
105
|
end
|
106
106
|
|
107
|
-
|
107
|
+
config.b.must_equal 'bar'
|
108
108
|
|
109
109
|
end
|
110
110
|
end
|
@@ -1,27 +1,28 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
describe Configy::ConfigFile do
|
4
|
+
|
5
|
+
it "test should load a config from a file" do
|
5
6
|
with_config_file( { 'common' => {'a' => '1', 'b' => '2' } }, 'app_config' ) do |file, hash|
|
6
7
|
configfile = Configy::ConfigFile.new(file, 'development')
|
7
|
-
|
8
|
+
configfile.load_file.must_equal hash
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
+
it "test should create an instance of config store" do
|
12
13
|
with_config_file( { 'common' => {'a' => '1', 'b' => '2' } }, 'app_config' ) do |file, hash|
|
13
14
|
configfile = Configy::ConfigFile.new(file, 'development')
|
14
|
-
|
15
|
+
configfile.config.must_be_instance_of Configy::ConfigStore
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
+
it "test should be aware of a files mtime" do
|
19
20
|
configfile = Configy::ConfigFile.new('nonexistent/file', 'development')
|
20
|
-
|
21
|
+
configfile.mtime.must_equal Time.at(0)
|
21
22
|
|
22
23
|
with_config_file( { 'common' => {'a' => '1', 'b' => '2' } }, 'app_config' ) do |file, hash|
|
23
24
|
configfile = Configy::ConfigFile.new(file, 'development')
|
24
|
-
|
25
|
+
configfile.mtime.must_equal File.mtime(file)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -1,13 +1,14 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
describe Configy::ConfigStore do
|
4
|
+
|
5
|
+
it "test should initialize with a hash" do
|
5
6
|
hash = {'common' => {'a' => 1, 'b' => 2} }
|
6
7
|
config = Configy::ConfigStore.new(hash)
|
7
|
-
|
8
|
+
config.to_hash.must_equal hash
|
8
9
|
end
|
9
10
|
|
10
|
-
|
11
|
+
it "test_should_compile_a_selected_section_with_the_common_section" do
|
11
12
|
hash1 = {
|
12
13
|
'common' => { 'a' => "A", 'b' => "B" },
|
13
14
|
'development' => { 'a' => "A*", 'c' => "C" }
|
@@ -15,12 +16,12 @@ class ConfigStoreTest < MiniTest::Unit::TestCase
|
|
15
16
|
|
16
17
|
config = Configy::ConfigStore.new(hash1).compile('development')
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
config['a'].must_equal "A*"
|
20
|
+
config['b'].must_equal "B"
|
21
|
+
config['c'].must_equal "C"
|
21
22
|
end
|
22
23
|
|
23
|
-
|
24
|
+
it "test should merge two configs together" do
|
24
25
|
hash1 = {
|
25
26
|
'common' => { 'a' => "A", 'b' => "B", 'c' => "C" },
|
26
27
|
'development' => { 'a' => "A*", 'c' => "C*", 'd' => "D", 'e' => "E" }
|
@@ -35,15 +36,15 @@ class ConfigStoreTest < MiniTest::Unit::TestCase
|
|
35
36
|
config2 = Configy::ConfigStore.new(hash2).compile('development')
|
36
37
|
config = config1.merge(config2)
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
config['a'].must_equal "A*"
|
40
|
+
config['b'].must_equal "B"
|
41
|
+
config['c'].must_equal "C**"
|
42
|
+
config['d'].must_equal "D"
|
43
|
+
config['e'].must_equal "E*"
|
44
|
+
config['f'].must_equal "F"
|
44
45
|
end
|
45
46
|
|
46
|
-
|
47
|
+
it "test should raise an exception if config is missing" do
|
47
48
|
assert_raises Configy::ConfigParamNotFound do
|
48
49
|
Configy::ConfigStore.new({})['oops']
|
49
50
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Configy do
|
4
|
+
before do
|
5
|
+
Configy.load_path = scratch_dir
|
6
|
+
Configy.cache_config = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should camelize" do
|
10
|
+
Configy.camelize('config').must_equal 'Config'
|
11
|
+
Configy.camelize('some_config').must_equal 'SomeConfig'
|
12
|
+
Configy.camelize('some-other_config').must_equal 'SomeOtherConfig'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should create a configuration class based on a yaml file" do
|
16
|
+
with_config_file( {'common' => {'a' => '1', 'b' => '2' }}, 'app_config' ) do |file, hash|
|
17
|
+
Configy.create('app_config')
|
18
|
+
Object.const_defined?(:AppConfig).must_equal true
|
19
|
+
AppConfig.b.must_equal '2'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "test should create a configuration class based on a yaml file within a parent module" do
|
24
|
+
with_config_file( {'common' => {'a' => '1', 'b' => '2' }}, 'app_config' ) do |file, hash|
|
25
|
+
Object.const_set('MyApp', Module)
|
26
|
+
Configy.create('app_config', MyApp)
|
27
|
+
MyApp.const_defined?(:AppConfig).must_equal true
|
28
|
+
MyApp::AppConfig.b.must_equal '2'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "test cache config always defaults to false" do
|
33
|
+
Configy.section = 'production'
|
34
|
+
Configy.cache_config.must_equal false
|
35
|
+
|
36
|
+
Configy.section = 'development'
|
37
|
+
Configy.cache_config.must_equal false
|
38
|
+
end
|
39
|
+
|
40
|
+
it "test should be able to manually set cache config" do
|
41
|
+
Configy.cache_config = true
|
42
|
+
Configy.create('dummy')
|
43
|
+
|
44
|
+
Configy.cache_config.must_equal true
|
45
|
+
Dummy.cache_config?.must_equal true
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Configy.load_path" do
|
4
|
+
before do
|
5
|
+
Configy.load_path = nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should default to config" do
|
9
|
+
Configy.load_path.must_equal "config"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should detect rails 3 config dir" do
|
13
|
+
rails3_obj = MiniTest::Mock.new
|
14
|
+
rails3_obj.expect :root, Pathname.new("path/to/rails/root")
|
15
|
+
|
16
|
+
with_const(:Rails, rails3_obj) do
|
17
|
+
Configy.load_path.must_equal Rails.root.join("config")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should detect rails 2 config dir" do
|
22
|
+
with_const( :RAILS_ROOT, "path/to/rails/root" ) do
|
23
|
+
Configy.load_path.must_equal "#{RAILS_ROOT}/config"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should detect rack config dir" do
|
28
|
+
with_const( :RACK_ROOT, "path/to/rack/root" ) do
|
29
|
+
Configy.load_path.must_equal "#{RACK_ROOT}/config"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Configy do
|
4
|
+
describe "with nested configurations" do
|
5
|
+
before do
|
6
|
+
Configy.load_path = scratch_dir
|
7
|
+
Configy.cache_config = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be accessbile as methods" do
|
11
|
+
with_config_file({
|
12
|
+
'common' => {
|
13
|
+
'level1' => {
|
14
|
+
'level2' => {
|
15
|
+
'level3' => 'whynot',
|
16
|
+
'falsekey' => false,
|
17
|
+
'truekey' => true
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}, 'nested_config') do
|
22
|
+
Configy.create('nested_config')
|
23
|
+
NestedConfig.level1.level2.level3.must_equal "whynot"
|
24
|
+
NestedConfig.level1.level2.nokey?.must_equal false
|
25
|
+
NestedConfig.level1.level2.falsekey?.must_equal false
|
26
|
+
NestedConfig.level1.level2.truekey?.must_equal true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Configy.section" do
|
4
|
+
before do
|
5
|
+
Configy.section = nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should default to development" do
|
9
|
+
Configy.section.must_equal "development"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should detect configy environment" do
|
13
|
+
with_const( :CONFIGY_ENV, "staging" ) do
|
14
|
+
Configy.section.must_equal "staging"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should detect rails 3 environment" do
|
19
|
+
rails3_obj = MiniTest::Mock.new
|
20
|
+
rails3_obj.expect :env, "staging"
|
21
|
+
|
22
|
+
with_const(:Rails, rails3_obj) do
|
23
|
+
Configy.section.must_equal "staging"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should detect rails 2 environment" do
|
28
|
+
with_const( :RAILS_ENV, "test" ) do
|
29
|
+
Configy.section.must_equal "test"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should detect rack environment" do
|
34
|
+
with_const( :RACK_ENV, "production" ) do
|
35
|
+
Configy.section.must_equal "production"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be able to override" do
|
40
|
+
Configy.section = "custom"
|
41
|
+
Configy.section.must_equal "custom"
|
42
|
+
end
|
43
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Gabe Varela
|
9
9
|
- Ben Marini
|
10
10
|
- Chip Miller
|
11
|
+
- Bram Swenson
|
12
|
+
- Jeremy Ruppel
|
11
13
|
autorequire:
|
12
14
|
bindir: bin
|
13
15
|
cert_chain: []
|
14
|
-
date: 2012-03-18 00:00:00.
|
16
|
+
date: 2012-03-18 00:00:00.000000000Z
|
15
17
|
dependencies:
|
16
18
|
- !ruby/object:Gem::Dependency
|
17
19
|
name: hashie
|
18
|
-
requirement: &
|
20
|
+
requirement: &2155296220 !ruby/object:Gem::Requirement
|
19
21
|
none: false
|
20
22
|
requirements:
|
21
23
|
- - ~>
|
@@ -23,10 +25,10 @@ dependencies:
|
|
23
25
|
version: 1.2.0
|
24
26
|
type: :runtime
|
25
27
|
prerelease: false
|
26
|
-
version_requirements: *
|
28
|
+
version_requirements: *2155296220
|
27
29
|
- !ruby/object:Gem::Dependency
|
28
30
|
name: bundler
|
29
|
-
requirement: &
|
31
|
+
requirement: &2155295760 !ruby/object:Gem::Requirement
|
30
32
|
none: false
|
31
33
|
requirements:
|
32
34
|
- - ! '>='
|
@@ -34,10 +36,10 @@ dependencies:
|
|
34
36
|
version: 1.0.0
|
35
37
|
type: :development
|
36
38
|
prerelease: false
|
37
|
-
version_requirements: *
|
39
|
+
version_requirements: *2155295760
|
38
40
|
- !ruby/object:Gem::Dependency
|
39
41
|
name: minitest
|
40
|
-
requirement: &
|
42
|
+
requirement: &2155295380 !ruby/object:Gem::Requirement
|
41
43
|
none: false
|
42
44
|
requirements:
|
43
45
|
- - ! '>='
|
@@ -45,7 +47,7 @@ dependencies:
|
|
45
47
|
version: '0'
|
46
48
|
type: :development
|
47
49
|
prerelease: false
|
48
|
-
version_requirements: *
|
50
|
+
version_requirements: *2155295380
|
49
51
|
description:
|
50
52
|
email: bmarini@gmail.com
|
51
53
|
executables: []
|
@@ -72,15 +74,15 @@ files:
|
|
72
74
|
- lib/generators/configy/install/templates/config/app_config.yml.tt
|
73
75
|
- lib/generators/configy/install/templates/config/initializers/configy.rb.tt
|
74
76
|
- lib/generators/configy_generator.rb
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
77
|
+
- spec/base_spec.rb
|
78
|
+
- spec/config_file_spec.rb
|
79
|
+
- spec/config_store_spec.rb
|
80
|
+
- spec/configy_spec.rb
|
81
|
+
- spec/load_path_spec.rb
|
82
|
+
- spec/nested_config_spec.rb
|
83
|
+
- spec/scratch/.gitkeep
|
84
|
+
- spec/section_spec.rb
|
85
|
+
- spec/spec_helper.rb
|
84
86
|
homepage: http://github.com/bmarini/configy
|
85
87
|
licenses: []
|
86
88
|
post_install_message:
|
@@ -102,8 +104,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
104
|
version: 1.3.6
|
103
105
|
requirements: []
|
104
106
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.8.
|
107
|
+
rubygems_version: 1.8.10
|
106
108
|
signing_key:
|
107
109
|
specification_version: 3
|
108
110
|
summary: Simple yaml driven configuration gem
|
109
111
|
test_files: []
|
112
|
+
has_rdoc:
|
data/test/configy_test.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ConfigyTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
Configy.load_path = scratch_dir
|
7
|
-
Configy.cache_config = nil
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_camelize
|
11
|
-
assert_equal 'Config', Configy.camelize('config')
|
12
|
-
assert_equal 'SomeConfig', Configy.camelize('some_config')
|
13
|
-
assert_equal 'SomeOtherConfig', Configy.camelize('some-other_config')
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_should_create_a_configuration_class_based_on_a_yaml_file
|
17
|
-
with_config_file( {'common' => {'a' => '1', 'b' => '2' }}, 'app_config' ) do |file, hash|
|
18
|
-
Configy.create('app_config')
|
19
|
-
assert Object.const_defined?(:AppConfig)
|
20
|
-
assert_equal AppConfig.b, '2'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_should_create_a_configuration_class_based_on_a_yaml_file_within_a_parent_module
|
25
|
-
with_config_file( {'common' => {'a' => '1', 'b' => '2' }}, 'app_config' ) do |file, hash|
|
26
|
-
Object.const_set('MyApp', Module)
|
27
|
-
Configy.create('app_config', MyApp)
|
28
|
-
assert MyApp.const_defined?(:AppConfig)
|
29
|
-
assert_equal MyApp::AppConfig.b, '2'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_cache_config_always_defaults_to_false
|
34
|
-
Configy.section = 'production'
|
35
|
-
assert_equal false, Configy.cache_config
|
36
|
-
|
37
|
-
Configy.section = 'development'
|
38
|
-
assert_equal false, Configy.cache_config
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_should_be_able_to_manually_set_cache_config
|
42
|
-
Configy.cache_config = true
|
43
|
-
Configy.create('dummy')
|
44
|
-
|
45
|
-
assert_equal true, Configy.cache_config
|
46
|
-
assert_equal true, Dummy.cache_config?
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
data/test/load_path_test.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class LoadPathTest < MiniTest::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
Configy.load_path = nil
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_should_default_to_config
|
9
|
-
assert_equal "config", Configy.load_path
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_should_detect_rails3_config_dir
|
13
|
-
rails3_obj = MiniTest::Mock.new
|
14
|
-
rails3_obj.expect :root, Pathname.new("path/to/rails/root")
|
15
|
-
|
16
|
-
with_const(:Rails, rails3_obj) do
|
17
|
-
assert_equal Rails.root.join("config"), Configy.load_path
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_should_detect_rails2_config_dir
|
22
|
-
with_const( :RAILS_ROOT, "path/to/rails/root" ) do
|
23
|
-
assert_equal "#{RAILS_ROOT}/config", Configy.load_path
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_should_detect_rack_config_dir
|
28
|
-
with_const( :RACK_ROOT, "path/to/rack/root" ) do
|
29
|
-
assert_equal "#{RACK_ROOT}/config", Configy.load_path
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/test/nested_config_test.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class NestedConfigTest < MiniTest::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
Configy.load_path = scratch_dir
|
6
|
-
Configy.cache_config = nil
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_nested_configs_should_be_accessible_as_methods
|
10
|
-
with_config_file({
|
11
|
-
'common' => {
|
12
|
-
'level1' => {
|
13
|
-
'level2' => {
|
14
|
-
'level3' => 'whynot'
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
18
|
-
}, 'nested_config') do
|
19
|
-
Configy.create('nested_config')
|
20
|
-
assert_equal 'whynot', NestedConfig.level1.level2.level3
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/test/section_test.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SectionTest < MiniTest::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
Configy.section = nil
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_should_default_to_development
|
9
|
-
assert_equal "development", Configy.section
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_should_detect_rails3_environment
|
13
|
-
rails3_obj = MiniTest::Mock.new
|
14
|
-
rails3_obj.expect :env, "staging"
|
15
|
-
|
16
|
-
with_const(:Rails, rails3_obj) do
|
17
|
-
assert_equal "staging", Configy.section
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_should_detect_rails2_environment
|
22
|
-
with_const( :RAILS_ENV, "test" ) do
|
23
|
-
assert_equal "test", Configy.section
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_should_detect_rack_environment
|
28
|
-
with_const( :RACK_ENV, "production" ) do
|
29
|
-
assert_equal "production", Configy.section
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_should_be_able_to_override
|
34
|
-
Configy.section = "custom"
|
35
|
-
assert_equal "custom", Configy.section
|
36
|
-
end
|
37
|
-
end
|