Use TEST_TMPDIR in rmdir tests.

This commit is contained in:
Michael Ledin 2017-02-19 07:59:57 +03:00
parent 5c185eaa43
commit 92fe130cbb
6 changed files with 25 additions and 9 deletions

View File

@ -271,15 +271,23 @@ describe Hbc::Artifact::Uninstall do
context "when using rmdir" do context "when using rmdir" do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-rmdir.rb") } let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-rmdir.rb") }
let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") } let(:empty_directory_path) { Pathname.new("#{TEST_TMPDIR}/empty_directory_path") }
before(:each) do
empty_directory_path.mkdir
end
after(:each) do
empty_directory_path.rmdir
end
it "can uninstall" do it "can uninstall" do
Hbc::FakeSystemCommand.expects_command( Hbc::FakeSystemCommand.expects_command(
sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")), sudo(%w[/bin/rm -f --], empty_directory_path/".DS_Store"),
) )
Hbc::FakeSystemCommand.expects_command( Hbc::FakeSystemCommand.expects_command(
sudo(%w[/bin/rmdir --], dir_pathname), sudo(%w[/bin/rmdir --], empty_directory_path),
) )
subject subject

View File

@ -272,15 +272,23 @@ describe Hbc::Artifact::Zap do
context "when using rmdir" do context "when using rmdir" do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-rmdir.rb") } let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-rmdir.rb") }
let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") } let(:empty_directory_path) { Pathname.new("#{TEST_TMPDIR}/empty_directory_path") }
before(:each) do
empty_directory_path.mkdir
end
after(:each) do
empty_directory_path.rmdir
end
it "can zap" do it "can zap" do
Hbc::FakeSystemCommand.expects_command( Hbc::FakeSystemCommand.expects_command(
sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")), sudo(%w[/bin/rm -f --], empty_directory_path/".DS_Store"),
) )
Hbc::FakeSystemCommand.expects_command( Hbc::FakeSystemCommand.expects_command(
sudo(%w[/bin/rmdir --], dir_pathname), sudo(%w[/bin/rmdir --], empty_directory_path),
) )
subject subject

View File

@ -17,5 +17,5 @@ cask 'with-installable' do
'impermissible/relative/path', 'impermissible/relative/path',
'/another/impermissible/../relative/path', '/another/impermissible/../relative/path',
], ],
rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" rmdir: "#{TEST_TMPDIR}/empty_directory_path"
end end

View File

@ -7,5 +7,5 @@ cask 'with-uninstall-rmdir' do
pkg 'MyFancyPkg/Fancy.pkg' pkg 'MyFancyPkg/Fancy.pkg'
uninstall rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" uninstall rmdir: "#{TEST_TMPDIR}/empty_directory_path"
end end

View File

@ -7,5 +7,5 @@ cask 'with-zap-rmdir' do
pkg 'MyFancyPkg/Fancy.pkg' pkg 'MyFancyPkg/Fancy.pkg'
zap rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" zap rmdir: "#{TEST_TMPDIR}/empty_directory_path"
end end