Use Dir.mktmpdir for tests more
This commit is contained in:
parent
c9d9bf679b
commit
7c5d118e0d
|
@ -6,8 +6,6 @@ require "tmpdir"
|
|||
|
||||
require "vagrant/util/file_mode"
|
||||
|
||||
require "support/tempdir"
|
||||
|
||||
describe Vagrant::Environment do
|
||||
include_context "unit"
|
||||
|
||||
|
@ -50,28 +48,31 @@ describe Vagrant::Environment do
|
|||
|
||||
describe "current working directory" do
|
||||
it "is the cwd by default" do
|
||||
temp_dir = Tempdir.new.path
|
||||
Dir.mktmpdir do |temp_dir|
|
||||
Dir.chdir(temp_dir) do
|
||||
with_temp_env("VAGRANT_CWD" => nil) do
|
||||
described_class.new.cwd.should == Pathname.new(Dir.pwd)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "is set to the cwd given" do
|
||||
directory = Tempdir.new.path
|
||||
Dir.mktmpdir do |directory|
|
||||
instance = described_class.new(:cwd => directory)
|
||||
instance.cwd.should == Pathname.new(directory)
|
||||
end
|
||||
end
|
||||
|
||||
it "is set to the environmental variable VAGRANT_CWD" do
|
||||
directory = Tempdir.new.path
|
||||
Dir.mktmpdir do |directory|
|
||||
instance = with_temp_env("VAGRANT_CWD" => directory) do
|
||||
described_class.new
|
||||
end
|
||||
|
||||
instance.cwd.should == Pathname.new(directory)
|
||||
end
|
||||
end
|
||||
|
||||
it "raises an exception if the CWD doesn't exist" do
|
||||
expect { described_class.new(:cwd => "doesntexist") }.
|
||||
|
@ -81,10 +82,11 @@ describe Vagrant::Environment do
|
|||
|
||||
describe "home path" do
|
||||
it "is set to the home path given" do
|
||||
dir = Tempdir.new.path
|
||||
Dir.mktmpdir do |dir|
|
||||
instance = described_class.new(:home_path => dir)
|
||||
instance.home_path.should == Pathname.new(dir)
|
||||
end
|
||||
end
|
||||
|
||||
it "is set to the environmental variable VAGRANT_HOME" do
|
||||
Dir.mktmpdir do |dir|
|
||||
|
@ -120,10 +122,11 @@ describe Vagrant::Environment do
|
|||
end
|
||||
|
||||
it "is set to the given value" do
|
||||
dir = Tempdir.new.path
|
||||
Dir.mktmpdir do |dir|
|
||||
instance = described_class.new(:local_data_path => dir)
|
||||
instance.local_data_path.to_s.should == dir
|
||||
end
|
||||
end
|
||||
|
||||
describe "upgrading V1 dotfiles" do
|
||||
let(:v1_dotfile_tempfile) { Tempfile.new("vagrant") }
|
||||
|
|
Loading…
Reference in New Issue