@@ -29,7 +29,8 @@ BeforeDiscovery {
29
29
30
30
Describe " Function: <_.BaseName>" - ForEach $PublicFunctions {
31
31
BeforeDiscovery {
32
- $Parameters = ((Get-Command $_.BaseName - ErrorAction SilentlyContinue).Parameters).Keys
32
+ $Command = Get-Command $_.BaseName - ErrorAction SilentlyContinue
33
+ $Parameters = $Command.Parameters.Keys
33
34
| Where-Object {
34
35
$_ -notin ([System.Management.Automation.PSCmdlet ]::CommonParameters) -and
35
36
$_ -notin ([System.Management.Automation.PSCmdlet ]::OptionalCommonParameters)
@@ -50,8 +51,8 @@ Describe "Function: <_.BaseName>" -ForEach $PublicFunctions {
50
51
}
51
52
}
52
53
53
- It " Should register command with Get-Command" {
54
- ( Get-Command $CurrentFunction .BaseName ) | Should - BeOfType [System.Management.Automation.CommandInfo ]
54
+ It " Should register command with Get-Command" - ForEach @ { Command = $Command } {
55
+ $Command | Should - BeOfType [System.Management.Automation.CommandInfo ]
55
56
}
56
57
It " Should have comment-based help block" {
57
58
$CurrentFunction.FullName | Should - FileContentMatch ' <#'
@@ -69,10 +70,8 @@ Describe "Function: <_.BaseName>" -ForEach $PublicFunctions {
69
70
It " Should have NOTES section in help" {
70
71
$CurrentFunction.FullName | Should - FileContentMatch ' .NOTES'
71
72
}
72
- It " Should be an advanced function" {
73
- $CurrentFunction.FullName | Should - FileContentMatch ' function'
74
- $CurrentFunction.FullName | Should - FileContentMatch ' cmdletbinding'
75
- $CurrentFunction.FullName | Should - FileContentMatch ' param'
73
+ It ' Should be an advanced function' - Skip:($Command.CommandType -ne ' Function' -or $Command.Name -in ' grep' ) - ForEach @ { Command = $Command } {
74
+ $Command.CmdletBinding | Should - BeTrue
76
75
}
77
76
It " Should have Begin and End Regions" {
78
77
$CurrentFunction.FullName | Should - FileContentMatch " #Region"
0 commit comments