1
1
# Taken with love from @juneb_get_help (https://raw.githubusercontent.com/juneb/PesterTDD/master/Module.Help.Tests.ps1)
2
2
3
3
BeforeDiscovery {
4
-
5
- function script :FilterOutCommonParams {
4
+ function global :FilterOutCommonParams {
6
5
param ($Params )
7
6
$commonParams = @ (
8
7
' Debug' , ' ErrorAction' , ' ErrorVariable' , ' InformationAction' , ' InformationVariable' ,
@@ -35,13 +34,17 @@ BeforeDiscovery {
35
34
# # To test, restart session.
36
35
}
37
36
37
+ AfterAll {
38
+ Remove-Item Function:/ FilterOutCommonParams
39
+ }
40
+
38
41
Describe " Test help for <_.Name>" - ForEach $commands {
39
42
40
43
BeforeDiscovery {
41
44
# Get command help, parameters, and links
42
45
$command = $_
43
46
$commandHelp = Get-Help $command.Name - ErrorAction SilentlyContinue
44
- $commandParameters = script :FilterOutCommonParams - Params $command.ParameterSets.Parameters
47
+ $commandParameters = global :FilterOutCommonParams - Params $command.ParameterSets.Parameters
45
48
$commandParameterNames = $commandParameters.Name
46
49
$helpLinks = $commandHelp.relatedLinks.navigationLink.uri
47
50
}
@@ -51,9 +54,9 @@ Describe "Test help for <_.Name>" -ForEach $commands {
51
54
$command = $_
52
55
$commandName = $_.Name
53
56
$commandHelp = Get-Help $command.Name - ErrorAction SilentlyContinue
54
- $commandParameters = script :FilterOutCommonParams - Params $command.ParameterSets.Parameters
57
+ $commandParameters = global :FilterOutCommonParams - Params $command.ParameterSets.Parameters
55
58
$commandParameterNames = $commandParameters.Name
56
- $helpParameters = script :FilterOutCommonParams - Params $commandHelp.Parameters.Parameter
59
+ $helpParameters = global :FilterOutCommonParams - Params $commandHelp.Parameters.Parameter
57
60
$helpParameterNames = $helpParameters.Name
58
61
}
59
62
0 commit comments