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

Describe benefits over FakeFS #11

Closed mikz closed 9 years ago

mikz commented 9 years ago

Why one should use MemFS over FakeFS ? What are the benefits? I believe this should be described in the README.

The target is to be 100% compliant with Ruby APIs, but FakeFS is not?

simonc commented 9 years ago

Well, FakeFS overrides several classes including FileUtils. This kind of override is problematic when you rely on real behavior from this kind of tool.

For instance, try testing the following with FakeFS ;)

FileUtils.touch('somefile.txt', noop: true)

This kind of option is totally ignored :(

MemFs tries to be compliant with the Ruby API by overriding only the low level classes (C classes) like File, Dir or File::Stat leaving the stdlib classes untouched and still working, being less intrusive that way :)

simonc commented 9 years ago

Another key point is that MemFs aims to implement every single method provided by Ruby classes (including IO ones for File when possible) and to behave and return exactly the same way as the original classes.

simonc commented 9 years ago

I'll try to add those details to the README. I'll keep your issue open to remind me ;) Thank you!

mikz commented 9 years ago

Now it makes sense. Thanks!

simonc commented 9 years ago

Awesome :)

simonc commented 9 years ago

It's now part of the README. Thanks ;)