Class: Servactory::TestKit::Rspec::Matchers::Submatchers::Shared::MustSubmatcher
- Inherits:
-
Base::Submatcher
- Object
- Base::Submatcher
- Servactory::TestKit::Rspec::Matchers::Submatchers::Shared::MustSubmatcher
- Defined in:
- lib/servactory/test_kit/rspec/matchers/submatchers/shared/must_submatcher.rb
Overview
Submatcher for validating custom ‘must` validation rules.
## Purpose
Validates that an attribute has the expected custom validation rules defined via the ‘must` option. Excludes dynamic options that are tested separately (consists_of, schema, be_inclusion, be_target).
## Usage
“‘ruby it { is_expected.to have_service_input(:email).must() } it { is_expected.to have_service_input(:age).must([:be_positive, :be_adult]) } “`
## Comparison
Uses set difference to compare validation names - order doesn’t matter.
Instance Attribute Summary
Attributes inherited from Base::Submatcher
Instance Method Summary collapse
-
#description ⇒ String
Returns description for RSpec output.
-
#initialize(context, must_names) ⇒ MustSubmatcher
constructor
Creates a new must 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, must_names) ⇒ MustSubmatcher
Creates a new must submatcher.
33 34 35 36 |
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/shared/must_submatcher.rb', line 33 def initialize(context, must_names) super(context) @must_names = must_names end |
Instance Method Details
#description ⇒ String
Returns description for RSpec output.
41 42 43 |
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/shared/must_submatcher.rb', line 41 def description "must: #{must_names.join(', ')}" end |