Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FakeFS Dir.glob behaves differently with recursive globs. #16

Closed
samg opened this issue Oct 25, 2009 · 3 comments
Closed

FakeFS Dir.glob behaves differently with recursive globs. #16

samg opened this issue Oct 25, 2009 · 3 comments
Labels

Comments

@samg
Copy link
Contributor

samg commented Oct 25, 2009

In the standard lib Dir class the ** recursive glob matches zero or more directories. In FakeFS it matches one or more.

>> File.open('/tmp/in_tmp.txt', 'w')
=> #<File:/tmp/in_tmp.txt>
>> Dir['/tmp/**/*']
=> ["/tmp/in_tmp.txt"]
>> require 'fakefs'
=> true
>> File.open('/tmp/in_tmp.txt', 'w')
=> #<FakeFS::File:0x12165dc @mode="w", @file=(FakeFile name:"in_tmp.txt" parent:"/tmp" size:0), @path="/tmp/in_tmp.txt", @open=true>
>> Dir['/tmp/**/*']
=> []
>> Dir['/tmp/*']
=> ["/tmp/in_tmp.txt"]

The FakeFS behavior should mimic the standard lib.
http://ruby-doc.org/core/classes/Dir.src/M002322.html

@samg
Copy link
Contributor Author

samg commented Oct 29, 2009

Actually the fakefs recursive glob (**) behaves exactly like a single wildcard (*) matching exactly one directory, not one or more as stated above.

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'fakefs'
=> true
irb(main):003:0> File.open('/one/two/three/four', 'w')
=> #<FakeFS::File:0x1216564 @mode="w", @file=(FakeFile name:"four" parent:"/one/two/three" size:0), @path="/one/two/three/four", @open=true>
irb(main):005:0> Dir["/*"]
=> ["/one"]
irb(main):006:0> Dir["/**"]
=> ["/one"]
irb(main):007:0> Dir["/**/*"]
=> ["/one/two"]
irb(main):008:0> Dir["/***/*"]
=> ["/one/two"]
irb(main):009:0> Dir["/***/*/**"]
=> ["/one/two/three"]
irb(main):010:0> Dir["/***/*/**/**"]
=> ["/one/two/three/four"]
irb(main):011:0> 

@samg
Copy link
Contributor Author

samg commented Oct 29, 2009

I've added recursive globbing functionality to my fork at samg/fakefs

@defunkt
Copy link
Collaborator

defunkt commented Oct 29, 2009

Fixed in 1c6825f

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants