add Enumerable#glob_include?

This commit is contained in:
mccxj
2013-01-11 15:33:11 +08:00
parent b3e27f2c5d
commit 3cf29eeee2
3 changed files with 32 additions and 6 deletions

View File

@@ -63,4 +63,26 @@ class TestCoreExt < Test::Unit::TestCase
end
end
context "enumerable" do
context "glob_include?" do
should "return false with no glob patterns" do
assert ![].glob_include?("a.txt")
end
should "return false with all not match path" do
data = ["a*", "b?"]
assert !data.glob_include?("ca.txt")
assert !data.glob_include?("ba.txt")
end
should "return true with match path" do
data = ["a*", "b?", "**/a*"]
assert data.glob_include?("a.txt")
assert data.glob_include?("ba")
assert data.glob_include?("c/a/a.txt")
assert data.glob_include?("c/a/b/a.txt")
end
end
end
end