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