microwave 1.0.4 → 11.400.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. data/CONTRIBUTING.md +155 -0
  2. data/README.md +89 -0
  3. data/Rakefile +2 -2
  4. data/bin/chef-apply +25 -0
  5. data/bin/chef-shell +34 -0
  6. data/bin/chef-solo +0 -2
  7. data/bin/shef +6 -5
  8. data/lib/chef.rb +2 -4
  9. data/spec/data/big_json.json +2 -1
  10. data/spec/data/big_json_plus_one.json +2 -1
  11. data/spec/data/cookbooks/chefignore +2 -0
  12. data/spec/data/cookbooks/openldap/attributes/default.rb +10 -9
  13. data/spec/data/cookbooks/openldap/attributes/smokey.rb +1 -1
  14. data/spec/data/git_bundles/sinatra-test-app-with-callback-files.gitbundle +0 -0
  15. data/spec/data/git_bundles/sinatra-test-app-with-symlinks.gitbundle +0 -0
  16. data/spec/data/git_bundles/sinatra-test-app.gitbundle +0 -0
  17. data/spec/data/lwrp/providers/inline_compiler.rb +26 -0
  18. data/spec/data/nodes/default.rb +3 -3
  19. data/spec/data/nodes/test.example.com.rb +3 -3
  20. data/spec/data/nodes/test.rb +3 -3
  21. data/spec/data/partial_one.erb +1 -0
  22. data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +4 -0
  23. data/spec/data/run_context/cookbooks/circular-dep1/definitions/circular_dep1_res.rb +1 -0
  24. data/spec/data/run_context/cookbooks/circular-dep1/libraries/lib.rb +2 -0
  25. data/spec/data/run_context/cookbooks/circular-dep1/metadata.rb +2 -0
  26. data/spec/data/run_context/cookbooks/circular-dep1/providers/provider.rb +1 -0
  27. data/spec/data/run_context/cookbooks/circular-dep1/recipes/default.rb +0 -0
  28. data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
  29. data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +3 -0
  30. data/spec/data/run_context/cookbooks/circular-dep2/definitions/circular_dep2_res.rb +1 -0
  31. data/spec/data/run_context/cookbooks/circular-dep2/libraries/lib.rb +2 -0
  32. data/spec/data/run_context/cookbooks/circular-dep2/metadata.rb +2 -0
  33. data/spec/data/run_context/cookbooks/circular-dep2/providers/provider.rb +1 -0
  34. data/spec/data/run_context/cookbooks/circular-dep2/recipes/default.rb +0 -0
  35. data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
  36. data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -0
  37. data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -0
  38. data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +3 -0
  39. data/spec/data/run_context/cookbooks/dependency1/definitions/dependency1_res.rb +1 -0
  40. data/spec/data/run_context/cookbooks/dependency1/libraries/lib.rb +2 -0
  41. data/spec/data/run_context/cookbooks/dependency1/providers/provider.rb +1 -0
  42. data/spec/data/run_context/cookbooks/dependency1/recipes/default.rb +0 -0
  43. data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
  44. data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +3 -0
  45. data/spec/data/run_context/cookbooks/dependency2/definitions/dependency2_res.rb +1 -0
  46. data/spec/data/run_context/cookbooks/dependency2/libraries/lib.rb +2 -0
  47. data/spec/data/run_context/cookbooks/dependency2/providers/provider.rb +1 -0
  48. data/spec/data/run_context/cookbooks/dependency2/recipes/default.rb +0 -0
  49. data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
  50. data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +3 -0
  51. data/spec/data/run_context/cookbooks/no-default-attr/definitions/no_default-attr_res.rb +1 -0
  52. data/spec/data/run_context/cookbooks/no-default-attr/providers/provider.rb +1 -0
  53. data/spec/data/run_context/cookbooks/no-default-attr/recipes/default.rb +0 -0
  54. data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
  55. data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +3 -0
  56. data/spec/data/run_context/cookbooks/test-with-circular-deps/definitions/test_with-circular-deps_res.rb +1 -0
  57. data/spec/data/run_context/cookbooks/test-with-circular-deps/libraries/lib.rb +2 -0
  58. data/spec/data/run_context/cookbooks/test-with-circular-deps/metadata.rb +2 -0
  59. data/spec/data/run_context/cookbooks/test-with-circular-deps/providers/provider.rb +1 -0
  60. data/spec/data/run_context/cookbooks/test-with-circular-deps/recipes/default.rb +0 -0
  61. data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +1 -0
  62. data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +3 -0
  63. data/spec/data/run_context/cookbooks/test-with-deps/definitions/test_with-deps_res.rb +1 -0
  64. data/spec/data/run_context/cookbooks/test-with-deps/libraries/lib.rb +1 -0
  65. data/spec/data/run_context/cookbooks/test-with-deps/metadata.rb +3 -0
  66. data/spec/data/run_context/cookbooks/test-with-deps/providers/provider.rb +1 -0
  67. data/spec/data/run_context/cookbooks/test-with-deps/recipes/default.rb +0 -0
  68. data/spec/data/run_context/cookbooks/test-with-deps/recipes/server.rb +0 -0
  69. data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
  70. data/spec/data/run_context/cookbooks/test/attributes/default.rb +0 -0
  71. data/spec/data/run_context/cookbooks/test/attributes/george.rb +1 -1
  72. data/spec/data/run_context/cookbooks/test/definitions/test_res.rb +1 -0
  73. data/spec/data/run_context/cookbooks/test/providers/provider.rb +1 -0
  74. data/spec/data/run_context/cookbooks/test/resources/resource.rb +1 -0
  75. data/spec/data/shef-config.rb +10 -0
  76. data/spec/functional/dsl/registry_helper_spec.rb +63 -0
  77. data/spec/functional/knife/cookbook_delete_spec.rb +0 -2
  78. data/spec/functional/knife/exec_spec.rb +4 -6
  79. data/spec/functional/knife/smoke_test.rb +34 -0
  80. data/spec/functional/knife/ssh_spec.rb +64 -3
  81. data/spec/functional/resource/cookbook_file_spec.rb +33 -2
  82. data/spec/functional/resource/deploy_revision_spec.rb +515 -0
  83. data/spec/functional/resource/directory_spec.rb +4 -0
  84. data/spec/functional/resource/file_spec.rb +56 -22
  85. data/spec/functional/resource/link_spec.rb +12 -10
  86. data/spec/functional/resource/registry_spec.rb +572 -0
  87. data/spec/functional/resource/remote_directory_spec.rb +142 -36
  88. data/spec/functional/resource/remote_file_spec.rb +28 -3
  89. data/spec/functional/resource/template_spec.rb +23 -2
  90. data/spec/functional/run_lock_spec.rb +238 -0
  91. data/spec/functional/shell_spec.rb +101 -0
  92. data/spec/functional/tiny_server_spec.rb +5 -4
  93. data/spec/functional/win32/registry_helper_spec.rb +632 -0
  94. data/spec/functional/win32/security_spec.rb +37 -0
  95. data/spec/spec_helper.rb +15 -3
  96. data/spec/stress/win32/security_spec.rb +5 -5
  97. data/spec/support/chef_helpers.rb +14 -3
  98. data/spec/support/lib/chef/resource/cat.rb +3 -5
  99. data/spec/support/lib/chef/resource/one_two_three_four.rb +8 -10
  100. data/spec/support/lib/chef/resource/zen_master.rb +8 -10
  101. data/spec/support/matchers/leak.rb +1 -1
  102. data/spec/support/platform_helpers.rb +18 -0
  103. data/spec/support/shared/functional/directory_resource.rb +85 -23
  104. data/spec/support/shared/functional/file_resource.rb +198 -53
  105. data/spec/support/shared/functional/securable_resource.rb +140 -105
  106. data/spec/support/shared/functional/securable_resource_with_reporting.rb +375 -0
  107. data/spec/support/shared/unit/file_system_support.rb +110 -0
  108. data/spec/support/shared/unit/platform_introspector.rb +162 -0
  109. data/spec/tiny_server.rb +29 -10
  110. data/spec/unit/api_client/registration_spec.rb +172 -0
  111. data/spec/unit/api_client_spec.rb +156 -103
  112. data/spec/unit/application/apply.rb +84 -0
  113. data/spec/unit/application/knife_spec.rb +5 -0
  114. data/spec/unit/application_spec.rb +57 -2
  115. data/spec/unit/chef_fs/diff_spec.rb +329 -0
  116. data/spec/unit/chef_fs/file_pattern_spec.rb +526 -0
  117. data/spec/unit/chef_fs/file_system/chef_server_root_dir_spec.rb +237 -0
  118. data/spec/unit/chef_fs/file_system/cookbooks_dir_spec.rb +568 -0
  119. data/spec/unit/chef_fs/file_system/data_bags_dir_spec.rb +220 -0
  120. data/spec/unit/chef_fs/file_system_spec.rb +136 -0
  121. data/spec/unit/client_spec.rb +188 -16
  122. data/spec/unit/config_spec.rb +54 -4
  123. data/spec/unit/cookbook/chefignore_spec.rb +2 -1
  124. data/spec/unit/cookbook/syntax_check_spec.rb +48 -109
  125. data/spec/unit/cookbook_loader_spec.rb +153 -91
  126. data/spec/unit/cookbook_manifest_spec.rb +81 -81
  127. data/spec/unit/cookbook_spec.rb +3 -20
  128. data/spec/unit/cookbook_version_spec.rb +23 -122
  129. data/spec/unit/digester_spec.rb +50 -0
  130. data/spec/unit/dsl/data_query_spec.rb +66 -0
  131. data/spec/unit/dsl/platform_introspection_spec.rb +130 -0
  132. data/spec/unit/dsl/regsitry_helper_spec.rb +55 -0
  133. data/spec/unit/encrypted_data_bag_item_spec.rb +126 -10
  134. data/spec/unit/environment_spec.rb +0 -130
  135. data/spec/unit/exceptions_spec.rb +2 -3
  136. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +23 -3
  137. data/spec/unit/json_compat_spec.rb +69 -0
  138. data/spec/unit/knife/bootstrap_spec.rb +81 -28
  139. data/spec/unit/knife/client_reregister_spec.rb +23 -22
  140. data/spec/unit/knife/configure_spec.rb +29 -26
  141. data/spec/unit/knife/cookbook_metadata_spec.rb +11 -4
  142. data/spec/unit/knife/cookbook_site_install_spec.rb +12 -2
  143. data/spec/unit/knife/cookbook_test_spec.rb +1 -0
  144. data/spec/unit/knife/cookbook_upload_spec.rb +41 -2
  145. data/spec/unit/knife/core/bootstrap_context_spec.rb +8 -1
  146. data/spec/unit/knife/core/ui_spec.rb +156 -7
  147. data/spec/unit/knife/data_bag_create_spec.rb +14 -0
  148. data/spec/unit/knife/data_bag_edit_spec.rb +14 -4
  149. data/spec/unit/knife/data_bag_from_file_spec.rb +17 -5
  150. data/spec/unit/knife/data_bag_show_spec.rb +11 -4
  151. data/spec/unit/knife/index_rebuild_spec.rb +96 -33
  152. data/spec/unit/knife/knife_help.rb +7 -7
  153. data/spec/unit/knife/node_run_list_remove_spec.rb +2 -1
  154. data/spec/unit/knife/ssh_spec.rb +121 -15
  155. data/spec/unit/knife/status_spec.rb +2 -2
  156. data/spec/unit/knife/user_create_spec.rb +86 -0
  157. data/spec/unit/knife/user_delete_spec.rb +39 -0
  158. data/spec/unit/knife/user_edit_spec.rb +42 -0
  159. data/spec/unit/knife/user_list_spec.rb +32 -0
  160. data/spec/unit/knife/user_reregister_spec.rb +53 -0
  161. data/spec/unit/knife/user_show_spec.rb +41 -0
  162. data/spec/unit/knife_spec.rb +53 -0
  163. data/spec/unit/lwrp_spec.rb +59 -17
  164. data/spec/unit/mixin/checksum_spec.rb +2 -2
  165. data/spec/unit/mixin/deep_merge_spec.rb +56 -491
  166. data/spec/unit/mixin/deprecation_spec.rb +23 -0
  167. data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +6 -1
  168. data/spec/unit/mixin/params_validate_spec.rb +4 -2
  169. data/spec/unit/mixin/securable_spec.rb +5 -3
  170. data/spec/unit/mixin/template_spec.rb +119 -0
  171. data/spec/unit/node/attribute_spec.rb +272 -137
  172. data/spec/unit/node/immutable_collections_spec.rb +139 -0
  173. data/spec/unit/node_spec.rb +411 -339
  174. data/spec/unit/platform_spec.rb +8 -8
  175. data/spec/unit/provider/breakpoint_spec.rb +8 -8
  176. data/spec/unit/provider/cookbook_file_spec.rb +4 -8
  177. data/spec/unit/provider/deploy/revision_spec.rb +2 -8
  178. data/spec/unit/provider/deploy_spec.rb +6 -40
  179. data/spec/unit/provider/directory_spec.rb +103 -68
  180. data/spec/unit/provider/erl_call_spec.rb +0 -2
  181. data/spec/unit/provider/file_spec.rb +69 -59
  182. data/spec/unit/provider/git_spec.rb +0 -10
  183. data/spec/unit/provider/group/groupadd_spec.rb +1 -1
  184. data/spec/unit/provider/group/usermod_spec.rb +2 -2
  185. data/spec/unit/provider/http_request_spec.rb +28 -69
  186. data/spec/unit/provider/ifconfig_spec.rb +2 -2
  187. data/spec/unit/provider/link_spec.rb +1 -1
  188. data/spec/unit/provider/ohai_spec.rb +4 -4
  189. data/spec/unit/provider/package/apt_spec.rb +0 -1
  190. data/spec/unit/provider/package/ips_spec.rb +0 -1
  191. data/spec/unit/provider/package/rubygems_spec.rb +0 -18
  192. data/spec/unit/provider/package/yum_spec.rb +79 -15
  193. data/spec/unit/provider/package_spec.rb +7 -5
  194. data/spec/unit/provider/registry_key_spec.rb +269 -0
  195. data/spec/unit/provider/remote_directory_spec.rb +24 -7
  196. data/spec/unit/provider/remote_file_spec.rb +36 -0
  197. data/spec/unit/provider/route_spec.rb +3 -6
  198. data/spec/unit/provider/ruby_block_spec.rb +8 -0
  199. data/spec/unit/provider/service/arch_service_spec.rb +4 -4
  200. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  201. data/spec/unit/provider/service/freebsd_service_spec.rb +4 -4
  202. data/spec/unit/provider/service/init_service_spec.rb +26 -3
  203. data/spec/unit/provider/service/insserv_service_spec.rb +1 -1
  204. data/spec/unit/provider/service/invokercd_service_spec.rb +3 -3
  205. data/spec/unit/provider/service/redhat_spec.rb +1 -1
  206. data/spec/unit/provider/service/simple_service_spec.rb +3 -3
  207. data/spec/unit/provider/service/upstart_service_spec.rb +7 -7
  208. data/spec/unit/provider/service_spec.rb +2 -2
  209. data/spec/unit/provider/subversion_spec.rb +1 -1
  210. data/spec/unit/provider/template_spec.rb +35 -11
  211. data/spec/unit/provider/user/dscl_spec.rb +57 -31
  212. data/spec/unit/provider/user_spec.rb +7 -16
  213. data/spec/unit/provider_spec.rb +4 -3
  214. data/spec/unit/recipe_spec.rb +10 -8
  215. data/spec/unit/registry_helper_spec.rb +376 -0
  216. data/spec/unit/resource/log_spec.rb +9 -0
  217. data/spec/unit/resource/registry_key_spec.rb +171 -0
  218. data/spec/unit/resource/remote_file_spec.rb +21 -23
  219. data/spec/unit/resource/ruby_block_spec.rb +7 -3
  220. data/spec/unit/resource/service_spec.rb +11 -0
  221. data/spec/unit/resource_spec.rb +27 -4
  222. data/spec/unit/rest/auth_credentials_spec.rb +2 -14
  223. data/spec/unit/rest_spec.rb +122 -187
  224. data/spec/unit/run_context/cookbook_compiler_spec.rb +181 -0
  225. data/spec/unit/run_context_spec.rb +18 -4
  226. data/spec/unit/run_list_spec.rb +0 -209
  227. data/spec/unit/run_lock_spec.rb +37 -0
  228. data/spec/unit/runner_spec.rb +101 -2
  229. data/spec/unit/scan_access_control_spec.rb +4 -4
  230. data/spec/unit/{shef → shell}/model_wrapper_spec.rb +5 -5
  231. data/spec/unit/{shef/shef_ext_spec.rb → shell/shell_ext_spec.rb} +21 -21
  232. data/spec/unit/{shef/shef_session_spec.rb → shell/shell_session_spec.rb} +12 -12
  233. data/spec/unit/shell_out_spec.rb +18 -0
  234. data/spec/unit/{shef_spec.rb → shell_spec.rb} +20 -20
  235. data/spec/unit/user_spec.rb +255 -0
  236. metadata +162 -157
  237. data/README.rdoc +0 -177
  238. data/spec/unit/certificate_spec.rb +0 -76
  239. data/spec/unit/checksum_cache_spec.rb +0 -209
  240. data/spec/unit/checksum_spec.rb +0 -94
  241. data/spec/unit/couchdb_spec.rb +0 -274
  242. data/spec/unit/index_queue_spec.rb +0 -391
  243. data/spec/unit/json_compat_spect.rb +0 -53
  244. data/spec/unit/mixin/language_spec.rb +0 -305
  245. data/spec/unit/openid_registration_spec.rb +0 -153
  246. data/spec/unit/solr_query/query_transform_spec.rb +0 -454
  247. data/spec/unit/solr_query/solr_http_request_spec.rb +0 -244
  248. data/spec/unit/solr_query_spec.rb +0 -203
  249. data/spec/unit/webui_user_spec.rb +0 -238
