Sha256: aa13afad5a9a775aa99ad02e12fec2574efa4a7bfd64bd7879e97b6b3b26579e

Contents?: true

Size: 864 Bytes

Versions: 4

Compression:

Stored size: 864 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 msg, actual_args
      if defi = __mock_defis[msg].find{ |d|
                  __mock_check_args(d.args, actual_args) }
        # our spies are interested in this
        __mock_disps_push(Definition.new(msg, actual_args))
        defi
      else
        Mock.__send__(:raise, # Wrong argument
          Unexpected.new(object, __mock_defis[msg], msg, actual_args))
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
muack-1.3.2 lib/muack/stub.rb
muack-1.3.1 lib/muack/stub.rb
muack-1.3.0 lib/muack/stub.rb
muack-1.2.0 lib/muack/stub.rb