I am trying to test a scenario where my app writes some files to a folder and that folder should then be removed after the test.
class TestDirectory < Test::Unit::TestCase
def setup
@target = "some/path"
FileUtils.mkdir_p(@target)
end
def teardown
FileUtils.rm_rf(@target)
end
test "remove directory" do
#some tests
end
end
But for some reason the folder does not get removed. I have also tried to set the secure option to false for FileUtils#rm_rf but that didn’t help either. Neither the parent nor the target folder are world writable, which could be an issue according to the documentation. I am running on Mac OS X Lion.
What am I doing wrong?
This code works for me: