Class: Servactory::TestKit::Rspec::Matchers::Submatchers::Shared::SchemaSubmatcher

Inherits:
Base::Submatcher
  • Object
show all
Defined in:
lib/servactory/test_kit/rspec/matchers/submatchers/shared/schema_submatcher.rb

Overview

Submatcher for validating Hash schema definitions.

## Purpose

Validates that a Hash attribute has the expected schema definition. Schemas define the structure and types of keys within a Hash.

## Usage

“‘ruby it { is_expected.to have_service_input(:config).schema({ api_key: String }) } it { is_expected.to have_service_input(:user_data).schema({ name: String, age: Integer }) } “`

## Note

Requires the ‘:types` option to be set first (via `.type` chain). Uses RSpec’s ‘match` matcher for schema comparison.

Constant Summary collapse

OPTION_NAME =

Option name in attribute data

:schema
OPTION_BODY_KEY =

Key for the schema value within the option

:is

Instance Attribute Summary

Attributes inherited from Base::Submatcher

#missing_option

Instance Method Summary collapse

Methods inherited from Base::Submatcher

#failure_message, #failure_message_when_negated, #matches?

Methods included from Concerns::ValueComparison

included

Methods included from Concerns::ErrorMessageBuilder

included

Methods included from Concerns::AttributeDataAccess

included

Constructor Details

#initialize(context, schema_data) ⇒ SchemaSubmatcher

Creates a new schema submatcher.

Parameters:



38
39
40
41
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/shared/schema_submatcher.rb', line 38

def initialize(context, schema_data)
  super(context)
  @schema_data = schema_data
end

Instance Method Details

#descriptionString

Returns description for RSpec output.

Returns:

  • (String)

    Human-readable description with schema



46
47
48
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/shared/schema_submatcher.rb', line 46

def description
  "schema: #{schema_data}"
end