Cleanup more files in tests

This commit is contained in:
Seth Vargo 2016-05-29 00:34:00 -04:00
parent 1b414d3d9e
commit b993699af6
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
6 changed files with 29 additions and 13 deletions

View File

@ -10,13 +10,17 @@ describe VagrantPlugins::DockerProvider::Config do
let(:machine) { double("machine") }
let(:build_dir) do
temporary_dir.tap do |dir|
dir.join("Dockerfile").open("w") do |f|
Dir.mktmpdir("vagrant-test-docker-provider-build-dir").tap do |dir|
File.open(File.join(dir, "Dockerfile"), "wb+") do |f|
f.write("Hello")
end
end
end
after do
FileUtils.rm_rf(build_dir)
end
def assert_invalid
errors = subject.validate(machine)
if !errors.values.any? { |v| !v.empty? }

View File

@ -125,6 +125,14 @@ describe VagrantPlugins::AtlasPush::Push do
end
describe "#uploader_path" do
let(:scratch) do
Pathname.new(Dir.mktmpdir("vagrant-test-atlas-push-upload-path"))
end
after do
FileUtils.rm_rf(scratch)
end
it "should return the configured path if set" do
config.uploader_path = "foo"
expect(subject.uploader_path).to eq("foo")
@ -141,12 +149,10 @@ describe VagrantPlugins::AtlasPush::Push do
end
it "should look up the uploader in the embedded dir if installer" do
dir = temporary_dir
allow(Vagrant).to receive(:in_installer?).and_return(true)
allow(Vagrant).to receive(:installer_embedded_dir).and_return(dir.to_s)
allow(Vagrant).to receive(:installer_embedded_dir).and_return(scratch.to_s)
bin_path = dir.join("bin", bin)
bin_path = scratch.join("bin", bin)
bin_path.dirname.mkpath
bin_path.open("w+") { |f| f.write("hi") }
@ -154,10 +160,8 @@ describe VagrantPlugins::AtlasPush::Push do
end
it "should look up the uploader in the PATH if not in the installer" do
dir = temporary_dir
allow(Vagrant).to receive(:in_installer?).and_return(true)
allow(Vagrant).to receive(:installer_embedded_dir).and_return(dir.to_s)
allow(Vagrant).to receive(:installer_embedded_dir).and_return(scratch.to_s)
expect(Vagrant::Util::Which).to receive(:which).
with(described_class.const_get(:UPLOADER_BIN)).

View File

@ -41,7 +41,7 @@ describe VagrantPlugins::FTPPush::Push do
end
@server.start
@dir = temporary_dir
@dir = Dir.mktmpdir("vagrant-ftp-push")
FileUtils.touch("#{@dir}/.hidden.rb")
FileUtils.touch("#{@dir}/application.rb")
FileUtils.touch("#{@dir}/config.rb")
@ -51,6 +51,7 @@ describe VagrantPlugins::FTPPush::Push do
end
after(:all) do
FileUtils.rm_rf(@dir)
@server.stop
end

View File

@ -290,6 +290,14 @@ describe Vagrant::Box, :skip_windows do
end
describe "repackaging" do
let(:scratch) { Dir.mktmpdir("vagrant-test-box-repackaging") }
let(:box_output_path) { File.join(scratch, "package.box") }
after do
FileUtils.rm_rf(scratch)
end
it "should repackage the box" do
test_file_contents = "hello, world!"
@ -300,7 +308,6 @@ describe Vagrant::Box, :skip_windows do
end
# Repackage our box to some temporary directory
box_output_path = temporary_dir.join("package.box")
expect(subject.repackage(box_output_path)).to be_true
# Let's now add this box again under a different name, and then

View File

@ -933,7 +933,7 @@ VF
let(:instance) { described_class.new(local_data_path: local_data_path) }
after do
File.unlink(v1_dotfile) if File.file?(v1_dotfile)
FileUtils.rm_rf(local_data_path)
end
it "should be fine if dotfile is empty" do

View File

@ -9,7 +9,7 @@ require "vagrant/machine_index"
describe Vagrant::MachineIndex do
include_context "unit"
let(:data_dir) { temporary_dir }
let(:data_dir) { Pathname.new(Dir.mktmpdir("vagrant-test-machine-index-data-dir")) }
let(:entry_klass) { Vagrant::MachineIndex::Entry }
let(:new_entry) do