@@ -61,26 +61,28 @@ function Get-Enlightenment {
6161
6262 Write-MeditationPrompt - Greeting
6363
64+ $KoanScripts = $null
65+
6466 $SortedKoanList = Get-ChildItem " $env: PSKoans_Folder " - Recurse - Filter ' *.Koans.ps1' |
6567 Get-Command {$_.FullName } |
6668 Where-Object {$_.ScriptBlock.Attributes.TypeID -match ' KoanAttribute' } |
6769 Sort-Object {
68- $_.ScriptBlock.Attributes.Where ( {
69- $_.TypeID -match ' KoanAttribute'
70- }).Position
71- } | Select-Object - ExpandProperty Path
70+ $_.ScriptBlock.Attributes.Where ( {
71+ $_.TypeID -match ' KoanAttribute'
72+ }).Position
73+ }
7274
73- $PesterParams = @ {
74- Script = $SortedKoanList
75- PassThru = $true
76- Show = ' None '
77- }
78- $PesterTestCount = Invoke-Pester @PesterParams |
79- Select-Object - ExpandProperty TotalCount
75+ $TotalKoans = $SortedKoanList .ScriptBlock.Ast.FindAll (
76+ {
77+ param ( $Item )
78+ $Item -is [ System.Management.Automation.Language.CommandAst ] -and
79+ $Item .GetCommandName () -eq ' It '
80+ } , $true
81+ ).Count
8082
8183 $KoansPassed = 0
8284
83- foreach ($KoanFile in $SortedKoanList ) {
85+ foreach ($KoanFile in $SortedKoanList.Path ) {
8486 $PesterParams = @ {
8587 Script = $KoanFile
8688 PassThru = $true
@@ -105,7 +107,7 @@ function Get-Enlightenment {
105107 ItName = $NextKoanFailed.Name
106108 Meditation = $NextKoanFailed.StackTrace
107109 KoansPassed = $KoansPassed
108- TotalKoans = $PesterTestCount
110+ TotalKoans = $TotalKoans
109111 }
110112 Write-MeditationPrompt @Meditation
111113 }
0 commit comments