@@ -129,8 +129,8 @@ describe Chef::Platform do
129
129
  kitty = Chef::Resource::Cat.new("loulou")
130
130
  node = Chef::Node.new
131
131
  node.name("Intel")
132
- node.platform("mac_os_x")
133
- node.platform_version("9.2.2")
132
+ node.automatic_attrs[:platform] = "mac_os_x"
133
+ node.automatic_attrs[:platform_version] = "9.2.2"
134
134
  Chef::Platform.find_provider_for_node(node, kitty).should eql("nice")
135
135
  end
136
136
 
@@ -139,8 +139,8 @@ describe Chef::Platform do
139
139
  kitty.stub!(:provider).and_return(Chef::Provider::File)
140
140
  node = Chef::Node.new
141
141
  node.name("Intel")
142
- node.platform("mac_os_x")
143
- node.platform_version("9.2.2")
142
+ node.automatic_attrs[:platform] = "mac_os_x"
143
+ node.automatic_attrs[:platform_version] = "9.2.2"
144
144
  Chef::Platform.find_provider_for_node(node, kitty).should eql(Chef::Provider::File)
145
145
  end
146
146
 
@@ -150,15 +150,15 @@ describe Chef::Platform do
150
150
  Chef::Platform.platforms[:default].delete(:cat)
