configloader 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/configloader.gemspec +1 -1
- data/lib/config_loader.rb +3 -1
- data/spec/config_loader/map_spec.rb +1 -0
- data/spec/config_loader_spec.rb +9 -6
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/configloader.gemspec
CHANGED
data/lib/config_loader.rb
CHANGED
@@ -42,7 +42,9 @@ module ConfigLoader
|
|
42
42
|
# db_config = ConfigLoader.load('database', 'production')
|
43
43
|
# db_config = ConfigLoader.load('database', 'test', '/home/user/my_special_project_root')
|
44
44
|
def self.load(file_name, running_env = Rails.env, project_root = RAILS_ROOT)
|
45
|
-
ConfigLoader::Map.new(file_name, running_env, project_root)
|
45
|
+
map = ConfigLoader::Map.new(file_name, running_env, project_root)
|
46
|
+
map.populate
|
47
|
+
map
|
46
48
|
end
|
47
49
|
|
48
50
|
end
|
data/spec/config_loader_spec.rb
CHANGED
@@ -6,24 +6,27 @@ describe "ConfigLoader" do
|
|
6
6
|
|
7
7
|
def prepare_mocks(running_env, project_root)
|
8
8
|
Rails.stub!(:env).and_return(running_env)
|
9
|
-
|
10
|
-
map_mock.should_receive(:populate)
|
11
|
-
|
9
|
+
ConfigLoader::Map.should_receive(:new).with('database', running_env, project_root).and_return(@map_mock)
|
10
|
+
@map_mock.should_receive(:populate)
|
11
|
+
end
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
@map_mock = mock('ConfigLoader::Map')
|
12
15
|
end
|
13
16
|
|
14
17
|
it "should delegate to ConfigLoader::Map.populate" do
|
15
18
|
prepare_mocks('development', '/home/user/project')
|
16
|
-
ConfigLoader.load('database').should ==
|
19
|
+
ConfigLoader.load('database').should == @map_mock
|
17
20
|
end
|
18
21
|
|
19
22
|
it "should delegate to ConfigLoader::Map.populate with the given running_env" do
|
20
23
|
prepare_mocks('production', '/home/user/project')
|
21
|
-
ConfigLoader.load('database', 'production').should ==
|
24
|
+
ConfigLoader.load('database', 'production').should == @map_mock
|
22
25
|
end
|
23
26
|
|
24
27
|
it "should delegate to ConfigLoader::Map.populate with the given project_root" do
|
25
28
|
prepare_mocks('development', '/home/user/another_project')
|
26
|
-
ConfigLoader.load('database', 'development', '/home/user/another_project').should ==
|
29
|
+
ConfigLoader.load('database', 'development', '/home/user/another_project').should == @map_mock
|
27
30
|
end
|
28
31
|
|
29
32
|
end
|