FileUtils.touch with multiple files was broken on 1.9.

String#each does not exist in ruby 1.9, so Array() must be used.
This commit is contained in:
Jeff Hodges 2009-06-13 23:56:14 -07:00
parent 3221e40dff
commit a201579ef4
2 changed files with 10 additions and 1 deletions

View File

@ -97,7 +97,7 @@ module FakeFS
end
def touch(list, options={})
list.each do |f|
Array(list).each do |f|
directory = File.dirname(f)
# FIXME this explicit check for '.' shouldn't need to happen
if File.exists?(directory) || directory == '.'

View File

@ -449,12 +449,21 @@ class FakeFSTest < Test::Unit::TestCase
def test_files_can_be_touched
FileUtils.touch('touched_file')
assert File.exists?('touched_file')
list = ['newfile', 'another']
FileUtils.touch(list)
list.each { |fp| assert(File.exists?(fp)) }
end
def test_touch_does_not_work_if_the_dir_path_cannot_be_found
assert_raises(Errno::ENOENT) {
FileUtils.touch('this/path/should/not/be/here')
}
FileUtils.mkdir_p('subdir')
list = ['subdir/foo', 'nosubdir/bar']
assert_raises(Errno::ENOENT) {
FileUtils.touch(list)
}
end
def here(fname)