151
151
  node = Chef::Node.new
152
152
  node.name("Intel")
153
- node.platform("mac_os")
154
- node.platform_version("8.5")
153
+ node.automatic_attrs[:platform] = "mac_os_x"
154
+ node.automatic_attrs[:platform_version] = "8.5"
155
155
  Chef::Platform.find_provider_for_node(node, kitty).should eql(Chef::Provider::Cat)
156
156
  end
157
157
 
158
158
  def setup_file_resource
159
159
  node = Chef::Node.new
160
- node.platform("mac_os_x")
161
- node.platform_version("9.2.2")
160
+ node.automatic_attrs[:platform] = "mac_os_x"
161
+ node.automatic_attrs[:platform_version] = "9.2.2"
162
162
  run_context = Chef::RunContext.new(node, {}, @events)
163
163
  [ Chef::Resource::File.new("whateva", run_context), run_context ]
164
164
  end
@@ -6,9 +6,9 @@
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
- #
9
+ #
10
10
  # http://www.apache.org/licenses/LICENSE-2.0
11
- #
11
+ #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
14
14
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,7 +19,7 @@
19
19
 
20
20
  require 'spec_helper'
21
21
  describe Chef::Provider::Breakpoint do
22
-
22
+
23
23
  before do
24
24
  @resource = Chef::Resource::Breakpoint.new
