File#puts accepts (*args) and arrays

Signed-off-by: Chris Wanstrath <chris@ozmm.org>
This commit is contained in:
David Reese 2009-09-10 07:43:28 +08:00 committed by Chris Wanstrath
parent ab81bbf8be
commit e8257feadd
2 changed files with 7 additions and 5 deletions

View File

@ -103,8 +103,10 @@ module FakeFS
@file @file
end end
def puts(content) def puts(*content)
write(content + "\n") content.flatten.each do |obj|
write(obj.to_s + "\n")
end
end end
def write(content) def write(content)

View File

@ -105,11 +105,11 @@ class FakeFSTest < Test::Unit::TestCase
def test_can_read_with_File_readlines def test_can_read_with_File_readlines
path = '/path/to/file.txt' path = '/path/to/file.txt'
File.open(path, 'w') do |f| File.open(path, 'w') do |f|
f.puts "Yatta!" f.puts "Yatta!", "Gatta!"
f.puts "woot" f.puts ["woot","toot"]
end end
assert_equal ["Yatta!", "woot"], File.readlines(path) assert_equal %w(Yatta! Gatta! woot toot), File.readlines(path)
end end
def test_File_close_disallows_further_access def test_File_close_disallows_further_access