Remove temporary files in uninstall and zap specs.

This commit is contained in:
Markus Reiter 2017-03-05 03:46:48 +01:00
parent b7135eec49
commit e0e0233b2d
2 changed files with 50 additions and 24 deletions

View File

@ -7,19 +7,32 @@ describe Hbc::Artifact::Uninstall do
Hbc::Artifact::Uninstall.new(cask, command: Hbc::FakeSystemCommand) Hbc::Artifact::Uninstall.new(cask, command: Hbc::FakeSystemCommand)
} }
let(:absolute_path) { Pathname.new("#{TEST_TMPDIR}/absolute_path") } let(:dir) { TEST_TMPDIR }
let(:path_with_tilde) { Pathname.new("#{TEST_TMPDIR}/path_with_tilde") } let(:absolute_path) { Pathname.new("#{dir}/absolute_path") }
let(:glob_path1) { Pathname.new("#{TEST_TMPDIR}/glob_path1") } let(:path_with_tilde) { Pathname.new("#{dir}/path_with_tilde") }
let(:glob_path2) { Pathname.new("#{TEST_TMPDIR}/glob_path2") } let(:glob_path1) { Pathname.new("#{dir}/glob_path1") }
let(:glob_path2) { Pathname.new("#{dir}/glob_path2") }
before(:each) do around(:each) do |example|
FileUtils.touch(absolute_path) begin
FileUtils.touch(path_with_tilde) ENV["HOME"] = dir
FileUtils.touch(glob_path1)
FileUtils.touch(glob_path2) paths = [
ENV["HOME"] = TEST_TMPDIR absolute_path,
shutup do path_with_tilde,
InstallHelper.install_without_artifacts(cask) glob_path1,
glob_path2,
]
FileUtils.touch paths
shutup do
InstallHelper.install_without_artifacts(cask)
end
example.run
ensure
FileUtils.rm_f paths
end end
end end

View File

@ -8,19 +8,32 @@ describe Hbc::Artifact::Zap do
Hbc::Artifact::Zap.new(cask, command: Hbc::FakeSystemCommand) Hbc::Artifact::Zap.new(cask, command: Hbc::FakeSystemCommand)
} }
let(:absolute_path) { Pathname.new("#{TEST_TMPDIR}/absolute_path") } let(:dir) { TEST_TMPDIR }
let(:path_with_tilde) { Pathname.new("#{TEST_TMPDIR}/path_with_tilde") } let(:absolute_path) { Pathname.new("#{dir}/absolute_path") }
let(:glob_path1) { Pathname.new("#{TEST_TMPDIR}/glob_path1") } let(:path_with_tilde) { Pathname.new("#{dir}/path_with_tilde") }
let(:glob_path2) { Pathname.new("#{TEST_TMPDIR}/glob_path2") } let(:glob_path1) { Pathname.new("#{dir}/glob_path1") }
let(:glob_path2) { Pathname.new("#{dir}/glob_path2") }
before(:each) do around(:each) do |example|
FileUtils.touch(absolute_path) begin
FileUtils.touch(path_with_tilde) ENV["HOME"] = dir
FileUtils.touch(glob_path1)
FileUtils.touch(glob_path2) paths = [
ENV["HOME"] = TEST_TMPDIR absolute_path,
shutup do path_with_tilde,
InstallHelper.install_without_artifacts(cask) glob_path1,
glob_path2,
]
FileUtils.touch paths
shutup do
InstallHelper.install_without_artifacts(cask)
end
example.run
ensure
FileUtils.rm_f paths
end end
end end