Improve examples on the new v6 Should-* assertion pages#377
Open
nohwnd wants to merge 1 commit into
Open
Conversation
Replace the carried-over/placeholder examples on the six new v6 assertion
command pages with correct, real-life, runnable examples (validated against
Pester 6.0.0):
- Should-Invoke / Should-NotInvoke: drop the broken {... Some Code ...}
placeholders and un-fenced examples; use real subjects (Save-Report,
Remove-TempFile, Get-Weather). Fix Should-NotInvoke explanations that were
copy-pasted from Should-Invoke and described the wrong behavior.
- Should-HaveParameter / Should-NotHaveParameter: switch from the old
'Should -HaveParameter' (space) syntax to the new 'Should-HaveParameter';
add Type/DefaultValue/Alias/InParameterSet examples and a passing
Should-NotHaveParameter example; drop the irrelevant ArgumentCompleter note.
- Should-MatchString / Should-NotMatchString: replace abstract hello/h.*o
samples with real-life regex checks (ids, GUIDs, version strings, leftover
template placeholders, secret-leak guard).
These pages are generated from Pester's comment-based help; the same fixes
should be ported to pester/Pester so regeneration keeps them.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
What & why
Follow-up to #374, which added command-reference pages for the six new v6 assertions. Those pages are generated from Pester's comment-based help, and several carried over poor or incorrect examples. This PR replaces them with correct, real-life, runnable examples (every one validated against Pester
6.0.0built from source).Changes per page
Should-Invoke/Should-NotInvoke— dropped the broken{... Some Code ...}placeholders and the un-fenced examples that rendered as escaped text. Use real subjects (Save-Report,Remove-TempFile,Get-Weather) and cover-ParameterFilter,-Times -Exactly,-Scope It,-ModuleNameand-ExclusiveFilter. Fixed theShould-NotInvokeexplanations, which were copy-pasted fromShould-Invokeand described the opposite behavior (e.g. "throws if … is not called").Should-HaveParameter/Should-NotHaveParameter— switched from the oldShould -HaveParameter(space) syntax to the newShould-HaveParameter; added-Type/-DefaultValue/-Alias/-InParameterSetexamples framed around testing a command's public contract; replaced the failingShould-NotHaveParametersample with a passing one; removed the irrelevant-HasArgumentCompleternote.Should-MatchString/Should-NotMatchString— replaced the abstracthello/h.*osamples with real-life regex checks (ids, GUIDs, version strings, leftover{{ }}template placeholders, a secret-leak guard).Validation
6.0.0(mock examples viaInvoke-Pester, the rest standalone) and behaves exactly as the surrounding text claims.yarn build(Docusaurus) succeeds, so all six MDX pages parse and render.Note on the source of truth
These pages are generated from comment-based help in
pester/Pester. I've prepared a matching patch for the inline help so a future regeneration keeps these improvements; it can go in as a follow-up topester/Pesteronce this merges.Relates to pester/Pester#2464.