From 27e24b22607fa5a6890f923a316e04a6103b97d7 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 13 Jun 2009 00:22:37 -0700 Subject: [PATCH] Added touch to fileutils --- lib/fakefs.rb | 4 ++++ test/fakefs_test.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/fakefs.rb b/lib/fakefs.rb index 550ef74..ed3ae98 100644 --- a/lib/fakefs.rb +++ b/lib/fakefs.rb @@ -95,6 +95,10 @@ module FakeFS def chown_R(user, group, list, options={}) chown(user, group, list, options={}) end + + def touch(path) + FileSystem.add(path, MockFile.new) + end end class File diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index c32a657..7481b95 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -445,6 +445,11 @@ class FakeFSTest < Test::Unit::TestCase FileUtils.ln_s 'subdir', 'new' assert_equal 'works', File.open('new/nother'){|f| f.read } end + + def test_files_can_be_touched + FileUtils.touch(here("file")) + assert File.exists?(here("file")) + end def here(fname) RealFile.expand_path(RealFile.dirname(__FILE__)+'/'+fname)