summaryrefslogtreecommitdiff
path: root/spec/unit/provider
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-08-07 15:13:25 -0700
committerPete Higgins <pete@peterhiggins.org>2020-08-07 15:13:25 -0700
commit8efbd03022ac730d342e6ad6c6701d97a9f1728e (patch)
treed771148ed9935045c06477ad319fc3cd5bec90c7 /spec/unit/provider
parent43314d143c95c06b0fbff83ead0b15460d2d3058 (diff)
downloadchef-8efbd03022ac730d342e6ad6c6701d97a9f1728e.tar.gz
Add regression test for powershell_script flag order.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Diffstat (limited to 'spec/unit/provider')
-rw-r--r--spec/unit/provider/powershell_script_spec.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb
index e0857a1ea4..a0f31c10f7 100644
--- a/spec/unit/provider/powershell_script_spec.rb
+++ b/spec/unit/provider/powershell_script_spec.rb
@@ -30,14 +30,20 @@ describe Chef::Provider::PowershellScript, "action_run" do
Chef::Provider::PowershellScript.new(new_resource, run_context)
end
- context "when setting interpreter flags" do
+ describe "#command" do
before(:each) do
- allow(provider).to receive(:basepath).and_return("C:\\Windows\\system32")
+ allow(provider).to receive(:basepath).and_return("C:/Windows/system32")
end
- it "sets the -File flag as the last flag" do
- flags = provider.command.split(" ").keep_if { |flag| flag =~ /^-/ }
- expect(flags.pop).to eq("-File")
+ it "includes the user's flags after the default flags when building the command" do
+ new_resource.flags = "-InputFormat Fabulous"
+ provider.send(:script_file_path=, "C:/Temp/Script.ps1")
+
+ expected = <<~CMD.strip
+ "C:/Windows/system32/WindowsPowerShell/v1.0/powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -InputFormat Fabulous -File "C:/Temp/Script.ps1"
+ CMD
+
+ expect(provider.command).to eq(expected)
end
end
end