From ba4de582333d774d929a5d90a6cb66c98911493a Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 1 Nov 2009 17:47:33 -0500 Subject: [PATCH] Add File#pos=, File#tell= --- lib/fakefs/file.rb | 5 +++++ test/fakefs_test.rb | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) 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'