chef 12.0.0.alpha.0-x86-mingw32 → 12.0.0.alpha.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +3 -5
  3. data/lib/chef/api_client.rb +1 -1
  4. data/lib/chef/application.rb +16 -8
  5. data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
  6. data/lib/chef/chef_fs/command_line.rb +1 -1
  7. data/lib/chef/chef_fs/file_system.rb +1 -1
  8. data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -1
  9. data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +3 -3
  10. data/lib/chef/chef_fs/file_system/cookbook_file.rb +2 -2
  11. data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -2
  12. data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -4
  13. data/lib/chef/config.rb +6 -5
  14. data/lib/chef/config_fetcher.rb +1 -1
  15. data/lib/chef/cookbook/cookbook_version_loader.rb +126 -43
  16. data/lib/chef/cookbook/metadata.rb +102 -53
  17. data/lib/chef/cookbook/syntax_check.rb +1 -1
  18. data/lib/chef/cookbook_loader.rb +62 -14
  19. data/lib/chef/cookbook_site_streaming_uploader.rb +12 -1
  20. data/lib/chef/cookbook_version.rb +13 -4
  21. data/lib/chef/data_bag.rb +28 -15
  22. data/lib/chef/data_bag_item.rb +5 -7
  23. data/lib/chef/digester.rb +5 -9
  24. data/lib/chef/dsl/recipe.rb +14 -0
  25. data/lib/chef/encrypted_data_bag_item.rb +1 -0
  26. data/lib/chef/encrypted_data_bag_item/assertions.rb +57 -0
  27. data/lib/chef/encrypted_data_bag_item/decryptor.rb +52 -28
  28. data/lib/chef/encrypted_data_bag_item/encrypted_data_bag_item_assertions.rb +37 -0
  29. data/lib/chef/encrypted_data_bag_item/encryption_failure.rb +22 -0
  30. data/lib/chef/encrypted_data_bag_item/encryptor.rb +79 -8
  31. data/lib/chef/environment.rb +1 -3
  32. data/lib/chef/exceptions.rb +18 -3
  33. data/lib/chef/formatters/base.rb +7 -0
  34. data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +1 -1
  35. data/lib/chef/handler/json_file.rb +0 -1
  36. data/lib/chef/http/json_output.rb +1 -1
  37. data/lib/chef/json_compat.rb +24 -6
  38. data/lib/chef/knife/bootstrap.rb +2 -2
  39. data/lib/chef/knife/client_delete.rb +1 -1
  40. data/lib/chef/knife/cookbook_site_download.rb +1 -1
  41. data/lib/chef/knife/cookbook_site_list.rb +1 -1
  42. data/lib/chef/knife/cookbook_site_search.rb +1 -1
  43. data/lib/chef/knife/cookbook_site_share.rb +2 -2
  44. data/lib/chef/knife/cookbook_site_show.rb +3 -3
  45. data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
  46. data/lib/chef/knife/core/node_editor.rb +2 -3
  47. data/lib/chef/knife/core/ui.rb +2 -2
  48. data/lib/chef/knife/deps.rb +2 -3
  49. data/lib/chef/mixin/shell_out.rb +1 -1
  50. data/lib/chef/mixin/windows_architecture_helper.rb +1 -0
  51. data/lib/chef/node.rb +1 -2
  52. data/lib/chef/platform/provider_mapping.rb +33 -6
  53. data/lib/chef/provider.rb +0 -2
  54. data/lib/chef/provider/cookbook_file/content.rb +1 -1
  55. data/lib/chef/provider/cron.rb +11 -0
  56. data/lib/chef/provider/deploy.rb +3 -2
  57. data/lib/chef/provider/deploy/revision.rb +2 -2
  58. data/lib/chef/provider/env.rb +1 -1
  59. data/lib/chef/provider/env/windows.rb +5 -9
  60. data/lib/chef/provider/file.rb +84 -33
  61. data/lib/chef/provider/git.rb +2 -1
  62. data/lib/chef/provider/group/aix.rb +17 -2
  63. data/lib/chef/provider/group/dscl.rb +27 -9
  64. data/lib/chef/provider/group/pw.rb +8 -1
  65. data/lib/chef/provider/http_request.rb +4 -4
  66. data/lib/chef/provider/log.rb +4 -14
  67. data/lib/chef/provider/mount/mount.rb +2 -2
  68. data/lib/chef/provider/package/ips.rb +17 -23
  69. data/lib/chef/provider/package/paludis.rb +2 -2
  70. data/lib/chef/provider/package/rpm.rb +2 -2
  71. data/lib/chef/provider/package/rubygems.rb +2 -0
  72. data/lib/chef/provider/package/yum.rb +2 -0
  73. data/lib/chef/provider/package/zypper.rb +1 -1
  74. data/lib/chef/provider/remote_file/cache_control_data.rb +2 -2
  75. data/lib/chef/provider/service/windows.rb +87 -21
  76. data/lib/chef/provider/user/aix.rb +95 -0
  77. data/lib/chef/provider/user/dscl.rb +544 -156
  78. data/lib/chef/provider/user/useradd.rb +1 -0
  79. data/lib/chef/providers.rb +1 -0
  80. data/lib/chef/resource.rb +4 -3
  81. data/lib/chef/resource/freebsd_package.rb +10 -2
  82. data/lib/chef/resource/paludis_package.rb +1 -0
  83. data/lib/chef/resource/scm.rb +10 -0
  84. data/lib/chef/resource/user.rb +27 -0
  85. data/lib/chef/resource/windows_service.rb +53 -0
  86. data/lib/chef/resource_collection.rb +23 -12
  87. data/lib/chef/resource_reporter.rb +10 -10
  88. data/lib/chef/resources.rb +1 -0
  89. data/lib/chef/role.rb +3 -3
  90. data/lib/chef/run_list.rb +6 -3
  91. data/lib/chef/user.rb +1 -1
  92. data/lib/chef/util/diff.rb +1 -2
  93. data/lib/chef/version.rb +1 -1
  94. data/lib/chef/version_constraint.rb +4 -4
  95. data/spec/data/cookbooks/angrybash/metadata.rb +2 -0
  96. data/spec/data/cookbooks/apache2/metadata.rb +2 -0
  97. data/spec/data/cookbooks/borken/metadata.rb +2 -0
  98. data/spec/data/cookbooks/ignorken/metadata.rb +2 -0
  99. data/spec/data/cookbooks/java/metadata.rb +2 -0
  100. data/spec/data/cookbooks/name-mismatch-versionnumber/README.md +4 -0
  101. data/spec/data/cookbooks/name-mismatch-versionnumber/metadata.rb +8 -0
  102. data/spec/data/cookbooks/name-mismatch-versionnumber/recipes/default.rb +8 -0
  103. data/spec/data/cookbooks/openldap/files/default/remotedir/not_a_template.erb +2 -0
  104. data/spec/data/cookbooks/preseed/metadata.rb +2 -0
  105. data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/README.md +4 -0
  106. data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/metadata.rb +13 -0
  107. data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/recipes/default.rb +8 -0
  108. data/spec/data/invalid-metadata-chef-repo/invalid-metadata/README.md +4 -0
  109. data/spec/data/invalid-metadata-chef-repo/invalid-metadata/metadata.rb +10 -0
  110. data/spec/data/invalid-metadata-chef-repo/invalid-metadata/recipes/default.rb +8 -0
  111. data/spec/data/mac_users/10.7-8.plist.xml +559 -0
  112. data/spec/data/mac_users/10.7-8.shadow.xml +11 -0
  113. data/spec/data/mac_users/10.7.plist.xml +559 -0
  114. data/spec/data/mac_users/10.7.shadow.xml +11 -0
  115. data/spec/data/mac_users/10.8.plist.xml +559 -0
  116. data/spec/data/mac_users/10.8.shadow.xml +21 -0
  117. data/spec/data/mac_users/10.9.plist.xml +560 -0
  118. data/spec/data/mac_users/10.9.shadow.xml +21 -0
  119. data/spec/data/object_loader/environments/test.json +2 -0
  120. data/spec/data/object_loader/environments/test_json_class.json +2 -0
  121. data/spec/data/object_loader/nodes/test.json +2 -0
  122. data/spec/data/object_loader/nodes/test_json_class.json +2 -0
  123. data/spec/data/object_loader/roles/test.json +2 -0
  124. data/spec/data/object_loader/roles/test_json_class.json +2 -0
  125. data/spec/functional/resource/bff_spec.rb +1 -1
  126. data/spec/functional/resource/cron_spec.rb +20 -1
  127. data/spec/functional/resource/env_spec.rb +137 -0
  128. data/spec/functional/resource/group_spec.rb +7 -5
  129. data/spec/functional/resource/remote_file_spec.rb +12 -1
  130. data/spec/functional/resource/user/dscl_spec.rb +198 -0
  131. data/spec/functional/resource/{user_spec.rb → user/useradd_spec.rb} +175 -37
  132. data/spec/integration/client/client_spec.rb +6 -4
  133. data/spec/integration/client/ipv6_spec.rb +16 -14
  134. data/spec/integration/knife/chef_fs_data_store_spec.rb +57 -46
  135. data/spec/integration/knife/chef_repo_path_spec.rb +105 -78
  136. data/spec/integration/knife/chef_repository_file_system_spec.rb +100 -84
  137. data/spec/integration/knife/chefignore_spec.rb +76 -46
  138. data/spec/integration/knife/common_options_spec.rb +16 -21
  139. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +3 -3
  140. data/spec/integration/knife/delete_spec.rb +66 -46
  141. data/spec/integration/knife/deps_spec.rb +145 -94
  142. data/spec/integration/knife/diff_spec.rb +176 -110
  143. data/spec/integration/knife/download_spec.rb +229 -133
  144. data/spec/integration/knife/list_spec.rb +62 -54
  145. data/spec/integration/knife/raw_spec.rb +24 -9
  146. data/spec/integration/knife/redirection_spec.rb +2 -2
  147. data/spec/integration/knife/serve_spec.rb +2 -2
  148. data/spec/integration/knife/show_spec.rb +32 -26
  149. data/spec/integration/knife/upload_spec.rb +308 -165
  150. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +10 -8
  151. data/spec/integration/solo/solo_spec.rb +22 -11
  152. data/spec/spec_helper.rb +3 -0
  153. data/spec/support/lib/chef/resource/zen_follower.rb +46 -0
  154. data/spec/support/platform_helpers.rb +12 -0
  155. data/spec/support/shared/functional/file_resource.rb +10 -0
  156. data/spec/support/shared/integration/chef_zero_support.rb +130 -0
  157. data/spec/support/shared/integration/integration_helper.rb +100 -98
  158. data/spec/support/shared/integration/knife_support.rb +0 -1
  159. data/spec/support/shared/unit/provider/file.rb +6 -4
  160. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +10 -1
  161. data/spec/unit/api_client/registration_spec.rb +83 -74
  162. data/spec/unit/application_spec.rb +32 -9
  163. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +179 -0
  164. data/spec/unit/cookbook/metadata_spec.rb +190 -150
  165. data/spec/unit/cookbook/syntax_check_spec.rb +3 -2
  166. data/spec/unit/cookbook_loader_spec.rb +114 -53
  167. data/spec/unit/{cookbook_site_streaming_uploader.rb → cookbook_site_streaming_uploader_spec.rb} +21 -1
  168. data/spec/unit/data_bag_spec.rb +88 -13
  169. data/spec/unit/deprecation_spec.rb +1 -2
  170. data/spec/unit/encrypted_data_bag_item_spec.rb +145 -9
  171. data/spec/unit/environment_spec.rb +1 -1
  172. data/spec/unit/formatters/base_spec.rb +48 -0
  173. data/spec/unit/json_compat_spec.rb +48 -17
  174. data/spec/unit/knife/client_delete_spec.rb +4 -4
  175. data/spec/unit/knife/client_show_spec.rb +15 -5
  176. data/spec/unit/knife/cookbook_site_download_spec.rb +1 -1
  177. data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
  178. data/spec/unit/knife/data_bag_from_file_spec.rb +0 -2
  179. data/spec/unit/knife/data_bag_show_spec.rb +23 -14
  180. data/spec/unit/knife/node_show_spec.rb +32 -15
  181. data/spec/unit/knife/role_show_spec.rb +59 -0
  182. data/spec/unit/platform_spec.rb +10 -0
  183. data/spec/unit/provider/deploy_spec.rb +4 -0
  184. data/spec/unit/provider/env_spec.rb +19 -0
  185. data/spec/unit/provider/git_spec.rb +22 -2
  186. data/spec/unit/provider/group/dscl_spec.rb +38 -1
  187. data/spec/unit/provider/group/pw_spec.rb +2 -2
  188. data/spec/unit/provider/http_request_spec.rb +8 -8
  189. data/spec/unit/provider/log_spec.rb +33 -53
  190. data/spec/unit/provider/mount/mount_spec.rb +12 -3
  191. data/spec/unit/provider/package/ips_spec.rb +96 -63
  192. data/spec/unit/provider/package/paludis_spec.rb +5 -5
  193. data/spec/unit/provider/package/rpm_spec.rb +12 -0
  194. data/spec/unit/provider/package/zypper_spec.rb +28 -16
  195. data/spec/unit/provider/service/windows_spec.rb +77 -17
  196. data/spec/unit/provider/user/dscl_spec.rb +659 -264
  197. data/spec/unit/provider/user/useradd_spec.rb +1 -0
  198. data/spec/unit/recipe_spec.rb +41 -0
  199. data/spec/unit/resource/scm_spec.rb +11 -0
  200. data/spec/unit/resource/user_spec.rb +4 -0
  201. data/spec/unit/resource/windows_service_spec.rb +46 -0
  202. data/spec/unit/resource_collection_spec.rb +33 -0
  203. data/spec/unit/resource_reporter_spec.rb +48 -0
  204. data/spec/unit/resource_spec.rb +9 -2
  205. data/spec/unit/role_spec.rb +6 -0
  206. data/spec/unit/version_constraint_spec.rb +28 -0
  207. metadata +61 -4
