From a8b57ba13fc8ba4579e10f708887c57a071b160f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 18 Jan 2013 12:27:29 -0800 Subject: [PATCH] Ignore empty error groups --- lib/vagrant/config/v2/root.rb | 6 ++++-- test/unit/vagrant/config/v2/root_test.rb | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/config/v2/root.rb b/lib/vagrant/config/v2/root.rb index 9b8cbf1f4..b2a6bf4f0 100644 --- a/lib/vagrant/config/v2/root.rb +++ b/lib/vagrant/config/v2/root.rb @@ -55,8 +55,10 @@ module Vagrant result = instance.validate(env) if result && !result.empty? result.each do |key, value| - errors[key] ||= [] - errors[key] += value + if !value.empty? + errors[key] ||= [] + errors[key] += value + end end end end diff --git a/test/unit/vagrant/config/v2/root_test.rb b/test/unit/vagrant/config/v2/root_test.rb index 10b5228a0..a705153ba 100644 --- a/test/unit/vagrant/config/v2/root_test.rb +++ b/test/unit/vagrant/config/v2/root_test.rb @@ -73,5 +73,16 @@ describe Vagrant::Config::V2::Root do instance.validate(env).should == expected_errors end + + it "shouldn't count empty keys" do + errors = { "foo" => [] } + env = { "errors" => errors } + foo = instance.foo + def foo.validate(env) + env["errors"] + end + + instance.validate(env).should == {} + end end end