Sha256: 8103d1daebbccda7f2a53f00aea35c6ef8bc60a6d2833410c90e3ed967390cd4

Contents?: true

Size: 656 Bytes

Versions: 4

Compression:

Stored size: 656 Bytes

Contents

require 'muack/mock'
require 'muack/stub'
require 'muack/spy'
require 'muack/any_instance_of'

module Muack
  class Session < Hash
    def mock obj; self["mk #{obj.__id__}"] ||= Mock.new(obj)      ; end
    def stub obj; self["sb #{obj.__id__}"] ||= Stub.new(obj)      ; end
    def spy  obj; self["sy #{obj.__id__}"] ||= Spy .new(stub(obj)); end

    def any_instance_of kls
      (@others ||= {})["ai #{kls.__id__}"] ||= AnyInstanceOf.new(kls)
    end

    def verify
      each_value.all?(&:__mock_verify)
    end

    def reset
      instance_variable_defined?(:@others) && @others.clear
      each_value(&:__mock_reset)
      clear
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
muack-0.7.3 lib/muack/session.rb
muack-0.7.2 lib/muack/session.rb
muack-0.7.1 lib/muack/session.rb
muack-0.7.0 lib/muack/session.rb