Class: Servactory::TestKit::Rspec::Matchers::Submatchers::Input::RequiredSubmatcher
- Inherits:
-
Base::Submatcher
- Object
- Base::Submatcher
- Servactory::TestKit::Rspec::Matchers::Submatchers::Input::RequiredSubmatcher
- Defined in:
- lib/servactory/test_kit/rspec/matchers/submatchers/input/required_submatcher.rb
Overview
Submatcher for validating that an input is required.
## Purpose
Validates that a service input has ‘required: true` option set. Optionally validates a custom error message for the required validation.
## Usage
“‘ruby it { is_expected.to have_service_input(:user_id).required } it { is_expected.to have_service_input(:name).required(“Name is mandatory”) } “`
## Validation
Checks the ‘:required` option in attribute data where `is: true`. If a custom message is provided, also validates the message matches.
Instance Attribute Summary
Attributes inherited from Base::Submatcher
Instance Method Summary collapse
-
#description ⇒ String
Returns description for RSpec output.
-
#initialize(context, custom_message = nil) ⇒ RequiredSubmatcher
constructor
Creates a new required 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, custom_message = nil) ⇒ RequiredSubmatcher
Creates a new required submatcher.
33 34 35 36 |
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/input/required_submatcher.rb', line 33 def initialize(context, = nil) super(context) @custom_message = end |
Instance Method Details
#description ⇒ String
Returns description for RSpec output.
41 42 43 |
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/input/required_submatcher.rb', line 41 def description "required: true" end |