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:
parent
3221e40dff
commit
a201579ef4
@ -97,7 +97,7 @@ module FakeFS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def touch(list, options={})
|
def touch(list, options={})
|
||||||
list.each do |f|
|
Array(list).each do |f|
|
||||||
directory = File.dirname(f)
|
directory = File.dirname(f)
|
||||||
# FIXME this explicit check for '.' shouldn't need to happen
|
# FIXME this explicit check for '.' shouldn't need to happen
|
||||||
if File.exists?(directory) || directory == '.'
|
if File.exists?(directory) || directory == '.'
|
||||||
|
@ -449,12 +449,21 @@ class FakeFSTest < Test::Unit::TestCase
|
|||||||
def test_files_can_be_touched
|
def test_files_can_be_touched
|
||||||
FileUtils.touch('touched_file')
|
FileUtils.touch('touched_file')
|
||||||
assert File.exists?('touched_file')
|
assert File.exists?('touched_file')
|
||||||
|
list = ['newfile', 'another']
|
||||||
|
FileUtils.touch(list)
|
||||||
|
list.each { |fp| assert(File.exists?(fp)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_touch_does_not_work_if_the_dir_path_cannot_be_found
|
def test_touch_does_not_work_if_the_dir_path_cannot_be_found
|
||||||
assert_raises(Errno::ENOENT) {
|
assert_raises(Errno::ENOENT) {
|
||||||
FileUtils.touch('this/path/should/not/be/here')
|
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
|
end
|
||||||
|
|
||||||
def here(fname)
|
def here(fname)
|
||||||
|
Loading…
Reference in New Issue
Block a user