class RSpec::Mocks::Configuration

def patch_marshal_to_support_partial_doubles=(val)

This method is idempotent.

the patch.
these singleton methods before serialization. Setting to falsey removes
adding singleton methods that cannot be serialized. This patch removes
objects. By default this will not work since RSpec mocks works by
Monkey-patch `Marshal.dump` to enable dumping of mocked or stubbed
def patch_marshal_to_support_partial_doubles=(val)
  if val
    RSpec::Mocks::MarshalExtension.patch!
  else
    RSpec::Mocks::MarshalExtension.unpatch!
  end
end