Config clearing.
This commit is contained in:
parent
1a6f838baa
commit
3b198e208d
|
@ -8,6 +8,11 @@ module Vagrant
|
||||||
@config_runners = []
|
@config_runners = []
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
def reset!
|
||||||
|
@config = nil
|
||||||
|
config_runners.clear
|
||||||
|
end
|
||||||
|
|
||||||
def config
|
def config
|
||||||
@config ||= Config::Top.new
|
@config ||= Config::Top.new
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,7 +38,8 @@ module Vagrant
|
||||||
load path if File.exist?(path)
|
load path if File.exist?(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Execute the configurations
|
# Execute the configurations, clearing out the old data
|
||||||
|
Config.reset!
|
||||||
Config.execute!
|
Config.execute!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,30 @@
|
||||||
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
||||||
|
|
||||||
class ConfigTest < Test::Unit::TestCase
|
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
|
context "accessing configuration" do
|
||||||
setup do
|
setup do
|
||||||
Vagrant::Config.run { |config| }
|
Vagrant::Config.run { |config| }
|
||||||
|
|
|
@ -59,6 +59,12 @@ class EnvTest < Test::Unit::TestCase
|
||||||
Vagrant::Env.stubs(:root_path).returns(@root_path)
|
Vagrant::Env.stubs(:root_path).returns(@root_path)
|
||||||
File.stubs(:exist?).returns(false)
|
File.stubs(:exist?).returns(false)
|
||||||
Vagrant::Config.stubs(:execute!)
|
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
|
end
|
||||||
|
|
||||||
should "load from the project root" do
|
should "load from the project root" do
|
||||||
|
|
Loading…
Reference in New Issue