summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerdar Sutay <serdar@opscode.com>2014-10-16 11:26:26 -0700
committerSerdar Sutay <serdar@opscode.com>2014-10-16 11:26:26 -0700
commit63d0d19723b77c6e29a01f897ffed34432a35584 (patch)
tree0935175ff78c105a5cdad0f770a5f4e010a2bab9
parentfa3e81ecd2df09afa4b9de2e4e95d3b637ee9641 (diff)
parentb54426e885ae47c84ef0b13363702255f138edd0 (diff)
downloadchef-63d0d19723b77c6e29a01f897ffed34432a35584.tar.gz
Merge pull request #2238 from opscode/sersut/chef-2174
Return correct value for tagged? when node[:tags] is nil.
-rw-r--r--lib/chef/recipe.rb2
-rw-r--r--spec/unit/recipe_spec.rb8
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb
index 32578da5ab..de72a8d0c4 100644
--- a/lib/chef/recipe.rb
+++ b/lib/chef/recipe.rb
@@ -96,6 +96,8 @@ class Chef
# true<TrueClass>:: If all the parameters are present
# false<FalseClass>:: If any of the parameters are missing
def tagged?(*tags)
+ return false if run_context.node[:tags].nil?
+
tags.each do |tag|
return false unless run_context.node[:tags].include?(tag)
end
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index e29ad47045..cb7581b5fb 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -434,6 +434,14 @@ describe Chef::Recipe do
end
describe "tags" do
+ describe "with the default node object" do
+ let(:node) { Chef::Node.new }
+
+ it "should return false for any tags" do
+ recipe.tagged?("foo").should be(false)
+ end
+ end
+
it "should set tags via tag" do
recipe.tag "foo"
node[:tags].should include("foo")