Permalink
Browse files

Merge pull request #97 from sometimesfood/dir_mkdir_subdir

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

Conflicts:
	lib/fakefs/dir.rb
	test/fakefs_test.rb
  • Loading branch information...
2 parents 6d76d30 + c4e36e9 commit 2a87046f5efe4dc0db14942621975fd3bd3eb8f7 @jfirebaugh jfirebaugh committed Apr 17, 2012
Showing with 13 additions and 9 deletions.
  1. +1 −9 lib/fakefs/dir.rb
  2. +12 −0 test/fakefs_test.rb
View
@@ -102,15 +102,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
@@ -1582,6 +1582,18 @@ def test_directory_mkdir_nested
assert File.exists?("/tmp/stream20120103-11847-xc8pb.lock")
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 2a87046

Please sign in to comment.