Problem
Each lesson checks that the learner used the API it teaches:
if [ "$("$GREP" -c "assert_contains" "$test_file" || true)" -eq 0 ]; then
echo "Your test should use assert_contains"
But the template that lesson generates contains the name in its own hint:
# TODO: Check that message contains "bashunit"
# Hint: assert_contains "substring" "$message"
so the gate passes before the learner writes anything. All 9 lessons with a grep gate are already satisfied by their own untouched template.
The consequence is not just a missing hint. A learner can complete a lesson without doing it:
function test_multiple_assertions() {
local message="Hello, bashunit!"
# TODO: Check that message contains "bashunit"
# Hint: assert_contains "substring" "$message"
assert_same 1 1
}
grep gate (assert_contains): 1 match — passes, on the comment
test run --fail-on-risky: exit 0
=> "✓ Excellent! Lesson 2 completed!" without ever using assert_contains
The lesson teaches assert_contains, assert_matches and assert_not_empty; none is required in practice.
Fix
Count matches in code, not comments — the gate should look at what the learner wrote, not at the hint it printed. A shared helper in src/learn/session.sh used by all nine lessons, rather than nine copies of a grep -v '^[[:space:]]*#'.
Related
#1257 fixed the other half of this: an untouched template used to complete a lesson because a test with no assertions is risky and risky exits 0. That closed the "no work at all" path; this closes the "wrong work" path.
Problem
Each lesson checks that the learner used the API it teaches:
But the template that lesson generates contains the name in its own hint:
so the gate passes before the learner writes anything. All 9 lessons with a grep gate are already satisfied by their own untouched template.
The consequence is not just a missing hint. A learner can complete a lesson without doing it:
The lesson teaches
assert_contains,assert_matchesandassert_not_empty; none is required in practice.Fix
Count matches in code, not comments — the gate should look at what the learner wrote, not at the hint it printed. A shared helper in
src/learn/session.shused by all nine lessons, rather than nine copies of agrep -v '^[[:space:]]*#'.Related
#1257 fixed the other half of this: an untouched template used to complete a lesson because a test with no assertions is risky and risky exits 0. That closed the "no work at all" path; this closes the "wrong work" path.