Skip to content

Instantly share code, notes, and snippets.

@nohwnd
Created December 12, 2018 15:54
Show Gist options
  • Save nohwnd/3ab59610d328efe4f862fb0951f70fe0 to your computer and use it in GitHub Desktop.
Save nohwnd/3ab59610d328efe4f862fb0951f70fe0 to your computer and use it in GitHub Desktop.
Shared state between DSL keywords in Pester
# in module scope
$script:pester
function describe () {
$script:pester.EnterBlock("describe")
}
function it () {
if ($script:pester.Block -ne "Describe") {
throw "it can only be in describe"
}
$script:pester.EnterBlock("it")
}
function should () {
if ($script:pester.Block -ne "It") {
throw "should can only be in it"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment