2015-11-19 07:21:47 +01:00
|
|
|
Describe "Invoke-Expression" {
|
2016-03-04 23:52:27 +01:00
|
|
|
|
2015-11-19 07:21:47 +01:00
|
|
|
Context "Should execute the invoked command validly" {
|
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should return the echoed text" {
|
|
|
|
(Invoke-Expression -command "echo pestertest1") | Should be "pestertest1"
|
|
|
|
}
|
2015-11-19 07:21:47 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should return the echoed text for the alias" {
|
|
|
|
(iex -command "echo pestertest2") | Should Be "pestertest2"
|
|
|
|
}
|
2015-11-19 07:21:47 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should return the echoed text from a script" {
|
|
|
|
$testfile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath echoscript.ps1
|
|
|
|
$testcommand = "echo pestertestscript"
|
|
|
|
$testcommand | Add-Content -Path $testfile
|
|
|
|
(Invoke-Expression $testfile) | Should Be "pestertestscript"
|
|
|
|
Remove-Item $testfile
|
|
|
|
}
|
2015-11-19 07:21:47 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should return the echoed text from a script from the alias" {
|
|
|
|
$testfile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath echoscript.ps1
|
|
|
|
$testcommand = "echo pestertestscript"
|
|
|
|
$testcommand | Add-Content -Path $testfile
|
|
|
|
(iex $testfile) | Should Be "pestertestscript"
|
|
|
|
Remove-Item $testfile
|
|
|
|
}
|
2015-11-19 07:21:47 +01:00
|
|
|
}
|
|
|
|
}
|