25
25
  @node = Chef::Node.new
@@ -29,13 +29,13 @@ describe Chef::Provider::Breakpoint do
29
29
  @run_context.stub!(:resource_collection).and_return(@collection)
30
30
  @provider = Chef::Provider::Breakpoint.new(@resource, @run_context)
31
31
  end
32
-
32
+
33
33
  it "responds to load_current_resource" do
34
34
  @provider.should respond_to(:load_current_resource)
35
35
  end
36
-
36
+
37
37
  it "gets the iterator from @collection and pauses it" do
38
- Shef.stub!(:running?).and_return(true)
38
+ Shell.stub!(:running?).and_return(true)
39
39
  @iterator = mock("stepable_iterator")
40
40
  @collection.stub!(:iterator).and_return(@iterator)
41
41
  @iterator.should_receive(:pause)
@@ -43,8 +43,8 @@ describe Chef::Provider::Breakpoint do
43
43
  @resource.should be_updated
44
44
  end
45
45
 
46
- it "doesn't pause the iterator if Shef isn't running" do
47
- Shef.stub!(:running?).and_return(false)
46
+ it "doesn't pause the iterator if chef-shell isn't running" do
47
+ Shell.stub!(:running?).and_return(false)
48
48
  @iterator = mock("stepable_iterator")
49
49
  @collection.stub!(:iterator).and_return(@iterator)
50
50
  @iterator.should_not_receive(:pause)
@@ -28,7 +28,9 @@ describe Chef::Provider::CookbookFile do
28
28
 
29
29
  @node = Chef::Node.new
30
30
  @events = Chef::EventDispatch::Dispatcher.new
31
- @cookbook_collection = Chef::CookbookCollection.new(Chef::CookbookLoader.new(@cookbook_repo))
31
+ cl = Chef::CookbookLoader.new(@cookbook_repo)
32
+ cl.load_cookbooks
33
+ @cookbook_collection = Chef::CookbookCollection.new(cl)
32
34
  @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
33
35
 
34
36
  @new_resource = Chef::Resource::CookbookFile.new('apache2_module_conf_generate.pl', @run_context)
@@ -83,7 +85,7 @@ EXPECTED
83
85
  @provider.current_resource = @current_resource
84
86
  end
85
87
 
86
- after { ::File.exist?(@install_to) && FileUtils.rm(@install_to) }
88
+ after { ::File.exist?(File.dirname(@install_to)) && FileUtils.rm_rf(@install_to) }
87
89
 
88
90
  it "loads the current file state" do
89
91
  @provider.load_current_resource
@@ -95,12 +97,6 @@ EXPECTED
95
97
  @provider.file_cache_location.should == expected
96
98
  end
97
99
 
98
- it "stages the cookbook to a temporary file" do
99
- @new_resource.path(@install_to)
100
- @provider.should_receive(:deploy_tempfile)
101
- @provider.run_action(:create)
102
- end
103
-
104
100
  it "installs the file from the cookbook cache" do
105
101
  @new_resource.path(@install_to)
106
102
  @provider.should_receive(:backup_new_resource)
@@ -53,13 +53,11 @@ describe Chef::Provider::Deploy::Revision do
53
53
 
54
54
  it "stores the release dir in the file cache when copying the cached repo" do
55
55
  FileUtils.stub!(:mkdir_p)
56
- @provider.stub!(:run_command).and_return(true)
56
+ FileUtils.stub!(:cp_r)
57
57
  @provider.copy_cached_repo
