Class: Mocha::ParameterMatchers::RegexpMatches

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

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Base

#&, #to_matcher, #|

Constructor Details

#initialize(regexp) ⇒ RegexpMatches

Returns a new instance of RegexpMatches.



26
27
28
# File 'lib/mocha/parameter_matchers/regexp_matches.rb', line 26

def initialize(regexp)
  @regexp = regexp
end

Instance Method Details

#matches?(available_parameters) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
# File 'lib/mocha/parameter_matchers/regexp_matches.rb', line 30

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

#mocha_inspectObject



36
37
38
# File 'lib/mocha/parameter_matchers/regexp_matches.rb', line 36

def mocha_inspect
  "regexp_matches(#{@regexp.mocha_inspect})"
end