public
Description: RSpec-style specification for the Ruby programming language
Homepage: http://rubyspec.org
Clone URL: git://github.com/brixen/rubyspec.git
Search Repo:
Add Dir.glob ordering spec when two entries share common sub paths
nicksieger (author)
Wed May 14 06:57:15 -0700 2008
commit  799fd9dc4e9b6d731d4d789687ee46d2949c3270
tree    25f0118d5379423ad270cda2f7bad41f53ff0fa3
parent  68b51a512dcca1e853a98f648957775b8ee7c060
...
43
44
45
 
 
 
46
47
48
...
86
87
88
 
 
89
90
91
...
43
44
45
46
47
48
49
50
51
...
89
90
91
92
93
94
95
96
0
@@ -43,6 +43,9 @@ module DirSpecs
0
                 #{mock_dir}/file_one.ext
0
                 #{mock_dir}/file_two.ext
0
 
0
+ #{mock_dir}/dir_filename_ordering
0
+ #{mock_dir}/dir/filename_ordering
0
+
0
                 #{mock_dir}/nondotfile
0
 
0
                 #{mock_dir}/subdir_one/.dotfile
0
@@ -86,6 +89,8 @@ module DirSpecs
0
       .dotfile
0
       .dotsubdir
0
       deeply
0
+ dir
0
+ dir_filename_ordering
0
       file_one.ext
0
       file_two.ext
0
       nondotfile
...
30
31
32
 
33
34
35
...
30
31
32
33
34
35
36
0
@@ -30,6 +30,7 @@ describe "Dir.glob" do
0
       deeply/nested/
0
       deeply/nested/directory/
0
       deeply/nested/directory/structure/
0
+ dir/
0
       special/
0
       subdir_one/
0
       subdir_two/
...
9
10
11
 
 
12
13
14
...
95
96
97
98
 
99
100
101
102
103
 
 
104
105
106
...
122
123
124
 
125
126
127
...
188
189
190
191
192
193
194
195
 
 
 
 
 
 
 
 
 
196
197
198
 
 
 
 
 
 
 
 
199
200
201
...
9
10
11
12
13
14
15
16
...
97
98
99
 
100
101
102
103
104
105
106
107
108
109
110
...
126
127
128
129
130
131
132
...
193
194
195
 
 
 
 
 
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
0
@@ -9,6 +9,8 @@ shared :dir_glob do |cmd|
0
     it "matches non-dotfiles with '*'" do
0
       expected = %w[
0
         deeply
0
+ dir
0
+ dir_filename_ordering
0
         file_one.ext
0
         file_two.ext
0
         nondotfile
0
@@ -95,12 +97,14 @@ shared :dir_glob do |cmd|
0
     end
0
 
0
     it "matches files with multiple '*' special characters" do
0
- Dir.send(cmd, '*fi*e*').sort.should == %w|nondotfile file_one.ext file_two.ext|.sort
0
+ Dir.send(cmd, '*fi*e*').sort.should == %w|dir_filename_ordering nondotfile file_one.ext file_two.ext|.sort
0
     end
0
 
0
     it "matches non-dotfiles in the current directory with '**'" do
0
       expected = %w[
0
         deeply
0
+ dir
0
+ dir_filename_ordering
0
         file_one.ext
0
         file_two.ext
0
         nondotfile
0
@@ -122,6 +126,7 @@ shared :dir_glob do |cmd|
0
         deeply/nested/
0
         deeply/nested/directory/
0
         deeply/nested/directory/structure/
0
+ dir/
0
         special/
0
         subdir_one/
0
         subdir_two/
0
@@ -188,14 +193,26 @@ shared :dir_glob do |cmd|
0
 
0
     it "recursively matches directories with '**/<characters>'" do
0
       %w|glob []|.each {|cmd|
0
- Dir.send(cmd, '**/*fil?{,.}*').sort.should == %w|deeply/nested/directory/structure/file_one
0
- deeply/nested/directory/structure/file_one.ext
0
- deeply/nondotfile file_one.ext file_two.ext
0
- nondotfile subdir_one/nondotfile
0
- subdir_two/nondotfile subdir_two/nondotfile.ext
0
+ Dir.send(cmd, '**/*fil?{,.}*').sort.should == %w|deeply/nested/directory/structure/file_one
0
+ deeply/nested/directory/structure/file_one.ext
0
+ deeply/nondotfile
0
+ dir/filename_ordering
0
+ dir_filename_ordering
0
+ file_one.ext file_two.ext
0
+ nondotfile subdir_one/nondotfile
0
+ subdir_two/nondotfile
0
+ subdir_two/nondotfile.ext
0
                                                          subdir_two/nondotfile.ext|
0
       }
0
     end
0
+
0
+ it "orders directory-based entries before files when a glob matches both" do
0
+ expected = %w[dir/filename_ordering dir_filename_ordering]
0
+ %w|glob []|.each do |cmd|
0
+ Dir.send(cmd, '**/*filename_ordering').should == expected
0
+ end
0
+ end
0
+
0
     after(:all) do
0
       Dir.chdir @cwd
0
     end

Comments

    No one has commented yet.