@@ -19,18 +19,11 @@ require 'support/shared/integration/integration_helper'
19
19
  require 'chef/knife/raw'
20
20
 
21
21
  describe 'knife common options' do
22
- extend IntegrationSupport
22
+ include IntegrationSupport
23
23
  include KnifeSupport
24
24
 
25
25
  when_the_repository "has a node" do
26
- file 'nodes/x.json', {}
27
-
28
- before(:each) do
29
- if ChefZero::RSpec.server
30
- ChefZero::RSpec.server.stop
31
- ChefZero::RSpec.server = nil
32
- end
33
- end
26
+ before { file 'nodes/x.json', {} }
34
27
 
35
28
  context 'When chef_zero.enabled is true' do
36
29
  before(:each) do
@@ -38,14 +31,14 @@ describe 'knife common options' do
38
31
  end
39
32
 
40
33
  it 'knife raw /nodes/x should retrieve the node' do
41
- knife('raw /nodes/x').should_succeed /"name": "x"/
34
+ knife('raw /nodes/x').should_succeed( /"name": "x"/ )
42
35
  end
43
36
 
44
37
  context 'And chef_zero.port is 9999' do
45
38
  before(:each) { Chef::Config.chef_zero.port = 9999 }
46
39
 
47
40
  it 'knife raw /nodes/x should retrieve the node' do
