configy 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- configy (1.1.0)
4
+ configy (1.1.2)
5
5
  hashie (~> 1.2.0)
6
6
 
7
7
  GEM
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.1.2 (2012-03-30)
2
+
3
+ * If CONFIGY_ENV is set, use that to determine config section to use.
4
+
1
5
  ## 1.1.1 (2012-03-18)
2
6
 
3
7
  * Allow Configy to define configs within other modules
data/README.md CHANGED
@@ -56,6 +56,8 @@ It doesn't allow to change the values in the application code, BTW.
56
56
  * Gabe Varela
57
57
  * Ben Marini
58
58
  * Chip Miller
59
+ * Bram Swenson
60
+ * Jeremy Ruppel
59
61
 
60
62
  ## History
61
63
 
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' << 'test'
7
- test.pattern = 'test/**/*_test.rb'
6
+ test.libs << 'lib' << 'spec'
7
+ test.pattern = 'spec/**/*_spec.rb'
8
8
  test.verbose = true
9
9
  end
10
10
 
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "configy"
3
- s.version = "1.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"
@@ -26,6 +26,8 @@ module Configy
26
26
  def section
27
27
  if @section
28
28
  @section
29
+ elsif defined? CONFIGY_ENV
30
+ CONFIGY_ENV
29
31
  elsif defined? Rails
30
32
  Rails.env
31
33
  elsif defined? RAILS_ENV
@@ -1,7 +1,7 @@
1
- require 'test_helper'
1
+ require 'spec_helper'
2
2
  require 'erb'
3
3
 
4
- class ConfigFileTest < MiniTest::Unit::TestCase
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
- def test_top_level_configs_should_be_accesssible_as_methods
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
- assert_equal 1, config.a
29
+ config.a.must_equal 1
30
30
  end
31
31
  end
32
32
 
33
- def test_method_missing
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
- def test_should_override_params_with_another_file_and_use_proper_section
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
- assert_equal '2', config.a
45
- assert_equal 8, config.b
46
- assert_equal 2, config.c
47
- assert_equal 6, config.d
48
- assert_equal 42, config.e
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
- def test_should_reload_a_config_file_if_changed
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
- assert_equal 'foo', config.a
59
- assert_equal 'bar', config.b
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
- assert_equal 'foo*', config.a
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
- assert_equal 'bar*', config.b
77
+ config.b.must_equal 'bar*'
78
78
 
79
79
  end
80
80
  end
81
81
  end
82
82
 
83
- def test_should_not_reload_a_config_file_if_changed_and_cache_config_is_true
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
- assert_equal 'foo', config.a
89
- assert_equal 'bar', config.b
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
- assert_equal 'foo', config.a
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
- assert_equal 'bar', config.b
107
+ config.b.must_equal 'bar'
108
108
 
109
109
  end
110
110
  end
@@ -1,27 +1,28 @@
1
- require 'test_helper'
1
+ require 'spec_helper'
2
2
 
3
- class ConfigFileTest < MiniTest::Unit::TestCase
4
- def test_should_load_a_config_from_a_file
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
- assert_equal hash, configfile.load_file
8
+ configfile.load_file.must_equal hash
8
9
  end
9
10
  end
10
11
 
11
- def test_should_create_an_instance_of_config_store
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
- assert_instance_of Configy::ConfigStore, configfile.config
15
+ configfile.config.must_be_instance_of Configy::ConfigStore
15
16
  end
16
17
  end
17
18
 
18
- def test_should_be_aware_of_a_files_mtime
19
+ it "test should be aware of a files mtime" do
19
20
  configfile = Configy::ConfigFile.new('nonexistent/file', 'development')
20
- assert_equal Time.at(0), configfile.mtime
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
- assert_equal File.mtime(file), configfile.mtime
25
+ configfile.mtime.must_equal File.mtime(file)
25
26
  end
26
27
  end
27
28
 
@@ -1,13 +1,14 @@
1
- require 'test_helper'
1
+ require 'spec_helper'
2
2
 
3
- class ConfigStoreTest < MiniTest::Unit::TestCase
4
- def test_should_initialize_with_a_hash
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
- assert_equal hash, config.to_hash
8
+ config.to_hash.must_equal hash
8
9
  end
9
10
 
10
- def test_should_compile_a_selected_section_with_the_common_section
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
- assert_equal "A*", config['a']
19
- assert_equal "B", config['b']
20
- assert_equal "C", config['c']
19
+ config['a'].must_equal "A*"
20
+ config['b'].must_equal "B"
21
+ config['c'].must_equal "C"
21
22
  end
22
23
 
23
- def test_should_merge_two_configs_together
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
- assert_equal "A*", config['a']
39
- assert_equal "B", config['b']
40
- assert_equal "C**", config['c']
41
- assert_equal "D", config['d']
42
- assert_equal "E*", config['e']
43
- assert_equal "F", config['f']
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
- def test_should_raise_an_exception_if_config_is_missing
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
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.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.000000000 Z
16
+ date: 2012-03-18 00:00:00.000000000Z
15
17
  dependencies:
16
18
  - !ruby/object:Gem::Dependency
17
19
  name: hashie
18
- requirement: &70109332176180 !ruby/object:Gem::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: *70109332176180
28
+ version_requirements: *2155296220
27
29
  - !ruby/object:Gem::Dependency
28
30
  name: bundler
29
- requirement: &70109332175720 !ruby/object:Gem::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: *70109332175720
39
+ version_requirements: *2155295760
38
40
  - !ruby/object:Gem::Dependency
39
41
  name: minitest
40
- requirement: &70109332175340 !ruby/object:Gem::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: *70109332175340
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
- - test/base_test.rb
76
- - test/config_file_test.rb
77
- - test/config_store_test.rb
78
- - test/configy_test.rb
79
- - test/load_path_test.rb
80
- - test/nested_config_test.rb
81
- - test/scratch/.gitkeep
82
- - test/section_test.rb
83
- - test/test_helper.rb
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.11
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:
@@ -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
@@ -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
@@ -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
@@ -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