module Marshal
def dump_with_mocks(object, *rest)
Duplicates any mock objects before serialization. Otherwise,
def dump_with_mocks(object, *rest) if ::RSpec::Mocks.space.nil? || !::RSpec::Mocks.space.registered?(object) || NilClass === object dump_without_mocks(object, *rest) else dump_without_mocks(object.dup, *rest) end end