48
- knife('raw /nodes/x').should_succeed /"name": "x"/
41
+ knife('raw /nodes/x').should_succeed( /"name": "x"/ )
49
42
  Chef::Config.chef_server_url.should == 'http://localhost:9999'
50
43
  end
51
44
  end
@@ -55,12 +48,13 @@ describe 'knife common options' do
55
48
  before(:each) { Chef::Config.chef_zero.host = '0.0.0.0' }
56
49
 
57
50
  it 'knife raw /nodes/x should retrieve the role' do
58
- knife('raw /nodes/x').should_succeed /"name": "x"/
51
+ knife('raw /nodes/x').should_succeed( /"name": "x"/ )
59
52
  end
60
53
  end
61
54
 
62
55
  context 'and there is a private key' do
63
- file 'mykey.pem', <<EOM
56
+ before do
57
+ file 'mykey.pem', <<EOM
64
58
  -----BEGIN RSA PRIVATE KEY-----
65
59
  MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf
66
60
  0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk
@@ -89,23 +83,24 @@ syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
89
83
  +vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA=
90
84
  -----END RSA PRIVATE KEY-----
91
85
  EOM
86
+ end
92
87
 
93
88
  it 'knife raw /nodes/x should retrieve the node' do
94
- knife('raw /nodes/x').should_succeed /"name": "x"/
89
+ knife('raw /nodes/x').should_succeed( /"name": "x"/ )
95
90
  end
96
91
  end
97
92
  end
98
93
 
99
94
  it 'knife raw -z /nodes/x retrieves the node' do
100
- knife('raw -z /nodes/x').should_succeed /"name": "x"/
95
+ knife('raw -z /nodes/x').should_succeed( /"name": "x"/ )
101
96
  end
102
97
 
103
98
  it 'knife raw --local-mode /nodes/x retrieves the node' do
104
- knife('raw --local-mode /nodes/x').should_succeed /"name": "x"/
99
+ knife('raw --local-mode /nodes/x').should_succeed( /"name": "x"/ )
105
100
  end
106
101
 
107
102
  it 'knife raw -z --chef-zero-port=9999 /nodes/x retrieves the node' do
108
- knife('raw -z --chef-zero-port=9999 /nodes/x').should_succeed /"name": "x"/
103
+ knife('raw -z --chef-zero-port=9999 /nodes/x').should_succeed( /"name": "x"/ )
109
104
  Chef::Config.chef_server_url.should == 'http://localhost:9999'
110
105
  end
111
106
 
@@ -123,7 +118,7 @@ EOM
123
118
  end
124
119
 
125
120
  it 'knife raw -z /nodes/x retrieves the node' do
126
- knife('raw -z /nodes/x').should_succeed /"name": "x"/
121
+ knife('raw -z /nodes/x').should_succeed( /"name": "x"/ )
127
122
  expect(URI(Chef::Config.chef_server_url).port).to be > 8889
128
123
  end
129
124
  end
@@ -142,18 +137,18 @@ EOM
142
137
  end
143
138
 
144
139
  it 'knife raw -z --chef-zero-port=9999-20000 /nodes/x' do
145
- knife('raw -z --chef-zero-port=9999-20000 /nodes/x').should_succeed /"name": "x"/
140
+ knife('raw -z --chef-zero-port=9999-20000 /nodes/x').should_succeed( /"name": "x"/ )
146
141
  expect(URI(Chef::Config.chef_server_url).port).to be > 9999
147
142
  end
148
143
 
149
144
  it 'knife raw -z --chef-zero-port=9999-9999,19423' do
150
- knife('raw -z --chef-zero-port=9999-9999,19423 /nodes/x').should_succeed /"name": "x"/
145
+ knife('raw -z --chef-zero-port=9999-9999,19423 /nodes/x').should_succeed( /"name": "x"/ )
151
146
  expect(URI(Chef::Config.chef_server_url).port).to be == 19423
152
147
  end
153
148
  end
154
149
 
155
150
  it 'knife raw -z --chef-zero-port=9999 /nodes/x retrieves the node' do
156
- knife('raw -z --chef-zero-port=9999 /nodes/x').should_succeed /"name": "x"/
151
+ knife('raw -z --chef-zero-port=9999 /nodes/x').should_succeed( /"name": "x"/ )
157
152
  Chef::Config.chef_server_url.should == 'http://localhost:9999'
158
153
  end
159
154
  end
@@ -19,7 +19,7 @@ require 'support/shared/integration/integration_helper'
19
19
  require 'chef/mixin/shell_out'
20
20
 
21
21
  describe "Knife cookbook API integration with IPv6" do
22
- extend IntegrationSupport
22
+ include IntegrationSupport
23
23
  include Chef::Mixin::ShellOut
24
24
 
25
25
  when_the_chef_server "is bound to IPv6" do
@@ -100,8 +100,8 @@ END_CLIENT_RB
100
100
  end
101
101
 
102
102
  it "downloads the cookbook" do
103
- s = shell_out!("knife cookbook download apache2 #{knife_config_flag} -d #{cache_path}", :cwd => chef_dir)
104
- Dir["#{cache_path}/*"].map {|entry| File.basename(entry)}.should include("apache2-0.0.0")
103
+ shell_out!("knife cookbook download apache2 #{knife_config_flag} -d #{cache_path}", :cwd => chef_dir)
104
+ Dir["#{cache_path}/*"].map {|entry| File.basename(entry)}.should include("apache2-0.0.1")
105
105
  end
106
106
  end
107
107
 
@@ -21,7 +21,7 @@ require 'chef/knife/list'
21
21
  require 'chef/knife/raw'
22
22
 
23
23
  describe 'knife delete' do
