From 253b433864924c8bcce3826f0d01ff8180a4da94 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 6 Nov 2012 21:32:26 -0800 Subject: [PATCH] Support configuring the version for test plugins. --- test/unit/support/shared/base_context.rb | 6 ++++-- test/unit/vagrant/config/v1/loader_test.rb | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/unit/support/shared/base_context.rb b/test/unit/support/shared/base_context.rb index 75891d820..e8417f6a0 100644 --- a/test/unit/support/shared/base_context.rb +++ b/test/unit/support/shared/base_context.rb @@ -18,6 +18,7 @@ shared_context "unit" do # Unregister each of the plugins we have may have temporarily # registered for the duration of this test. @_plugins.each do |plugin| + Vagrant.plugin("1").manager.unregister(plugin) Vagrant.plugin("2").manager.unregister(plugin) end end @@ -40,8 +41,9 @@ shared_context "unit" do # # @yield [plugin] Yields the plugin class for you to call the public # API that you need to. - def register_plugin - plugin = Class.new(Vagrant.plugin("2")) + def register_plugin(version=nil) + version ||= Vagrant::Config::CURRENT_VERSION + plugin = Class.new(Vagrant.plugin(version)) plugin.name("Test Plugin #{plugin.inspect}") yield plugin if block_given? @_plugins << plugin diff --git a/test/unit/vagrant/config/v1/loader_test.rb b/test/unit/vagrant/config/v1/loader_test.rb index 65b937313..653890154 100644 --- a/test/unit/vagrant/config/v1/loader_test.rb +++ b/test/unit/vagrant/config/v1/loader_test.rb @@ -21,7 +21,7 @@ describe Vagrant::Config::V1::Loader do stub_const("Vagrant::Config::CURRENT_VERSION", "1") # Register some config classes. - register_plugin do |p| + register_plugin("1") do |p| p.config("foo") { OpenStruct } p.config("bar", true) { OpenStruct } end @@ -37,7 +37,7 @@ describe Vagrant::Config::V1::Loader do stub_const("Vagrant::Config::CURRENT_VERSION", "2") # Register some config classes. - register_plugin do |p| + register_plugin("1") do |p| p.config("foo") { OpenStruct } p.config("bar", true) { OpenStruct } end @@ -52,7 +52,7 @@ describe Vagrant::Config::V1::Loader do describe "finalizing" do it "should call `#finalize` on the configuration object" do # Register a plugin for our test - register_plugin do |plugin| + register_plugin("1") do |plugin| plugin.config "foo" do Class.new do attr_accessor :bar @@ -82,7 +82,7 @@ describe Vagrant::Config::V1::Loader do describe "loading" do it "should configure with all plugin config keys loaded" do # Register a plugin for our test - register_plugin do |plugin| + register_plugin("1") do |plugin| plugin.config("foo") { OpenStruct } end