few more read tests, readlines
This commit is contained in:
parent
33e176a353
commit
b9a8f4e8ca
@ -87,6 +87,10 @@ module FakeFS
|
||||
new(path).read
|
||||
end
|
||||
|
||||
def self.readlines(path)
|
||||
read(path).split("\n")
|
||||
end
|
||||
|
||||
attr_reader :path
|
||||
def initialize(path, mode = nil)
|
||||
@path = path
|
||||
|
@ -79,6 +79,25 @@ class FakeFSTest < Test::Unit::TestCase
|
||||
assert_equal "Yatta!", File.read(path)
|
||||
end
|
||||
|
||||
def test_can_read_with_File_readlines
|
||||
path = '/path/to/file.txt'
|
||||
File.open(path, 'w') do |f|
|
||||
f.puts "Yatta!"
|
||||
f.puts "woot"
|
||||
end
|
||||
|
||||
assert_equal ["Yatta!", "woot"], File.readlines(path)
|
||||
end
|
||||
|
||||
def test_can_read_from_file_objects
|
||||
path = '/path/to/file.txt'
|
||||
File.open(path, 'w') do |f|
|
||||
f.write "Yatta!"
|
||||
end
|
||||
|
||||
assert_equal "Yatta!", File.new(path).read
|
||||
end
|
||||
|
||||
def test_knows_files_are_files
|
||||
path = '/path/to/file.txt'
|
||||
File.open(path, 'w') do |f|
|
||||
|
Loading…
Reference in New Issue
Block a user