Skip to content

Commit

Permalink
Bump 4.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd committed May 1, 2019
1 parent 4456afe commit 106d157
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 21 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 4.8.0 (May 1, 2019)

- Add parameter to remove validation when mocking [#1278](https://github.com/pester/Pester/pull/1278)
- Add built-in readonly variables to conflicting params list [#1298](https://github.com/pester/Pester/pull/1298)
- Fix using function definition as mock paramfilter [#1293](https://github.com/pester/Pester/pull/1293)
- Fix temp path on macOS [#1294](https://github.com/pester/Pester/pull/1294)
- Fix filtering out error lines [#1253](https://github.com/pester/Pester/pull/1253)
- Fix mock teardown when mock is outside of Describe [#1255](https://github.com/pester/Pester/pull/1255)
- Remove arrow from string comparison [#1264](https://github.com/pester/Pester/pull/1264)

## 4.7.3 (March 23,2019)

- Add shorter output when comparing long strings [#1248](https://github.com/pester/Pester/pull/1248)
Expand Down
57 changes: 39 additions & 18 deletions Functions/Mock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ is to be mocked. This should be a module that _calls_ the mocked
command; it doesn't necessarily have to be the same module which
originally implemented the command.
.PARAMETER RemoveParameterType
Optional parameter that removes a type of a parameter in the fuction
declaration. This is useful when you are testing a function that has a
strongly typed parameter but you are not able to create an object of the
required type.
This parameter applies only to the first definintion of a mock within the
current scope. If there are multiple mocks with the same name, any subsequent
configuration of parameters will be ingored, including parameter validation
described below.
.PARAMETER RemoveParameterValidation
Optional parameter that removes validation from a parameter in the fuction
declaration. This is useful when you are testing a function that validates
it's input, but you are unable to satisfy the validation.
This parameter applies only to the first definintion of a mock within the
current scope. If there are multiple mocks with the same name, any subsequent
configuration of parameters will be ingored, including parameter types described
above.
.EXAMPLE
Mock Get-ChildItem { return @{FullName = "A_File.TXT"} }
Expand Down Expand Up @@ -157,9 +178,9 @@ about_Mocking
[CmdletBinding()]
param(
[string]$CommandName,
[ScriptBlock]$MockWith = {},
[ScriptBlock]$MockWith = { },
[switch]$Verifiable,
[ScriptBlock]$ParameterFilter = {$True},
[ScriptBlock]$ParameterFilter = { $True },
[string]$ModuleName,
[string[]]$RemoveParameterType,
[string[]]$RemoveParameterValidation
Expand Down Expand Up @@ -222,7 +243,7 @@ about_Mocking
# Some versions of PowerShell may include dynamic parameters here
# We will filter them out and add them at the end to be
# compatible with both earlier and later versions
$dynamicParams = $metadata.Parameters.Values | & $SafeCommands['Where-Object'] {$_.IsDynamic}
$dynamicParams = $metadata.Parameters.Values | & $SafeCommands['Where-Object'] { $_.IsDynamic }
if ($null -ne $dynamicParams) {
$dynamicparams | & $SafeCommands['ForEach-Object'] { $null = $metadata.Parameters.Remove($_.name) }
}
Expand Down Expand Up @@ -399,13 +420,13 @@ This will not throw an exception because the mock was invoked.
[CmdletBinding()]param()
Assert-DescribeInProgress -CommandName Assert-VerifiableMock

$unVerified = @{}
$unVerified = @{ }
$mockTable.Keys | & $SafeCommands['ForEach-Object'] {
$m = $_;

$mockTable[$m].blocks |
& $SafeCommands['Where-Object'] { $_.Verifiable } |
& $SafeCommands['ForEach-Object'] { $unVerified[$m] = $_ }
& $SafeCommands['Where-Object'] { $_.Verifiable } |
& $SafeCommands['ForEach-Object'] { $unVerified[$m] = $_ }
}
if ($unVerified.Count -gt 0) {
foreach ($mock in $unVerified.Keys) {
Expand Down Expand Up @@ -571,7 +592,7 @@ to the original.
[int]$Times = 1,

[Parameter(ParameterSetName = 'ParameterFilter', Position = 2)]
[ScriptBlock]$ParameterFilter = {$True},
[ScriptBlock]$ParameterFilter = { $True },

[Parameter(ParameterSetName = 'ExclusiveFilter', Mandatory = $true)]
[scriptblock] $ExclusiveFilter,
Expand Down Expand Up @@ -856,7 +877,7 @@ function Validate-Command([string]$CommandName, [string]$ModuleName) {
$session = Set-SessionStateHint -PassThru -Hint "Module - $($module.Name)" -SessionState ( & $module { $ExecutionContext.SessionState } )
}

$hash = @{Command = $command; Session = $session}
$hash = @{Command = $command; Session = $session }

if ($command.CommandType -eq 'Function') {
foreach ($mock in $mockTable.Values) {
Expand Down Expand Up @@ -922,7 +943,7 @@ function Invoke-Mock {
$ModuleName,

[hashtable]
$BoundParameters = @{},
$BoundParameters = @{ },

[object[]]
$ArgumentList = @(),
Expand Down Expand Up @@ -1054,7 +1075,7 @@ function FindMock {
function FindMatchingBlock {
param (
[object] $Mock,
[hashtable] $BoundParameters = @{},
[hashtable] $BoundParameters = @{ },
[object[]] $ArgumentList = @()
)

Expand Down Expand Up @@ -1082,7 +1103,7 @@ function ExecuteBlock {
[object] $Mock,
[string] $CommandName,
[string] $ModuleName,
[hashtable] $BoundParameters = @{},
[hashtable] $BoundParameters = @{ },
[object[]] $ArgumentList = @()
)

Expand All @@ -1103,7 +1124,7 @@ function ExecuteBlock {
${Script Block},

[hashtable]
$___BoundParameters___ = @{},
$___BoundParameters___ = @{ },

[object[]]
$___ArgumentList___ = @(),
Expand Down Expand Up @@ -1197,7 +1218,7 @@ function Test-ParameterFilter {
)

if ($null -eq $BoundParameters) {
$BoundParameters = @{}
$BoundParameters = @{ }
}
if ($null -eq $ArgumentList) {
$ArgumentList = @()
Expand Down Expand Up @@ -1289,7 +1310,7 @@ function Set-DynamicParameterVariable {
)

if ($null -eq $Parameters) {
$Parameters = @{}
$Parameters = @{ }
}

foreach ($keyValuePair in $Parameters.GetEnumerator()) {
Expand Down Expand Up @@ -1324,8 +1345,8 @@ function Get-DynamicParamBlock {
If ( $ScriptBlock.AST.psobject.Properties.Name -match "Body") {
if ($null -ne $ScriptBlock.Ast.Body.DynamicParamBlock) {
$statements = $ScriptBlock.Ast.Body.DynamicParamBlock.Statements |
& $SafeCommands['Select-Object'] -ExpandProperty Extent |
& $SafeCommands['Select-Object'] -ExpandProperty Text
& $SafeCommands['Select-Object'] -ExpandProperty Extent |
& $SafeCommands['Select-Object'] -ExpandProperty Text

return $statements -join "$([System.Environment]::NewLine)"
}
Expand Down Expand Up @@ -1429,7 +1450,7 @@ function Get-DynamicParametersForCmdlet {
}
else {
if ($null -eq $Parameters) {
$Parameters = @{}
$Parameters = @{ }
}

$cmdlet = & $SafeCommands['New-Object'] $command.ImplementingType.FullName
Expand Down Expand Up @@ -1697,7 +1718,7 @@ function New-BlockWithoutParameterAliases {
$params = $Metadata.Parameters.Values
$ast = Get-ScriptBlockAST $Block
$blockText = $ast.Extent.Text
$variables = [array]($Ast.FindAll( { param($ast) $ast -is [System.Management.Automation.Language.VariableExpressionAst]}, $true))
$variables = [array]($Ast.FindAll( { param($ast) $ast -is [System.Management.Automation.Language.VariableExpressionAst] }, $true))
[array]::Reverse($variables)

foreach ($var in $variables) {
Expand Down
6 changes: 3 additions & 3 deletions Pester.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ModuleToProcess = 'Pester.psm1'

# Version number of this module.
ModuleVersion = '4.7.3'
ModuleVersion = '4.8.0'

# ID used to uniquely identify this module
GUID = 'a699dea5-2c73-4616-a270-1f7abb777e71'
Expand Down Expand Up @@ -68,7 +68,7 @@
)

# # Cmdlets to export from this module
CmdletsToExport = ''
CmdletsToExport = ''

# Variables to export from this module
VariablesToExport = @(
Expand Down Expand Up @@ -127,7 +127,7 @@
LicenseUri = "https://www.apache.org/licenses/LICENSE-2.0.html"

# Release notes for this particular version of the module
ReleaseNotes = 'https://github.com/pester/Pester/releases/tag/4.7.3'
ReleaseNotes = 'https://github.com/pester/Pester/releases/tag/4.8.0'

# Prerelease string of this module
Prerelease = ''
Expand Down

0 comments on commit 106d157

Please sign in to comment.