Skip to content

Commit

Permalink
Fixed incorrect variable used for hooks with tags in Invoke-GherkinHo…
Browse files Browse the repository at this point in the history
…ok. (pester#1400)
  • Loading branch information
jtomkiew-mng authored and nohwnd committed Dec 24, 2019
1 parent 4dd21ea commit 6155fdd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Examples/Gherkin/HookTag.Steps.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
BeforeEachFeature -Tags FeatureHookTag {
# NOOP
}

BeforeEachFeature -Tags ScenarioHookTag {
# NOOP
}

Then "not much is going on" {
# NOOP
}
6 changes: 6 additions & 0 deletions Examples/Gherkin/HookTag.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@FeatureHookTag
Feature: A test feature that has a tag

@ScenarioHookTag
Scenario: A scenario that has another tag
Then not much is going on
22 changes: 22 additions & 0 deletions Functions/Gherkin.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -698,3 +698,25 @@ Describe "A generated NUnit report" -Tag Gherkin {
}

}

Describe "When hook has tags no errors should be thrown" -Tag Gherkin {
# Calling this in a job so we don't monkey with the active pester state that's already running
$job = Start-Job -ArgumentList $scriptRoot -ScriptBlock {
param ($scriptRoot)
Get-Module Pester | Remove-Module -Force
Import-Module $scriptRoot\Pester.psd1 -Force

New-Object psobject -Property @{
Results = Invoke-Gherkin (Join-Path $scriptRoot Examples\Gherkin\HookTag.feature) -PassThru -Show None -ErrorAction Stop
}
}

$gherkin = $job | Wait-Job | Receive-Job
Remove-Job $job

It 'Should have results' {
$gherkin | Should -Not -BeNullOrEmpty -Because "test were run with ErrorAction = Stop and no errors should be thrown"
$gherkin.Results | Should -Not -BeNullOrEmpty -Because "test were run with ErrorAction = Stop and no errors should be thrown"
}

}
2 changes: 1 addition & 1 deletion Functions/Gherkin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Invoke-GherkinHook {
:tags foreach ($hookTag in $GherkinHook.Tags) {
foreach ($testTag in $Tags) {
if ($testTag -match "^($hookTag)$") {
& $hook.Script $Name
& $GherkinHook.Script $Name
break :tags
}
}
Expand Down

0 comments on commit 6155fdd

Please sign in to comment.