spec/figgy_spec.rb in figgy-0.9.0 vs spec/figgy_spec.rb in figgy-0.9.1
- old
+ new
@@ -99,9 +99,65 @@
second.still.should == "a dottable hash"
second[:still].should == "a dottable hash"
second["still"].should == "a dottable hash"
end
+
+ it "supports dottable and indifferent setting" do
+ write_config 'values', "number: 1"
+ config = test_config
+ config.values["number"] = 2
+ config.values.number.should == 2
+ config.values[:number] = 3
+ config.values.number.should == 3
+ config.values.number = 4
+ config.values.number.should == 4
+ end
+ end
+
+ context "multiple roots" do
+ it "can be told to read from multiple directories" do
+ write_config 'root1/values', 'foo: 1'
+ write_config 'root2/values', 'bar: 2'
+
+ config = test_config do |config|
+ config.root = File.join(current_dir, 'root1')
+ config.add_root File.join(current_dir, 'root2')
+ end
+
+ config.values.foo.should == 1
+ config.values.bar.should == 2
+ end
+
+ it "supports overlays in each root" do
+ write_config 'root1/values', 'foo: 1'
+ write_config 'root1/prod/values', 'foo: 2'
+ write_config 'root2/values', 'bar: 1'
+ write_config 'root2/prod/values', 'bar: 2'
+
+ config = test_config do |config|
+ config.root = File.join(current_dir, 'root1')
+ config.add_root File.join(current_dir, 'root2')
+ config.define_overlay :environment, 'prod'
+ end
+
+ config.values.foo.should == 2
+ config.values.bar.should == 2
+ end
+
+ it "reads from roots in *reverse* order of definition" do
+ write_config 'root1/values', 'foo: 1'
+ write_config 'root1/prod/values', 'foo: 2'
+ write_config 'root2/prod/values', 'foo: 3'
+
+ config = test_config do |config|
+ config.root = File.join(current_dir, 'root1')
+ config.add_root File.join(current_dir, 'root2')
+ config.define_overlay :environment, 'prod'
+ end
+
+ config.values.foo.should == 2
+ end
end
context "overlays" do
it "defaults to no overlay, thus reading directly from the config root" do
write_config 'values', "foo: 1"