Sha256: adc6118e5f8227bf1b8fe1be7311f66123b14f7cf23a799a9eef47d437412863
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'mocha/parameter_matchers/base' module Mocha module ParameterMatchers # :call-seq: all_of -> parameter_matcher # # Matches if all +matchers+ match. # object = mock() # object.expects(:method_1).with(all_of(includes(1), includes(3))) # object.method_1([1, 3]) # # no error raised # # object = mock() # object.expects(:method_1).with(all_of(includes(1), includes(3))) # object.method_1([1, 2]) # # error raised, because method_1 was not called with object including 1 and 3 def all_of(*matchers) AllOf.new(*matchers) end class AllOf < Base # :nodoc: def initialize(*matchers) @matchers = matchers end def matches?(available_parameters) parameter = available_parameters.shift @matchers.all? { |matcher| matcher.matches?([parameter]) } end def mocha_inspect "all_of(#{@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/all_of.rb |