2727 @cl = Chef ::CookbookLoader . new ( )
2828 end
2929
30- it "should be a Chef::CookbookLoader object" do
31- @cl . should be_kind_of ( Chef ::CookbookLoader )
30+ describe "initialize" do
31+ it "should be a Chef::CookbookLoader object" do
32+ @cl . should be_kind_of ( Chef ::CookbookLoader )
33+ end
3234 end
3335
34- it "should return cookbook objects with []" do
35- @cl [ :openldap ] . should be_a_kind_of ( Chef ::Cookbook )
36- end
36+ describe "[]" do
37+ it "should return cookbook objects with []" do
38+ @cl [ :openldap ] . should be_a_kind_of ( Chef ::Cookbook )
39+ end
3740
38- it "should raise an exception if it cannot find a cookbook with []" do
39- lambda { @cl [ :monkeypoop ] } . should raise_error ( ArgumentError )
40- end
4141
42- it "should allow you to look up available cookbooks with [] and a symbol " do
43- @cl [ :openldap ] . name . should eql ( :openldap )
44- end
42+ it "should raise an exception if it cannot find a cookbook with []" do
43+ lambda { @cl [ :monkeypoop ] } . should raise_error ( ArgumentError )
44+ end
4545
46- it "should allow you to look up available cookbooks with [] and a string " do
47- @cl [ " openldap" ] . name . should eql ( :openldap )
48- end
46+ it "should allow you to look up available cookbooks with [] and a symbol " do
47+ @cl [ : openldap] . name . should eql ( :openldap )
48+ end
4949
50- it "should allow you to iterate over cookbooks with each" do
51- seen = Hash . new
52- @cl . each do |cb |
53- seen [ cb . name ] = true
50+ it "should allow you to look up available cookbooks with [] and a string" do
51+ @cl [ "openldap" ] . name . should eql ( :openldap )
5452 end
55- seen . should have_key ( :openldap )
56- seen . should have_key ( :apache2 )
5753 end
5854
59- it "should find all the cookbooks in the cookbook path" do
60- Chef ::Config . cookbook_path << File . join ( File . dirname ( __FILE__ ) , ".." , "data" , "hidden-cookbooks" )
61- @cl . load_cookbooks
62- @cl . detect { |cb | cb . name == :openldap } . should_not eql ( nil )
63- @cl . detect { |cb | cb . name == :apache2 } . should_not eql ( nil )
55+ describe "each" do
56+ it "should allow you to iterate over cookbooks with each" do
57+ seen = Hash . new
58+ @cl . each do |cb |
59+ seen [ cb . name ] = true
60+ end
61+ seen . should have_key ( :openldap )
62+ seen . should have_key ( :apache2 )
63+ end
6464 end
6565
66- it "should allow you to override an attribute file via cookbook_path" do
67- @cl [ :openldap ] . attribute_files . detect { |f |
68- f =~ /cookbooks\/ openldap\/ attributes\/ default.rb/
69- } . should_not eql ( nil )
70- @cl [ :openldap ] . attribute_files . detect { |f |
71- f =~ /kitchen\/ openldap\/ attributes\/ default.rb/
72- } . should eql ( nil )
73- end
66+ describe "load_cookbooks" do
67+ it "should find all the cookbooks in the cookbook path" do
68+ Chef ::Config . cookbook_path << File . join ( File . dirname ( __FILE__ ) , ".." , "data" , "hidden-cookbooks" )
69+ @cl . load_cookbooks
70+ @cl . detect { |cb | cb . name == :openldap } . should_not eql ( nil )
71+ @cl . detect { |cb | cb . name == :apache2 } . should_not eql ( nil )
72+ end
7473
75- it "should load different attribute files from deeper paths" do
76- @cl [ :openldap ] . attribute_files . detect { |f |
77- f =~ /kitchen\/ openldap\/ attributes\/ robinson.rb/
78- } . should_not eql ( nil )
79- end
74+ it "should allow you to override an attribute file via cookbook_path" do
75+ @cl [ :openldap ] . attribute_files . detect { |f |
76+ f =~ /cookbooks\/ openldap\/ attributes\/ default.rb/
77+ } . should_not eql ( nil )
78+ @cl [ :openldap ] . attribute_files . detect { |f |
79+ f =~ /kitchen\/ openldap\/ attributes\/ default.rb/
80+ } . should eql ( nil )
81+ end
8082
81- it "should allow you to override a definition file via cookbook_path" do
82- @cl [ :openldap ] . definition_files . detect { |f |
83- f =~ /cookbooks\/ openldap\/ definitions\/ client.rb/
84- } . should_not eql ( nil )
85- @cl [ :openldap ] . definition_files . detect { |f |
86- f =~ /kitchen\/ openldap\/ definitions\/ client.rb/
87- } . should eql ( nil )
88- end
83+ it "should load different attribute files from deeper paths" do
84+ @cl [ :openldap ] . attribute_files . detect { |f |
85+ f =~ /kitchen\/ openldap\/ attributes\/ robinson.rb/
86+ } . should_not eql ( nil )
87+ end
8988
90- it "should load definition files from deeper paths" do
91- @cl [ :openldap ] . definition_files . detect { |f |
92- f =~ /kitchen\/ openldap\/ definitions\/ drewbarrymore.rb/
93- } . should_not eql ( nil )
94- end
89+ it "should allow you to override a definition file via cookbook_path" do
90+ @cl [ :openldap ] . definition_files . detect { |f |
91+ f =~ /cookbooks\/ openldap\/ definitions\/ client.rb/
92+ } . should_not eql ( nil )
93+ @cl [ :openldap ] . definition_files . detect { |f |
94+ f =~ /kitchen\/ openldap\/ definitions\/ client.rb/
95+ } . should eql ( nil )
96+ end
9597
96- it "should allow you to override a recipe file via cookbook_path" do
97- @cl [ :openldap ] . recipe_files . detect { |f |
98- f =~ /cookbooks\/ openldap\/ recipes\/ gigantor.rb/
99- } . should_not eql ( nil )
100- @cl [ :openldap ] . recipe_files . detect { |f |
101- f =~ /kitchen\/ openldap\/ recipes\/ gigantor.rb/
102- } . should eql ( nil )
103- end
98+ it "should load definition files from deeper paths" do
99+ @cl [ :openldap ] . definition_files . detect { |f |
100+ f =~ /kitchen\/ openldap\/ definitions\/ drewbarrymore.rb/
101+ } . should_not eql ( nil )
102+ end
104103
105- it "should load recipe files from deeper paths" do
106- @cl [ :openldap ] . recipe_files . detect { |f |
107- f =~ /kitchen\/ openldap\/ recipes\/ woot.rb/
108- } . should_not eql ( nil )
109- end
104+ it "should allow you to override a recipe file via cookbook_path" do
105+ @cl [ :openldap ] . recipe_files . detect { |f |
106+ f =~ /cookbooks\/ openldap\/ recipes\/ gigantor.rb/
107+ } . should_not eql ( nil )
108+ @cl [ :openldap ] . recipe_files . detect { |f |
109+ f =~ /kitchen\/ openldap\/ recipes\/ gigantor.rb/
110+ } . should eql ( nil )
111+ end
112+
113+ it "should load recipe files from deeper paths" do
114+ @cl [ :openldap ] . recipe_files . detect { |f |
115+ f =~ /kitchen\/ openldap\/ recipes\/ woot.rb/
116+ } . should_not eql ( nil )
117+ end
110118
111- it "should allow you to have an 'ignore' file, which skips loading files in later cookbooks" do
112- @cl [ :openldap ] . recipe_files . detect { |f |
113- f =~ /kitchen\/ openldap\/ recipes\/ ignoreme.rb/
114- } . should eql ( nil )
119+ it "should allow you to have an 'ignore' file, which skips loading files in later cookbooks" do
120+ @cl [ :openldap ] . recipe_files . detect { |f |
121+ f =~ /kitchen\/ openldap\/ recipes\/ ignoreme.rb/
122+ } . should eql ( nil )
123+ end
124+
125+ it "should find files that start with a ." do
126+ @cl [ :openldap ] . remote_files . detect { |f |
127+ f =~ /\. dotfile$/
128+ } . should =~ /\. dotfile$/
129+ end
115130 end
116131
117132end
0 commit comments