-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch between fake & real fs. #24
Conversation
# @return nothing | ||
def halt | ||
|
||
switch_to = -> dir_class, file_class { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer do...end
for multi-line blocks without chaining.
Use the lambda
method for multi-line lambdas.
Wrap stabby lambda arguments with parentheses.
Trailing whitespace detected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups, sorry for the many violations - feel free to rewrite the code if you like the feature. I'm still a sort of apprentice when it comes to Ruby...
Hi @thsur and thanks a lot for this cool idea! I think the It would also require tests before being merged 😉 |
Hi @simonc,
yep, you're right - I didn't focus enough on my problem, which was not so much switching between file systems, but to keep the state of the faked one. So I've rewritten the code and also wrote a spec for |
Hi @thsur. I think we have several options here:
I would vote for the |
…ameter for MemFs#activate!
Hi @simonc, sorry, took me a while to come back to the issue. I wanted to introduce some sort of parameter for |
before :each do | ||
described_class.activate! | ||
described_class.deactivate! | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this before
block?
Hey @thsur. That's pretty cool. Two small things though:
After this, it's a GO! |
Hey @simonc, thanks for your comments!
Hm. Good question. Maybe it's purpose was to illustrate my lack of talent when coding by copy & paste...
Absolutely. It's in now. |
Merged! 🎉 |
Thank you! 🍻 |
Somewhat related to #23 & #7 - I needed to read from the original file system, and this is what I came up with to switch between both file systems.
Background story: I'm testing a command line app lazy-loading subcommands via some loader class that
require
s the appropriate files. With the switch implemented, mocking the loader was easy as saying:So this is might be a valid use case, or it might be not, or it might be a stupid implementation, but I thought to give it a try.