diff --git a/lib/fakefs/dir.rb b/lib/fakefs/dir.rb index d5c0314c..db6bd76d 100644 --- a/lib/fakefs/dir.rb +++ b/lib/fakefs/dir.rb @@ -180,6 +180,7 @@ class << self alias_method :getwd, :pwd alias_method :rmdir, :delete alias_method :unlink, :delete + alias_method :exist?, :exists? end end end diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 47e17349..1d31bd34 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -1705,6 +1705,14 @@ def test_directory_open_block test.each { |t| assert yielded.include?(t) } end + def test_directory_exists + assert Dir.exists?('/this/path/should/be/here') == false + assert Dir.exist?('/this/path/should/be/here') == false + FileUtils.mkdir_p('/this/path/should/be/here') + assert Dir.exists?('/this/path/should/be/here') == true + assert Dir.exist?('/this/path/should/be/here') == true + end + def test_tmpdir assert Dir.tmpdir == "/tmp" end