diff --git a/lib/fakefs.rb b/lib/fakefs.rb index 6f4f04e..3b04080 100644 --- a/lib/fakefs.rb +++ b/lib/fakefs.rb @@ -98,15 +98,12 @@ module FakeFS def touch(list, options={}) list.each do |f| - if f =~ /(.+\/)/ - dir_path = f.scan(/(.+\/)/) - if FileSystem.find(dir_path.to_s) - FileSystem.add(f, MockFile.new) - else - raise Errno::ENOENT, f - end - else + directory = File.dirname(f) + # FIXME this explicit check for '.' shouldn't need to happen + if File.exists?(directory) || directory == '.' FileSystem.add(f, MockFile.new) + else + raise Errno::ENOENT, f end end end