summaryrefslogtreecommitdiff
path: root/chef/spec/unit
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2010-11-02 16:56:52 -0700
committerDaniel DeLeo <dan@opscode.com>2011-02-01 19:26:51 -0800
commite4d729d938894a91b7fa15834a11f56e72d756e4 (patch)
treeb0337f5844c196cb5709b88639da39c22292cf25 /chef/spec/unit
parentae9a59e09cbe8e5471f3fd36124d892ed2e30189 (diff)
downloadchef-e4d729d938894a91b7fa15834a11f56e72d756e4.tar.gz
[CHEF-1844] Add support for deleting attributes
Diffstat (limited to 'chef/spec/unit')
-rw-r--r--chef/spec/unit/node/attribute_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/chef/spec/unit/node/attribute_spec.rb b/chef/spec/unit/node/attribute_spec.rb
index bb99d6468b..abce8630ca 100644
--- a/chef/spec/unit/node/attribute_spec.rb
+++ b/chef/spec/unit/node/attribute_spec.rb
@@ -1002,4 +1002,32 @@ describe Chef::Node::Attribute do
@attributes.inspect.should =~ /@normal=\{\.\.\.\}/
end
end
+
+ describe "when a value has been set at all four precedence levels" do
+ before do
+ @default_attrs = {"foo" => {"bar" => "default_value"}}
+ @normal_attrs = {"foo" => {"bar" => "normal_value"}}
+ @override_attrs = {"foo" => {"bar" => "override_value"}}
+ @automatic_attrs = {"foo" => {"bar" => "automatic_value"}}
+
+ #(normal, default, override, automatic, state=[])
+ @attributes = Chef::Node::Attribute.new(@normal_attrs, @default_attrs, @override_attrs, @automatic_attrs)
+ end
+
+ it "deletes a key from all precedence levels" do
+ @attributes["foo"].delete("bar")
+ @attributes.reset
+ @attributes["foo"].should_not have_key("bar")
+ @default_attrs["foo"].should_not have_key("bar")
+ @normal_attrs["foo"].should_not have_key("bar")
+ @override_attrs["foo"].should_not have_key("bar")
+ @automatic_attrs["foo"].should_not have_key("bar")
+ end
+
+ it "returns the automatic (highest precedence) value when deleting a key" do
+ @attributes["foo"].delete("bar").should == "automatic_value"
+ end
+
+ end
+
end