Add File#pos=, File#tell=

This commit is contained in:
Scott Taylor 2009-11-01 17:47:33 -05:00
parent 9e50475cb3
commit ba4de58233
2 changed files with 27 additions and 0 deletions

View File

@ -253,6 +253,11 @@ module FakeFS
@stream.pos
end
def pos=(pos)
@stream.pos=(pos)
end
alias_method :tell=, :pos=
private
def check_modes!

View File

@ -465,6 +465,28 @@ class FakeFSTest < Test::Unit::TestCase
end
end
def test_should_set_pos
File.open("/foo", "w") do |f|
f << "foo"
end
fp = File.open("/foo", "r")
fp.pos = 1
assert_equal 1, fp.pos
end
def test_should_set_pos_with_tell_method
File.open("/foo", "w") do |f|
f << "foo"
end
fp = File.open("/foo", "r")
fp.tell = 1
assert_equal 1, fp.pos
end
def test_chdir_changes_directories_like_a_boss
# I know memes!
FileUtils.mkdir_p '/path'