Make both boolean assertions negate the same way - #80
Merged
Conversation
--assert-ok=false asserted the status IS an error. --assert-body-empty=false
asserted nothing at all, and the run died reporting that no assertion had
been made:
$ http-assert --assert-body-empty=false http://…/ok
Error: Cannot perform request: no assertions defined
Two flags of the same shape, one of them telling a user who had just
named an assertion that there were none. Neither behaviour was written
down anywhere.
=false now selects the opposite assertion on both, so
--assert-body-empty=false asserts the body is not empty. That is the
reading --assert-ok already had, it is the only one under which naming a
flag cannot yield nothing, and it adds the assertion by the shortest
route rather than by a new flag.
The pairing lives in one helper rather than being written out per flag.
The two drifted apart because nothing connected them -- the same root as
#35, where the fix was likewise to derive the rule instead of repeating
it. A boolean assertion added later gets the behaviour on the day it is
added.
Negation is now documented in the README, --help and the package comment.
Repeating a negated flag is still refused, since naming it twice is still
naming it twice.
Closes #32
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019EMMhgmTkbzAsmeNy97PrP
korya
force-pushed
the
korya-fix-bool-assertion-negation
branch
from
August 8, 2026 13:15
df3d77c to
aacdc72
Compare
korya
marked this pull request as ready for review
August 8, 2026 13:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two boolean assertions of the same shape did two different things with
=false, and one of them told the user they had made no assertion.The second is the one that matters. The user named an assertion and was told there were none — the run cannot even be said to have failed, it never started. Nothing in the README,
--helpor the package comment described either behaviour, so neither was discoverable except by trying it.Solution
=falsenow selects the opposite assertion on both flags.That reading is the one
--assert-okalready had; it is the only one under which naming a flag can never yield nothing; and it adds a genuinely useful assertion by the shortest available route.--assert-ok=false--assert-body-empty=falseThe pairing lives in one place now
The two flags drifted apart because nothing connected them — one was written with
Changed(), the other with the value, and no rule said they were the same kind of thing. That is the same root cause as #35, where the fix was likewise to derive the rule rather than repeat it per flag:rejectRepeatsreads the flag's type instead of consulting a list.boolAssertion(cmd, name, whenTrue, whenFalse)is the equivalent here. A boolean assertion added later gets the behaviour on the day it is added, rather than whenever someone notices.Deliberately not done
The issue floats promoting this to first-class
--assert-not-okand--assert-body-not-emptyflags. That is a feature, not the fix —=falsealready works, is now consistent, and is now documented. Adding two flags for a spelling that exists would need its own argument about which is canonical, and it does not have to be made to close this.Other Changes
Negation is documented in three places that previously described neither behaviour: the README's assertion section (with both flags shown doing something a reader would actually want), the
--helpprose, the two flag descriptions, and the package comment.TestKnownIssue32NegatedBooleanFlagsDifferis deleted, replaced byTestE2EAssertBooleanNegation— both flags, both directions, both outcomes, eight cases. Plus a guard that no negated flag is ever treated as no assertion at all, which is the specific failure this closes, and a check that repeating a negated flag is still refused, since naming it twice is still naming it twice.Test_AssertBodyNotEmptycovers the new constructor including a nil body (what a 204 produces) and whitespace, which counts as content. It also asserts the pair are exact inverses across five bodies — without that,=falsecould quietly mean something subtly other than "not that".There are no screenshots because there is no rendered UI; this tool's user-visible surface is terminal output, shown inline above.
Closes #32
Related:
🤖 Generated with Claude Code
https://claude.ai/code/session_019EMMhgmTkbzAsmeNy97PrP