From 02b76af287d27db1f2bb9162f0d7904abf10ee0e Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 8 Nov 2009 01:17:42 -0500 Subject: [PATCH] Add File#to_i (an alias for fileno) --- lib/fakefs/file.rb | 4 +--- test/fakefs_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/fakefs/file.rb b/lib/fakefs/file.rb index 55e727b..2739475 100644 --- a/lib/fakefs/file.rb +++ b/lib/fakefs/file.rb @@ -237,9 +237,7 @@ module FakeFS raise NotImplementedError end - def to_i - raise NotImplementedError - end + alias_method :to_i, :fileno def to_io self diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 9e25aa9..15ef168 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -369,6 +369,11 @@ class FakeFSTest < Test::Unit::TestCase assert_equal f, f.to_io end + def test_File_to_i_is_alias_for_filno + f = File.open("/foo", "w") + assert_equal f.method(:to_i), f.method(:fileno) + end + def test_knows_symlink_files_are_files path = '/path/to/file.txt' File.open(path, 'w') do |f|