Implement an internal stub method to make time travel not dependent on mocha

Before this patch time travel feature depends on mocha's stub feature.
Since mocha is not a Rails dependency we can't depend on this specific
library.

We choose to use our own implementation to avoid adding one more
dependency to Rails.

Fixes #13380

[Rafael Mendonça França + Erich Kist]