Sha256: 81aebc99a93b149f4be0a3f69830085c8b2875a08237d00bbd78056cd0bdffe5

Contents?: true

Size: 1 KB

Versions: 41

Compression:

Stored size: 1 KB

Contents

require 'mocha/parameter_matchers/base'

module Mocha
  module ParameterMatchers
    # Matches any parameters. This is used as the default for a newly built expectation.
    #
    # @return [AnyParameters] parameter matcher.
    #
    # @see Expectation#with
    #
    # @example Any parameters will match.
    #   object = mock()
    #   object.expects(:method_1).with(any_parameters)
    #   object.method_1(1, 2, 3, 4)
    #   # no error raised
    #
    #   object = mock()
    #   object.expects(:method_1).with(any_parameters)
    #   object.method_1(5, 6, 7, 8, 9, 0)
    #   # no error raised
    def any_parameters
      AnyParameters.new
    end

    # Parameter matcher which always matches whatever the parameters.
    class AnyParameters < Base
      # @private
      def matches?(available_parameters)
        until available_parameters.empty?
          available_parameters.shift
        end
        true
      end

      # @private
      def mocha_inspect
        'any_parameters'
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 3 rubygems

Version Path
mocha-2.7.1 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.7.0 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.6.1 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.6.0 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.5.0 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.4.5 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.4.4 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.4.3 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.4.2 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.4.1 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.4.0 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.2.0 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.1.0 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.0.4 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.0.3 lib/mocha/parameter_matchers/any_parameters.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/mocha-2.0.2/lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.0.2 lib/mocha/parameter_matchers/any_parameters.rb
mocha-1.16.1 lib/mocha/parameter_matchers/any_parameters.rb
mocha-1.15.1 lib/mocha/parameter_matchers/any_parameters.rb
mocha-2.0.1 lib/mocha/parameter_matchers/any_parameters.rb