Public/New-PsScript.tests.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' . "$here\$sut" . "$here\Get-PsModuleBuilderPath.ps1" Describe New-PsScript { $testPath = "TestDrive:" $testScriptName = "ScriptName" $scriptsPath = Get-PsModuleBuilderPath Context "When no path is provided..." { New-PsScript $testScriptName It "should create a new script file in the current directory..." { Test-Path "$here\$testScriptName.ps1" -PathType Leaf | Should -Be $true } } Context "When path is provided..." { New-PsScript $testScriptName "$testPath\" It "should create a new script file at the given path..." { Test-Path "$testPath\$testScriptName.ps1" -PathType Leaf | Should -Be $true } } Context "When path is provided is invalid..." { It "should throw an error about the invalid path..." { {New-PsScript $testScriptName "$testPath\not a real path"} | Should -Throw } } } |