simonc / memfs

MemFs provides a fake file system that can be used for tests. Strongly inspired by FakeFS.
MIT License
320 stars 27 forks source link

Missing File.write #29

Open tonobo opened 5 years ago

tonobo commented 5 years ago

I've tried using File.write but it's not captured by your library. I'm not sure why because File normally inherits the method from IO and it looks like you've already catched those.

simonc commented 5 years ago

Hi @tonobo. Sorry for not answering sooner, the Github notification went to my junk folder. did you find a workaround in the mean time? I'll try to address the issue asap, thanks for bringing it to my attention 😊

tonobo commented 5 years ago

No, i've easily fixed this by not using file write. :smile:

simonc commented 5 years ago

Haha ok. I'll keep this issue open and try to address it anyway 🙂

G-Rath commented 3 years ago

I'm guessing this is related to this #20?

20 seems to fix this by defining write, but without the monkey patch provided by @rmm5t, I get "ENOENT: No such file or directory" errors.

Is that the error you're getting @tonobo when you attempt to use File.write, or are you getting something else?

Right now it seems like that current implementation of IO#write is missing touching the file before attempting to write, as if I do FileUtils.touch before calling File.write everything works as expected (which is the native behaviour)

If my understanding of this is correct, I can try and make a PR :)

simonc commented 3 years ago

Hi @G-Rath. You are right! File.write does need to touch the file before trying to open it. A PR is indeed very welcome if you have the time for it, thank you! 😍