Sha256: 7ab610913277ff776295c80f5e9ff975d1157855b9387f4cd1e096a2d8a93b7a

Contents?: true

Size: 824 Bytes

Versions: 4

Compression:

Stored size: 824 Bytes

Contents

require 'muack/mock'

module Muack
  class Stub < Mock
    # used for Muack::Session#verify
    def __mock_verify; true; end

    # used for Muack::Modifier#times
    def __mock_defis_push defi
      # since stubs never wear out, the reverse ordering would make more sense
      # so that the latter wins over the previous one (overwrite)
      __mock_defis[defi.msg].unshift(defi)
    end

    # used for mocked object to dispatch mocked method
    def __mock_dispatch actual_call
      defis = __mock_defis[actual_call.msg]

      if disp = __mock_find_checked_difi(defis, actual_call)
        # our spies are interested in this
        __mock_disps_push(actual_call)
        disp
      else
        Mock.__send__(:raise, # Wrong argument
          Unexpected.new(object, defis, actual_call))
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
muack-1.7.0 lib/muack/stub.rb
muack-1.6.0 lib/muack/stub.rb
muack-1.5.1 lib/muack/stub.rb
muack-1.5.0 lib/muack/stub.rb