Class: Mocha::ParameterMatchers::AnyOf

Inherits:
Base show all
Defined in:
lib/mocha/parameter_matchers/any_of.rb

Overview

Parameter matcher which combines a number of other matchers using a logical OR.

Instance Method Summary collapse

Methods inherited from Base

#&, #to_matcher, #|

Constructor Details

#initialize(*matchers) ⇒ AnyOf


39
40
41
# File 'lib/mocha/parameter_matchers/any_of.rb', line 39

def initialize(*matchers)
  @matchers = matchers
end

Instance Method Details

#matches?(available_parameters) ⇒ Boolean


44
45
46
47
# File 'lib/mocha/parameter_matchers/any_of.rb', line 44

def matches?(available_parameters)
  parameter = available_parameters.shift
  @matchers.any? { |matcher| matcher.to_matcher.matches?([parameter]) }
end

#mocha_inspectObject


50
51
52
# File 'lib/mocha/parameter_matchers/any_of.rb', line 50

def mocha_inspect
  "any_of(#{@matchers.map { |matcher| matcher.mocha_inspect }.join(", ") })"
end