From e8257feadd4154da4794f2d00c31e558bcdabc45 Mon Sep 17 00:00:00 2001 From: David Reese Date: Thu, 10 Sep 2009 07:43:28 +0800 Subject: [PATCH] File#puts accepts (*args) and arrays Signed-off-by: Chris Wanstrath --- lib/fakefs/file.rb | 6 ++++-- test/fakefs_test.rb | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/fakefs/file.rb b/lib/fakefs/file.rb index b97e301..37230e6 100644 --- a/lib/fakefs/file.rb +++ b/lib/fakefs/file.rb @@ -103,8 +103,10 @@ module FakeFS @file end - def puts(content) - write(content + "\n") + def puts(*content) + content.flatten.each do |obj| + write(obj.to_s + "\n") + end end def write(content) diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 5b75f1a..26747b7 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -105,11 +105,11 @@ class FakeFSTest < Test::Unit::TestCase def test_can_read_with_File_readlines path = '/path/to/file.txt' File.open(path, 'w') do |f| - f.puts "Yatta!" - f.puts "woot" + f.puts "Yatta!", "Gatta!" + f.puts ["woot","toot"] end - assert_equal ["Yatta!", "woot"], File.readlines(path) + assert_equal %w(Yatta! Gatta! woot toot), File.readlines(path) end def test_File_close_disallows_further_access