lib/mspec/helpers/fs.rb in mspec-1.5.17 vs lib/mspec/helpers/fs.rb in mspec-1.5.18
- old
+ new
@@ -35,10 +35,14 @@
prefix = SPEC_TEMP_DIR
unless path[0, prefix.size] == prefix
raise ArgumentError, "#{path} is not prefixed by #{prefix}"
end
- if File.directory? path
+ # File.symlink? needs to be checked first as
+ # File.exists? returns false for dangling symlinks
+ if File.symlink? path
+ File.unlink path
+ elsif File.directory? path
Dir.entries(path).each { |x| rm_r "#{path}/#{x}" unless x =~ /^\.\.?$/ }
Dir.rmdir path
elsif File.exists? path
File.delete path
end