|
1 | 1 | BeforeDiscovery { |
2 | | - if ($null -eq $env:BHProjectPath) { |
3 | | - $path = Join-Path -Path $PSScriptRoot -ChildPath '..\build.ps1' |
4 | | - . $path -Task Build |
5 | | - } |
6 | | - $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest |
7 | | - $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' |
8 | | - $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName |
9 | | - $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion |
10 | | - $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" |
11 | | - Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore |
12 | | - Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop |
| 2 | + if ($null -eq $env:BHProjectPath) { |
| 3 | + $path = Join-Path -Path $PSScriptRoot -ChildPath '..\build.ps1' |
| 4 | + . $path -Task Build |
| 5 | + } |
| 6 | + $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest |
| 7 | + $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' |
| 8 | + $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName |
| 9 | + $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion |
| 10 | + $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" |
| 11 | + Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore |
| 12 | + Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop |
13 | 13 | } |
14 | 14 | Describe 'Initialize-PredefinedVariables' { |
15 | | - InModuleScope $env:BHProjectName { |
16 | | - BeforeDiscovery { |
17 | | - $script:variables = @( |
18 | | - 'PLASTER_TemplatePath', |
19 | | - 'PLASTER_DestinationPath', |
20 | | - 'PLASTER_DestinationName', |
21 | | - 'PLASTER_DirSepChar', |
22 | | - 'PLASTER_HostName', |
23 | | - 'PLASTER_Version', |
24 | | - 'PLASTER_Guid1', |
25 | | - 'PLASTER_Guid2', |
26 | | - 'PLASTER_Guid3', |
27 | | - 'PLASTER_Guid4', |
28 | | - 'PLASTER_Guid5', |
29 | | - 'PLASTER_Date', |
30 | | - 'PLASTER_Time', |
31 | | - 'PLASTER_Year' |
32 | | - ) |
33 | | - foreach ($var in $script:variables) { |
34 | | - if (Get-Variable -Name $var -ErrorAction SilentlyContinue) { |
35 | | - Remove-Variable -Name $var -Scope Script |
| 15 | + InModuleScope $env:BHProjectName { |
| 16 | + BeforeDiscovery { |
| 17 | + $script:variables = @( |
| 18 | + 'PLASTER_TemplatePath', |
| 19 | + 'PLASTER_DestinationPath', |
| 20 | + 'PLASTER_DestinationName', |
| 21 | + 'PLASTER_DirSepChar', |
| 22 | + 'PLASTER_HostName', |
| 23 | + 'PLASTER_Version', |
| 24 | + 'PLASTER_Guid1', |
| 25 | + 'PLASTER_Guid2', |
| 26 | + 'PLASTER_Guid3', |
| 27 | + 'PLASTER_Guid4', |
| 28 | + 'PLASTER_Guid5', |
| 29 | + 'PLASTER_Date', |
| 30 | + 'PLASTER_Time', |
| 31 | + 'PLASTER_Year' |
| 32 | + ) |
| 33 | + foreach ($var in $script:variables) { |
| 34 | + if (Get-Variable -Name $var -ErrorAction SilentlyContinue) { |
| 35 | + Remove-Variable -Name $var -Scope Script |
| 36 | + } |
| 37 | + } |
| 38 | + } |
| 39 | + BeforeAll { |
| 40 | + $script:examplesPath = Resolve-Path "$env:BHProjectPath/examples/" |
| 41 | + $script:destPath = 'Test:\Destination' |
| 42 | + $script:output = Initialize-PredefinedVariables -TemplatePath $script:examplesPath -DestPath $script:destPath |
| 43 | + } |
| 44 | + It 'should not return any output' { |
| 45 | + $script:output | Should -BeNullOrEmpty |
36 | 46 | } |
37 | | - } |
38 | | - } |
39 | | - BeforeAll { |
40 | | - $script:examplesPath = Resolve-Path "$env:BHProjectPath/examples/" |
41 | | - $script:destPath = 'Test:\Destination' |
42 | | - $script:output = Initialize-PredefinedVariables -TemplatePath $script:examplesPath -DestPath $script:destPath |
43 | | - } |
44 | | - It 'should not return any output' { |
45 | | - $script:output | Should -BeNullOrEmpty |
46 | | - } |
47 | 47 |
|
48 | | - It "initializes predefined variable <_>" -ForEach $script:variables { |
49 | | - $varValue = Get-Variable -name $_ -Scope Script -ErrorAction SilentlyContinue |
50 | | - $varValue | Should -Not -BeNullOrEmpty |
51 | | - } |
| 48 | + It "initializes predefined variable <_>" -ForEach $script:variables { |
| 49 | + $varValue = Get-Variable -Name $_ -Scope Script -ErrorAction SilentlyContinue |
| 50 | + $varValue | Should -Not -BeNullOrEmpty |
| 51 | + } |
52 | 52 |
|
53 | | - It 'PLASTER_TemplatePath should match the provided template path' { |
54 | | - $expectedPath = $script:examplesPath.TrimEnd('\', '/') |
55 | | - $actualPath = (Get-Variable -Name 'PLASTER_TemplatePath' -Scope Script).Value |
56 | | - $actualPath | Should -Be $expectedPath |
57 | | - } |
| 53 | + It 'PLASTER_TemplatePath should match the provided template path' { |
| 54 | + $expectedPath = ($script:examplesPath).ToString().TrimEnd('\', '/') |
| 55 | + $actualPath = (Get-Variable -Name 'PLASTER_TemplatePath' -Scope Script).Value |
| 56 | + $actualPath | Should -Be $expectedPath |
| 57 | + } |
58 | 58 |
|
59 | | - It 'PLASTER_DestinationPath should match the provided destination path' { |
60 | | - $expectedPath = $script:destPath.TrimEnd('\', '/') |
61 | | - $actualPath = (Get-Variable -Name 'PLASTER_DestinationPath' -Scope Script).Value |
62 | | - $actualPath | Should -Be $expectedPath |
| 59 | + It 'PLASTER_DestinationPath should match the provided destination path' { |
| 60 | + $expectedPath = ($script:destPath).ToString().TrimEnd('\', '/') |
| 61 | + $actualPath = (Get-Variable -Name 'PLASTER_DestinationPath' -Scope Script).Value |
| 62 | + $actualPath | Should -Be $expectedPath |
| 63 | + } |
63 | 64 | } |
64 | | - } |
65 | 65 | } |
0 commit comments