|
182 | 182 | Dir.glob('**/**/**').should_not.empty?
|
183 | 183 | end
|
184 | 184 |
|
| 185 | + it "handles **/** with base keyword argument" do |
| 186 | + Dir.glob('**/**', base: "dir").should == ["filename_ordering"] |
| 187 | + |
| 188 | + expected = %w[ |
| 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 |
| 198 | + ].sort |
| 199 | + |
| 200 | + Dir.glob('**/**', base: "deeply").sort.should == expected |
| 201 | + end |
| 202 | + |
| 203 | + it "handles **/ with base keyword argument" do |
| 204 | + expected = %w[ |
| 205 | + / |
| 206 | + directory/ |
| 207 | + directory/structure/ |
| 208 | + ] |
| 209 | + Dir.glob('**/', base: "deeply/nested").sort.should == expected |
| 210 | + end |
| 211 | + |
| 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 |
| 221 | + |
| 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 |
| 233 | + |
| 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 |
| 265 | + it "handles **/.* with base keyword argument and FNM_DOTMATCH" do |
| 266 | + expected = %w[ |
| 267 | + . |
| 268 | + .dotfile.ext |
| 269 | + directory/structure/.ext |
| 270 | + ].sort |
| 271 | + |
| 272 | + Dir.glob('**/.*', File::FNM_DOTMATCH, base: "deeply/nested").sort.should == expected |
| 273 | + end |
| 274 | + |
| 275 | + it "handles **/** with base keyword argument and FNM_DOTMATCH" do |
| 276 | + expected = %w[ |
| 277 | + . |
| 278 | + .dotfile.ext |
| 279 | + directory |
| 280 | + directory/structure |
| 281 | + directory/structure/.ext |
| 282 | + directory/structure/bar |
| 283 | + directory/structure/baz |
| 284 | + directory/structure/file_one |
| 285 | + directory/structure/file_one.ext |
| 286 | + directory/structure/foo |
| 287 | + ].sort |
| 288 | + |
| 289 | + Dir.glob('**/**', File::FNM_DOTMATCH, base: "deeply/nested").sort.should == expected |
| 290 | + end |
| 291 | + end |
| 292 | + |
| 293 | + it "handles **/*pattern* with base keyword argument and FNM_DOTMATCH" do |
| 294 | + expected = %w[ |
| 295 | + .dotfile.ext |
| 296 | + directory/structure/file_one |
| 297 | + directory/structure/file_one.ext |
| 298 | + ] |
| 299 | + |
| 300 | + Dir.glob('**/*file*', File::FNM_DOTMATCH, base: "deeply/nested").sort.should == expected |
| 301 | + end |
| 302 | + |
| 303 | + it "handles **/glob with base keyword argument and FNM_EXTGLOB" do |
| 304 | + expected = %w[ |
| 305 | + directory/structure/bar |
| 306 | + directory/structure/file_one |
| 307 | + directory/structure/file_one.ext |
| 308 | + ] |
| 309 | + |
| 310 | + Dir.glob('**/*{file,bar}*', File::FNM_EXTGLOB, base: "deeply/nested").sort.should == expected |
| 311 | + end |
| 312 | + |
185 | 313 | it "handles simple filename patterns" do
|
186 | 314 | Dir.glob('.dotfile').should == ['.dotfile']
|
187 | 315 | end
|
|
0 commit comments