-
-
Save bbrowning/0ca01f4ed76bb234bc0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Marshal | |
class << self | |
def dump_with_mocks(*args) | |
object = args.shift | |
return dump_without_mocks(*args.unshift(object)) unless object.instance_variable_defined?(:@mock_proxy) | |
mp = object.instance_variable_get(:@mock_proxy) | |
return dump_without_mocks(*args.unshift(object)) unless mp.is_a?(::RSpec::Mocks::Proxy) | |
object.__send__(:remove_instance_variable, :@mock_proxy) | |
begin | |
dump_without_mocks(*args.unshift(object.dup)) | |
ensure | |
object.instance_variable_set(:@mock_proxy,mp) | |
end | |
end | |
alias_method :dump_without_mocks, :dump | |
undef_method :dump | |
alias_method :dump, :dump_with_mocks | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment