Module: Marshal

Defined in:
lib/rspec/mocks/extensions/marshal.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) dump_with_mocks(object, *rest) Also known as: dump

Duplicates any mock objects before serialization. Otherwise, serialization will fail because methods exist on the singleton class.

5
6
7
8
9
10
11
# File 'lib/rspec/mocks/extensions/marshal.rb', line 5
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