Skip to content

Commit

Permalink
Remove pipeline support from Should -Invoke (pester#1698)
Browse files Browse the repository at this point in the history
* Removed pipeline support for Should -Invoke
  • Loading branch information
fflaten authored Sep 30, 2020
1 parent 4c0f523 commit 5a7d93e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/functions/Pester.SessionState.Mock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -856,12 +856,7 @@ to the original.
)

if ($null -ne $ActualValue) {
if ($ActualValue -is [string]) {
$CommandName = $ActualValue
}
else {
throw "Should -Invoke does not take pipeline input or ActualValue."
}
throw "Should -Invoke does not take pipeline input or ActualValue."
}

# Assert-DescribeInProgress -CommandName Should -Invoke
Expand Down
12 changes: 12 additions & 0 deletions tst/functions/Mock.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,18 @@ Describe "When Calling Should -Not -Invoke -ExclusiveFilter" {
}
}

Describe "When Calling Should -Invoke with pipeline-input or -ActualValue" {
It "Should throw an error on pipeline-input" {
$scriptBlock = { "value" | Should -Invoke -CommandName "ABC" -Scope Describe }
$scriptBlock | Should -Throw 'Should -Invoke does not take pipeline input or ActualValue.'
}

It "Should throw an error on ActualInput-value" {
$scriptBlock = { Should -Invoke -CommandName "ABC" -ActualValue "value" -Scope Describe }
$scriptBlock | Should -Throw 'Should -Invoke does not take pipeline input or ActualValue.'
}
}

Describe "Using Pester Scopes (Describe,Context,It)" {
BeforeAll {
Mock FunctionUnderTest {return "I am the first mock test"} -parameterFilter {$param1 -eq "one"}
Expand Down

0 comments on commit 5a7d93e

Please sign in to comment.