58
- @provider.converge
59
58
  @provider.stub!(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
60
59
  @provider.load_current_resource
61
60
  @provider.copy_cached_repo
62
- @provider.converge
63
61
  second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2"
64
62
 
65
63
  @provider.all_releases.should == [@expected_release_dir,second_release]
@@ -67,22 +65,18 @@ describe Chef::Provider::Deploy::Revision do
67
65
 
68
66
  it "removes a release from the file cache when it's used again in another release and append it to the end" do
69
67
  FileUtils.stub!(:mkdir_p)
70
- @provider.stub!(:run_command).and_return(true)
68
+ FileUtils.stub!(:cp_r)
71
69
  @provider.copy_cached_repo
72
- @provider.converge
73
70
  @provider.stub!(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
74
71
  @provider.load_current_resource
75
72
  @provider.copy_cached_repo
76
- @provider.converge
77
73
  second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2"
78
74
  @provider.all_releases.should == [@expected_release_dir,second_release]
79
75
  @provider.copy_cached_repo
80
- @provider.converge
81
76
 
82
77
  @provider.stub!(:release_slug).and_return("8a3195bf3efa246f743c5dfa83683201880f935c")
83
78
  @provider.load_current_resource
84
79
  @provider.copy_cached_repo
85
- @provider.converge
86
80
  @provider.all_releases.should == [second_release, @expected_release_dir]
87
81
  end
88
82
 
@@ -54,15 +54,11 @@ describe Chef::Provider::Deploy do
54
54
  end
55
55
 
56
56
  it "creates deploy_to dir" do
57
+ ::Dir.should_receive(:chdir).with(@expected_release_dir).exactly(4).times
57
58
  @provider.stub(:update_cached_repo)
58
59
  @provider.deploy
59
60
  end
60
61
 
61
- it "creates deploy_to dir before calling update_cached_repo (CHEF-3435)" do
62
- @provider.send(:converge_actions).should_receive(:empty?).and_return(false)
63
- @provider.should_receive(:update_cached_repo).ordered
64
- @provider.deploy
65
- end
66
62
  end
67
63
 
68
64
  it "does not create deploy_to dir if it exists" do
@@ -75,10 +71,10 @@ describe Chef::Provider::Deploy do
75
71
  @provider.stub(:symlink)
76
72
  @provider.stub(:migrate)
77
73
  @provider.deploy
78
- @provider.converge
79
74
  end
80
75
 
81
76
  it "ensures the deploy_to dir ownership after the verfication that it exists" do
77
+ ::Dir.should_receive(:chdir).with(@expected_release_dir).exactly(4).times
82
78
  @provider.should_receive(:verify_directories_exist).ordered
83
79
  @provider.should_receive(:enforce_ownership).ordered
84
80
  @provider.stub(:copy_cached_repo)
@@ -106,7 +102,6 @@ describe Chef::Provider::Deploy do
106
102
  @provider.should_receive(:callback).with(:after_restart, nil)
107
103
  @provider.should_receive(:cleanup!)
108
104
  @provider.deploy
109
- @provider.converge
110
105
  end
111
106
 
112
107
  it "should not deploy if there is already a deploy at release_path, and it is the current release" do
@@ -134,7 +129,6 @@ describe Chef::Provider::Deploy do
134
129
  @resource.svn_force_export true
135
130
  @provider.scm_provider.should_receive(:run_action).with(:force_export)
136
131
  @provider.update_cached_repo
137
- @provider.converge
138
132
  end
139
133
 
140
134
  it "Removes the old release before deploying when force deploying over it" do
@@ -259,7 +253,6 @@ describe Chef::Provider::Deploy do
259
253
  @runner.should_receive(:converge)
260
254
  callback_code = Proc.new { :noop }
261
255
  @provider.callback(:whatevs, callback_code)
262
- @provider.converge
263
256
  end
264
257
 
265
258
  it "loads callback files from the release/ dir if the file exists" do
@@ -268,7 +261,6 @@ describe Chef::Provider::Deploy do
268
261
  ::Dir.should_receive(:chdir).with(@expected_release_dir).and_yield
269
262
  @provider.should_receive(:from_file).with(foo_callback)
270
263
  @provider.callback(:foo, "deploy/foo.rb")
271
- @provider.converge
272
264
  end
273
265
 
274
266
  it "raises a runtime error if a callback file is explicitly specified but does not exist" do
@@ -286,7 +278,6 @@ describe Chef::Provider::Deploy do
286
278
  ::Dir.should_receive(:chdir).with(@expected_release_dir).and_yield
287
279
  @provider.should_receive(:from_file).with(bar_callback)
288
280
  @provider.callback(:bar, nil)
289
- @provider.converge
290
281
  end
291
282
 
292
283
  it "skips an eval callback if the file doesn't exist" do
@@ -295,7 +286,6 @@ describe Chef::Provider::Deploy do
295
286
  ::Dir.should_receive(:chdir).with(@expected_release_dir).and_yield
296
287
  @provider.should_not_receive(:from_file)
297
288
  @provider.callback(:barbaz, nil)
298
- @provider.converge
299
289
  end
300
290
 
301
291
  # CHEF-3449 #converge_by is called in #recipe_eval and must happen in sequence
@@ -326,22 +316,19 @@ describe Chef::Provider::Deploy do
326
316
  it "syncs the cached copy of the repo" do
327
317
  @provider.scm_provider.should_receive(:run_action).with(:sync)
328
318
  @provider.update_cached_repo
329
- @provider.converge
330
319
  end
331
320
 
332
321
  it "makes a copy of the cached repo in releases dir" do
333
322
  FileUtils.should_receive(:mkdir_p).with("/my/deploy/dir/releases")
334
- @provider.should_receive(:run_command).with({:command => "cp -RPp /my/deploy/dir/shared/cached-copy/. #{@expected_release_dir}"})
323
+ FileUtils.should_receive(:cp_r).with("/my/deploy/dir/shared/cached-copy/.", @expected_release_dir, :preserve => true)
335
324
  @provider.copy_cached_repo
336
- @provider.converge
337
325
  end
338
326
 
339
327
  it "calls the internal callback :release_created when copying the cached repo" do
340
328
  FileUtils.stub!(:mkdir_p)
341
- @provider.stub!(:run_command).and_return(true)
329
+ FileUtils.stub!(:cp_r)
342
330
  @provider.should_receive(:release_created)
343
331
  @provider.copy_cached_repo
344
- @provider.converge
345
332
  end
346
333
 
347
334
  it "chowns the whole release dir to user and group specified in the resource" do
@@ -349,7 +336,6 @@ describe Chef::Provider::Deploy do
349
336
  @resource.group "bar"
350
337
  FileUtils.should_receive(:chown_R).with("foo", "bar", "/my/deploy/dir")
351
338
  @provider.enforce_ownership
352
- @provider.converge
353
339
  end
354
340
 
355
341
  it "skips the migration when resource.migrate => false but runs symlinks before migration" do
@@ -357,7 +343,6 @@ describe Chef::Provider::Deploy do
357
343
  @provider.should_not_receive :run_command
358
344
  @provider.should_receive :run_symlinks_before_migrate
359
345
  @provider.migrate
360
- @provider.converge
361
346
  end
362
347
 
363
348
  it "links the database.yml and runs resource.migration_command when resource.migrate #=> true" do
@@ -377,7 +362,6 @@ describe Chef::Provider::Deploy do
377
362
  :log_tag => "deploy[/my/deploy/dir]",
378
363
  :environment => {"RAILS_ENV"=>"production"})
379
364
  @provider.migrate
380
- @provider.converge
381
365
  end
382
366
 
383
367
  it "purges the current release's /log /tmp/pids/ and /public/system directories" do
@@ -385,7 +369,6 @@ describe Chef::Provider::Deploy do
385
369
  FileUtils.should_receive(:rm_rf).with(@expected_release_dir + "/tmp/pids")
386
370
  FileUtils.should_receive(:rm_rf).with(@expected_release_dir + "/public/system")
387
371
  @provider.purge_tempfiles_from_current_release
388
- @provider.converge
389
372
  end
390
373
 
391
374
  it "symlinks temporary files and logs from the shared dir into the current release" do
@@ -401,7 +384,6 @@ describe Chef::Provider::Deploy do
401
384
  FileUtils.should_receive(:ln_sf).with("/my/deploy/dir/shared/config/database.yml", @expected_release_dir + "/config/database.yml")
402
385
  @provider.should_receive(:enforce_ownership)
403
386
  @provider.link_tempfiles_to_current_release
404
- @provider.converge
405
387
  end
406
388
 
407
389
  it "symlinks the current release dir into production" do
@@ -409,7 +391,6 @@ describe Chef::Provider::Deploy do
409
391
  FileUtils.should_receive(:ln_sf).with(@expected_release_dir, "/my/deploy/dir/current")
410
392
  @provider.should_receive(:enforce_ownership)
411
393
  @provider.link_current_release_to_production
412
- @provider.converge
413
394
  end
414
395
 
415
396
  context "with a customized app layout" do
@@ -419,14 +400,12 @@ describe Chef::Provider::Deploy do
419
400
  @resource.create_dirs_before_symlink(%w{baz qux})
420
401
  @resource.symlinks "foo/bar" => "foo/bar", "baz" => "qux/baz"
421
402
  @resource.symlink_before_migrate "radiohead/in_rainbows.yml" => "awesome"
422
- @provider.converge
423
403
  end
424
404
 
425
405
  it "purges the purge_before_symlink directories" do
426
406
  FileUtils.should_receive(:rm_rf).with(@expected_release_dir + "/foo")
427
407
  FileUtils.should_receive(:rm_rf).with(@expected_release_dir + "/bar")
428
408
  @provider.purge_tempfiles_from_current_release
429
- @provider.converge
430
409
  end
431
410
 
432
411
  it "symlinks files from the shared directory to the current release directory" do
@@ -439,7 +418,6 @@ describe Chef::Provider::Deploy do
439
418
  FileUtils.should_receive(:ln_sf).with("/my/deploy/dir/shared/radiohead/in_rainbows.yml", @expected_release_dir + "/awesome")
440
419
  @provider.should_receive(:enforce_ownership)
441
420
  @provider.link_tempfiles_to_current_release
442
- @provider.converge
443
421
  end
444
422
 
445
423
  end
@@ -447,14 +425,12 @@ describe Chef::Provider::Deploy do
447
425
  it "does nothing for restart if restart_command is empty" do
448
426
  @provider.should_not_receive(:run_command)
449
427
  @provider.restart
450
- @provider.converge
451
428
  end
452
429
 
453
430
  it "runs the restart command in the current application dir when the resource has a restart_command" do
454
431
  @resource.restart_command "restartcmd"
455
432
  @provider.should_receive(:run_command).with(:command => "restartcmd", :cwd => "/my/deploy/dir/current", :log_tag => "deploy[/my/deploy/dir]", :log_level => :debug)
456
433
  @provider.restart
457
- @provider.converge
458
434
  end
459
435
 
460
436
  it "lists all available releases" do
@@ -474,7 +450,6 @@ describe Chef::Provider::Deploy do
474
450
  FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/20040200000000")
475
451
  FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/20040300000000")
476
452
  @provider.cleanup!
477
- @provider.converge
478
453
  end
479
454
 
480
455
  it "removes all but a certain number of releases when the resource has a keep_releases" do
@@ -486,7 +461,6 @@ describe Chef::Provider::Deploy do
486
461
  @provider.stub!(:all_releases).and_return(all_releases)
487
462
  FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/20040100000000")
488
463
  @provider.cleanup!
489
- @provider.converge
490
464
  end
491
465
 
492
466
  it "fires a callback for :release_deleted when deleting an old release" do
@@ -497,7 +471,6 @@ describe Chef::Provider::Deploy do
497
471
  FileUtils.stub!(:rm_rf)
498
472
  @provider.should_receive(:release_deleted).with("/my/deploy/dir/20040300000000")
499
473
  @provider.cleanup!
500
- @provider.converge
501
474
  end
502
475
 
503
476
  it "puts resource.to_hash in @configuration for backwards compat with capistano-esque deploy hooks" do
@@ -509,7 +482,6 @@ describe Chef::Provider::Deploy do
509
482
  resource.environment "production"
510
483
  provider = Chef::Provider::Deploy.new(resource, @run_context)
511
484
  provider.instance_variable_get(:@configuration)[:environment].should eql("production")
512
- @provider.converge
513
485
  end
514
486
 
515
487
  it "shouldn't give a no method error on migrate if the environment is nil" do
@@ -517,7 +489,7 @@ describe Chef::Provider::Deploy do
517
489
  @provider.stub!(:run_symlinks_before_migrate)
518
490
  @provider.stub!(:run_command)
519
491
  @provider.migrate
520
- @provider.converge
492
+
521
493
  end
522
494
 
523
495
  context "using inline recipes for callbacks" do
@@ -527,7 +499,6 @@ describe Chef::Provider::Deploy do
527
499
  recipe_code = Proc.new {snitch = 42}
528
500
  #@provider.should_receive(:instance_eval).with(&recipe_code)
529
501
  @provider.callback(:whateverz, recipe_code)
530
- @provider.converge
531
502
  snitch.should == 42
532
503
  end
533
504
 
@@ -536,7 +507,6 @@ describe Chef::Provider::Deploy do
536
507
  ::Dir.should_receive(:chdir).with(@expected_release_dir).and_yield
537
508
  @provider.should_receive(:from_file).with(@expected_release_dir + "/chefz/foobar_callback.rb")
538
509
  @provider.callback(:whateverz, "chefz/foobar_callback.rb")
539
- @provider.converge
540
510
  end
541
511
 
542
512
  it "instance_evals a block/proc for restart command" do
@@ -544,7 +514,6 @@ describe Chef::Provider::Deploy do
544
514
  restart_cmd = Proc.new {snitch = 42}
545
515
  @resource.restart(&restart_cmd)
546
516
  @provider.restart
547
- @provider.converge
548
517
  snitch.should == 42
549
518
  end
550
519
 
@@ -554,7 +523,6 @@ describe Chef::Provider::Deploy do
554
523
  it "defines sudo as a forwarder to execute" do
555
524
  @provider.should_receive(:execute).with("the moon, fool")
556
525
  @provider.sudo("the moon, fool")
557
- @provider.converge
558
526
  end
559
527
 
560
528
  it "defines run as a forwarder to execute, setting the user, group, cwd and environment to new_resource.user" do
@@ -583,7 +551,7 @@ describe Chef::Provider::Deploy do
583
551
  end
584
552
  }.twice
