2121describe Chef ::Recipe do
2222 before ( :each ) do
2323 @recipe = Chef ::Recipe . new ( "hjk" , "test" , Chef ::Node . new )
24+ @recipe . node [ :tags ] = Array . new
2425 end
2526
2627 it "should load a two word (zen_master) resource" do
140141 res . pretty_kitty . should eql ( true )
141142 end
142143
144+ it "should set tags via tag" do
145+ @recipe . tag "foo"
146+ @recipe . node [ :tags ] . should include ( "foo" )
147+ end
148+
149+ it "should set multiple tags via tag" do
150+ @recipe . tag "foo" , "bar"
151+ @recipe . node [ :tags ] . should include ( "foo" )
152+ @recipe . node [ :tags ] . should include ( "bar" )
153+ end
154+
155+ it "should not set the same tag twice via tag" do
156+ @recipe . tag "foo"
157+ @recipe . tag "foo"
158+ @recipe . node [ :tags ] . should eql ( [ "foo" ] )
159+ end
160+
161+ it "should return the current list of tags from tag with no arguments" do
162+ @recipe . tag "foo"
163+ @recipe . tag . should eql ( [ "foo" ] )
164+ end
165+
166+ it "should return true from tagged? if node is tagged" do
167+ @recipe . tag "foo"
168+ @recipe . tagged? ( "foo" ) . should be ( true )
169+ end
170+
171+ it "should return false from tagged? if node is not tagged" do
172+ @recipe . tagged? ( "foo" ) . should be ( false )
173+ end
174+
175+ it "should return false from tagged? if node is not tagged" do
176+ @recipe . tagged? ( "foo" ) . should be ( false )
177+ end
178+
179+ it "should remove a tag from the tag list via untag" do
180+ @recipe . tag "foo"
181+ @recipe . untag "foo"
182+ @recipe . node [ :tags ] . should eql ( [ ] )
183+ end
184+
185+ it "should remove multiple tags from the tag list via untag" do
186+ @recipe . tag "foo" , "bar"
187+ @recipe . untag "bar" , "foo"
188+ @recipe . node [ :tags ] . should eql ( [ ] )
189+ end
143190end
0 commit comments