Class: Mocha::ParameterMatchers::Includes

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

Overview

Parameter matcher which matches when actual parameter includes expected value.

Instance Method Summary collapse

Methods inherited from Base

#&, #to_matcher, #|

Constructor Details

#initialize(item) ⇒ Includes


31
32
33
# File 'lib/mocha/parameter_matchers/includes.rb', line 31

def initialize(item)
  @item = item
end

Instance Method Details

#matches?(available_parameters) ⇒ Boolean


36
37
38
39
40
# File 'lib/mocha/parameter_matchers/includes.rb', line 36

def matches?(available_parameters)
  parameter = available_parameters.shift
  return false unless parameter.respond_to?(:include?)
  return parameter.include?(@item)
end

#mocha_inspectObject


43
44
45
# File 'lib/mocha/parameter_matchers/includes.rb', line 43

def mocha_inspect
  "includes(#{@item.mocha_inspect})"
end