From 128ffdd40823a877b3063856a9f107d4264e7b6a Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 28 Aug 2017 13:06:51 -0700 Subject: speed up immutabilization since we only inject Mash/VividMashes do not convert Signed-off-by: Lamont Granquist --- spec/unit/node/immutable_collections_spec.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb index 520bc1ba42..68ce5e5abd 100644 --- a/spec/unit/node/immutable_collections_spec.rb +++ b/spec/unit/node/immutable_collections_spec.rb @@ -21,10 +21,10 @@ require "chef/node/immutable_collections" describe Chef::Node::ImmutableMash do before do - @data_in = { :top => { :second_level => "some value" }, + @data_in = { "top" => { "second_level" => "some value" }, "top_level_2" => %w{array of values}, - :top_level_3 => [{ :hash_array => 1, :hash_array_b => 2 }], - :top_level_4 => { :level2 => { :key => "value" } }, + "top_level_3" => [{ "hash_array" => 1, "hash_array_b" => 2 }], + "top_level_4" => { "level2" => { "key" => "value" } }, } @immutable_mash = Chef::Node::ImmutableMash.new(@data_in) end @@ -54,6 +54,14 @@ describe Chef::Node::ImmutableMash do expect(@immutable_mash[:top_level_4][:level2]).to be_a(Chef::Node::ImmutableMash) end + # we only ever absorb VividMashes from other precedence levels, which already have + # been coerced to only have string keys, so we do not need to do that work twice (performance). + it "does not call convert_value like Mash/VividMash" do + @mash = Chef::Node::ImmutableMash.new({ test: "foo", "test2" => "bar" }) + expect(@mash[:test]).to eql("foo") + expect(@mash["test2"]).to eql("bar") + end + describe "to_hash" do before do @copy = @immutable_mash.to_hash -- cgit v1.2.1