我需要一些将实际文件系统伪装成假的代码。因此,当我启动它时,它会转换/home/user/Documents/fake_fs
为/
,因此每个Dir
orFile
调用都会转到该目录。一个例子:
我想在 上制作一个文件/some_file
,所以我使用:
File.open('/some_file', 'w') do |f|
f.puts 'something on this file'
end
它会写在/home/user/Documents/fake_fs/some_file
而不是/some_file
. 有没有办法做到这一点?谢谢!