From 97a68c01ba979a4f95078c358fd07558dbf24b20 Mon Sep 17 00:00:00 2001 From: Greg Campbell <gtcampbell@gmail.com> Date: Fri, 2 Jul 2010 13:18:30 -0700 Subject: [PATCH] FileUtils#mkdir_p accepts options. Closes #41. --- lib/fakefs/fileutils.rb | 2 +- test/fakefs_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/fakefs/fileutils.rb b/lib/fakefs/fileutils.rb index 4297c4e..352463e 100644 --- a/lib/fakefs/fileutils.rb +++ b/lib/fakefs/fileutils.rb @@ -2,7 +2,7 @@ module FakeFS module FileUtils extend self - def mkdir_p(path) + def mkdir_p(path, options = {}) FileSystem.add(path, FakeDir.new) end alias_method :mkpath, :mkdir_p diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 774f829..721742d 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -28,11 +28,21 @@ class FakeFSTest < Test::Unit::TestCase assert_kind_of FakeDir, FileSystem.fs['path']['to']['dir'] end + def test_can_create_directories_with_options + FileUtils.mkdir_p("/path/to/dir", :mode => 0755) + assert_kind_of FakeDir, FileSystem.fs['path']['to']['dir'] + end + def test_can_create_directories_with_mkpath FileUtils.mkpath("/path/to/dir") assert_kind_of FakeDir, FileSystem.fs['path']['to']['dir'] end + def test_can_create_directories_with_mkpath_and_options + FileUtils.mkpath("/path/to/dir", :mode => 0755) + assert_kind_of FakeDir, FileSystem.fs['path']['to']['dir'] + end + def test_can_delete_directories FileUtils.mkdir_p("/path/to/dir") FileUtils.rmdir("/path/to/dir")