Class: Servactory::TestKit::Rspec::Matchers::Submatchers::Input::ValidWithSubmatcher

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

Overview

Submatcher for integration testing of input validation.

## Purpose

Performs integration testing of input attributes by calling the actual service and verifying validation behavior. Tests type checks, required/optional status, inclusion, and target validations.

## Usage

“‘ruby it { is_expected.to have_service_input(:status).valid_with(valid_attributes) } it { is_expected.to have_service_input(:count).valid_with(false) } “`

## Deprecation Notice

This submatcher is planned to be decommissioned. Consider using direct service call tests instead.

## Validation Steps

  1. ‘success_passes?` - service succeeds with valid attributes

  2. ‘failure_type_passes?` - fails correctly with wrong type

  3. ‘failure_required_passes?` - fails when required input is nil

  4. ‘failure_optional_passes?` - succeeds when optional input is nil

  5. ‘failure_inclusion_passes?` - fails with value outside inclusion

  6. ‘failure_target_passes?` - fails with value outside target

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, attributes) ⇒ ValidWithSubmatcher

Creates a new valid_with submatcher.

Parameters:

  • context (Base::SubmatcherContext)

    The submatcher context

  • attributes (Hash, FalseClass)

    Test attributes or false to skip



43
44
45
46
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/input/valid_with_submatcher.rb', line 43

def initialize(context, attributes)
  super(context)
  @attributes = attributes.is_a?(FalseClass) ? attributes : Servactory::Utils.adapt(attributes)
end

Instance Method Details

#descriptionString

Returns description for RSpec output.

Returns:

  • (String)

    Human-readable description



51
52
53
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/input/valid_with_submatcher.rb', line 51

def description
  "valid_with attribute checking"
end