Sha256: 28dc388cb69664f0a207ec8744f5d0f9f40535bf230406209a89c3ad3cf4d0ac

Contents?: true

Size: 840 Bytes

Versions: 145

Compression:

Stored size: 840 Bytes

Contents

require 'rspec/mocks/extensions/marshal'
require 'rspec/mocks/extensions/psych' if defined?(::Psych)

module RSpec
  module Mocks
    # @private
    module Serialization
      # @private
      def self.fix_for(object)
        object.extend(YAML) if defined?(::YAML)
      rescue TypeError
        # Can't extend Fixnums, Symbols, true, false, or nil
      end

      # @private
      module YAML
        # @private
        def to_yaml(options = {})
          return nil if defined?(::Psych) && options.respond_to?(:[]) && options[:nodump]
          return super(options) unless instance_variable_defined?(:@mock_proxy)

          mp = @mock_proxy
          remove_instance_variable(:@mock_proxy)

          begin
            super(options)
          ensure
            @mock_proxy = mp
          end
        end
      end
    end
  end
end

Version data entries

145 entries across 94 versions & 18 rubygems

Version Path
classicCMS-0.2.1 vendor/bundle/gems/rspec-mocks-2.9.0/lib/rspec/mocks/serialization.rb
classicCMS-0.2.0 vendor/bundle/gems/rspec-mocks-2.9.0/lib/rspec/mocks/serialization.rb
classicCMS-0.1.2 vendor/bundle/gems/rspec-mocks-2.9.0/lib/rspec/mocks/serialization.rb
rspec-mocks-2.9.0 lib/rspec/mocks/serialization.rb
rspec-mocks-2.9.0.rc2 lib/rspec/mocks/serialization.rb