core: Vagrant.installer_embedded_dir

This commit is contained in:
Mitchell Hashimoto 2014-03-03 09:37:22 -08:00
parent 7194fc9173
commit 616bf15df5
2 changed files with 24 additions and 0 deletions

View File

@ -8,6 +8,15 @@ module Vagrant
# @return [String] # @return [String]
DEFAULT_SERVER_URL = "https://www.vagrantcloud.com" DEFAULT_SERVER_URL = "https://www.vagrantcloud.com"
# Returns the path to the embedded directory of the Vagrant installer,
# if there is one (if we're running in an installer).
#
# @return [String]
def self.installer_embedded_dir
return nil if !Vagrant.in_installer?
ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"]
end
# This returns whether or not 3rd party plugins should be loaded. # This returns whether or not 3rd party plugins should be loaded.
# #
# @return [Boolean] # @return [Boolean]

View File

@ -8,6 +8,21 @@ describe Vagrant do
subject { described_class } subject { described_class }
describe "#installer_embedded_dir" do
it "returns nil if not in an installer" do
Vagrant.stub(in_installer?: false)
expect(subject.installer_embedded_dir).to be_nil
end
it "returns the set directory" do
Vagrant.stub(in_installer?: true)
with_temp_env("VAGRANT_INSTALLER_EMBEDDED_DIR" => "/foo") do
expect(subject.installer_embedded_dir).to eq("/foo")
end
end
end
describe "#plugins_enabled?" do describe "#plugins_enabled?" do
it "returns true if the env is not set" do it "returns true if the env is not set" do
with_temp_env("VAGRANT_NO_PLUGINS" => nil) do with_temp_env("VAGRANT_NO_PLUGINS" => nil) do