Class: Pact::Matchers::V2::Regex
- Defined in:
- lib/pact/matchers/v2/regex.rb
Instance Attribute Summary
Attributes inherited from Base
#kind, #opts, #spec_version, #template
Instance Method Summary collapse
-
#initialize(regex, template) ⇒ Regex
constructor
A new instance of Regex.
Methods inherited from Base
Constructor Details
#initialize(regex, template) ⇒ Regex
Returns a new instance of Regex.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pact/matchers/v2/regex.rb', line 7 def initialize(regex, template) unless regex.is_a?(Regexp) raise MatcherInitializationError, "#{self.class}: #{regex} should be an instance of Regexp" end unless template.is_a?(String) || template.is_a?(Array) raise MatcherInitializationError, "#{self.class}: #{template} should be an instance of String or Array" end if template.is_a?(Array) && !template.all?(String) raise MatcherInitializationError, "#{self.class}: #{template} array values should be strings" end super(spec_version: Pact::Matchers::PACT_SPEC_V2, kind: 'regex', template: template, opts: { regex: regex.to_s }) # rubocop:disable Layout/LineLength end |