From ad890ea5a9a0380f413050e8a3d35fd21e928158 Mon Sep 17 00:00:00 2001 From: Dave Wyatt Date: Mon, 28 Jul 2014 10:22:33 -0400 Subject: [PATCH] Assert-MockCalled fix The value of the ModuleName parameter in Assert-MockCalled now defaults to Pester's current session state. Normally, this won't change its behavior, but inside an InModuleScope block, you no longer need to explicitly specify -ModuleName when calling Assert-MockCalled for mocks in the same module. (This brings Assert-MockCalled functionality back in line with the Mock command, which also doesn't require you to specify -ModuleName inside an InModuleScope block.) --- Functions/Mock.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Functions/Mock.ps1 b/Functions/Mock.ps1 index 08db60567..423d6a47a 100644 --- a/Functions/Mock.ps1 +++ b/Functions/Mock.ps1 @@ -454,6 +454,11 @@ param( [ValidateSet('Describe','Context','It')] [string] $Scope ) + if (-not $PSBoundParameters.ContainsKey('ModuleName') -and $null -ne $pester.SessionState.Module) + { + $ModuleName = $pester.SessionState.Module.Name + } + $mock = $script:mockTable["$ModuleName||$commandName"] $moduleMessage = ''