Fixed Dir read method to strip the path, so it matches the Ruby Dir path. Bumped version number

This commit is contained in:
Myles Eftos 2009-09-13 22:50:34 +08:00
parent 9f70cc3c8c
commit 1403c5b421
4 changed files with 35 additions and 29 deletions

View File

@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = %q{fakefs}
s.version = "0.1.2"
s.version = "0.1.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Chris Wanstrath"]

View File

@ -39,7 +39,7 @@ module FakeFS
raise IOError, "closed directory" if @pointer == nil
n = @contents[@pointer]
@pointer += 1
n.to_s if n
n.to_s.gsub(path + '/', '') if n
end
def rewind
@ -97,7 +97,7 @@ module FakeFS
end
end
def tmpdir
def self.tmpdir
'/tmp'
end

View File

@ -1,6 +1,6 @@
module FakeFS
module Version
VERSION = "0.1.1"
VERSION = "0.1.3"
def self.to_s
VERSION

View File

@ -558,12 +558,12 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_each
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
dir = Dir.new('/this/path/should/be/here')
@ -583,10 +583,10 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_pos
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
dir = Dir.new('/this/path/should/be/here')
@ -605,10 +605,11 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_pos_assign
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
dir = Dir.new('/this/path/should/be/here')
@ -619,10 +620,11 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_read
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
dir = Dir.new('/this/path/should/be/here')
@ -638,10 +640,11 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_read_past_length
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
dir = Dir.new('/this/path/should/be/here')
@ -665,10 +668,11 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_rewind
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
dir = Dir.new('/this/path/should/be/here')
@ -681,10 +685,11 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_seek
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
dir = Dir.new('/this/path/should/be/here')
@ -702,10 +707,11 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_class_delete_does_not_act_on_non_empty_directory
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
assert_raises(SystemCallError) do
@ -714,12 +720,12 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_entries
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
yielded = Dir.entries('/this/path/should/be/here')
@ -728,12 +734,12 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_foreach
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
yielded = []
@ -764,12 +770,12 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_open
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
dir = Dir.open('/this/path/should/be/here')
@ -777,12 +783,12 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_directory_open_block
test = ['.', '..', '/this/path/should/be/here/file_1', '/this/path/should/be/here/file_2', '/this/path/should/be/here/file_3', '/this/path/should/be/here/file_4', '/this/path/should/be/here/file_5' ]
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
FileUtils.mkdir_p('/this/path/should/be/here')
test.each do |f|
FileUtils.touch(f)
FileUtils.touch("/this/path/should/be/here/#{f}")
end
yielded = []
@ -795,7 +801,7 @@ class FakeFSTest < Test::Unit::TestCase
end
def test_tmpdir
assert Dir.tmp_dir == "/tmp"
assert Dir.tmpdir == "/tmp"
end
def here(fname)