24
- extend IntegrationSupport
24
+ include IntegrationSupport
25
25
  include KnifeSupport
26
26
 
27
27
  let :everything do
@@ -99,23 +99,27 @@ EOM
99
99
  end
100
100
 
101
101
  when_the_chef_server "has one of each thing" do
102
- client 'x', '{}'
103
- cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"' }
104
- data_bag 'x', { 'y' => '{}' }
105
- environment 'x', '{}'
106
- node 'x', '{}'
107
- role 'x', '{}'
108
- user 'x', '{}'
102
+ before do
103
+ client 'x', '{}'
104
+ cookbook 'x', '1.0.0'
105
+ data_bag 'x', { 'y' => '{}' }
106
+ environment 'x', '{}'
107
+ node 'x', '{}'
108
+ role 'x', '{}'
109
+ user 'x', '{}'
110
+ end
109
111
 
110
112
  when_the_repository 'also has one of each thing' do
111
- file 'clients/x.json', {}
112
- file 'cookbooks/x/metadata.rb', ''
113
- file 'data_bags/x/y.json', {}
114
- file 'environments/_default.json', {}
115
- file 'environments/x.json', {}
116
- file 'nodes/x.json', {}
117
- file 'roles/x.json', {}
118
- file 'users/x.json', {}
113
+ before do
114
+ file 'clients/x.json', {}
115
+ file 'cookbooks/x/metadata.rb', ''
116
+ file 'data_bags/x/y.json', {}
117
+ file 'environments/_default.json', {}
118
+ file 'environments/x.json', {}
119
+ file 'nodes/x.json', {}
120
+ file 'roles/x.json', {}
121
+ file 'users/x.json', {}
122
+ end
119
123
 
120
124
  it 'knife delete --both /cookbooks/x fails' do
121
125
  knife('delete --both /cookbooks/x').should_fail <<EOM
@@ -216,8 +220,11 @@ EOM
216
220
 
217
221
  # TODO delete empty data bag (particularly different on local side)
218
222
  context 'with an empty data bag on both' do
219
- data_bag 'empty', {}
220
- directory 'data_bags/empty'
223
+ before do
224
+ data_bag 'empty', {}
225
+ directory 'data_bags/empty'
226
+ end
227
+
221
228
  it 'knife delete --both /data_bags/empty fails but deletes local version' do
222
229
  knife('delete --both /data_bags/empty').should_fail <<EOM
223
230
  ERROR: /data_bags/empty (remote) must be deleted recursively! Pass -r to knife delete.
@@ -468,13 +475,15 @@ EOM
468
475
  end
469
476
 
470
477
  when_the_repository 'has only top-level directories' do
471
- directory 'clients'
472
- directory 'cookbooks'
473
- directory 'data_bags'
474
- directory 'environments'
475
- directory 'nodes'
476
- directory 'roles'
477
- directory 'users'
478
+ before do
479
+ directory 'clients'
480
+ directory 'cookbooks'
481
+ directory 'data_bags'
482
+ directory 'environments'
483
+ directory 'nodes'
484
+ directory 'roles'
485
+ directory 'users'
486
+ end
478
487
 
479
488
  it 'knife delete --both /cookbooks/x fails' do
480
489
  knife('delete --both /cookbooks/x').should_fail "ERROR: /cookbooks/x (remote) must be deleted recursively! Pass -r to knife delete.\n"
@@ -632,7 +641,7 @@ EOM
632
641
  end
633
642
 
634
643
  context 'and cwd is at the top level' do
635
- cwd '.'
644
+ before { cwd '.' }
636
645
  it 'knife delete fails' do
637
646
  knife('delete').should_fail "FATAL: Must specify at least one argument. If you want to delete everything in this directory, type \"knife delete --recurse .\"\n", :stdout => /USAGE/
638
647
  knife('list -Rf /').should_succeed <<EOM
@@ -673,14 +682,16 @@ EOM
673
682
 
674
683
  when_the_chef_server 'is empty' do
675
684
  when_the_repository 'has one of each thing' do
676
- file 'clients/x.json', {}
677
- file 'cookbooks/x/metadata.rb', ''
678
- file 'data_bags/x/y.json', {}
679
- file 'environments/_default.json', {}
680
- file 'environments/x.json', {}
681
- file 'nodes/x.json', {}
682
- file 'roles/x.json', {}
683
- file 'users/x.json', {}
685
+ before do
686
+ file 'clients/x.json', {}
687
+ file 'cookbooks/x/metadata.rb', ''
688
+ file 'data_bags/x/y.json', {}
689
+ file 'environments/_default.json', {}
690
+ file 'environments/x.json', {}
691
+ file 'nodes/x.json', {}
692
+ file 'roles/x.json', {}
693
+ file 'users/x.json', {}
694
+ end
684
695
 
685
696
  it 'knife delete --both /cookbooks/x fails' do
686
697
  knife('delete --both /cookbooks/x').should_fail "ERROR: /cookbooks/x (local) must be deleted recursively! Pass -r to knife delete.\n"
@@ -843,7 +854,7 @@ EOM
843
854
  end
844
855
 
845
856
  context 'and cwd is at the top level' do
846
- cwd '.'
857
+ before { cwd '.' }
847
858
  it 'knife delete fails' do
848
859
  knife('delete').should_fail "FATAL: Must specify at least one argument. If you want to delete everything in this directory, type \"knife delete --recurse .\"\n", :stdout => /USAGE/
849
860
  knife('list -Rf /').should_succeed <<EOM
@@ -884,12 +895,16 @@ EOM
884
895
  end
885
896
 
886
897
  when_the_repository 'has a cookbook' do
887
- file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
888
- file 'cookbooks/x/onlyin1.0.0.rb', 'old_text'
898
+ before do
899
+ file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
900
+ file 'cookbooks/x/onlyin1.0.0.rb', 'old_text'
901
+ end
889
902
 
890
903
  when_the_chef_server 'has a later version for the cookbook' do
891
- cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"', 'onlyin1.0.0.rb' => '' }
892
- cookbook 'x', '1.0.1', { 'metadata.rb' => 'version "1.0.1"', 'onlyin1.0.1.rb' => 'hi' }
904
+ before do
905
+ cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' }
906
+ cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' }
907
+ end
893
908
 
894
909
  # TODO this seems wrong
895
910
  it 'knife delete --both -r /cookbooks/x deletes the latest version on the server and the local version' do
@@ -900,8 +915,10 @@ EOM
900
915
  end
901
916
 
902
917
  when_the_chef_server 'has an earlier version for the cookbook' do
903
- cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"', 'onlyin1.0.0.rb' => ''}
904
- cookbook 'x', '0.9.9', { 'metadata.rb' => 'version "0.9.9"', 'onlyin0.9.9.rb' => 'hi' }
918
+ before do
919
+ cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''}
920
+ cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' }
921
+ end
905
922
 
906
923
  it 'knife delete --both /cookbooks/x deletes the latest version on the server and the local version' do
907
924
  knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n"
@@ -911,7 +928,7 @@ EOM
911
928
  end
912
929
 
