Fixed FileUtils.rmdir and Dir.unlink
This commit is contained in:
parent
a926ebf1c5
commit
c9bd3260c5
@ -108,7 +108,7 @@ module FakeFS
|
|||||||
class << self
|
class << self
|
||||||
alias_method :getwd, :pwd
|
alias_method :getwd, :pwd
|
||||||
alias_method :rmdir, :delete
|
alias_method :rmdir, :delete
|
||||||
alias_method :unline, :delete
|
alias_method :unlink, :delete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,11 @@ module FakeFS
|
|||||||
def rmdir(list, options = {})
|
def rmdir(list, options = {})
|
||||||
list = [ list ] unless list.is_a?(Array)
|
list = [ list ] unless list.is_a?(Array)
|
||||||
list.each do |l|
|
list.each do |l|
|
||||||
|
parent = l.split('/')
|
||||||
|
parent.pop
|
||||||
|
raise Errno::ENOENT, "No such file or directory - #{l}" unless parent.join == "" || FileSystem.find(parent.join('/'))
|
||||||
raise Errno::ENOENT, l unless FileSystem.find(l)
|
raise Errno::ENOENT, l unless FileSystem.find(l)
|
||||||
|
raise Errno::ENOTEMPTY, l unless FileSystem.find(l).values.empty?
|
||||||
rm(l)
|
rm(l)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -17,6 +21,7 @@ module FakeFS
|
|||||||
def rm(path)
|
def rm(path)
|
||||||
FileSystem.delete(path)
|
FileSystem.delete(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :rm_rf, :rm
|
alias_method :rm_rf, :rm
|
||||||
alias_method :rm_r, :rm
|
alias_method :rm_r, :rm
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user