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

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

Overview

Submatcher for validating input default values.

## Purpose

Validates that a service input has the expected default value. Useful for testing optional inputs with predefined fallback values.

## Usage

“‘ruby it { is_expected.to have_service_input(:limit).default(10) } it { is_expected.to have_service_input(:enabled).default(true) } it { is_expected.to have_service_input(:options).default({}) } “`

## Comparison

Uses case-insensitive string comparison for value matching. Handles nil values specially - matches only when expected is also nil.

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, expected_value) ⇒ DefaultSubmatcher

Creates a new default submatcher.

Parameters:

  • context (Base::SubmatcherContext)

    The submatcher context

  • expected_value (Object)

    The expected default value



34
35
36
37
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/input/default_submatcher.rb', line 34

def initialize(context, expected_value)
  super(context)
  @expected_value = expected_value
end

Instance Method Details

#descriptionString

Returns description for RSpec output.

Returns:

  • (String)

    Human-readable description with expected value



42
43
44
# File 'lib/servactory/test_kit/rspec/matchers/submatchers/input/default_submatcher.rb', line 42

def description
  "default: #{expected_value.inspect}"
end