diff --git a/lib/fakefs/file.rb b/lib/fakefs/file.rb index 7479f2c..fb5cc4b 100644 --- a/lib/fakefs/file.rb +++ b/lib/fakefs/file.rb @@ -253,6 +253,11 @@ module FakeFS @stream.pos end + def pos=(pos) + @stream.pos=(pos) + end + alias_method :tell=, :pos= + private def check_modes! diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 806a849..39412ec 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -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'