File#puts accepts (*args) and arrays
Signed-off-by: Chris Wanstrath <chris@ozmm.org>
This commit is contained in:
parent
ab81bbf8be
commit
e8257feadd
@ -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)
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user