Permalink
Browse files

fixes failure line numbers from should assertions on PS 2

  • Loading branch information...
1 parent dbbc551 commit fdc9829d2241255756af4fbdb1d9020e76184181 @mwrock mwrock committed Apr 3, 2013
Showing with 5 additions and 3 deletions.
  1. +1 −0 Functions/Assertions/Should.ps1
  2. +1 −1 Functions/It.Tests.ps1
  3. +3 −2 Functions/It.ps1
@@ -44,6 +44,7 @@ function Should {
$testFailed = Get-TestResult $parsedArgs $value
if ($testFailed) {
+ $pester.ShouldExceptionLine = $MyInvocation.ScriptLineNumber
throw (Get-FailureMessage $parsedArgs $value)
}
}
View
@@ -23,7 +23,7 @@ Describe "It" {
It "does not pollute the global namespace" {
$extra_keys = List-ExtraKeys $pester.starting_variables $(Get-VariableAsHash)
$expected_keys = "here", "name", "test", "Matches", "fixture", "script", "_", "psitem"
- $extra_keys | ? { !($expected_keys -contains $_) } | Should Be 0
+ $extra_keys | ? { !($expected_keys -contains $_) } | Should BeNullOrEmpty
}
}
View
@@ -121,8 +121,9 @@ function Get-PesterResult{
if(!$exception){$testResult.success = $true}
else {
$testResult.failureMessage = $Exception.toString() -replace "Exception calling", "Assert failed on"
- if($Exception.ScriptStackTrace -match "\\pester\\temp.ps1: line (?<line>[\d]+)") {
- $line=$matches['line']
+ if($pester.ShouldExceptionLine) {
+ $line=$pester.ShouldExceptionLine
+ $pester.ShouldExceptionLine=$null
}
else {
$line=$exception.InvocationInfo.ScriptLineNumber

0 comments on commit fdc9829

Please sign in to comment.