913
930
  when_the_chef_server 'has a later version for the cookbook, and no current version' do
914
- cookbook 'x', '1.0.1', { 'metadata.rb' => 'version "1.0.1"', 'onlyin1.0.1.rb' => 'hi' }
931
+ before { cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } }
915
932
 
916
933
  it 'knife delete --both /cookbooks/x deletes the server and client version of the cookbook' do
917
934
  knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n"
@@ -921,7 +938,7 @@ EOM
921
938
  end
922
939
 
923
940
  when_the_chef_server 'has an earlier version for the cookbook, and no current version' do
924
- cookbook 'x', '0.9.9', { 'metadata.rb' => 'version "0.9.9"', 'onlyin0.9.9.rb' => 'hi' }
941
+ before { cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } }
925
942
 
926
943
  it 'knife delete --both /cookbooks/x deletes the server and client version of the cookbook' do
927
944
  knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n"
@@ -933,11 +950,14 @@ EOM
933
950
 
934
951
  when_the_repository 'is empty' do
935
952
  when_the_chef_server 'has two versions of a cookbook' do
936
- cookbook 'x', '2.0.11', { 'metadata.rb' => 'version "2.0.11"' }
937
- cookbook 'x', '11.0.0', { 'metadata.rb' => 'version "11.0.0"' }
953
+ before do
954
+ cookbook 'x', '2.0.11'
955
+ cookbook 'x', '11.0.0'
956
+ end
957
+
938
958
  it 'knife delete deletes the latest version' do
939
959
  knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n"
940
- knife('raw /cookbooks/x').should_succeed /2.0.11/
960
+ knife('raw /cookbooks/x').should_succeed( /2.0.11/ )
941
961
  end
942
962
  end
943
963
  end
@@ -20,24 +20,26 @@ require 'support/shared/context/config'
20
20
  require 'chef/knife/deps'
21
21
 
22
22
  describe 'knife deps' do
23
- extend IntegrationSupport
23
+ include IntegrationSupport
24
24
  include KnifeSupport
25
25
 
26
26
  context 'local' do
27
27
  when_the_repository 'has a role with no run_list' do
28
- file 'roles/starring.json', {}
28
+ before { file 'roles/starring.json', {} }
29
29
  it 'knife deps reports no dependencies' do
30
30
  knife('deps /roles/starring.json').should_succeed "/roles/starring.json\n"
31
31
  end
32
32
  end
33
33
 
34
34
  when_the_repository 'has a role with a default run_list' do
35
- file 'roles/starring.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
36
- file 'roles/minor.json', {}
37
- file 'cookbooks/quiche/metadata.rb', 'name "quiche"'
38
- file 'cookbooks/quiche/recipes/default.rb', ''
39
- file 'cookbooks/soup/metadata.rb', 'name "soup"'
40
- file 'cookbooks/soup/recipes/chicken.rb', ''
35
+ before do
36
+ file 'roles/starring.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
37
+ file 'roles/minor.json', {}
38
+ file 'cookbooks/quiche/metadata.rb', 'name "quiche"'
39
+ file 'cookbooks/quiche/recipes/default.rb', ''
40
+ file 'cookbooks/soup/metadata.rb', 'name "soup"'
41
+ file 'cookbooks/soup/recipes/chicken.rb', ''
42
+ end
41
43
  it 'knife deps reports all dependencies' do
42
44
  knife('deps /roles/starring.json').should_succeed <<EOM
43
45
  /roles/minor.json
@@ -49,12 +51,14 @@ EOM
49
51
  end
50
52
 
51
53
  when_the_repository 'has a role with an env_run_list' do
52
- file 'roles/starring.json', { 'env_run_lists' => { 'desert' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } }
53
- file 'roles/minor.json', {}
54
- file 'cookbooks/quiche/metadata.rb', 'name "quiche"'
55
- file 'cookbooks/quiche/recipes/default.rb', ''
56
- file 'cookbooks/soup/metadata.rb', 'name "soup"'
57
- file 'cookbooks/soup/recipes/chicken.rb', ''
54
+ before do
55
+ file 'roles/starring.json', { 'env_run_lists' => { 'desert' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } }
56
+ file 'roles/minor.json', {}
57
+ file 'cookbooks/quiche/metadata.rb', 'name "quiche"'
58
+ file 'cookbooks/quiche/recipes/default.rb', ''
59
+ file 'cookbooks/soup/metadata.rb', 'name "soup"'
60
+ file 'cookbooks/soup/recipes/chicken.rb', ''
61
+ end
58
62
  it 'knife deps reports all dependencies' do
59
63
  knife('deps /roles/starring.json').should_succeed <<EOM
60
64
  /roles/minor.json
@@ -66,25 +70,29 @@ EOM
66
70
  end
67
71
 
68
72
  when_the_repository 'has a node with no environment or run_list' do
69
- file 'nodes/mort.json', {}
73
+ before { file 'nodes/mort.json', {} }
70
74
  it 'knife deps reports just the node' do
71
75
  knife('deps /nodes/mort.json').should_succeed "/nodes/mort.json\n"
72
76
  end
73
77
  end
74
78
  when_the_repository 'has a node with an environment' do
75
- file 'environments/desert.json', {}
76
- file 'nodes/mort.json', { 'chef_environment' => 'desert' }
79
+ before do
80
+ file 'environments/desert.json', {}
81
+ file 'nodes/mort.json', { 'chef_environment' => 'desert' }
82
+ end
77
83
  it 'knife deps reports just the node' do
78
84
  knife('deps /nodes/mort.json').should_succeed "/environments/desert.json\n/nodes/mort.json\n"
79
85
  end
80
86
  end
81
87
  when_the_repository 'has a node with roles and recipes in its run_list' do
82
- file 'roles/minor.json', {}
83
- file 'cookbooks/quiche/metadata.rb', 'name "quiche"'
84
- file 'cookbooks/quiche/recipes/default.rb', ''
85
- file 'cookbooks/soup/metadata.rb', 'name "soup"'
86
- file 'cookbooks/soup/recipes/chicken.rb', ''
87
- file 'nodes/mort.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
88
+ before do
89
+ file 'roles/minor.json', {}
90
+ file 'cookbooks/quiche/metadata.rb', 'name "quiche"'
91
+ file 'cookbooks/quiche/recipes/default.rb', ''
92
+ file 'cookbooks/soup/metadata.rb', 'name "soup"'
93
+ file 'cookbooks/soup/recipes/chicken.rb', ''
94
+ file 'nodes/mort.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
95
+ end
88
96
  it 'knife deps reports just the node' do
89
97
  knife('deps /nodes/mort.json').should_succeed <<EOM
90
98
  /roles/minor.json
@@ -95,42 +103,48 @@ EOM
95
103
  end
96
104
  end
97
105
  when_the_repository 'has a cookbook with no dependencies' do
98
- file 'cookbooks/quiche/metadata.rb', 'name "quiche"'
99
- file 'cookbooks/quiche/recipes/default.rb', ''
106
+ before do
107
+ file 'cookbooks/quiche/metadata.rb', 'name "quiche"'
108
+ file 'cookbooks/quiche/recipes/default.rb', ''
109
+ end
100
110
  it 'knife deps reports just the cookbook' do
