lib/fakefs/fileutils.rb in fakefs-0.3.2 vs lib/fakefs/fileutils.rb in fakefs-0.4.0

- old
+ new

@@ -28,22 +28,30 @@ end end def rm(list, options = {}) Array(list).each do |path| - FileSystem.delete(path) + FileSystem.delete(path) or raise Errno::ENOENT.new(path) end end alias_method :rm_rf, :rm alias_method :rm_r, :rm alias_method :rm_f, :rm def ln_s(target, path, options = {}) options = { :force => false }.merge(options) - (FileSystem.find(path) and !options[:force]) ? raise(Errno::EEXIST, path) : FileSystem.delete(path) + (FileSystem.find(path) && !options[:force]) ? + raise(Errno::EEXIST, path) : + FileSystem.delete(path) + + if !options[:force] && !Dir.exists?(File.dirname(path)) + raise Errno::ENOENT, path + end + FileSystem.add(path, FakeSymlink.new(target)) end + def ln_sf(target, path) ln_s(target, path, { :force => true }) end def cp(src, dest)