585
553
  @provider.run("iGoToHell4this")
586
- @provider.converge
554
+
587
555
  end
588
556
 
589
557
  it "defines run as a forwarder to execute, setting cwd and environment but not override" do
@@ -594,7 +562,6 @@ describe Chef::Provider::Deploy do
594
562
  mock_execution.should_receive(:cwd).with(no_args()).and_return("/some/value")
595
563
  mock_execution.should_receive(:environment).with(no_args()).and_return({})
596
564
  @provider.run("iGoToHell4this")
597
- @provider.converge
598
565
  end
599
566
 
600
567
 
@@ -615,7 +582,6 @@ describe Chef::Provider::Deploy do
615
582
  runner.should_receive(:converge)
616
583
  #
617
584
  @provider.callback(:phony, callback_code)
618
- @provider.converge
619
585
  snitch.should be_an_instance_of(Chef::Resource::Execute)
620
586
  snitch.user.should == "tehCat"
621
587
  end
@@ -19,13 +19,16 @@
19
19
  require 'ostruct'
20
20
 
21
21
  require 'spec_helper'
22
+ require 'tmpdir'
22
23
 
23
24
  describe Chef::Provider::Directory do
24
25
  before(:each) do
25
- @new_resource = Chef::Resource::Directory.new('/tmp')
26
- @new_resource.owner(500)
27
- @new_resource.group(500)
28
- @new_resource.mode(0644)
26
+ @new_resource = Chef::Resource::Directory.new(Dir.tmpdir)
27
+ if !windows?
28
+ @new_resource.owner(500)
29
+ @new_resource.group(500)
30
+ @new_resource.mode(0644)
31
+ end
29
32
  @node = Chef::Node.new
