Module: Servactory::TestKit::Rspec::Matchers::Base::SubmatcherRegistry

Included in:
AttributeMatcher
Defined in:
lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb

Overview

Registry mixin providing DSL for registering submatchers in attribute matchers.

## Purpose

SubmatcherRegistry provides a class-level DSL for declaratively registering submatchers in AttributeMatcher subclasses. It handles inheritance of submatcher definitions and configuration options for each submatcher.

## Usage

Include this module in AttributeMatcher subclasses:

“‘ruby class HaveServiceInputMatcher < Base::AttributeMatcher

include SubmatcherRegistry

register_submatcher :required,
                    class_name: "Input::RequiredSubmatcher",
                    mutually_exclusive_with: [:optional]

register_submatcher :types,
                    class_name: "Shared::TypesSubmatcher",
                    chain_method: :type,
                    chain_aliases: [:types],
                    stores_option_types: true

end “‘

## Features

  • **Declarative Registration** - register submatchers with options hash

  • **Chain Method Generation** - creates fluent API methods automatically

  • **Inheritance Support** - subclasses inherit parent’s submatcher definitions

  • **Argument Transformation** - customize how arguments are passed to submatchers

  • **Mutual Exclusivity** - define conflicting submatchers that replace each other

## Architecture

Works with:

  • AttributeMatcher - uses registry to build chain methods

  • SubmatcherDefinition - holds configuration for each submatcher

  • Submatcher - base class for actual validation logic

Defined Under Namespace

Modules: ClassMethods Classes: SubmatcherDefinition

Class Method Summary collapse

Class Method Details

.included(base) ⇒ void

This method returns an undefined value.

Extends the including class with ClassMethods.

Parameters:

  • base (Class)

    The class including this module



55
56
57
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 55

def self.included(base)
  base.extend(ClassMethods)
end