Fix for {} patterns that have last element empty (Closes #65)

This commit is contained in:
Andrius Chamentauskas 2011-03-14 18:34:45 +02:00 committed by Scott Taylor
parent 6c7fd0291a
commit 8b0d10b94b
2 changed files with 3 additions and 1 deletions

View File

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

View File

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