3 ms·
Because Time.now is a global method whose behavior you've just (temporarily) modified. Any tests or code that do depend on Time.now returning the actual current
by awj 14y ago
Because Time.now is a global method whose behavior you've just (temporarily) modified. Any tests or code that do depend on Time.now returning the actual current time won't work correctly.
- mcphage 14y agoEh, Ruby doesn't do well with parallelism anyway. If you're running your tests in parallel, you're usually running them in different processes. Or on different machines entirely. Either way, monkey patching one of those processes won't affect other ones. Besides, if there is a testing library that runs multiple tests in parallel in the same processes (which maybe there is and I'm just not aware of it), making your mocking library smart enough to handle that, isn't difficult. Stubbing only for a particular thread, for instance.