mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-28 03:01:03 -04:00
0
test/safe_glob_test[/find_me.txt
Normal file
0
test/safe_glob_test[/find_me.txt
Normal file
@@ -195,4 +195,43 @@ class TestUtils < JekyllUnitTest
|
||||
assert_equal "/:basename", Utils.add_permalink_suffix("/:basename", "/:title")
|
||||
end
|
||||
end
|
||||
|
||||
context "The \`Utils.safe_glob\` method" do
|
||||
should "not apply pattern to the dir" do
|
||||
dir = "test/safe_glob_test["
|
||||
assert_equal [], Dir.glob(dir + "/*")
|
||||
assert_equal ["test/safe_glob_test[/find_me.txt"], Utils.safe_glob(dir, "*")
|
||||
end
|
||||
|
||||
should "return the same data to #glob" do
|
||||
dir = "test"
|
||||
assert_equal Dir.glob(dir + "/*"), Utils.safe_glob(dir, "*")
|
||||
assert_equal Dir.glob(dir + "/**/*"), Utils.safe_glob(dir, "**/*")
|
||||
end
|
||||
|
||||
should "return the same data to #glob if dir is not found" do
|
||||
dir = "dir_not_exist"
|
||||
assert_equal [], Utils.safe_glob(dir, "*")
|
||||
assert_equal Dir.glob(dir + "/*"), Utils.safe_glob(dir, "*")
|
||||
end
|
||||
|
||||
should "return the same data to #glob if pattern is blank" do
|
||||
dir = "test"
|
||||
assert_equal [dir], Utils.safe_glob(dir, "")
|
||||
assert_equal Dir.glob(dir), Utils.safe_glob(dir, "")
|
||||
assert_equal Dir.glob(dir), Utils.safe_glob(dir, nil)
|
||||
end
|
||||
|
||||
should "return the same data to #glob if flag is given" do
|
||||
dir = "test"
|
||||
assert_equal Dir.glob(dir + "/*", File::FNM_DOTMATCH),
|
||||
Utils.safe_glob(dir, "*", File::FNM_DOTMATCH)
|
||||
end
|
||||
|
||||
should "support pattern as an array to support windows" do
|
||||
dir = "test"
|
||||
assert_equal Dir.glob(dir + "/**/*"), Utils.safe_glob(dir, ["**", "*"])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user