Files
cleveragents-core/features/yaml_template_engine_coverage_boost.feature

65 lines
3.3 KiB
Gherkin

Feature: YAML Template Engine coverage boost for uncovered lines
Targets uncovered lines 101-105, 134-136, 138-142, 172, 236-237
Background:
Given a fresh YAML template engine instance
# ── Lines 101-105: fallback path returns a valid dict after _fix_common_yaml_issues ──
Scenario: Fallback fix path returns a dict after first parse raises YAMLError
Given a YAML template with Jinja2 that renders valid content
And a context that produces parseable YAML on fix retry
When I render and parse with a forced first-parse YAMLError returning a dict
Then the fallback parse should return a dict result
# ── Lines 101-104: fallback path raises ValueError when fixed YAML is not a dict ──
Scenario: Fallback fix path raises ValueError when repaired YAML is not a dict
Given a YAML template with Jinja2 that renders valid content
And a context that produces parseable YAML on fix retry
When I render and parse with a forced first-parse YAMLError returning a list
Then a ValueError should be raised from the fallback path
# ── Lines 134-136: _postprocess_rendered_yaml reaches value_words split branch ──
Scenario: Postprocess reaches value_words splitting logic for single-colon line with spaced value
Given rendered YAML with a single-colon line whose value has multiple words
When I postprocess the YAML content
Then the value_words branch should be entered and evaluated
# ── Lines 138-142: dead code in postprocess (guard conflict prevents entry) ──
# These lines are structurally unreachable due to conflicting guards on lines 128+133 vs 135-136.
# We exercise the closest reachable branch and document the dead code.
Scenario: Postprocess value_words inner condition evaluates False for no-colon values
Given rendered YAML content " key: alpha beta gamma" with spaces in value
When I postprocess the YAML content
Then the line should pass through unchanged because value words lack colons
# ── Line 172: _fix_common_yaml_issues appends line with single or zero colons ──
Scenario: Fix common YAML issues preserves a line with exactly one colon
Given YAML content with a single-colon line "simple: value"
When I apply fix common YAML issues
Then the single-colon line should be preserved verbatim
Scenario: Fix common YAML issues preserves a line with zero colons
Given YAML content with a zero-colon line "no colons here"
When I apply fix common YAML issues
Then the zero-colon line should be preserved verbatim
# ── Lines 236-237: _sum_filter raises ValueError for non-summable input ──
# (pragma: no cover marked, but we exercise it anyway)
Scenario: Sum filter raises ValueError for non-summable sequences
Given a sequence of non-summable items
When I call the sum filter on the non-summable sequence
Then a ValueError should be raised with a descriptive message
# ── Integration: end-to-end render that exercises fallback fix returning a dict ──
Scenario: End-to-end render with mocked first-parse failure and successful fix
Given a template "result: {{ val }}" with context val set to "ok"
When rendering triggers a YAMLError on first parse but fix produces a dict
Then the final result should be the fixed dict