diff options
author | Pete Higgins <pete@peterhiggins.org> | 2020-06-02 17:06:09 -0700 |
---|---|---|
committer | Pete Higgins <pete@peterhiggins.org> | 2020-06-03 11:46:53 -0700 |
commit | 0e8e9aefd262b4849c5f908715d0c819ba8d642d (patch) | |
tree | 10d0b3a0ed9153d056e741f583858bc840a63d68 | |
parent | f9e8f76bea0752b79cb97a5509dae8cce3eaf9c3 (diff) | |
download | chef-0e8e9aefd262b4849c5f908715d0c819ba8d642d.tar.gz |
Move test of resource behavior to resource test.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r-- | spec/unit/provider/powershell_script_spec.rb | 17 | ||||
-rw-r--r-- | spec/unit/resource/powershell_script_spec.rb | 25 |
2 files changed, 10 insertions, 32 deletions
diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb index 388d0a8c43..e0857a1ea4 100644 --- a/spec/unit/provider/powershell_script_spec.rb +++ b/spec/unit/provider/powershell_script_spec.rb @@ -39,22 +39,5 @@ describe Chef::Provider::PowershellScript, "action_run" do flags = provider.command.split(" ").keep_if { |flag| flag =~ /^-/ } expect(flags.pop).to eq("-File") end - - let(:execution_policy_flag) do - provider_flags = provider.flags.split(" ") - # Last occurance of "executionpolicy" - execution_policy_index = provider_flags.map(&:downcase).rindex("-executionpolicy") - - execution_policy_index ? provider_flags[execution_policy_index + 1] : nil - end - - it "sets default -ExecutionPolicy flag to 'Bypass'" do - expect(execution_policy_flag).to eq("Bypass") - end - - it "sets user defined -ExecutionPolicy flag to 'RemoteSigned'" do - new_resource.flags "-ExecutionPolicy RemoteSigned" - expect(execution_policy_flag).to eq("RemoteSigned") - end end end diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb index f949fb498c..6666c4749b 100644 --- a/spec/unit/resource/powershell_script_spec.rb +++ b/spec/unit/resource/powershell_script_spec.rb @@ -136,23 +136,18 @@ describe Chef::Resource::PowershellScript do it_behaves_like "a Windows script resource" end - context "Attribute: flags" do + describe "#flags" do let(:resource) { @resource } - let(:default) { "FLAGS" } - before(:each) do - allow(@resource).to receive(:default_flags).and_return(default) - end - context "When User input given" do - it "Appands user input after the default flags" do - flags = "USER FLAGS" - resource.flags flags - expect(resource.flags).to eql(default + " " + flags) - end + + it "appends user's flags to the defaults" do + flags = %q{-Lunch "tacos"} + resource.flags = flags + + expect(resource.flags).to eq("#{resource.default_flags} #{flags}") end - context "When User input is not given" do - it "Uses default flags" do - expect(resource.flags).to eql(default) - end + + it "uses the defaults when user doesn't provide flags" do + expect(resource.flags).to eq(resource.default_flags) end end end |