Class: Sbmt::Pact::Matchers::V2::Regex
- Defined in:
- lib/sbmt/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.
8 9 10 11 12 13 14 |
# File 'lib/sbmt/pact/matchers/v2/regex.rb', line 8 def initialize(regex, template) raise MatcherInitializationError, "#{self.class}: #{regex} should be an instance of Regexp" unless regex.is_a?(Regexp) raise MatcherInitializationError, "#{self.class}: #{template} should be an instance of String or Array" unless template.is_a?(String) || template.is_a?(Array) raise MatcherInitializationError, "#{self.class}: #{template} array values should be strings" if template.is_a?(Array) && !template.all?(String) super(spec_version: Sbmt::Pact::Matchers::PACT_SPEC_V2, kind: "regex", template: template, opts: {regex: regex.to_s}) end |