default File.open to read mode

This commit is contained in:
Jeff Hodges 2009-05-30 11:31:19 -07:00
parent d9a44e5482
commit 35c88244de
2 changed files with 6 additions and 1 deletions

View File

@ -89,7 +89,7 @@ module FakeFS
FileSystem.find(symlink.target).to_s
end
def self.open(path, mode)
def self.open(path, mode='r')
if block_given?
yield new(path, mode)
else

View File

@ -188,4 +188,9 @@ class FakeFSTest < Test::Unit::TestCase
assert_equal(['foo', 'foobar'], FileSystem.fs['path'].keys.sort)
end
def test_file_open_defaults_to_read
File.open('foo','w'){|f| f.write 'bar' }
assert_equal 'bar', File.open('foo'){|f| f.read }
end
end