Class: Spec::Mocks::RegexpArgConstraint

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/mocks/argument_expectation.rb

Instance Method Summary collapse

Constructor Details

#initialize(regexp) ⇒ RegexpArgConstraint

Returns a new instance of RegexpArgConstraint.



25
26
27
# File 'lib/spec/mocks/argument_expectation.rb', line 25

def initialize(regexp)
  @regexp = regexp
end

Instance Method Details

#matches?(value) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/spec/mocks/argument_expectation.rb', line 29

def matches?(value)
  return value =~ @regexp unless value.is_a?(Regexp)
  value == @regexp
end