From 8aba1ad6a505c113b0749f013b44b076b14a24dc Mon Sep 17 00:00:00 2001 From: Jeff Hodges Date: Tue, 2 Jun 2009 00:16:19 -0700 Subject: [PATCH] we can now clone even hard to find dotfiles --- lib/fakefs.rb | 3 +-- test/fakefs_test.rb | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/fakefs.rb b/lib/fakefs.rb index 59037b6..4fd169a 100644 --- a/lib/fakefs.rb +++ b/lib/fakefs.rb @@ -231,8 +231,7 @@ module FakeFS def clone(path) path = File.expand_path(path) pattern = File.join(path, '**', '*') - dot_pattern = File.join(path, '**', '.*') - files = RealFile.file?(path) ? [path] : [path] + RealDir.glob([pattern, dot_pattern]) + files = RealFile.file?(path) ? [path] : [path] + RealDir.glob(pattern, RealFile::FNM_DOTMATCH) files.each do |f| if RealFile.file?(f) diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 533f2d7..c59a152 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -364,11 +364,13 @@ class FakeFSTest < Test::Unit::TestCase RealFileUtils.rm_rf(here('subdir')) if RealFile.exists?(here('subdir')) end - def test_clone_clones_dot_files - RealFileUtils.mkdir_p(here('subdir/.bar')) + def test_clone_clones_dot_files_even_hard_to_find_ones + RealFileUtils.mkdir_p(here('subdir/.bar/baz/.quux/foo')) assert !File.exists?(here('subdir')) + FileSystem.clone(here('subdir')) assert_equal ['.bar'], FileSystem.find(here('subdir')).keys + assert_equal ['foo'], FileSystem.find(here('subdir/.bar/baz/.quux')).keys ensure RealFileUtils.rm_rf(here('subdir')) if RealFile.exists?(here('subdir')) end