1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
# frozen_string_literal: true
require_relative 'test_helper'
# Trivial IO test class
# Behavior is not really tested, as call is forwarded to File class
class IOTest < Minitest::Test
def test_method_IO_read_works
begin
::FakeFS.activate!(io_mocks: true)
::File.write('foo', 'bar')
assert_equal 'bar', ::IO.read('foo')
ensure
::FakeFS.deactivate!
::FakeFS::FileSystem.clear
end
refute ::File.exist?('foo')
end
def test_method_IO_write_works
begin
::FakeFS.activate!(io_mocks: true)
::IO.write('foo', 'bar')
assert_equal 'bar', ::File.read('foo')
ensure
::FakeFS.deactivate!
::FakeFS::FileSystem.clear
end
refute ::File.exist?('foo')
end
def test_method_IO_binread_works
begin
::FakeFS.activate!(io_mocks: true)
::File.write('foo', 'bar')
assert_equal 'bar', ::IO.binread('foo')
ensure
::FakeFS.deactivate!
::FakeFS::FileSystem.clear
end
refute ::File.exist?('foo')
end
end
|