101
111
  knife('deps /cookbooks/quiche').should_succeed "/cookbooks/quiche\n"
102
112
  end
103
113
  end
104
114
  when_the_repository 'has a cookbook with dependencies' do
105
- file 'cookbooks/kettle/metadata.rb', 'name "kettle"'
106
- file 'cookbooks/quiche/metadata.rb', "name 'quiche'\ndepends 'kettle'\n"
107
- file 'cookbooks/quiche/recipes/default.rb', ''
115
+ before do
116
+ file 'cookbooks/kettle/metadata.rb', 'name "kettle"'
117
+ file 'cookbooks/quiche/metadata.rb', "name 'quiche'\ndepends 'kettle'\n"
118
+ file 'cookbooks/quiche/recipes/default.rb', ''
119
+ end
108
120
  it 'knife deps reports just the cookbook' do
109
121
  knife('deps /cookbooks/quiche').should_succeed "/cookbooks/kettle\n/cookbooks/quiche\n"
110
122
  end
111
123
  end
112
124
  when_the_repository 'has a data bag' do
113
- file 'data_bags/bag/item.json', {}
125
+ before { file 'data_bags/bag/item.json', {} }
114
126
  it 'knife deps reports just the data bag' do
115
127
  knife('deps /data_bags/bag/item.json').should_succeed "/data_bags/bag/item.json\n"
116
128
  end
117
129
  end
118
130
  when_the_repository 'has an environment' do
119
- file 'environments/desert.json', {}
131
+ before { file 'environments/desert.json', {} }
120
132
  it 'knife deps reports just the environment' do
121
133
  knife('deps /environments/desert.json').should_succeed "/environments/desert.json\n"
122
134
  end
123
135
  end
124
136
  when_the_repository 'has a deep dependency tree' do
125
- file 'roles/starring.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
126
- file 'roles/minor.json', {}
127
- file 'cookbooks/quiche/metadata.rb', 'name "quiche"'
128
- file 'cookbooks/quiche/recipes/default.rb', ''
129
- file 'cookbooks/soup/metadata.rb', 'name "soup"'
130
- file 'cookbooks/soup/recipes/chicken.rb', ''
131
- file 'environments/desert.json', {}
132
- file 'nodes/mort.json', { 'chef_environment' => 'desert', 'run_list' => [ 'role[starring]' ] }
133
- file 'nodes/bart.json', { 'run_list' => [ 'role[minor]' ] }
137
+ before do
138
+ file 'roles/starring.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
139
+ file 'roles/minor.json', {}
140
+ file 'cookbooks/quiche/metadata.rb', 'name "quiche"'
141
+ file 'cookbooks/quiche/recipes/default.rb', ''
142
+ file 'cookbooks/soup/metadata.rb', 'name "soup"'
143
+ file 'cookbooks/soup/recipes/chicken.rb', ''
144
+ file 'environments/desert.json', {}
145
+ file 'nodes/mort.json', { 'chef_environment' => 'desert', 'run_list' => [ 'role[starring]' ] }
146
+ file 'nodes/bart.json', { 'run_list' => [ 'role[minor]' ] }
147
+ end
134
148
 
135
149
  it 'knife deps reports all dependencies' do
136
150
  knife('deps /nodes/mort.json').should_succeed <<EOM
@@ -189,10 +203,13 @@ EOM
189
203
 
190
204
  context 'circular dependencies' do
191
205
  when_the_repository 'has cookbooks with circular dependencies' do
192
- file 'cookbooks/foo/metadata.rb', "name 'foo'\ndepends 'bar'\n"
193
- file 'cookbooks/bar/metadata.rb', "name 'bar'\ndepends 'baz'\n"
194
- file 'cookbooks/baz/metadata.rb', "name 'baz'\ndepends 'foo'\n"
195
- file 'cookbooks/self/metadata.rb', "name 'self'\ndepends 'self'\n"
206
+ before do
207
+ file 'cookbooks/foo/metadata.rb', "name 'foo'\ndepends 'bar'\n"
208
+ file 'cookbooks/bar/metadata.rb', "name 'bar'\ndepends 'baz'\n"
209
+ file 'cookbooks/baz/metadata.rb', "name 'baz'\ndepends 'foo'\n"
210
+ file 'cookbooks/self/metadata.rb', "name 'self'\ndepends 'self'\n"
211
+ end
212
+
196
213
  it 'knife deps prints each once' do
197
214
  knife('deps /cookbooks/foo /cookbooks/self').should_succeed <<EOM
198
215
  /cookbooks/baz
@@ -213,10 +230,12 @@ EOM
213
230
  end
214
231
  end
215
232
  when_the_repository 'has roles with circular dependencies' do
216
- file 'roles/foo.json', { 'run_list' => [ 'role[bar]' ] }
217
- file 'roles/bar.json', { 'run_list' => [ 'role[baz]' ] }
218
- file 'roles/baz.json', { 'run_list' => [ 'role[foo]' ] }
219
- file 'roles/self.json', { 'run_list' => [ 'role[self]' ] }
233
+ before do
234
+ file 'roles/foo.json', { 'run_list' => [ 'role[bar]' ] }
235
+ file 'roles/bar.json', { 'run_list' => [ 'role[baz]' ] }
236
+ file 'roles/baz.json', { 'run_list' => [ 'role[foo]' ] }
237
+ file 'roles/self.json', { 'run_list' => [ 'role[self]' ] }
238
+ end
220
239
  it 'knife deps prints each once' do
221
240
  knife('deps /roles/foo.json /roles/self.json').should_succeed <<EOM
222
241
  /roles/baz.json
@@ -280,7 +299,9 @@ EOM
280
299
  end
281
300
  end
282
301
  when_the_repository 'is missing a dependent cookbook' do
283
- file 'roles/starring.json', { 'run_list' => [ 'recipe[quiche]'] }
302
+ before do
303
+ file 'roles/starring.json', { 'run_list' => [ 'recipe[quiche]'] }
304
+ end
284
305
  it 'knife deps reports the cookbook, along with an error' do
