@@ -4,26 +4,23 @@ BeforeDiscovery {
44
55 function global :FilterOutCommonParams {
66 param ($Params )
7- $commonParams = @ (
8- ' Debug' , ' ErrorAction' , ' ErrorVariable' , ' InformationAction' , ' InformationVariable' ,
9- ' OutBuffer' , ' OutVariable' , ' PipelineVariable' , ' Verbose' , ' WarningAction' ,
10- ' WarningVariable' , ' Confirm' , ' Whatif'
11- )
12- $params | Where-Object { $_.Name -notin $commonParams } | Sort-Object - Property Name - Unique
7+ $commonParameters = [System.Management.Automation.PSCmdlet ]::CommonParameters +
8+ [System.Management.Automation.PSCmdlet ]::OptionalCommonParameters
9+ $params | Where-Object { $_.Name -notin $commonParameters } | Sort-Object - Property Name - Unique
1310 }
1411
15- $manifest = Import-PowerShellDataFile - Path $env: BHPSModuleManifest
16- $outputDir = Join-Path - Path $env: BHProjectPath - ChildPath ' Output'
17- $outputModDir = Join-Path - Path $outputDir - ChildPath $env: BHProjectName
18- $outputModVerDir = Join-Path - Path $outputModDir - ChildPath $manifest.ModuleVersion
12+ $manifest = Import-PowerShellDataFile - Path $env: BHPSModuleManifest
13+ $outputDir = Join-Path - Path $env: BHProjectPath - ChildPath ' Output'
14+ $outputModDir = Join-Path - Path $outputDir - ChildPath $env: BHProjectName
15+ $outputModVerDir = Join-Path - Path $outputModDir - ChildPath $manifest.ModuleVersion
1916 $outputModVerManifest = Join-Path - Path $outputModVerDir - ChildPath " $ ( $env: BHProjectName ) .psd1"
2017
2118 # Get module commands
2219 # Remove all versions of the module from the session. Pester can't handle multiple versions.
2320 Get-Module $env: BHProjectName | Remove-Module - Force - ErrorAction Ignore
2421 Import-Module - Name $outputModVerManifest - Verbose:$false - ErrorAction Stop
2522 $params = @ {
26- Module = (Get-Module $env: BHProjectName )
23+ Module = (Get-Module $env: BHProjectName )
2724 CommandType = [System.Management.Automation.CommandTypes []]' Cmdlet, Function' # Not alias
2825 }
2926 if ($PSVersionTable.PSVersion.Major -lt 6 ) {
@@ -39,22 +36,22 @@ Describe "Test help for <_.Name>" -ForEach $commands {
3936
4037 BeforeDiscovery {
4138 # Get command help, parameters, and links
42- $command = $_
43- $commandHelp = Get-Help $command.Name - ErrorAction SilentlyContinue
44- $commandParameters = global:FilterOutCommonParams - Params $command.ParameterSets.Parameters
39+ $command = $_
40+ $commandHelp = Get-Help $command.Name - ErrorAction SilentlyContinue
41+ $commandParameters = global:FilterOutCommonParams - Params $command.ParameterSets.Parameters
4542 $commandParameterNames = $commandParameters.Name
46- $helpLinks = $commandHelp.relatedLinks.navigationLink.uri
43+ $helpLinks = $commandHelp.relatedLinks.navigationLink.uri
4744 }
4845
4946 BeforeAll {
5047 # These vars are needed in both discovery and test phases so we need to duplicate them here
51- $command = $_
52- $commandName = $_.Name
53- $commandHelp = Get-Help $command.Name - ErrorAction SilentlyContinue
54- $commandParameters = global:FilterOutCommonParams - Params $command.ParameterSets.Parameters
55- $commandParameterNames = $commandParameters.Name
56- $helpParameters = global:FilterOutCommonParams - Params $commandHelp.Parameters.Parameter
57- $helpParameterNames = $helpParameters.Name
48+ $command = $_
49+ $commandName = $_.Name
50+ $commandHelp = Get-Help $command.Name - ErrorAction SilentlyContinue
51+ $commandParameters = global:FilterOutCommonParams - Params $command.ParameterSets.Parameters
52+ $commandParameterNames = $commandParameters.Name
53+ $helpParameters = global:FilterOutCommonParams - Params $commandHelp.Parameters.Parameter
54+ $helpParameterNames = $helpParameters.Name
5855 }
5956
6057 # If help is not found, synopsis in auto-generated help is the syntax diagram
@@ -81,12 +78,12 @@ Describe "Test help for <_.Name>" -ForEach $commands {
8178 (Invoke-WebRequest - Uri $_ - UseBasicParsing).StatusCode | Should - Be ' 200'
8279 }
8380
84- Context " Parameter <_.Name>" - Foreach $commandParameters {
81+ Context " Parameter <_.Name>" - ForEach $commandParameters {
8582
8683 BeforeAll {
87- $parameter = $_
88- $parameterName = $parameter.Name
89- $parameterHelp = $commandHelp.parameters.parameter | Where-Object Name -eq $parameterName
84+ $parameter = $_
85+ $parameterName = $parameter.Name
86+ $parameterHelp = $commandHelp.parameters.parameter | Where-Object Name -EQ $parameterName
9087 $parameterHelpType = if ($parameterHelp.ParameterValue ) { $parameterHelp.ParameterValue.Trim () }
9188 }
9289
@@ -107,7 +104,7 @@ Describe "Test help for <_.Name>" -ForEach $commands {
107104 }
108105 }
109106
110- Context " Test <_> help parameter help for <commandName>" - Foreach $helpParameterNames {
107+ Context " Test <_> help parameter help for <commandName>" - ForEach $helpParameterNames {
111108
112109 # Shouldn't find extra parameters in help.
113110 It " finds help parameter in code: <_>" {
0 commit comments