11# Taken with love from @juneb_get_help (https://raw.githubusercontent.com/juneb/PesterTDD/master/Module.Help.Tests.ps1)
22
33BeforeDiscovery {
4-
5- function script :FilterOutCommonParams {
4+ function global :FilterOutCommonParams {
65 param ($Params )
76 $commonParams = @ (
87 ' Debug' , ' ErrorAction' , ' ErrorVariable' , ' InformationAction' , ' InformationVariable' ,
@@ -35,13 +34,17 @@ BeforeDiscovery {
3534 # # To test, restart session.
3635}
3736
37+ AfterAll {
38+ Remove-Item Function:/ FilterOutCommonParams
39+ }
40+
3841Describe " Test help for <_.Name>" - ForEach $commands {
3942
4043 BeforeDiscovery {
4144 # Get command help, parameters, and links
4245 $command = $_
4346 $commandHelp = Get-Help $command.Name - ErrorAction SilentlyContinue
44- $commandParameters = script :FilterOutCommonParams - Params $command.ParameterSets.Parameters
47+ $commandParameters = global :FilterOutCommonParams - Params $command.ParameterSets.Parameters
4548 $commandParameterNames = $commandParameters.Name
4649 $helpLinks = $commandHelp.relatedLinks.navigationLink.uri
4750 }
@@ -51,9 +54,9 @@ Describe "Test help for <_.Name>" -ForEach $commands {
5154 $command = $_
5255 $commandName = $_.Name
5356 $commandHelp = Get-Help $command.Name - ErrorAction SilentlyContinue
54- $commandParameters = script :FilterOutCommonParams - Params $command.ParameterSets.Parameters
57+ $commandParameters = global :FilterOutCommonParams - Params $command.ParameterSets.Parameters
5558 $commandParameterNames = $commandParameters.Name
56- $helpParameters = script :FilterOutCommonParams - Params $commandHelp.Parameters.Parameter
59+ $helpParameters = global :FilterOutCommonParams - Params $commandHelp.Parameters.Parameter
5760 $helpParameterNames = $helpParameters.Name
5861 }
5962
0 commit comments