2011-12-15 06:43:45 +00:00
|
|
|
require File.expand_path("../base", __FILE__)
|
|
|
|
|
|
|
|
describe Vagrant do
|
2013-02-22 23:10:34 +00:00
|
|
|
include_context "unit"
|
|
|
|
|
2011-12-15 06:43:45 +00:00
|
|
|
it "has the path to the source root" do
|
|
|
|
described_class.source_root.should == Pathname.new(File.expand_path("../../../", __FILE__))
|
|
|
|
end
|
|
|
|
|
2012-04-15 20:34:44 +00:00
|
|
|
describe "plugin superclass" do
|
2012-06-26 22:47:26 +00:00
|
|
|
describe "v1" do
|
|
|
|
it "returns the proper class for version 1" do
|
|
|
|
described_class.plugin("1").should == Vagrant::Plugin::V1::Plugin
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns the proper components for version 1" do
|
2012-06-26 23:18:02 +00:00
|
|
|
described_class.plugin("1", :command).should == Vagrant::Plugin::V1::Command
|
2012-08-09 04:28:28 +00:00
|
|
|
described_class.plugin("1", :communicator).should == Vagrant::Plugin::V1::Communicator
|
2012-06-26 22:47:26 +00:00
|
|
|
described_class.plugin("1", :config).should == Vagrant::Plugin::V1::Config
|
2012-06-26 23:28:49 +00:00
|
|
|
described_class.plugin("1", :guest).should == Vagrant::Plugin::V1::Guest
|
2012-06-27 16:26:03 +00:00
|
|
|
described_class.plugin("1", :host).should == Vagrant::Plugin::V1::Host
|
2012-07-14 23:57:54 +00:00
|
|
|
described_class.plugin("1", :provider).should == Vagrant::Plugin::V1::Provider
|
2012-06-26 22:47:26 +00:00
|
|
|
described_class.plugin("1", :provisioner).should == Vagrant::Plugin::V1::Provisioner
|
|
|
|
end
|
2012-04-15 20:34:44 +00:00
|
|
|
end
|
|
|
|
|
2013-11-22 01:38:17 +00:00
|
|
|
describe "v2" do
|
|
|
|
it "returns the proper class for version 2" do
|
|
|
|
described_class.plugin("2").should == Vagrant::Plugin::V2::Plugin
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns the proper components for version 2" do
|
|
|
|
described_class.plugin("2", :command).should == Vagrant::Plugin::V2::Command
|
|
|
|
described_class.plugin("2", :communicator).should == Vagrant::Plugin::V2::Communicator
|
|
|
|
described_class.plugin("2", :config).should == Vagrant::Plugin::V2::Config
|
|
|
|
described_class.plugin("2", :guest).should == Vagrant::Plugin::V2::Guest
|
|
|
|
described_class.plugin("2", :host).should == Vagrant::Plugin::V2::Host
|
|
|
|
described_class.plugin("2", :provider).should == Vagrant::Plugin::V2::Provider
|
|
|
|
described_class.plugin("2", :provisioner).should == Vagrant::Plugin::V2::Provisioner
|
|
|
|
described_class.plugin("2", :synced_folder).should == Vagrant::Plugin::V2::SyncedFolder
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-04-15 20:34:44 +00:00
|
|
|
it "raises an exception if an unsupported version is given" do
|
|
|
|
expect { described_class.plugin("88") }.
|
|
|
|
to raise_error(ArgumentError)
|
|
|
|
end
|
|
|
|
end
|
2012-05-06 21:01:10 +00:00
|
|
|
|
|
|
|
describe "requiring plugins" do
|
|
|
|
it "should require the plugin given" do
|
|
|
|
# For now, just require a stdlib
|
|
|
|
expect { described_class.require_plugin "set" }.
|
|
|
|
to_not raise_error
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should raise an error if the file doesn't exist" do
|
|
|
|
expect { described_class.require_plugin("i_dont_exist") }.
|
|
|
|
to raise_error(Vagrant::Errors::PluginLoadError)
|
|
|
|
end
|
2013-02-22 23:10:34 +00:00
|
|
|
|
|
|
|
it "should raise an error if the loading failed in some other way" do
|
|
|
|
plugin_dir = temporary_dir
|
|
|
|
plugin_path = plugin_dir.join("test.rb")
|
|
|
|
plugin_path.open("w") do |f|
|
|
|
|
f.write(%Q[require 'I_dont_exist'])
|
|
|
|
end
|
|
|
|
|
|
|
|
expect { described_class.require_plugin(plugin_path.to_s) }.
|
|
|
|
to raise_error(Vagrant::Errors::PluginLoadFailed)
|
|
|
|
end
|
2012-05-06 21:01:10 +00:00
|
|
|
end
|
2013-09-11 19:58:21 +00:00
|
|
|
|
|
|
|
describe "has_plugin?" do
|
|
|
|
after(:each) do
|
|
|
|
described_class.plugin('2').manager.reset!
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return true if the plugin is installed" do
|
|
|
|
plugin = Class.new(described_class.plugin('2')) do
|
|
|
|
name "i_am_installed"
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.has_plugin?("i_am_installed").should be_true
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return false if the plugin is not installed" do
|
|
|
|
described_class.has_plugin?("i_dont_exist").should be_false
|
|
|
|
end
|
|
|
|
end
|
2013-11-23 20:23:34 +00:00
|
|
|
|
|
|
|
describe "require_version" do
|
|
|
|
it "should succeed if valid range" do
|
|
|
|
expect { described_class.require_version(Vagrant::VERSION) }.
|
|
|
|
to_not raise_error
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not succeed if bad range" do
|
|
|
|
expect { described_class.require_version("> #{Vagrant::VERSION}") }.
|
|
|
|
to raise_error(Vagrant::Errors::VagrantVersionBad)
|
|
|
|
end
|
|
|
|
end
|
2011-12-15 06:43:45 +00:00
|
|
|
end
|