diff --git a/lib/vagrant/config/v1.rb b/lib/vagrant/config/v1.rb index bf8936a9d..706e41ec8 100644 --- a/lib/vagrant/config/v1.rb +++ b/lib/vagrant/config/v1.rb @@ -1,6 +1,7 @@ module Vagrant module Config module V1 + autoload :DummyConfig, "vagrant/config/v1/dummy_config" autoload :Loader, "vagrant/config/v1/loader" autoload :Root, "vagrant/config/v1/root" end diff --git a/lib/vagrant/config/v1/dummy_config.rb b/lib/vagrant/config/v1/dummy_config.rb new file mode 100644 index 000000000..dc678a33d --- /dev/null +++ b/lib/vagrant/config/v1/dummy_config.rb @@ -0,0 +1,13 @@ +module Vagrant + module Config + module V1 + # This is a configuration object that can have anything done + # to it. Anything, and it just appears to keep working. + class DummyConfig + def method_missing(name, *args, &block) + DummyConfig.new + end + end + end + end +end diff --git a/lib/vagrant/config/v1/root.rb b/lib/vagrant/config/v1/root.rb index ba3288095..1f7db9763 100644 --- a/lib/vagrant/config/v1/root.rb +++ b/lib/vagrant/config/v1/root.rb @@ -1,4 +1,3 @@ -require "ostruct" require "set" module Vagrant @@ -31,7 +30,7 @@ module Vagrant else # Record access to a missing key as an error @missing_key_calls.add(name.to_s) - return OpenStruct.new + return DummyConfig.new end end diff --git a/test/unit/vagrant/config/v1/dummy_config_test.rb b/test/unit/vagrant/config/v1/dummy_config_test.rb new file mode 100644 index 000000000..22a99a97b --- /dev/null +++ b/test/unit/vagrant/config/v1/dummy_config_test.rb @@ -0,0 +1,24 @@ +require File.expand_path("../../../../base", __FILE__) + +describe Vagrant::Config::V1::DummyConfig do + it "should allow attribute setting" do + expect { subject.foo = :bar }. + to_not raise_error + end + + it "should allow method calls that return more DummyConfigs" do + subject.foo.should be_kind_of(described_class) + end + + it "should allow hash access" do + expect { subject[:foo] }. + to_not raise_error + + subject[:foo].should be_kind_of(described_class) + end + + it "should allow setting hash values" do + expect { subject[:foo] = :bar }. + to_not raise_error + end +end