class Muack::Spy

Public Class Methods

new(stub) click to toggle source
Calls superclass method Muack::Mock::new
# File lib/muack/spy.rb, line 6
def initialize stub
  super(stub.object)
  @stub = stub
end

Public Instance Methods

__mock_reset() click to toggle source

used for Muack::Session#reset, but spies never leave any track

# File lib/muack/spy.rb, line 18
def __mock_reset; end
__mock_verify() click to toggle source

used for Muack::Session#verify

Calls superclass method Muack::Mock#__mock_verify
# File lib/muack/spy.rb, line 12
def __mock_verify
  __mock_dispatch_spy
  super
end

Private Instance Methods

__mock_dispatch_spy() click to toggle source

simulate dispatching before passing to mock to verify

# File lib/muack/spy.rb, line 24
def __mock_dispatch_spy
  @stub.__mock_disps.values.flatten.each do |disp|
    next unless __mock_defis.key?(disp.msg) # ignore undefined spies

    defis = __mock_defis[disp.msg]
    if idx = __mock_find_checked_difi(defis, disp, :index)
      __mock_disps_push(defis.delete_at(idx)) # found, dispatch it
    elsif defis.empty? # show called candidates
      __mock_failed(disp)
    else # show expected candidates
      __mock_failed(disp, defis)
    end
  end
end
__mock_inject_method(defi;) click to toggle source
# File lib/muack/spy.rb, line 21
def __mock_inject_method defi; end