Fix for finding files by patterns that include {..,..} (#65)

This commit is contained in:
Andrius Chamentauskas 2011-02-19 13:01:11 +02:00 committed by Scott Taylor
parent 2b13555845
commit 6c7fd0291a
2 changed files with 4 additions and 1 deletions

View File

@ -121,7 +121,8 @@ module FakeFS
directories_under(dir)
end
else
dir.reject {|k,v| /\A#{pattern.gsub('?','.').gsub('*', '.*')}\Z/ !~ k }.values
regexp_pattern = /\A#{pattern.gsub('?','.').gsub('*', '.*').gsub(/\{(.*?)\}/) { "(#{$1.split(',').join('|')})" }}\Z/
dir.reject {|k,v| regexp_pattern !~ k }.values
end
if parts.empty? # we're done recursing

View File

@ -573,6 +573,8 @@ class FakeFSTest < Test::Unit::TestCase
FileUtils.cp_r '/path', '/otherpath'
assert_equal %w( /otherpath/foo /otherpath/foobar /path/foo /path/foobar ), Dir['/*/foo*']
assert_equal ['/path/bar', '/path/foo'], Dir['/path/{foo,bar}']
end
def test_dir_glob_handles_root