Skip to content

Commit 7e1cdca

Browse files
committed
Add more specs for additional scenarios with globs starting with "**/"
1 parent 797ac69 commit 7e1cdca

File tree

1 file changed

+61
-17
lines changed

1 file changed

+61
-17
lines changed

spec/ruby/core/dir/glob_spec.rb

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,18 @@
186186
Dir.glob('**/**', base: "dir").should == ["filename_ordering"]
187187

188188
expected = %w[
189-
directory
190-
directory/structure
191-
directory/structure/bar
192-
directory/structure/baz
193-
directory/structure/file_one
194-
directory/structure/file_one.ext
195-
directory/structure/foo
189+
nested
190+
nested/directory
191+
nested/directory/structure
192+
nested/directory/structure/bar
193+
nested/directory/structure/baz
194+
nested/directory/structure/file_one
195+
nested/directory/structure/file_one.ext
196+
nested/directory/structure/foo
197+
nondotfile
196198
].sort
197199

198-
Dir.glob('**/**', base: "deeply/nested").sort.should == expected
200+
Dir.glob('**/**', base: "deeply").sort.should == expected
199201
end
200202

201203
it "handles **/ with base keyword argument" do
@@ -207,17 +209,59 @@
207209
Dir.glob('**/', base: "deeply/nested").sort.should == expected
208210
end
209211

210-
# 2.7 and 3.0 include a "." entry for every dir: ["directory/.", "directory/structure/.", ...]
211-
guard_not -> { ruby_version_is ''...'3.1' } do
212-
it "handles **/.* with base keyword argument" do
213-
expected = %w[
214-
.dotfile.ext
215-
directory/structure/.ext
216-
].sort
212+
it "handles **/nondotfile with base keyword argument" do
213+
expected = %w[
214+
deeply/nondotfile
215+
nondotfile
216+
subdir_one/nondotfile
217+
subdir_two/nondotfile
218+
]
219+
Dir.glob('**/nondotfile', base: ".").sort.should == expected
220+
end
217221

218-
Dir.glob('**/.*', base: "deeply/nested").sort.should == expected
219-
end
222+
it "handles **/nondotfile with base keyword argument and FNM_DOTMATCH" do
223+
expected = %w[
224+
.dotsubdir/nondotfile
225+
deeply/nondotfile
226+
nested/.dotsubir/nondotfile
227+
nondotfile
228+
subdir_one/nondotfile
229+
subdir_two/nondotfile
230+
]
231+
Dir.glob('**/nondotfile', File::FNM_DOTMATCH, base: ".").sort.should == expected
232+
end
220233

234+
it "handles **/.dotfile with base keyword argument" do
235+
expected = %w[
236+
.dotfile
237+
deeply/.dotfile
238+
subdir_one/.dotfile
239+
]
240+
Dir.glob('**/.dotfile', base: ".").sort.should == expected
241+
end
242+
243+
it "handles **/.dotfile with base keyword argument and FNM_DOTMATCH" do
244+
expected = %w[
245+
.dotfile
246+
.dotsubdir/.dotfile
247+
deeply/.dotfile
248+
nested/.dotsubir/.dotfile
249+
subdir_one/.dotfile
250+
]
251+
Dir.glob('**/.dotfile', File::FNM_DOTMATCH, base: ".").sort.should == expected
252+
end
253+
254+
it "handles **/.* with base keyword argument" do
255+
expected = %w[
256+
.dotfile.ext
257+
directory/structure/.ext
258+
].sort
259+
260+
Dir.glob('**/.*', base: "deeply/nested").sort.should == expected
261+
end
262+
263+
# 2.7 and 3.0 include a "." entry for every dir: ["directory/.", "directory/structure/.", ...]
264+
ruby_version_is '3.1' do
221265
it "handles **/.* with base keyword argument and FNM_DOTMATCH" do
222266
expected = %w[
223267
.

0 commit comments

Comments
 (0)