From a8a8e2091c2fc26250e24c7c5e9bf0e368ebe651 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Fri, 7 Aug 2015 11:31:50 -0700 Subject: [PATCH] changed filtering test to be better --- src/pester-tests/Test-Format-List.Tests.ps1 | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/pester-tests/Test-Format-List.Tests.ps1 b/src/pester-tests/Test-Format-List.Tests.ps1 index 9f070082e2..4b9deeaf11 100644 --- a/src/pester-tests/Test-Format-List.Tests.ps1 +++ b/src/pester-tests/Test-Format-List.Tests.ps1 @@ -71,9 +71,20 @@ Describe "Test-Format-List" { $output = ( Get-Process | Format-List -Property Name | Out-String) - $output.Contains("CPU") | Should Be $false - $output.Contains("Id") | Should Be $false - $output.Contains("Handle") | Should Be $false + $output | Should Not Match "CPU" + $output | Should Not Match "Id" + $output | Should Not Match "Handle" + + # Testing each element of format-list, using a for-each loop since the Format-List is so opaque + (Get-Process | Format-List -Property CPU | Out-String) -Split "`n" | + Where-Object { + $_.trim() -ne "" + } | + + ForEach-Object{ + $_ | Should Match "CPU :" + } + } It "Should be able to take input without piping objects to it" {