TestDouble #freeze should return #self
Created by: alxberardi
When calling the freeze method on a double, it is a good thing that actual freezing does not happen and that a warning is shown.
That said, the expected return value for the freeze method on an object is the object itself.
In my particular case, I'm experiencing issues writing unit tests for classes that include Memoizable.
With memoized methods, the gem caches the return value of the freeze method called on the return value of the memoized method, which, in the case of doubles, would be nil
instead of the double itself.
The suggestion would be to return self
in TestDouble#freeze
(lib/rspec/mocks/test_double.rb:67)
def freeze
RSpec.warn_with("WARNING: you attempted to freeze a test double. This is explicitly a no-op as freezing doubles can lead to undesired behaviour when resetting tests.")
self
end
Thanks!