summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2015-12-15 10:24:21 +0000
committerThom May <thom@may.lt>2015-12-15 10:24:21 +0000
commit33aba5c6cc2d028223732bb3802504a95be9b0d8 (patch)
treef2425533f33e6e2d2f2c76f324ce0323f6159695 /spec/unit
parentfbf1f7d21c059d75b9978b34f9b9b5021c6dbfa3 (diff)
parent54799d8d25ed4565177f2a752088a220220c7344 (diff)
downloadchef-33aba5c6cc2d028223732bb3802504a95be9b0d8.tar.gz
Merge pull request #4309 from chef/lcg/fix-tags-and-set-unless
tags always an array; fix set_unless
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/node_spec.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 4b57a93009..76cf451323 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# Copyright:: Copyright (c) 2008-2015 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -264,6 +264,12 @@ describe Chef::Node do
expect(node[:snoopy][:is_a_puppy]).to eq(true)
end
+ it "should allow you to set an attribute with set_unless if is a nil value" do
+ node.attributes.normal = { snoopy: { is_a_puppy: nil } }
+ node.set_unless[:snoopy][:is_a_puppy] = false
+ expect(node[:snoopy][:is_a_puppy]).to eq(false)
+ end
+
it "should allow you to set a value after a set_unless" do
# this tests for set_unless_present state bleeding between statements CHEF-3806
node.set_unless[:snoopy][:is_a_puppy] = false
@@ -798,6 +804,24 @@ describe Chef::Node do
expect(node.tags).to eql([ "radiohead" ])
end
+ it "should set the tags attribute to an empty array if it is nil" do
+ node.attributes.normal = { 'tags' => nil }
+ node.consume_external_attrs(@ohai_data, {})
+ expect(node.tags).to eql([])
+ end
+
+ it "should return an array if it is fed a string" do
+ node.normal[:tags] = "string"
+ node.consume_external_attrs(@ohai_data, {})
+ expect(node.tags).to eql(["string"])
+ end
+
+ it "should return an array if it is fed a hash" do
+ node.normal[:tags] = {}
+ node.consume_external_attrs(@ohai_data, {})
+ expect(node.tags).to eql([])
+ end
+
it "deep merges attributes instead of overwriting them" do
node.consume_external_attrs(@ohai_data, "one" => {"two" => {"three" => "four"}})
expect(node.one.to_hash).to eq({"two" => {"three" => "four"}})