30
33
  @events = Chef::EventDispatch::Dispatcher.new
31
34
  @run_context = Chef::RunContext.new(@node, {}, @events)
@@ -33,80 +36,112 @@ describe Chef::Provider::Directory do
33
36
  @directory = Chef::Provider::Directory.new(@new_resource, @run_context)
34
37
  end
35
38
 
36
- context "load_current_resource_attrs", :unix_only do
37
- it "should load the current resource based on the new resource" do
38
- File.stub!(:exist?).and_return(true)
39
+
40
+ describe "scanning file security metadata on windows" do
41
+ before do
42
+ end
43
+
44
+ it "describes the directory's access rights" do
45
+ pending
46
+ end
47
+ end
48
+
49
+ describe "scanning file security metadata on unix" do
50
+ before do
51
+ Chef::Platform.stub!(:windows?).and_return(false)
52
+ end
53
+ let(:mock_stat) do
39
54
  cstats = mock("stats")
40
55
  cstats.stub!(:uid).and_return(500)
41
56
  cstats.stub!(:gid).and_return(500)
42
57
  cstats.stub!(:mode).and_return(0755)
43
- File.should_receive(:stat).twice.and_return(cstats)
44
- @directory.load_current_resource
45
- @directory.current_resource.path.should eql(@new_resource.path)
46
- @directory.current_resource.owner.should eql(500)
47
- @directory.current_resource.group.should eql(500)
48
- @directory.current_resource.mode.should == 00755
49
- end
50
-
51
- it "should create a new directory on create, setting updated to true" do
52
- @new_resource.path "/tmp/foo"
53
-
54
- File.should_receive(:exist?).exactly(3).and_return(false)
55
- Dir.should_receive(:mkdir).with(@new_resource.path).once.and_return(true)
56
-
57
- @directory.should_receive(:set_all_access_controls)
58
- @directory.stub!(:update_new_file_state)
59
- @directory.run_action(:create)
60
- @directory.new_resource.should be_updated
58
+ cstats
61
59
  end
