Class: Servactory::TestKit::Rspec::Matchers::Submatchers::Shared::SchemaSubmatcher
- Inherits:
-
Base::Submatcher
- Object
- Base::Submatcher
- Servactory::TestKit::Rspec::Matchers::Submatchers::Shared::SchemaSubmatcher
- 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
Instance Method Summary collapse
-
#description ⇒ String
Returns description for RSpec output.
-
#initialize(context, schema_data) ⇒ SchemaSubmatcher
constructor
Creates a new schema submatcher.
Methods inherited from Base::Submatcher
#failure_message, #failure_message_when_negated, #matches?
Methods included from Concerns::ValueComparison
Methods included from Concerns::ErrorMessageBuilder
Methods included from Concerns::AttributeDataAccess
Constructor Details
#initialize(context, schema_data) ⇒ SchemaSubmatcher
Creates a new schema submatcher.
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
#description ⇒ String
Returns description for RSpec output.
46 47 48 |
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/shared/schema_submatcher.rb', line 46 def description "schema: #{schema_data}" end |