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]
Release the stub lock if the stub method is called again in the same
object
Add nodoc to the methods
Only include the internal stubs methods in the needed classes