diff options
author | Tim Smith <tsmith@chef.io> | 2018-03-27 14:08:14 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-03-27 14:08:14 -0700 |
commit | 52ccca2a16379b51e2ec68365263735e5888fcd1 (patch) | |
tree | 98e401df2ec1be7fb48f9965f74138f49e0cb2ed /spec/unit | |
parent | c70852e8966997c547f8f97379f218e656622e4b (diff) | |
download | chef-52ccca2a16379b51e2ec68365263735e5888fcd1.tar.gz |
Fix array parsing in windows_feature_dism / windows_feature_powershellfix_dism
This fixes how we parse out the arrays and adds testing to make sure it's doing what we want.
Plus it properly continues on when the user has removed all local feature but specified an external source of those via the registry. That was a reported issue that came in on the cookbook after the rewrite.
Lastly this also fixes a bad method call to the dism method that came over when diffing from the cookbook.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/resource/windows_feature_dism.rb | 14 | ||||
-rw-r--r-- | spec/unit/resource/windows_feature_powershell.rb | 14 |
2 files changed, 24 insertions, 4 deletions
diff --git a/spec/unit/resource/windows_feature_dism.rb b/spec/unit/resource/windows_feature_dism.rb index 3885f4813e..1004b75ba9 100644 --- a/spec/unit/resource/windows_feature_dism.rb +++ b/spec/unit/resource/windows_feature_dism.rb @@ -18,7 +18,7 @@ require "spec_helper" describe Chef::Resource::WindowsFeatureDism do - let(:resource) { Chef::Resource::WindowsFeatureDism.new("SNMP") } + let(:resource) { Chef::Resource::WindowsFeatureDism.new(%w{SNMP DHCP}) } it "sets resource name as :windows_feature_dism" do expect(resource.resource_name).to eql(:windows_feature_dism) @@ -28,7 +28,17 @@ describe Chef::Resource::WindowsFeatureDism do expect(resource.action).to eql([:install]) end - it "sets the feature_name property as its name and coerces it to an array" do + it "sets the feature_name property as its name property" do + expect(resource.feature_name).to eql(%w{SNMP DHCP}) + end + + it "coerces comma separated lists of features to arrays" do + resource.feature_name "SNMP, DHCP" + expect(resource.feature_name).to eql(%w{SNMP DHCP}) + end + + it "coerces a single feature as a String into an array" do + resource.feature_name "SNMP" expect(resource.feature_name).to eql(["SNMP"]) end diff --git a/spec/unit/resource/windows_feature_powershell.rb b/spec/unit/resource/windows_feature_powershell.rb index 02f308ca73..5ea226575c 100644 --- a/spec/unit/resource/windows_feature_powershell.rb +++ b/spec/unit/resource/windows_feature_powershell.rb @@ -18,7 +18,7 @@ require "spec_helper" describe Chef::Resource::WindowsFeaturePowershell do - let(:resource) { Chef::Resource::WindowsFeaturePowershell.new("SNMP") } + let(:resource) { Chef::Resource::WindowsFeaturePowershell.new(%w{SNMP DHCP}) } it "sets resource name as :windows_feature_powershell" do expect(resource.resource_name).to eql(:windows_feature_powershell) @@ -28,7 +28,17 @@ describe Chef::Resource::WindowsFeaturePowershell do expect(resource.action).to eql([:install]) end - it "sets the feature_name property as its name and coerces it to an array" do + it "sets the feature_name property as its name property" do + expect(resource.feature_name).to eql(%w{SNMP DHCP}) + end + + it "coerces comma separated lists of features to arrays" do + resource.feature_name "SNMP, DHCP" + expect(resource.feature_name).to eql(%w{SNMP DHCP}) + end + + it "coerces a single feature as a String into an array" do + resource.feature_name "SNMP" expect(resource.feature_name).to eql(["SNMP"]) end |