Class: Mocha::ParameterMatchers::RegexpMatches
- Defined in:
- lib/mocha/parameter_matchers/regexp_matches.rb
Overview
Parameter matcher which matches if specified regular expression matches actual paramter.
Instance Method Summary collapse
-
#initialize(regexp) ⇒ RegexpMatches
constructor
A new instance of RegexpMatches.
- #matches?(available_parameters) ⇒ Boolean
- #mocha_inspect ⇒ Object
Methods inherited from Base
#&, #to_matcher, #|
Constructor Details
#initialize(regexp) ⇒ RegexpMatches
Returns a new instance of RegexpMatches.
34 35 36 |
# File 'lib/mocha/parameter_matchers/regexp_matches.rb', line 34 def initialize(regexp) @regexp = regexp end |
Instance Method Details
#matches?(available_parameters) ⇒ Boolean
39 40 41 42 43 |
# File 'lib/mocha/parameter_matchers/regexp_matches.rb', line 39 def matches?(available_parameters) parameter = available_parameters.shift return false unless parameter.respond_to?(:=~) parameter =~ @regexp end |
#mocha_inspect ⇒ Object
46 47 48 |
# File 'lib/mocha/parameter_matchers/regexp_matches.rb', line 46 def mocha_inspect "regexp_matches(#{@regexp.mocha_inspect})" end |