1
1
$PSModuleAutoLoadingPreference = " None"
2
2
3
3
BeforeEachFeature {
4
- Remove-Module Configuration - ErrorAction Ignore - Force
5
- Import-Module Configuration - MinimumVersion 1.1
4
+ Remove-Module " Configuration" - ErrorAction Ignore - Force
5
+ Import-Module " Configuration" - MinimumVersion 1.1
6
6
}
7
7
AfterEachFeature {
8
- Remove-Module Configuration - ErrorAction Ignore - Force
9
- Import-Module Configuration - MinimumVersion 1.1
8
+ Remove-Module " Configuration" - ErrorAction Ignore - Force
9
+ Import-Module " Configuration" - MinimumVersion 1.1
10
10
}
11
11
12
12
Given ' the configuration module is imported with testing paths:' {
13
13
param ($Table )
14
- $ModuleBase = (Get-Module Configuration - ListAvailable | Sort-Object Version - Descending)[0 ].ModuleBase
15
- Remove-Module Configuration - ErrorAction Ignore - Force
16
- Import-Module $ModuleBase \ Configuration.psd1 - Args @ ($null , $Table.Enterprise , $Table.User , $Table.Machine ) - Scope Global
14
+ $ModuleBase = (Get-Module " Configuration" - ListAvailable | Sort-Object Version - Descending)[0 ].ModuleBase
15
+ Remove-Module " Configuration" - ErrorAction Ignore - Force
16
+ Import-Module $ModuleBase / Configuration.psd1 - Args @ ($null , $Table.Enterprise , $Table.User , $Table.Machine ) - Scope Global
17
17
}
18
18
19
19
Given ' the configuration module is imported with a URL converter' {
20
20
param ($Table )
21
21
$ModuleBase = " ."
22
- $ModuleBase = (Get-Module Configuration).ModuleBase
23
- Remove-Module Configuration - ErrorAction Ignore - Force
24
- Import-Module $ModuleBase \ Configuration.psd1 - Args @ {
22
+ $ModuleBase = (Get-Module " Configuration" ).ModuleBase
23
+ Remove-Module " Configuration" - ErrorAction Ignore - Force
24
+ Import-Module $ModuleBase / Configuration.psd1 - Args @ {
25
25
[Uri ] = { " Uri '$_ ' " }
26
26
" Uri" = {
27
27
param ([string ]$Value )
@@ -32,15 +32,15 @@ Given 'the configuration module is imported with a URL converter' {
32
32
33
33
Given ' the manifest module is imported' {
34
34
param ($Table )
35
- $ModuleBase = (Get-Module Configuration).ModuleBase
36
- Remove-Module Configuration, Manifest
37
- Import-Module $ModuleBase \ Manifest.psm1 - Scope Global
35
+ $ModuleBase = (Get-Module " Configuration" ).ModuleBase
36
+ Remove-Module " Configuration" , Manifest
37
+ Import-Module $ModuleBase / Manifest.psm1 - Scope Global
38
38
}
39
39
40
40
Given " a module with(?:\s+\w+ name '(?<name>.+?)'|\s+\w+ the company '(?<company>.+?)'|\s+\w+ the author '(?<author>.+?)')+" {
41
41
param ($name , $Company = " " , $Author = " " )
42
42
43
- $ModulePath = " TestDrive:\ Modules\ $name "
43
+ $ModulePath = " TestDrive:/ Modules/ $name "
44
44
Remove-Module $name - ErrorAction Ignore
45
45
Remove-Item $ModulePath - Recurse - ErrorAction Ignore
46
46
@@ -51,27 +51,27 @@ Given "a module with(?:\s+\w+ name '(?<name>.+?)'|\s+\w+ the company '(?<company
51
51
if (! (Test-Path $ModulePath - PathType Container)) {
52
52
$null = New-Item $ModulePath - Type Directory - Force
53
53
}
54
- $Env: PSModulePath = $Env: PSModulePath + " ;TestDrive:\ Modules" -replace " (;TestDrive:\\ Modules)+?$" , " ;TestDrive:\ Modules"
54
+ $Env: PSModulePath = $Env: PSModulePath + " ;TestDrive:/ Modules" -replace " (;TestDrive:/ Modules)+?$" , " ;TestDrive:/ Modules"
55
55
56
- Set-Content $ModulePath \ ${Name}.psm1 "
56
+ Set-Content $ModulePath / ${Name}.psm1 "
57
57
function GetStoragePath { Get-StoragePath @Args }
58
58
function ImportConfiguration { Import-Configuration }
59
59
function ImportConfigVersion { Import-Configuration -Version 2.0 }
60
60
filter ExportConfiguration { `$ _ | Export-Configuration }
61
61
filter ExportConfigVersion { `$ _ | Export-Configuration -Version 2.0 }
62
62
"
63
63
64
- New-ModuleManifest $ModulePath \ ${Name}.psd1 - RootModule .\ ${Name}.psm1 - Description " A Super Test Module" - Company $Company - Author $Author
64
+ New-ModuleManifest $ModulePath / ${Name}.psd1 - RootModule ./ ${Name}.psm1 - Description " A Super Test Module" - Company $Company - Author $Author
65
65
66
66
# New-ModuleManifest sets things even when we don't want it to:
67
67
if (! $Author ) {
68
- Set-Content $ModulePath \ ${Name}.psd1 ((Get-Content $ModulePath \ ${Name}.psd1 ) -Replace " ^(Author.*)$" , ' #$1' )
68
+ Set-Content $ModulePath / ${Name}.psd1 ((Get-Content $ModulePath / ${Name}.psd1 ) -Replace " ^(Author.*)$" , ' #$1' )
69
69
}
70
70
if (! $Company ) {
71
- Set-Content $ModulePath \ ${Name}.psd1 ((Get-Content $ModulePath \ ${Name}.psd1 ) -Replace " ^(Company.*)$" , ' #$1' )
71
+ Set-Content $ModulePath / ${Name}.psd1 ((Get-Content $ModulePath / ${Name}.psd1 ) -Replace " ^(Company.*)$" , ' #$1' )
72
72
}
73
73
74
- Import-Module $ModulePath \ ${Name}.psd1
74
+ Import-Module $ModulePath / ${Name}.psd1
75
75
}
76
76
77
77
When " the module's (\w+) path should (\w+) (.+)$" {
@@ -81,7 +81,18 @@ When "the module's (\w+) path should (\w+) (.+)$" {
81
81
82
82
$LocalStoragePath = GetStoragePath - Scope $Scope
83
83
foreach ($PathAssertion in $Path ) {
84
- $LocalStoragePath | Should $Comparator $PathAssertion
84
+ $LocalStoragePath -replace " \\" , " /" | Should $Comparator $PathAssertion
85
+ }
86
+ }
87
+
88
+ Then " the script's (\w+) path should (\w+) (.+)$" {
89
+ param ($Scope , $Comparator , $Path )
90
+
91
+ [string []]$Path = $Path -split " \s*and\s*" | % { $_.Trim (" ['`" ]" ) }
92
+
93
+ $LocalStoragePath = iex " TestDrive:/${ScriptName} .ps1"
94
+ foreach ($PathAssertion in $Path ) {
95
+ $LocalStoragePath -replace " \\" , " /" | Should $Comparator $PathAssertion
85
96
}
86
97
}
87
98
@@ -91,43 +102,31 @@ When "the resulting path should (\w+) (.+)$" {
91
102
[string []]$Path = $Path -split " \s*and\s*" | % { $_.Trim (" ['`" ]" ) }
92
103
93
104
foreach ($PathAssertion in $Path ) {
94
- $folder | Should $Comparator $PathAssertion
105
+ $folder -replace " \\ " , " / " | Should $Comparator $PathAssertion
95
106
}
96
107
}
97
108
98
109
Given " a script with the name '(.+)' that calls Get-StoragePath with no parameters" {
99
110
param ($name )
100
- Set-Content " TestDrive:\ ${name} .ps1" " Get-StoragePath"
111
+ Set-Content " TestDrive:/ ${name} .ps1" " Get-StoragePath"
101
112
$ScriptName = $Name
102
113
}
114
+
103
115
Given " a script with the name '(?<File>.+)' that calls Get-StoragePath (?:-Name (?<Name>\w*) ?|-Author (?<Author>\w*) ?){2}" {
104
116
param ($File , $Name , $Author )
105
- Set-Content " TestDrive:\ ${File} .ps1" " Get-StoragePath -Name $Name -Author $Author "
117
+ Set-Content " TestDrive:/ ${File} .ps1" " Get-StoragePath -Name $Name -Author $Author "
106
118
$ScriptName = $File
107
119
}
108
120
109
121
Then " the script should throw an exception$" {
110
- { $LocalStoragePath = iex " TestDrive:\${ScriptName} .ps1" } | Should throw
111
- }
112
-
113
-
114
- Then " the script's (\w+) path should (\w+) (.+)$" {
115
- param ($Scope , $Comparator , $Path )
116
-
117
- [string []]$Path = $Path -split " \s*and\s*" | % { $_.Trim (" ['`" ]" ) }
118
-
119
- $LocalStoragePath = iex " TestDrive:\${ScriptName} .ps1"
120
- foreach ($PathAssertion in $Path ) {
121
- $LocalStoragePath | Should $Comparator $PathAssertion
122
- }
122
+ { $LocalStoragePath = iex " TestDrive:/${ScriptName} .ps1" } | Should throw
123
123
}
124
124
125
125
When " the module's storage path should end with a version number if one is passed in" {
126
- GetStoragePath - Version " 2.0" | Should Match " \\ 2.0$"
127
- GetStoragePath - Version " 4.0" | Should Match " \\ 4.0$"
126
+ ( GetStoragePath - Version " 2.0" ) -replace " \\ " , " / " | Should Match " / 2.0$"
127
+ ( GetStoragePath - Version " 4.0" ) -replace " \\ " , " / " | Should Match " / 4.0$"
128
128
}
129
129
130
-
131
130
When " a settings hashtable" {
132
131
param ($hashtable )
133
132
$Settings = iex " [ordered]$hashtable "
@@ -156,7 +155,7 @@ When "a (?:settings file|module manifest) named (\S+)(?:(?: in the (?<Scope>\S+)
156
155
} elseif (Test-Path " $ModulePath " ) {
157
156
$folder = $ModulePath
158
157
} else {
159
- $folder = " TestDrive:\ "
158
+ $folder = " TestDrive:/ "
160
159
}
161
160
$SettingsFile = Join-Path $folder $fileName
162
161
@@ -269,7 +268,7 @@ When "we convert the settings to metadata" {
269
268
When " we export to a settings file named (.*)" {
270
269
param ($fileName )
271
270
if (! $ModulePath -or ! (Test-Path $ModulePath )) {
272
- $ModulePath = " TestDrive:\ "
271
+ $ModulePath = " TestDrive:/ "
273
272
}
274
273
$SettingsFile = Join-Path $ModulePath $fileName
275
274
$File = $Settings | Export-Metadata ${SettingsFile} - Passthru
@@ -331,7 +330,7 @@ When "the settings file should (\w+)\s*(.*)?" {
331
330
Given " the settings file does not exist" {
332
331
#
333
332
if (! $ModulePath -or ! (Test-Path $ModulePath )) {
334
- $ModulePath = " TestDrive:\ "
333
+ $ModulePath = " TestDrive:/ "
335
334
}
336
335
if (! ${SettingsFile} ) {
337
336
$SettingsFile = Join-Path $ModulePath " NoSuchFile.psd1"
@@ -556,7 +555,7 @@ Then "a settings file named (\S+) should exist(?:(?: in the (?<Scope>\S+) folder
556
555
} elseif (Test-Path " ${ModulePath} " ) {
557
556
$folder = $ModulePath
558
557
} else {
559
- $folder = " TestDrive:\ "
558
+ $folder = " TestDrive:/ "
560
559
}
561
560
$SettingsFile = Join-Path $folder $fileName
562
561
$SettingsFile | Should Exist
0 commit comments