62
-
63
- it "should raise an exception if the parent directory does not exist and recursive is false" do
64
- @new_resource.path "/tmp/some/dir"
65
- @new_resource.recursive false
66
- lambda { @directory.run_action(:create) }.should raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
67
- end
68
-
69
- it "should create a new directory when parent directory does not exist if recursive is true and permissions are correct" do
70
- @new_resource.path "/path/to/dir"
71
- @new_resource.recursive true
72
- File.should_receive(:exist?).with(@new_resource.path).ordered.and_return(false)
73
- File.should_receive(:exist?).with(@new_resource.path).ordered.and_return(false)
74
-
75
- File.should_receive(:exist?).with('/path/to').ordered.and_return(false)
76
- File.should_receive(:exist?).with('/path').ordered.and_return(true)
77
- File.should_receive(:writable?).with('/path').ordered.and_return(true)
78
- File.should_receive(:exist?).with(@new_resource.path).ordered.and_return(false)
79
-
80
- FileUtils.should_receive(:mkdir_p).with(@new_resource.path).and_return(true)
81
- @directory.should_receive(:set_all_access_controls)
82
- @directory.stub!(:update_new_file_state)
83
- @directory.run_action(:create)
84
- @new_resource.should be_updated
60
+
61
+ it "describes the access mode as a String of octal integers" do
62
+ File.stub!(:exist?).and_return(true)
63
+ File.should_receive(:stat).and_return(mock_stat)
64
+ @directory.load_current_resource
65
+ @directory.current_resource.mode.should == "0755"
85
66
  end
86
-
87
- # it "should raise an error when creating a directory recursively and permissions do not allow creation" do
88
-
89
- # end
90
-
91
- it "should raise an error when creating a directory when parent directory is a file" do
92
- File.should_receive(:directory?).and_return(false)
93
- Dir.should_not_receive(:mkdir).with(@new_resource.path)
94
- lambda { @directory.run_action(:create) }.should raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
95
- @directory.new_resource.should_not be_updated
67
+
68
+ context "when user and group are specified with UID/GID" do
69
+ it "describes the current owner and group as UID and GID" do
70
+ File.stub!(:exist?).and_return(true)
71
+ File.should_receive(:stat).and_return(mock_stat)
72
+ @directory.load_current_resource
73
+ @directory.current_resource.path.should eql(@new_resource.path)
74
+ @directory.current_resource.owner.should eql(500)
75
+ @directory.current_resource.group.should eql(500)
76
+ end
96
77
  end
97
-
98
- it "should not create the directory if it already exists" do
99
- stub_file_cstats
100
- @new_resource.path "/tmp/foo"
101
- File.should_receive(:exist?).exactly(3).and_return(true)
102
- Dir.should_not_receive(:mkdir).with(@new_resource.path)
103
- @directory.should_receive(:set_all_access_controls)
104
- @directory.run_action(:create)
78
+
79
+ context "when user/group are specified with user/group names" do
105
80
  end
106
81
  end
107
82
 
108
- context "load_current_resource_attrs", :windows_only do
109
- pending "CHEF-3557: Fix implicit resource change collection on Windows"
83
+ # Unix only for now. While file security attribute reporting for windows is
84
+ # disabled, unix and windows differ in the number of exist? calls that are
85
+ # made by the provider.
86
+ it "should create a new directory on create, setting updated to true", :unix_only do
87
+ @new_resource.path "/tmp/foo"
88
+
89
+ File.should_receive(:exist?).exactly(2).and_return(false)
90
+ File.should_receive(:directory?).with("/tmp").and_return(true)
91
+ Dir.should_receive(:mkdir).with(@new_resource.path).once.and_return(true)
92
+
93
+ @directory.should_receive(:set_all_access_controls)
94
+ @directory.stub!(:update_new_file_state)
95
+ @directory.run_action(:create)
96
+ @directory.new_resource.should be_updated
97
+ end
98
+
99
+ it "should raise an exception if the parent directory does not exist and recursive is false" do
100
+ @new_resource.path "/tmp/some/dir"
101
+ @new_resource.recursive false
102
+ lambda { @directory.run_action(:create) }.should raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
103
+ end
104
+
105
+ # Unix only for now. While file security attribute reporting for windows is
106
+ # disabled, unix and windows differ in the number of exist? calls that are
107
+ # made by the provider.
108
+ it "should create a new directory when parent directory does not exist if recursive is true and permissions are correct", :unix_only do
109
+ @new_resource.path "/path/to/dir"
110
+ @new_resource.recursive true
111
+ File.should_receive(:exist?).with(@new_resource.path).ordered.and_return(false)
112
+
113
+ File.should_receive(:exist?).with('/path/to').ordered.and_return(false)
114
+ File.should_receive(:exist?).with('/path').ordered.and_return(true)
115
+ File.should_receive(:writable?).with('/path').ordered.and_return(true)
116
+ File.should_receive(:exist?).with(@new_resource.path).ordered.and_return(false)
117
+
118
+ FileUtils.should_receive(:mkdir_p).with(@new_resource.path).and_return(true)
119
+ @directory.should_receive(:set_all_access_controls)
120
+ @directory.stub!(:update_new_file_state)
121
+ @directory.run_action(:create)
122
+ @new_resource.should be_updated
123
+ end
124
+
125
+
126
+ it "should raise an error when creating a directory when parent directory is a file" do
127
+ File.should_receive(:directory?).and_return(false)
128
+ Dir.should_not_receive(:mkdir).with(@new_resource.path)
129
+ lambda { @directory.run_action(:create) }.should raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
130
+ @directory.new_resource.should_not be_updated
131
+ end
132
+
133
+ # Unix only for now. While file security attribute reporting for windows is
134
+ # disabled, unix and windows differ in the number of exist? calls that are
135
+ # made by the provider.
136
+ it "should not create the directory if it already exists", :unix_only do
137
+ stub_file_cstats
138
+ @new_resource.path "/tmp/foo"
139
+ File.should_receive(:directory?).twice.and_return(true)
140
+ File.should_receive(:writable?).with("/tmp").and_return(true)
141
+ File.should_receive(:exist?).exactly(3).and_return(true)
142
+ Dir.should_not_receive(:mkdir).with(@new_resource.path)
143
+ @directory.should_receive(:set_all_access_controls)
144
+ @directory.run_action(:create)
110
145
  end
111
146
 
112
147
  it "should delete the directory if it exists, and is writable with action_delete" do