Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for mocking cmdlets with an -ArgumentList parameter #354

Merged
merged 3 commits into from May 18, 2015

Conversation

dlwyatt
Copy link
Member

@dlwyatt dlwyatt commented May 18, 2015

Fixes #353 . $ArgumentList variable in the MockPrototype code has been renamed to ${a r g s}, to avoid naming / validation conflicts.

Repro for pester#353 in PowerShell 2.0.  I wasn't able to reproduce this using a function for some reason, but mocking Start-Process does cause the error to occur.

Incidentally, it's being caused by this line in MockPrototype:

[object] $ArgumentList = Get-Variable -Name args -ValueOnly -Scope Local -ErrorAction $IgnoreErrorPreference

It appears to be a problem when the mocked command also has an -ArgumentList parameter, which contains Validation attributes such as ValidateNotNullOrEmpty() (though why I wasn't able to reproduce this with a mocked function instead of Start-Process, I don't know.)
$ArgumentList variable renamed to something that's extremely unlikely to conflict with an actual parameter name.
dlwyatt added a commit that referenced this pull request May 18, 2015
Fix for mocking cmdlets with an -ArgumentList parameter
@dlwyatt dlwyatt merged commit 1a1cef0 into pester:master May 18, 2015
@dlwyatt dlwyatt deleted the MockFix branch May 18, 2015 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strange error when running pester with a function that calls Start-Process
1 participant