docs(doubles): document bashunit::unmock and the double lifecycle - #908
Merged
Merged
Conversation
bashunit::unmock was public but absent from the test-doubles page, and the per-test auto-cleanup was invisible from the docs — leaving a reader to guess whether they must unmock in every tear_down. Document the helper, and state the lifecycle: a double declared in a test dies with it, one declared in set_up_before_script lives for the whole file. Every claim was verified against the runner rather than taken from the issue. Two corrections to its framing: unmock cannot undo a set_up_before_script double for the *other* tests (each test is a subshell, so it only suspends it for the current one), and re-declaring a double does not need an unmock first — the second mock/spy simply replaces the first. A new tests/functional/doubles_lifecycle_test.sh pins all of it, so the page cannot drift from the behaviour. Closes #899
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.
🤔 Background
Related #899
bashunit::unmockis public but missing from the test-doubles page, and the per-test auto-cleanup is invisible from the docs — so a reader cannot tell whether they are supposed to unmock in everytear_down.💡 Changes
bashunit::unmockwith an example, plus a "Lifecycle of a double" section: declared in a test it dies with the test, declared inset_up_before_scriptit lives for the whole file.tests/functional/doubles_lifecycle_test.sh, so the page cannot drift.Two corrections to the issue's framing, both verified against the runner:
unmockcannot undo aset_up_before_scriptdouble for the other tests (each test is a subshell, so it only suspends it for the current one), and re-declaring a double does not need anunmockfirst.