Sha256: a67f9d62df509275a69c5622a7968f27f91610d37a9322a1569d242db5c9e210

Contents?: true

Size: 667 Bytes

Versions: 4

Compression:

Stored size: 667 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
      reverse_each{ |_, m| m.__mock_reset }
      clear
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
muack-1.0.3 lib/muack/session.rb
muack-1.0.2 lib/muack/session.rb
muack-1.0.1 lib/muack/session.rb
muack-1.0.0 lib/muack/session.rb