summaryrefslogtreecommitdiff
path: root/spec/unit/mixin/powershell_out_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/mixin/powershell_out_spec.rb')
-rw-r--r--spec/unit/mixin/powershell_out_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/unit/mixin/powershell_out_spec.rb b/spec/unit/mixin/powershell_out_spec.rb
index 7306332057..14a9483758 100644
--- a/spec/unit/mixin/powershell_out_spec.rb
+++ b/spec/unit/mixin/powershell_out_spec.rb
@@ -44,6 +44,20 @@ describe Chef::Mixin::PowershellOut, :windows_only do
expect(object.powershell_out("Get-Process", timeout: 600)).to eql(ret)
end
+ it "uses pwsh.exe when given :pwsh interpreter" do
+ ret = double("Mixlib::ShellOut")
+ expect(object).to receive(:shell_out).with(
+ "pwsh.exe #{flags} -Command \"Get-Process\"",
+ timeout: 600
+ ).and_return(ret)
+ expect(object.powershell_out("Get-Process", :pwsh, timeout: 600)).to eql(ret)
+ end
+
+ it "raises error if interpreter is invalid" do
+ ret = double("Mixlib::ShellOut")
+ expect { object.powershell_out("Get-Process", :blah, timeout: 600) }.to raise_error(ArgumentError)
+ end
+
context "when double quote is passed in the powershell command" do
it "passes if double quote is appended with single escape" do
result = object.powershell_out("Write-Verbose \"Some String\" -Verbose")