Created
September 8, 2019 08:11
-
-
Save nohwnd/58ff2f1b5864567290de052adabe0778 to your computer and use it in GitHub Desktop.
Using ModuleName to test public surface of a module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Module Pester, m | Remove-Module | |
Import-Module Pester -MaximumVersion 4.9.9 | |
New-Module -Name m -ScriptBlock { | |
function a { "hello" } | |
function b { a } | |
Export-ModuleMember -Function b | |
} | Import-Module | |
Describe "m" { | |
It "can't see 'a'" { | |
{ a } | Should -Throw | |
} | |
It "but it can mock 'a'" { | |
Mock a -ModuleName m { "fuuuu" } | |
b | Should -Be "fuuuu" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment