22 [version ]$Version
33)
44
5-
6- BeforeDiscovery {
7- $CommandNames = @ (
8- ' Get-ScriptPath' ,
9- ' Get-ProjectRoot' ,
10- ' Test-SemanticVersionUpdate'
11- ) | Sort-Object
12- $script :Commands = foreach ($command in $CommandNames ) { @ { Command = $command } }
13- $script :Stupid = @ ( @ {CommandNames = $CommandNames } )
14- }
15-
165BeforeAll {
176 Import-Module - Name PesterExtensions
187 $ModulePath = " $ ( Get-ScriptPath - Path $PSCommandPath - Extension Manifest) "
@@ -25,8 +14,6 @@ BeforeAll {
2514}
2615
2716Describe ' All the important fields are not empty' {
28- BeforeAll {
29- }
3017 It ' <property> should not be null' - TestCases @ (
3118 @ { Property = ' Path' }
3219 @ { Property = ' Description' }
@@ -55,18 +42,57 @@ Describe 'Validate the version' {
5542 }
5643}
5744
58- Describe ' Exported functions' {
59- Context ' stupid' - ForEach $stupid {
60- It ' Module manifest contains all the exported commands' {
61- $ModuleInfo.ExportedCommands.Keys | Sort-Object | Should - Be $CommandNames
45+ Describe ' Check functions' - ForEach @ (
46+ @ {
47+ CommandName = ' Get-ScriptPath' ;
48+ Verb = ' Get' ;
49+ Noun = ' ScriptPath' ;
50+ Parameters = @ (
51+ @ {Parameter = ' Path' ; Mandatory = $true }
52+ @ {Parameter = ' Extension' ; Mandatory = $false }
53+ @ {Parameter = ' SourceDirectory' ; Mandatory = $false }
54+ @ {Parameter = ' TestsDirectory' ; Mandatory = $false }
55+ )
56+ }
57+ @ {
58+ CommandName = ' Get-ProjectRoot' ;
59+ Verb = ' Get' ;
60+ Noun = ' ProjectRoot' ;
61+ Parameters = @ (
62+ @ {Parameter = ' Path' ; Mandatory = $true }
63+ @ {Parameter = ' ProjectsRoot' ; Mandatory = $false }
64+ @ {Parameter = ' Name' ; Mandatory = $false }
65+ @ {Parameter = ' Markers' ; Mandatory = $false }
66+ )
67+ }
68+ @ {
69+ CommandName = ' Test-SemanticVersionUpdate' ;
70+ Verb = ' Test' ;
71+ Noun = ' SemanticVersionUpdate' ;
72+ Parameters = @ (
73+ @ {Parameter = ' Current' ; Mandatory = $true }
74+ @ {Parameter = ' Next' ; Mandatory = $true }
75+ )
76+ }
77+ ) {
78+ BeforeAll {
79+ $script :Command = Get-Command $CommandName
80+ }
81+ It ' Module manifest contains <commandName>' {
82+ $ModuleInfo.ExportedCommands.Keys | Should - Contain $CommandName
83+ }
84+ It ' Imported Module contains <commandName>' {
85+ $ImportedModule.ExportedCommands.Keys | Should - Contain $CommandName
86+ }
87+ Describe ' <parameter>' - ForEach $Parameters {
88+ It ' <CommandName> contains <parameter>' {
89+ $command | Should - HaveParameter $parameter - Mandatory:$mandatory
6290 }
63- It ' Imported Module contains all the exported commands' {
64- $ImportedModule.ExportedCommands.Keys | Sort-Object | Should - Be $CommandNames
91+ It ' <parameter> should be documented' {
92+ $help = Get-Help $CommandName - Parameter $parameter
93+ $help.Description | Should -Not - BeNullOrEmpty - Because " $parameter should have description"
6594 }
6695 }
67- It ' <command> is exported' - TestCases $Commands {
68- Get-Command - Name $command - ErrorAction Ignore | Should -Not - Be $null - Because " $command function should be exporeted"
69- }
7096}
7197
7298AfterAll {
0 commit comments