Class: Servactory::TestKit::Rspec::Matchers::Submatchers::Shared::TargetSubmatcher
- Inherits:
-
Base::Submatcher
- Object
- Base::Submatcher
- Servactory::TestKit::Rspec::Matchers::Submatchers::Shared::TargetSubmatcher
- Defined in:
- lib/servactory/test_kit/rspec/matchers/submatchers/shared/target_submatcher.rb
Overview
Submatcher for validating target constraints.
## Purpose
Validates that an attribute has the expected target values defined. Targets are similar to inclusions but can be named differently (e.g., :target, :category, :group).
## Usage
“‘ruby it { is_expected.to have_service_input(:category).target([Category::A, Category::B], name: :category) } it { is_expected.to have_service_input(:type).target(%i[user admin], name: :type) } “`
## Comparison
Uses set difference to compare values - order doesn’t matter. Supports both single values and arrays.
Constant Summary collapse
- OPTION_BODY_KEY =
Key for the target values within the option
:in
Instance Attribute Summary
Attributes inherited from Base::Submatcher
Instance Method Summary collapse
-
#description ⇒ String
Returns description for RSpec output.
-
#initialize(context, option_name, values) ⇒ TargetSubmatcher
constructor
Creates a new target 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, option_name, values) ⇒ TargetSubmatcher
Creates a new target submatcher.
38 39 40 41 42 |
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/shared/target_submatcher.rb', line 38 def initialize(context, option_name, values) super(context) @option_name = option_name @values = values end |
Instance Method Details
#description ⇒ String
Returns description for RSpec output.
47 48 49 |
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/shared/target_submatcher.rb', line 47 def description "#{option_name}: #{formatted_values}" end |