Raise an error if the CWD is incorrect
This commit is contained in:
parent
6969f791ad
commit
f8fa859b5f
|
@ -59,6 +59,7 @@ module Vagrant
|
|||
opts[:cwd] ||= ENV["VAGRANT_CWD"] if ENV.has_key?("VAGRANT_CWD")
|
||||
opts[:cwd] ||= Dir.pwd
|
||||
opts[:cwd] = Pathname.new(opts[:cwd])
|
||||
raise Errors::EnvironmentNonExistentCWD if !opts[:cwd].directory?
|
||||
|
||||
# Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that
|
||||
# those continue to work as well, but anything custom will take precedence.
|
||||
|
|
|
@ -173,6 +173,11 @@ module Vagrant
|
|||
error_key(:status_error, "vagrant.downloaders.http")
|
||||
end
|
||||
|
||||
class EnvironmentNonExistentCWD < VagrantError
|
||||
status_code(75)
|
||||
error_key(:environment_non_existent_cwd)
|
||||
end
|
||||
|
||||
class EnvironmentLockedError < VagrantError
|
||||
status_code(52)
|
||||
error_key(:environment_locked)
|
||||
|
|
|
@ -17,13 +17,19 @@ describe Vagrant::Environment do
|
|||
end
|
||||
|
||||
it "is set to the cwd given" do
|
||||
instance = described_class.new(:cwd => "foobarbaz")
|
||||
instance.cwd.should == Pathname.new("foobarbaz")
|
||||
directory = File.dirname(__FILE__)
|
||||
instance = described_class.new(:cwd => directory)
|
||||
instance.cwd.should == Pathname.new(directory)
|
||||
end
|
||||
|
||||
it "is set to the environmental variable VAGRANT_CWD" do
|
||||
pending "A good temporary ENV thing"
|
||||
end
|
||||
|
||||
it "raises an exception if the CWD doesn't exist" do
|
||||
expect { described_class.new(:cwd => "doesntexist") }.
|
||||
to raise_error(Vagrant::Errors::EnvironmentNonExistentCWD)
|
||||
end
|
||||
end
|
||||
|
||||
describe "home path" do
|
||||
|
|
Loading…
Reference in New Issue