test/environment_test.rb in rubber-2.1.1 vs test/environment_test.rb in rubber-2.1.2
- old
+ new
@@ -73,10 +73,17 @@
assert_equal({1 => "1", 2 => "2", 3 => "3", 4 => "4"}, env.combine({1 => "1", 2 => "2"}, {3 => "3", 4 => "4"}), "Maps should be unioned when combined")
assert_equal({1 => "2"}, env.combine({1 => "1"}, {1 => "2"}), "Last should win for scalars in maps when combined")
assert_equal({1 => {1 => "1", 2 => "2"}}, env.combine({1 => {1 => "1"}}, {1 => {2 => "2"}}), "Maps should be unioned recursively when combined")
end
+ def test_combine_override
+ env = Rubber::Configuration::Environment
+ assert_equal({"x" => 4, "y" => 2, "z" => 3}, env.combine({"x" => 1, "y" => 2}, {"^x" => 4, "z" => 3}), "scalars should override")
+ assert_equal({"x" => [3, 4]}, env.combine({"x" => [1, 2]}, {"^x" => [3, 4]}), "lists should override")
+ assert_equal({"x" => {"y" => [3, 4]}}, env.combine({"x" => {"y" => [1, 2]}}, {"x" => {"^y" => [3, 4]}}), "Maps should override recursively")
+ end
+
def test_expansion
env = Rubber::Configuration::Environment.new("#{File.dirname(__FILE__)}/fixtures/expansion", 'test')
e = env.bind()
assert_equal 'val1', e['var1']
assert_equal 'val2', e['var2']
@@ -150,6 +157,12 @@
e = config.environment.bind()
e.stubs(:rubber_instances).returns(config.instance)
assert_equal "50.1.1.1", e['var1']
end
+ def test_erb_yml
+ env = Rubber::Configuration::Environment.new("#{File.dirname(__FILE__)}/fixtures/basic", 'test')
+ e = env.bind()
+ assert_equal [0, 1, 2], e["erb_var"], 'should be able to generate env using erb'
+ end
+
end