Sha256: 4a86c09ceb9eec36d930efd09227ba9c9c49e6d88468f524972db0b61ba13fb4

Contents?: true

Size: 641 Bytes

Versions: 1

Compression:

Stored size: 641 Bytes

Contents

require 'muack/definition'

module Muack
  class Modifier < Struct.new(:mock, :defi)
    # Public API
    def with_any_args
      defi.args = [WithAnyArgs]
      self
    end

    # Public API
    def returns val=nil, &block
      defi.block = block || lambda{ val }
    end

    # Public API
    def times number
      if number >= 1
        (number - 1).times{ mock.__mock_defis_push(defi) }
      elsif number == 0
        mock.__mock_defis_pop(defi)
      else
        raise "What would you expect from calling a method #{number} times?"
      end
      self
    end

    # Public API
    def object
      mock.object
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
muack-0.5.2 lib/muack/modifier.rb