diff options
author | Vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2018-07-31 15:09:40 +0530 |
---|---|---|
committer | Vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2018-07-31 15:09:40 +0530 |
commit | abf0deee9c83b468d5d01b321dff9d7d9cbb7b92 (patch) | |
tree | b8ae3532a8e8f748f554e9611634c5fb052248cd | |
parent | 94a4b1c304c0175940a1e6cfca8043fa3ce0a97c (diff) | |
download | chef-abf0deee9c83b468d5d01b321dff9d7d9cbb7b92.tar.gz |
MSYS-872 Fix for registry key resource doesn't recognise keys when passed as attribute
Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
-rw-r--r-- | lib/chef/resource/registry_key.rb | 7 | ||||
-rw-r--r-- | spec/unit/resource/registry_key_spec.rb | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/chef/resource/registry_key.rb b/lib/chef/resource/registry_key.rb index 36a6db1100..30233ddc8b 100644 --- a/lib/chef/resource/registry_key.rb +++ b/lib/chef/resource/registry_key.rb @@ -74,9 +74,12 @@ class Chef def values(arg = nil) if not arg.nil? if arg.is_a?(Hash) - @values = [ arg ] + @values = [ Mash.new(arg).symbolize_keys ] elsif arg.is_a?(Array) - @values = arg + @values = [] + arg.each do |value| + @values << Mash.new(value).symbolize_keys + end else raise ArgumentError, "Bad type for RegistryKey resource, use Hash or Array" end diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb index 147bc8492c..47d624a758 100644 --- a/spec/unit/resource/registry_key_spec.rb +++ b/spec/unit/resource/registry_key_spec.rb @@ -133,6 +133,10 @@ describe Chef::Resource::RegistryKey, "values" do expect { resource.values([ { name: "123", type: :string, data: "carmen" } ]) }.to_not raise_error end end + + it "does not raise an exception if keys are in string format" do + expect { resource.values([ { "name" => "123", "type" => :string, "data" => "carmen" } ]) }.to_not raise_error + end end describe Chef::Resource::RegistryKey, "recursive" do |