Sha256: b2fcf91b190b7a86e0390973768251ac754b489025dfcbb9295c06f3c59885bd

Contents?: true

Size: 1 KB

Versions: 9

Compression:

Stored size: 1 KB

Contents

require 'date'

module Mocha
  module Inspect
    module ObjectMethods
      def mocha_inspect
        address = __id__ * 2
        address += 0x100000000 if address < 0
        inspect =~ /#</ ? "#<#{self.class}:0x#{Kernel.format('%x', address)}>" : inspect
      end
    end

    module ArrayMethods
      def mocha_inspect
        "[#{collect(&:mocha_inspect).join(', ')}]"
      end
    end

    module HashMethods
      def mocha_inspect
        "{#{collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')}}"
      end
    end

    module TimeMethods
      def mocha_inspect
        "#{inspect} (#{to_f} secs)"
      end
    end

    module DateMethods
      def mocha_inspect
        to_s
      end
    end
  end
end

class Object
  include Mocha::Inspect::ObjectMethods
end

class Array
  include Mocha::Inspect::ArrayMethods
end

class Hash
  include Mocha::Inspect::HashMethods
end

class Time
  include Mocha::Inspect::TimeMethods
end

class Date
  include Mocha::Inspect::DateMethods
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mocha-1.12.0 lib/mocha/inspect.rb
mocha-1.11.2 lib/mocha/inspect.rb
mocha-1.11.1 lib/mocha/inspect.rb
mocha-1.11.0 lib/mocha/inspect.rb
mocha-1.10.2 lib/mocha/inspect.rb
mocha-1.10.1 lib/mocha/inspect.rb
mocha-1.10.0 lib/mocha/inspect.rb
mocha-1.10.0.beta.1 lib/mocha/inspect.rb
mocha-1.10.0.alpha lib/mocha/inspect.rb