parent
4e9355dc9e
commit
66c27ff31b
@ -78,8 +78,9 @@ module FakeFS
|
||||
Dir.open(dirname) { |file| yield file }
|
||||
end
|
||||
|
||||
def self.glob(pattern)
|
||||
[FileSystem.find(pattern) || []].flatten.map{|e| e.to_s}.sort
|
||||
def self.glob(pattern, &block)
|
||||
files = [FileSystem.find(pattern) || []].flatten.map(&:to_s).sort
|
||||
block_given? ? files.each { |file| block.call(file) } : files
|
||||
end
|
||||
|
||||
def self.mkdir(string, integer = 0)
|
||||
|
@ -588,6 +588,16 @@ class FakeFSTest < Test::Unit::TestCase
|
||||
assert_equal ['/one/five.rb', '/one/two'], Dir['/one/**']
|
||||
end
|
||||
|
||||
def test_dir_glob_with_block
|
||||
FileUtils.touch('foo')
|
||||
FileUtils.touch('bar')
|
||||
|
||||
yielded = []
|
||||
Dir.glob('*') { |file| yielded << file }
|
||||
|
||||
assert_equal 2, yielded.size
|
||||
end
|
||||
|
||||
def test_should_report_pos_as_0_when_opening
|
||||
File.open("/foo", "w") do |f|
|
||||
f << "foobar"
|
||||
|
Loading…
Reference in New Issue
Block a user