285
306
  knife('deps /roles/starring.json').should_fail(
286
307
  :exit_code => 2,
@@ -290,7 +311,9 @@ EOM
290
311
  end
291
312
  end
292
313
  when_the_repository 'is missing a dependent environment' do
293
- file 'nodes/mort.json', { 'chef_environment' => 'desert' }
314
+ before do
315
+ file 'nodes/mort.json', { 'chef_environment' => 'desert' }
316
+ end
294
317
  it 'knife deps reports the environment, along with an error' do
295
318
  knife('deps /nodes/mort.json').should_fail(
296
319
  :exit_code => 2,
@@ -300,7 +323,9 @@ EOM
300
323
  end
301
324
  end
302
325
  when_the_repository 'is missing a dependent role' do
303
- file 'roles/starring.json', { 'run_list' => [ 'role[minor]'] }
326
+ before do
327
+ file 'roles/starring.json', { 'run_list' => [ 'role[minor]'] }
328
+ end
304
329
  it 'knife deps reports the role, along with an error' do
305
330
  knife('deps /roles/starring.json').should_fail(
306
331
  :exit_code => 2,
@@ -324,13 +349,13 @@ EOM
324
349
  end
325
350
  end
326
351
  when_the_repository 'has a data bag' do
327
- file 'data_bags/bag/item.json', ''
352
+ before { file 'data_bags/bag/item.json', '' }
328
353
  it 'knife deps /data_bags/bag shows no dependencies' do
329
354
  knife('deps /data_bags/bag').should_succeed("/data_bags/bag\n")
330
355
  end
331
356
  end
332
357
  when_the_repository 'has a cookbook' do
333
- file 'cookbooks/blah/metadata.rb', 'name "blah"'
358
+ before { file 'cookbooks/blah/metadata.rb', 'name "blah"' }
334
359
  it 'knife deps on a cookbook file shows no dependencies' do
335
360
  knife('deps /cookbooks/blah/metadata.rb').should_succeed(
336
361
  "/cookbooks/blah/metadata.rb\n"
@@ -342,19 +367,21 @@ EOM
342
367
 
343
368
  context 'remote' do
344
369
  include_context "default config options"
345
-
370
+
346
371
  when_the_chef_server 'has a role with no run_list' do
347
- role 'starring', {}
372
+ before { role 'starring', {} }
348
373
  it 'knife deps reports no dependencies' do
349
374
  knife('deps --remote /roles/starring.json').should_succeed "/roles/starring.json\n"
350
375
  end
351
376
  end
352
377
 
353
378
  when_the_chef_server 'has a role with a default run_list' do
354
- role 'starring', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
355
- role 'minor', {}
356
- cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\nversion '1.0.0'\n", 'recipes' => { 'default.rb' => '' } }
357
- cookbook 'soup', '1.0.0', { 'metadata.rb' => "name 'soup'\nversion '1.0.0'\n", 'recipes' => { 'chicken.rb' => '' } }
379
+ before do
380
+ role 'starring', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
381
+ role 'minor', {}
382
+ cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\nversion '1.0.0'\n", 'recipes' => { 'default.rb' => '' } }
383
+ cookbook 'soup', '1.0.0', { 'metadata.rb' => "name 'soup'\nversion '1.0.0'\n", 'recipes' => { 'chicken.rb' => '' } }
384
+ end
358
385
  it 'knife deps reports all dependencies' do
359
386
  knife('deps --remote /roles/starring.json').should_succeed <<EOM
360
387
  /roles/minor.json
@@ -366,10 +393,12 @@ EOM
366
393
  end
367
394
 
368
395
  when_the_chef_server 'has a role with an env_run_list' do
369
- role 'starring', { 'env_run_lists' => { 'desert' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } }
370
- role 'minor', {}
371
- cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\nversion '1.0.0'\n", 'recipes' => { 'default.rb' => '' } }
372
- cookbook 'soup', '1.0.0', { 'metadata.rb' => "name 'soup'\nversion '1.0.0'\n", 'recipes' => { 'chicken.rb' => '' } }
396
+ before do
397
+ role 'starring', { 'env_run_lists' => { 'desert' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } }
398
+ role 'minor', {}
399
+ cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\nversion '1.0.0'\n", 'recipes' => { 'default.rb' => '' } }
400
+ cookbook 'soup', '1.0.0', { 'metadata.rb' => "name 'soup'\nversion '1.0.0'\n", 'recipes' => { 'chicken.rb' => '' } }
401
+ end
373
402
  it 'knife deps reports all dependencies' do
374
403
  knife('deps --remote /roles/starring.json').should_succeed <<EOM
375
404
  /roles/minor.json
@@ -381,23 +410,27 @@ EOM
381
410
  end
382
411
 
383
412
  when_the_chef_server 'has a node with no environment or run_list' do
384
- node 'mort', {}
413
+ before { node 'mort', {} }
385
414
  it 'knife deps reports just the node' do
386
415
  knife('deps --remote /nodes/mort.json').should_succeed "/nodes/mort.json\n"
387
416
  end
388
417
  end
389
418
  when_the_chef_server 'has a node with an environment' do
390
- environment 'desert', {}
391
- node 'mort', { 'chef_environment' => 'desert' }
419
+ before do
420
+ environment 'desert', {}
421
+ node 'mort', { 'chef_environment' => 'desert' }
422
+ end
392
423
  it 'knife deps reports just the node' do
393
424
  knife('deps --remote /nodes/mort.json').should_succeed "/environments/desert.json\n/nodes/mort.json\n"
394
425
  end
395
426
  end
396
427
  when_the_chef_server 'has a node with roles and recipes in its run_list' do
397
- role 'minor', {}
398
- cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\nversion '1.0.0'\n", 'recipes' => { 'default.rb' => '' } }
399
- cookbook 'soup', '1.0.0', { 'metadata.rb' => "name 'soup'\nversion '1.0.0'\n", 'recipes' => { 'chicken.rb' => '' } }
400
- node 'mort', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
428
+ before do
429
+ role 'minor', {}
430
+ cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\nversion '1.0.0'\n", 'recipes' => { 'default.rb' => '' } }
431
+ cookbook 'soup', '1.0.0', { 'metadata.rb' => "name 'soup'\nversion '1.0.0'\n", 'recipes' => { 'chicken.rb' => '' } }
432
+ node 'mort', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
433
+ end
401
434
  it 'knife deps reports just the node' do
402
435
  knife('deps --remote /nodes/mort.json').should_succeed <<EOM
403
436
  /roles/minor.json
@@ -408,38 +441,44 @@ EOM
408
441
  end
409
442
  end
410
443
  when_the_chef_server 'has a cookbook with no dependencies' do
411
- cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\nversion '1.0.0'\n", 'recipes' => { 'default.rb' => '' } }
444
+ before do
445
+ cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\nversion '1.0.0'\n", 'recipes' => { 'default.rb' => '' } }
446
+ end
412
447
  it 'knife deps reports just the cookbook' do
413
448
  knife('deps --remote /cookbooks/quiche').should_succeed "/cookbooks/quiche\n"
414
449
  end
415
450
  end
416
451
  when_the_chef_server 'has a cookbook with dependencies' do
417
- cookbook 'kettle', '1.0.0', { 'metadata.rb' => "name 'kettle'\nversion '1.0.0'\n" }
418
- cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\ndepends 'kettle'\n", 'recipes' => { 'default.rb' => '' } }
452
+ before do
453
+ cookbook 'kettle', '1.0.0', { 'metadata.rb' => "name 'kettle'\nversion '1.0.0'\n" }
454
+ cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\ndepends 'kettle'\n", 'recipes' => { 'default.rb' => '' } }
455
+ end
419
456
  it 'knife deps reports the cookbook and its dependencies' do
420
457
  knife('deps --remote /cookbooks/quiche').should_succeed "/cookbooks/kettle\n/cookbooks/quiche\n"
421
458
  end
422
459
  end
423
460
  when_the_chef_server 'has a data bag' do
424
- data_bag 'bag', { 'item' => {} }
461
+ before { data_bag 'bag', { 'item' => {} } }
425
462
  it 'knife deps reports just the data bag' do
426
463
  knife('deps --remote /data_bags/bag/item.json').should_succeed "/data_bags/bag/item.json\n"
427
464
  end
428
465
  end
429
466
  when_the_chef_server 'has an environment' do
430
- environment 'desert', {}
467
+ before { environment 'desert', {} }
431
468
  it 'knife deps reports just the environment' do
432
469
  knife('deps --remote /environments/desert.json').should_succeed "/environments/desert.json\n"
433
470
  end
434
471
  end
435
472
  when_the_chef_server 'has a deep dependency tree' do
436
- role 'starring', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
437
- role 'minor', {}
438
- cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\nversion '1.0.0'\n", 'recipes' => { 'default.rb' => '' } }
439
- cookbook 'soup', '1.0.0', { 'metadata.rb' => "name 'soup'\nversion '1.0.0'\n", 'recipes' => { 'chicken.rb' => '' } }
440
- environment 'desert', {}
441
- node 'mort', { 'chef_environment' => 'desert', 'run_list' => [ 'role[starring]' ] }
442
- node 'bart', { 'run_list' => [ 'role[minor]' ] }
473
+ before do
474
+ role 'starring', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
475
+ role 'minor', {}
476
+ cookbook 'quiche', '1.0.0', { 'metadata.rb' => "name 'quiche'\nversion '1.0.0'\n", 'recipes' => { 'default.rb' => '' } }
477
+ cookbook 'soup', '1.0.0', { 'metadata.rb' => "name 'soup'\nversion '1.0.0'\n", 'recipes' => { 'chicken.rb' => '' } }
478
+ environment 'desert', {}
479
+ node 'mort', { 'chef_environment' => 'desert', 'run_list' => [ 'role[starring]' ] }
480
+ node 'bart', { 'run_list' => [ 'role[minor]' ] }
481
+ end
443
482
 
444
483
  it 'knife deps reports all dependencies' do
445
484
  knife('deps --remote /nodes/mort.json').should_succeed <<EOM
@@ -498,10 +537,12 @@ EOM
498
537
 
499
538
  context 'circular dependencies' do
500
539
  when_the_chef_server 'has cookbooks with circular dependencies' do
501
- cookbook 'foo', '1.0.0', { 'metadata.rb' => "name 'foo'\ndepends 'bar'\n" }
502
- cookbook 'bar', '1.0.0', { 'metadata.rb' => "name 'bar'\ndepends 'baz'\n" }
503
- cookbook 'baz', '1.0.0', { 'metadata.rb' => "name 'baz'\ndepends 'foo'\n" }
504
- cookbook 'self', '1.0.0', { 'metadata.rb' => "name 'self'\ndepends 'self'\n" }
540
+ before do
541
+ cookbook 'foo', '1.0.0', { 'metadata.rb' => "name 'foo'\ndepends 'bar'\n" }
542
+ cookbook 'bar', '1.0.0', { 'metadata.rb' => "name 'bar'\ndepends 'baz'\n" }
543
+ cookbook 'baz', '1.0.0', { 'metadata.rb' => "name 'baz'\ndepends 'foo'\n" }
544
+ cookbook 'self', '1.0.0', { 'metadata.rb' => "name 'self'\ndepends 'self'\n" }
545
+ end
505
546
  it 'knife deps prints each once' do
506
547
  knife('deps --remote /cookbooks/foo /cookbooks/self').should_succeed <<EOM
507
548
  /cookbooks/baz
@@ -522,10 +563,12 @@ EOM
522
563
  end
523
564
  end
524
565
  when_the_chef_server 'has roles with circular dependencies' do
525
- role 'foo', { 'run_list' => [ 'role[bar]' ] }
526
- role 'bar', { 'run_list' => [ 'role[baz]' ] }
527
- role 'baz', { 'run_list' => [ 'role[foo]' ] }
528
- role 'self', { 'run_list' => [ 'role[self]' ] }
566
+ before do
567
+ role 'foo', { 'run_list' => [ 'role[bar]' ] }
568
+ role 'bar', { 'run_list' => [ 'role[baz]' ] }
569
+ role 'baz', { 'run_list' => [ 'role[foo]' ] }
570
+ role 'self', { 'run_list' => [ 'role[self]' ] }
571
+ end
529
572
  it 'knife deps prints each once' do
530
573
  knife('deps --remote /roles/foo.json /roles/self.json').should_succeed <<EOM
531
574
  /roles/baz.json
@@ -589,7 +632,9 @@ EOM
589
632
  end
590
633
  end
591
634
  when_the_chef_server 'is missing a dependent cookbook' do
592
- role 'starring', { 'run_list' => [ 'recipe[quiche]'] }
635
+ before do
636
+ role 'starring', { 'run_list' => [ 'recipe[quiche]'] }
637
+ end
593
638
  it 'knife deps reports the cookbook, along with an error' do
594
639
  knife('deps --remote /roles/starring.json').should_fail(
595
640
  :exit_code => 2,
@@ -599,7 +644,9 @@ EOM
599
644
  end
600
645
  end
601
646
  when_the_chef_server 'is missing a dependent environment' do
602
- node 'mort', { 'chef_environment' => 'desert' }
647
+ before do
648
+ node 'mort', { 'chef_environment' => 'desert' }
649
+ end
603
650
  it 'knife deps reports the environment, along with an error' do
604
651
  knife('deps --remote /nodes/mort.json').should_fail(
605
652
  :exit_code => 2,
@@ -609,7 +656,9 @@ EOM
609
656
  end
610
657
  end
611
658
  when_the_chef_server 'is missing a dependent role' do
612
- role 'starring', { 'run_list' => [ 'role[minor]'] }
659
+ before do
660
+ role 'starring', { 'run_list' => [ 'role[minor]'] }
661
+ end
613
662
  it 'knife deps reports the role, along with an error' do
614
663
  knife('deps --remote /roles/starring.json').should_fail(
615
664
  :exit_code => 2,
@@ -629,13 +678,15 @@ EOM
629
678
  end
630
679
  end
631
680
  when_the_chef_server 'has a data bag' do
632
- data_bag 'bag', { 'item' => {} }
681
+ before { data_bag 'bag', { 'item' => {} } }
633
682
  it 'knife deps /data_bags/bag shows no dependencies' do
634
683
  knife('deps --remote /data_bags/bag').should_succeed("/data_bags/bag\n")
635
684
  end
636
685
  end
637
686
  when_the_chef_server 'has a cookbook' do
638
- cookbook 'blah', '1.0.0', { 'metadata.rb' => 'name "blah"' }
687
+ before do
688
+ cookbook 'blah', '1.0.0', { 'metadata.rb' => 'name "blah"' }
689
+ end
639
690
  it 'knife deps on a cookbook file shows no dependencies' do
640
691
  knife('deps --remote /cookbooks/blah/metadata.rb').should_succeed(
641
692
  "/cookbooks/blah/metadata.rb\n"