Permalink
Browse files

Fix creation of absolute path subdirs with Dir.mkdir, closes #96

  • Loading branch information...
sometimesfood committed Sep 6, 2011
1 parent ec9c54e commit c4e36e92f6a1a769a414899afad7af17a5d97409
Showing with 13 additions and 9 deletions.
  1. +1 −9 lib/fakefs/dir.rb
  2. +12 −0 test/fakefs_test.rb
View
@@ -96,15 +96,7 @@ def self.glob(pattern, &block)
end
def self.mkdir(string, integer = 0)
- parent = string.split('/')
- parent.pop
-
- joined_parent_path = parent.join
-
- _check_for_valid_file(joined_parent_path) unless joined_parent_path == ""
- raise Errno::EEXIST, "File exists - #{string}" if File.exists?(string)
-
- FileUtils.mkdir_p(string)
+ FileUtils.mkdir(string)
end
def self.open(string, &block)
View
@@ -1413,6 +1413,18 @@ def test_directory_mkdir
assert File.exists?('/path')
end
+ def test_can_create_subdirectories_with_dir_mkdir
+ Dir.mkdir 'foo'
+ Dir.mkdir 'foo/bar'
+ assert Dir.exists?('foo/bar')
+ end
+
+ def test_can_create_absolute_subdirectories_with_dir_mkdir
+ Dir.mkdir '/foo'
+ Dir.mkdir '/foo/bar'
+ assert Dir.exists?('/foo/bar')
+ end
+
def test_directory_mkdir_relative
FileUtils.mkdir_p('/new/root')
FileSystem.chdir('/new/root')

0 comments on commit c4e36e9

Please sign in to comment.