Skip to content

Instantly share code, notes, and snippets.

@shaneis
Created February 22, 2019 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaneis/cd3ed86cefc649fd2dbec0da512deb3f to your computer and use it in GitHub Desktop.
Save shaneis/cd3ed86cefc649fd2dbec0da512deb3f to your computer and use it in GitHub Desktop.
describe 'testing our function with scriptroot' {
# Get our self contained script info.
. .\Get-FunctionInfo.ps1
$fInfo = Get-FunctionInfo -Path .\Get-NameScriptBlock.ps1
# Create something we can dot-source.
$Fake = "function $($fInfo.Name) { $($fInfo.Definition) }"
$FakeFunc = [scriptblock]::Create($Fake)
. $FakeFunc
Context 'Results' {
It 'should have the expected default result' {
Get-Name | Should -Be 'Hello, you. Script root is C:\Users\shane.oneill\Git\Blog'
}
It 'should have the expected result for passed in values' {
Get-Name -Name 'Shane' | Should -Be 'Hello, Shane. Script root is C:\Users\shane.oneill\Git\Blog'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment