PropertyExpression is a new parameter on Get-PoshspecParam that allows for evaluating an expression that may include method calls and filtering.
Example:
Describe Website {
WebSite 'Default Web Site' 'Bindings.Where({$_.Protocol -match "https"}).Count' { Should be '1' }
}
To implement, add a similar statement to the resource in quesetion:
This calls Get-PoshspecParam passing in the Property variable via the -PropertyExpression parameter. Get-PoshspecParam then calls a new function named Invoke-PoshspecExpression
that combines the TestExpression with the Property expression. Below shows an example of those two values would be and how then would get joined:
$TestExpression = { Get-IISSIte -SiteName "Default Web Site"}
$PropertyExpression = 'Bindings.Where({$_.Protocol -match "https"}).Count'
(Get-IISSIte -SiteName "Default Web Site").Bindings.Where({$_.Protocol -match "https"}).Count
Note: If you are defining the Poshspec test and using double quotes, make sure to escape the $ properly, or just use single quotes. Otherwise there will be problems with interpolation.
PropertyExpression
PropertyExpression is a new parameter on Get-PoshspecParam that allows for evaluating an expression that may include method calls and filtering. Example:
To implement, add a similar statement to the resource in quesetion:
This calls Get-PoshspecParam passing in the Property variable via the -PropertyExpression parameter. Get-PoshspecParam then calls a new function named Invoke-PoshspecExpression that combines the TestExpression with the Property expression. Below shows an example of those two values would be and how then would get joined:
Note: If you are defining the Poshspec test and using double quotes, make sure to escape the $ properly, or just use single quotes. Otherwise there will be problems with interpolation.