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
|
|
|
|
2013-09-11 19:58:21 +00:00
|
|
|
describe "has_plugin?" do
|
2013-12-18 02:20:10 +00:00
|
|
|
before(:each) do
|
|
|
|
Class.new(described_class.plugin("2")) do
|
|
|
|
name "i_am_installed"
|
|
|
|
end
|
|
|
|
manager.plugin_required("plugin_gem")
|
|
|
|
end
|
2013-09-11 19:58:21 +00:00
|
|
|
after(:each) do
|
2013-12-18 02:20:10 +00:00
|
|
|
manager.reset!
|
2013-09-11 19:58:21 +00:00
|
|
|
end
|
2013-12-18 02:20:10 +00:00
|
|
|
let(:manager) { described_class.plugin("2").manager }
|
2013-09-11 19:58:21 +00:00
|
|
|
|
2013-12-18 02:20:10 +00:00
|
|
|
it "should find the installed plugin by the gem name" do
|
|
|
|
expect(described_class.has_plugin?("plugin_gem")).to be_true
|
|
|
|
end
|
2013-09-11 19:58:21 +00:00
|
|
|
|
2013-12-18 02:20:10 +00:00
|
|
|
it "should find the installed plugin by the registered name" do
|
|
|
|
expect(described_class.has_plugin?("i_am_installed")).to be_true
|
2013-09-11 19:58:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should return false if the plugin is not installed" do
|
2013-12-18 02:20:10 +00:00
|
|
|
expect(described_class.has_plugin?("i_dont_exist")).to be_false
|
2013-09-11 19:58:21 +00:00
|
|
|
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
|