Class: Ward::Matchers::Match

Inherits:
Matcher
  • Object
show all
Defined in:
lib/ward/matchers/match.rb

Overview

Tests whether the validation value matches the expected value with a regular expression.

Examples:


class Person
  validate do |person|
    person.name.matches(/^Michael (Scarn|Scott)$/)
  end
end

Instance Attribute Summary

Attributes inherited from Matcher

#expected, #extra_args

Instance Method Summary collapse

Methods inherited from Matcher

#customise_error_values, error_id, #initialize

Constructor Details

This class inherits a constructor from Ward::Matchers::Matcher

Instance Method Details

#matches?(actual) ⇒ Boolean

Returns whether the given value matches the expected value.

Parameters:

  • actual (#include?)

    The validation value.

Returns:

  • (Boolean)


23
24
25
# File 'lib/ward/matchers/match.rb', line 23

def matches?(actual)
  actual.match(@expected)
end