From 9212ba104a673286567192bf28caefb17db5a809 Mon Sep 17 00:00:00 2001 From: Keita Urashima Date: Wed, 25 Nov 2009 01:21:25 +0900 Subject: [PATCH] FileUtils.rm should be able to delete two or more files. Closes #23 --- lib/fakefs/fileutils.rb | 6 ++++-- test/fakefs_test.rb | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/fakefs/fileutils.rb b/lib/fakefs/fileutils.rb index bb61c07..34fec0e 100644 --- a/lib/fakefs/fileutils.rb +++ b/lib/fakefs/fileutils.rb @@ -19,8 +19,10 @@ module FakeFS end end - def rm(path) - FileSystem.delete(path) + def rm(list, options = {}) + Array(list).each do |path| + FileSystem.delete(path) + end end alias_method :rm_rf, :rm diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index ab4e0e2..8e31376 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -37,6 +37,13 @@ class FakeFSTest < Test::Unit::TestCase assert File.exists?("/path/to/dir") == false end + def test_can_delete_multiple_files + FileUtils.touch(["foo", "bar"]) + FileUtils.rm(["foo", "bar"]) + assert File.exists?("foo") == false + assert File.exists?("bar") == false + end + def test_knows_directories_exist FileUtils.mkdir_p(path = "/path/to/dir") assert File.exists?(path)