diff options
-rw-r--r-- | lib/chef/data_bag_item.rb | 3 | ||||
-rw-r--r-- | spec/unit/data_bag_item_spec.rb | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb index ddb520dc0b..d0fca26125 100644 --- a/lib/chef/data_bag_item.rb +++ b/lib/chef/data_bag_item.rb @@ -75,6 +75,7 @@ class Chef end def raw_data=(new_data) + new_data = Mash.new(new_data) unless new_data.respond_to?(:[]) && new_data.respond_to?(:keys) raise Exceptions::ValidationFailed, "Data Bag Items must contain a Hash or Mash!" end @@ -132,7 +133,7 @@ class Chef item = new item.data_bag(h.delete("data_bag")) if h.key?("data_bag") if h.key?("raw_data") - item.raw_data = Mash.new(h["raw_data"]) + item.raw_data = h["raw_data"] else item.raw_data = h end diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb index e83f0ca0ec..7094a7b1f7 100644 --- a/spec/unit/data_bag_item_spec.rb +++ b/spec/unit/data_bag_item_spec.rb @@ -52,6 +52,10 @@ describe Chef::DataBagItem do expect { data_bag_item.raw_data = { "id" => "octahedron" } }.not_to raise_error end + it "should let you set the raw_data with a hash containing symbols" do + expect { data_bag_item.raw_data = { :id => "octahedron" } }.not_to raise_error + end + it "should let you set the raw_data from a mash" do expect { data_bag_item.raw_data = Mash.new({ "id" => "octahedron" }) }.not_to raise_error end |