Sha256: 52d5ae2b10832f9f72d97602bb6258cb68eb23c7d923cf243e3e66fcd410b018
Contents?: true
Size: 756 Bytes
Versions: 1
Compression:
Stored size: 756 Bytes
Contents
module Mocha module ParameterMatchers def optionally(*matchers) Optionally.new(*matchers) end class Optionally < Base # :nodoc: def initialize(*parameters) @matchers = parameters.map { |parameter| parameter.to_matcher } end def matches?(available_parameters) index = 0 while (available_parameters.length > 0) && (index < @matchers.length) do matcher = @matchers[index] return false unless matcher.matches?(available_parameters) index += 1 end return true end def mocha_inspect "optionally(#{@matchers.map { |matcher| matcher.mocha_inspect }.join(", ") })" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mocha-0.5.6 | lib/mocha/parameter_matchers/optionally.rb |