Hi!
I came across some minor "bug" when using $pwd or $(pwd) directly as -Path argument:
New-Fixture -Path $pwd
New-Fixture -Path $(pwd)
[W0216 12:44:14 C:\Temp]> New-Fixture -path $Pwd -name "Out-Log"
Method invocation failed because [System.Management.Automation.PathInfo] doesn't contain a method named 'TrimStart'.
At C:\Users\michael.kargl\Documents\WindowsPowerShell\Modules\Pester\Pester.psm1:197 char:9
-
$path = $path.TrimStart(".")
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [System.Management.Automation.PathInfo] doesn't contain a method named 'TrimStart'.
At C:\Users\michael.kargl\Documents\WindowsPowerShell\Modules\Pester\Pester.psm1:198 char:9
-
$path = $path.TrimStart("\")
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [System.Management.Automation.PathInfo] doesn't contain a method named 'TrimStart'.
At C:\Users\michael.kargl\Documents\WindowsPowerShell\Modules\Pester\Pester.psm1:199 char:9
-
$path = $path.TrimStart("/")
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : MethodNotFound
New-Fixture -Path "$pwd"
works just fine.
The reason is because of powershell's dynamic typing:
$PWD stores the value of $(pwd) which is a System.Management.Automation.PathInfo Object.
Possible fix:
Changing the New-Fixture Param section to:
param(
[string] $path,
[string] $name
)
This way only strings would be allowed as path and fix the minor bug.
Hi!
I came across some minor "bug" when using$pwd or $ (pwd) directly as -Path argument:
New-Fixture -Path $pwd
New-Fixture -Path $(pwd)
[W0216 12:44:14 C:\Temp]> New-Fixture -path $Pwd -name "Out-Log"
Method invocation failed because [System.Management.Automation.PathInfo] doesn't contain a method named 'TrimStart'.
At C:\Users\michael.kargl\Documents\WindowsPowerShell\Modules\Pester\Pester.psm1:197 char:9
Method invocation failed because [System.Management.Automation.PathInfo] doesn't contain a method named 'TrimStart'.
At C:\Users\michael.kargl\Documents\WindowsPowerShell\Modules\Pester\Pester.psm1:198 char:9
Method invocation failed because [System.Management.Automation.PathInfo] doesn't contain a method named 'TrimStart'.
At C:\Users\michael.kargl\Documents\WindowsPowerShell\Modules\Pester\Pester.psm1:199 char:9
New-Fixture -Path "$pwd"
works just fine.
The reason is because of powershell's dynamic typing:
$PWD stores the value of $ (pwd) which is a System.Management.Automation.PathInfo Object.
Possible fix:
Changing the New-Fixture Param section to:
param(
[string] $path,
[string] $name
)
This way only strings would be allowed as path and fix the minor bug.