Sha256: b136c43964f03b6586b68455f747b2aa60dc24387a7c94984856feb629a964a3

Contents?: true

Size: 646 Bytes

Versions: 4

Compression:

Stored size: 646 Bytes

Contents

module Bogus
  class WithArguments
    attr_reader :predicate

    def initialize(&predicate)
      @predicate = predicate
    end

    def matches?(args)
      predicate.call(*args)
    end

    def self.matches?(opts = {})
      stubbed = opts.fetch(:stubbed)
      recorded = opts.fetch(:recorded)
      return false unless with_matcher?(stubbed)
      return extract(stubbed).matches?(recorded)
    end

    def self.with_matcher?(args)
      args.first.is_a?(WithArguments)
    end

    private

    def self.extract(args)
      args.first
    end
  end

  AnyArgs = WithArguments.new{ true }

  def AnyArgs.inspect
    "any_args"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bogus-0.1.4 lib/bogus/stubbing/any_args.rb
bogus-0.1.3 lib/bogus/any_args.rb
bogus-0.1.2 lib/bogus/any_args.rb
bogus-0.1.1 lib/bogus/any_args.rb