From 8fd708ae585f993f399bf540f653f22d8cd6c604 Mon Sep 17 00:00:00 2001 From: Frode Flaten <3436158+fflaten@users.noreply.github.com> Date: Fri, 17 May 2024 22:22:08 +0200 Subject: [PATCH] Remove Should legacy syntax error (#2445) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use new certificate thumbprint * Remove Should legacy syntax warning --------- Co-authored-by: Jakub Jareš --- src/functions/assertions/Should.ps1 | 15 +-------------- tst/Pester.RSpec.ts.ps1 | 18 ------------------ 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/src/functions/assertions/Should.ps1 b/src/functions/assertions/Should.ps1 index 428f44bdb..83dcdfec2 100644 --- a/src/functions/assertions/Should.ps1 +++ b/src/functions/assertions/Should.ps1 @@ -99,20 +99,7 @@ function Should { ) dynamicparam { - # Figuring out if we are using the old syntax is 'easy' - # we can use $myInvocation.Line to get the surrounding context - $myLine = if ($null -ne $MyInvocation -and 0 -le ($MyInvocation.OffsetInLine - 1)) { - $MyInvocation.Line.Substring($MyInvocation.OffsetInLine - 1) - } - - # A bit of Regex lets us know if the line used the old form - if ($myLine -match '^\s{0,}should\s{1,}(?[^\-\@\s]+)') { - $shouldErrorMsg = "Legacy Should syntax (without dashes) is not supported in Pester 5. Please refer to migration guide at: https://pester.dev/docs/migrations/v3-to-v4" - throw $shouldErrorMsg - } - else { - Get-AssertionDynamicParams - } + Get-AssertionDynamicParams } begin { diff --git a/tst/Pester.RSpec.ts.ps1 b/tst/Pester.RSpec.ts.ps1 index cbb62d8ef..29bfde9d5 100644 --- a/tst/Pester.RSpec.ts.ps1 +++ b/tst/Pester.RSpec.ts.ps1 @@ -1990,24 +1990,6 @@ i -PassThru:$PassThru { } } - b "Should with legacy syntax will throw" { - t "Should with legacy syntax will throw" { - $sb = { - Describe "d" { - It "i" { - 1 | Should Be 1 - } - } - } - - $container = New-PesterContainer -ScriptBlock $sb - $r = Invoke-Pester -Container $container -PassThru - $test = $r.Containers[0].Blocks[0].Tests[0] - $test.Result | Verify-Equal "Failed" - $test.ErrorRecord[0] -like "*Legacy Should syntax (without dashes) is not supported in Pester 5.*" - } - } - b "Running Pester in Pester" { t "Invoke-Pester can run in Invoke-Pester" { $container = New-PesterContainer -ScriptBlock {