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