pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/jruby/jruby/commit/d2d385d6d2aca37ded21da86862775b9641c6308

> Add specs for glob with filesystem-based schemes · jruby/jruby@d2d385d · GitHub
Skip to content

Commit d2d385d

Browse files
committed
Add specs for glob with filesystem-based schemes
This tests uri:classpath: and file: URIs in Dir.glob against an on-filesystem path. See #8973.
1 parent 0552e96 commit d2d385d

5 files changed

Lines changed: 57 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test4

spec/jruby/core/dir/glob_spec.rb

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,66 @@
1717
it 'can glob directories with URI special chars in it (GH-2264)' do
1818
expect(Dir.glob("#{dir_name}/**/*").size).to eq 1
1919
end
20-
end
2120

22-
describe "Dir.glob" do
2321
# We have common option processing code and a logic mistake made
2422
# us process argv[2] as both a kwarg then try to convert it to an
2523
# integer.
2624
it "does not think the third arg should be an integer when it is kwargs" do
2725
expect { Dir["*", "*", base: "."] }.not_to raise_error
2826
end
27+
28+
describe "with a uri:classloader: scheme" do
29+
before :all do
30+
# FIXME: unsanitary because we can't clear entries from $CLASSPATH
31+
$CLASSPATH << __dir__
32+
end
33+
34+
it "can find a specific file" do
35+
test1_files = Dir.glob("uri:classloader:/fixtures/test1.txt")
36+
expect(test1_files[0]).to eq "uri:classloader:/fixtures/test1.txt"
37+
expect(File.read(test1_files[0])).to eq "test1"
38+
end
39+
40+
it "can find a set of files for a wildcard filename" do
41+
test_txt_files = Dir.glob("uri:classloader:/fixtures/test*.txt")
42+
expect(test_txt_files).to eq %w[test1 test2 test3].map { "uri:classloader:/fixtures/#{_1}.txt" }
43+
test_txt_files.each { expect(File.read(_1)).to eq File.basename(_1).split(".").first }
44+
45+
test_txt_files = Dir.glob("uri:classloader:/fixtures/test?.txt")
46+
expect(test_txt_files).to eq %w[test1 test2 test3].map { "uri:classloader:/fixtures/#{_1}.txt" }
47+
test_txt_files.each { expect(File.read(_1)).to eq File.basename(_1).split(".").first }
48+
end
49+
50+
it "can find a specific file in a double star path" do
51+
test5_files = Dir.glob("uri:classloader:/fixtures/**/test4.txt")
52+
expect(test5_files[0]).to eq "uri:classloader:/fixtures/testdir/test4.txt"
53+
expect(File.read(test5_files[0])).to eq "test4"
54+
end
55+
end
56+
57+
describe "with a file: scheme" do
58+
it "can find a specific file" do
59+
test1_files = Dir.glob("file:#{__dir__}/fixtures/test1.txt")
60+
expect(test1_files[0]).to eq "file:#{__dir__}/fixtures/test1.txt"
61+
expect(File.read(test1_files[0])).to eq "test1"
62+
end
63+
64+
it "can find a set of files for a wildcard filename" do
65+
test_txt_files = Dir.glob("file:#{__dir__}/fixtures/test*.txt")
66+
expect(test_txt_files).to eq %w[test1 test2 test3].map { "file:#{__dir__}/fixtures/#{_1}.txt" }
67+
test_txt_files.each { expect(File.read(_1)).to eq File.basename(_1).split(".").first }
68+
69+
test_txt_files = Dir.glob("file:#{__dir__}/fixtures/test?.txt")
70+
expect(test_txt_files).to eq %w[test1 test2 test3].map { "file:#{__dir__}/fixtures/#{_1}.txt" }
71+
test_txt_files.each { expect(File.read(_1)).to eq File.basename(_1).split(".").first }
72+
end
73+
74+
it "can find a specific file in a double star path" do
75+
test5_files = Dir.glob("file:#{__dir__}/fixtures/**/test4.txt")
76+
expect(test5_files[0]).to eq "file:#{__dir__}/fixtures/testdir/test4.txt"
77+
expect(File.read(test5_files[0])).to eq "test4"
78+
end
79+
end
2980
end
3081

3182

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy