Class: Mocha::ParameterMatchers::InstanceOf

Inherits:
Base
  • Object
show all
Defined in:
lib/mocha/parameter_matchers/instance_of.rb

Overview

Parameter matcher which matches when actual parameter is an instance of the specified class.

Instance Method Summary collapse

Methods inherited from Base

#&, #to_matcher, #|

Constructor Details

#initialize(klass) ⇒ InstanceOf

Returns a new instance of InstanceOf


34
35
36
# File 'lib/mocha/parameter_matchers/instance_of.rb', line 34

def initialize(klass)
  @klass = klass
end

Instance Method Details

#matches?(available_parameters) ⇒ Boolean

Returns:

  • (Boolean)

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

def matches?(available_parameters)
  parameter = available_parameters.shift
  parameter.instance_of?(@klass)
end

#mocha_inspectObject


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

def mocha_inspect
  "instance_of(#{@klass.mocha_inspect})"
end