summaryrefslogtreecommitdiff
path: root/spec/unit/node
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2012-10-25 12:19:24 -0700
committerdanielsdeleo <dan@opscode.com>2012-11-02 09:26:30 -0700
commit7456f37b7b0332b172c421e243fca6ae055aaaa7 (patch)
treedeccfa0b5a3c9aba71203f0eaa79e03b3dd8a89b /spec/unit/node
parente23ff4bc2c6c3f897537586098fc04dc7db57355 (diff)
downloadchef-7456f37b7b0332b172c421e243fca6ae055aaaa7.tar.gz
[CHEF-2936] add role and environment components to Node::Attribute
I reformatted Chef::Node::Attribute because the indentation was busted. The actual code change is that Attribute now has components for role_default, env_default, role_override, and env_override, and merges them according to the precedence given in the documentation. These new components are not yet wired in to Chef::Node, however.
Diffstat (limited to 'spec/unit/node')
-rw-r--r--spec/unit/node/attribute_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb
index 422b34f252..bba3078d7c 100644
--- a/spec/unit/node/attribute_spec.rb
+++ b/spec/unit/node/attribute_spec.rb
@@ -234,6 +234,44 @@ describe Chef::Node::Attribute do
end
end
+ describe "when fetching values based on precedence" do
+ before do
+ @attributes.default["default"] = "cookbook default"
+ @attributes.override["override"] = "cookbook override"
+ end
+
+ it "prefers role_default over environment or cookbook default" do
+ @attributes.role_default["default"] = "role default"
+ @attributes.env_default["default"] = "environment default"
+ @attributes["default"].should == "role default"
+ end
+
+ it "prefers environment default over cookbook default" do
+ @attributes.env_default["default"] = "environment default"
+ @attributes["default"].should == "environment default"
+ end
+
+ it "returns the cookbook default when no other default values are present" do
+ @attributes["default"].should == "cookbook default"
+ end
+
+ it "prefers environment overrides over role or cookbook overrides" do
+ @attributes.env_override["override"] = "environment override"
+ @attributes.role_override["override"] = "role override"
+ @attributes["override"].should == "environment override"
+ end
+
+ it "prefers role overrides over cookbook overrides" do
+ @attributes.role_override["override"] = "role override"
+ @attributes["override"].should == "role override"
+ end
+
+ it "returns cookbook overrides when no other overrides are present" do
+ @attributes["override"].should == "cookbook override"
+ end
+
+ end
+
describe "[]" do
it "should return override data if it exists" do
@attributes["macaddress"].should == "00:00:00:00:00:00"