Config clearing.

This commit is contained in:
Mitchell Hashimoto 2010-02-23 21:39:56 -08:00
parent 1a6f838baa
commit 3b198e208d
4 changed files with 37 additions and 1 deletions

View File

@ -8,6 +8,11 @@ module Vagrant
@config_runners = []
class << self
def reset!
@config = nil
config_runners.clear
end
def config
@config ||= Config::Top.new
end

View File

@ -38,7 +38,8 @@ module Vagrant
load path if File.exist?(path)
end
# Execute the configurations
# Execute the configurations, clearing out the old data
Config.reset!
Config.execute!
end

View File

@ -1,6 +1,30 @@
require File.join(File.dirname(__FILE__), '..', 'test_helper')
class ConfigTest < Test::Unit::TestCase
context "resetting" do
setup do
Vagrant::Config.run { |config| }
Vagrant::Config.execute!
end
should "return the same config object typically" do
config = Vagrant::Config.config
assert config.equal?(Vagrant::Config.config)
end
should "create a new object if cleared" do
config = Vagrant::Config.config
Vagrant::Config.reset!
assert !config.equal?(Vagrant::Config.config)
end
should "empty the runners" do
assert !Vagrant::Config.config_runners.empty?
Vagrant::Config.reset!
assert Vagrant::Config.config_runners.empty?
end
end
context "accessing configuration" do
setup do
Vagrant::Config.run { |config| }

View File

@ -59,6 +59,12 @@ class EnvTest < Test::Unit::TestCase
Vagrant::Env.stubs(:root_path).returns(@root_path)
File.stubs(:exist?).returns(false)
Vagrant::Config.stubs(:execute!)
Vagrant::Config.stubs(:reset!)
end
should "reset the configuration object" do
Vagrant::Config.expects(:reset!).once
Vagrant::Env.load_config!
end
should "load from the project root" do