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
@@ -20,14 +20,16 @@ require 'chef/knife/list'
20
20
  require 'chef/knife/show'
21
21
 
22
22
  describe 'General chef_repo file system checks' do
23
- extend IntegrationSupport
23
+ include IntegrationSupport
24
24
  include KnifeSupport
25
25
 
26
26
  context 'directories and files that should/should not be ignored' do
27
27
  when_the_repository "has empty roles, environments and data bag item directories" do
28
- directory "roles"
29
- directory "environments"
30
- directory "data_bags/bag1"
28
+ before do
29
+ directory "roles"
30
+ directory "environments"
31
+ directory "data_bags/bag1"
32
+ end
31
33
 
32
34
  it "knife list --local -Rfp / returns them" do
33
35
  knife('list --local -Rfp /').should_succeed <<EOM
@@ -40,7 +42,7 @@ EOM
40
42
  end
41
43
 
42
44
  when_the_repository "has an empty data_bags directory" do
43
- directory "data_bags"
45
+ before { directory "data_bags" }
44
46
 
45
47
  it "knife list --local / returns it" do
46
48
  knife('list --local /').should_succeed "/data_bags\n"
@@ -48,7 +50,7 @@ EOM
48
50
  end
49
51
 
50
52
  when_the_repository "has an empty cookbook directory" do
51
- directory 'cookbooks/cookbook1'
53
+ before { directory 'cookbooks/cookbook1' }
52
54
 
53
55
  it "knife list --local -Rfp / does not return it" do
54
56
  knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
@@ -58,7 +60,7 @@ EOM
58
60
  end
59
61
 
60
62
  when_the_repository "has only empty cookbook subdirectories" do
61
- directory 'cookbooks/cookbook1/recipes'
63
+ before { directory 'cookbooks/cookbook1/recipes' }
62
64
 
63
65
  it "knife list --local -Rfp / does not return it" do
64
66
  knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
@@ -68,8 +70,10 @@ EOM
68
70
  end
69
71
 
70
72
  when_the_repository "has empty and non-empty cookbook subdirectories" do
71
- directory 'cookbooks/cookbook1/recipes'
72
- file 'cookbooks/cookbook1/templates/default/x.txt', ''
73
+ before do
74
+ directory 'cookbooks/cookbook1/recipes'
75
+ file 'cookbooks/cookbook1/templates/default/x.txt', ''
76
+ end
73
77
 
74
78
  it "knife list --local -Rfp / does not return the empty ones" do
75
79
  knife('list --local -Rfp /').should_succeed <<EOM
@@ -83,7 +87,7 @@ EOM
83
87
  end
84
88
 
85
89
  when_the_repository "has only empty cookbook sub-sub-directories" do
86
- directory 'cookbooks/cookbook1/templates/default'
90
+ before { directory 'cookbooks/cookbook1/templates/default' }
87
91
 
88
92
  it "knife list --local -Rfp / does not return it" do
89
93
  knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
@@ -93,9 +97,11 @@ EOM
93
97
  end
94
98
 
95
99
  when_the_repository "has empty cookbook sub-sub-directories alongside non-empty ones" do
96
- file 'cookbooks/cookbook1/templates/default/x.txt', ''
97
- directory 'cookbooks/cookbook1/templates/rhel'
98
- directory 'cookbooks/cookbook1/files/default'
100
+ before do
101
+ file 'cookbooks/cookbook1/templates/default/x.txt', ''
102
+ directory 'cookbooks/cookbook1/templates/rhel'
103
+ directory 'cookbooks/cookbook1/files/default'
104
+ end
99
105
 
100
106
  it "knife list --local -Rfp / does not return the empty ones" do
101
107
  knife('list --local -Rfp /').should_succeed <<EOM
@@ -109,8 +115,10 @@ EOM
109
115
  end
110
116
 
111
117
  when_the_repository "has an extra schmenvironments directory" do
112
- directory "schmenvironments" do
113
- file "_default.json", {}
118
+ before do
119
+ directory "schmenvironments" do
120
+ file "_default.json", {}
121
+ end
114
122
  end
115
123
 
116
124
  it "knife list --local -Rfp / should NOT return it" do
@@ -119,20 +127,22 @@ EOM
119
127
  end
120
128
 
121
129
  when_the_repository "has extra subdirectories and files under data bag items, roles, and environments" do
122
- directory "data_bags/bag1" do
123
- file "item1.json", {}
124
- file "item2.xml", ""
125
- file "another_subdir/item.json", {}
126
- end
127
- directory "roles" do
128
- file "role1.json", {}
129
- file "role2.xml", ""
130
- file "subdir/role.json", {}
131
- end
132
- directory "environments" do
133
- file "environment1.json", {}
134
- file "environment2.xml", ""
135
- file "subdir/environment.json", {}
130
+ before do
131
+ directory "data_bags/bag1" do
132
+ file "item1.json", {}
133
+ file "item2.xml", ""
134
+ file "another_subdir/item.json", {}
135
+ end
136
+ directory "roles" do
137
+ file "role1.json", {}
138
+ file "role2.xml", ""
139
+ file "subdir/role.json", {}
140
+ end
141
+ directory "environments" do
142
+ file "environment1.json", {}
143
+ file "environment2.xml", ""
144
+ file "subdir/environment.json", {}
145
+ end
136
146
  end
137
147
 
138
148
  it "knife list --local -Rfp / should NOT return them" do
@@ -149,56 +159,58 @@ EOM
149
159
  end
150
160
 
151
161
  when_the_repository "has extraneous subdirectories and files under a cookbook" do
152
- directory 'cookbooks/cookbook1' do
153
- file 'a.rb', ''
154
- file 'blarghle/blah.rb', ''
155
- directory 'attributes' do
156
- file 'a.rb', ''
157
- file 'b.json', {}
158
- file 'c/d.rb', ''
159
- file 'c/e.json', {}
160
- end
161
- directory 'definitions' do
162
- file 'a.rb', ''
163
- file 'b.json', {}
164
- file 'c/d.rb', ''
165
- file 'c/e.json', {}
166
- end
167
- directory 'recipes' do
162
+ before do
163
+ directory 'cookbooks/cookbook1' do
168
164
  file 'a.rb', ''
169
- file 'b.json', {}
170
- file 'c/d.rb', ''
171
- file 'c/e.json', {}
172
- end
173
- directory 'libraries' do
174
- file 'a.rb', ''
175
- file 'b.json', {}
176
- file 'c/d.rb', ''
177
- file 'c/e.json', {}
178
- end
179
- directory 'templates' do
180
- file 'a.rb', ''
181
- file 'b.json', {}
182
- file 'c/d.rb', ''
183
- file 'c/e.json', {}
184
- end
185
- directory 'files' do
186
- file 'a.rb', ''
187
- file 'b.json', {}
188
- file 'c/d.rb', ''
189
- file 'c/e.json', {}
190
- end
191
- directory 'resources' do
192
- file 'a.rb', ''
193
- file 'b.json', {}
194
- file 'c/d.rb', ''
195
- file 'c/e.json', {}
196
- end
197
- directory 'providers' do
198
- file 'a.rb', ''
199
- file 'b.json', {}
200
- file 'c/d.rb', ''
201
- file 'c/e.json', {}
165
+ file 'blarghle/blah.rb', ''
166
+ directory 'attributes' do
167
+ file 'a.rb', ''
168
+ file 'b.json', {}
169
+ file 'c/d.rb', ''
170
+ file 'c/e.json', {}
171
+ end
172
+ directory 'definitions' do
173
+ file 'a.rb', ''
174
+ file 'b.json', {}
175
+ file 'c/d.rb', ''
176
+ file 'c/e.json', {}
177
+ end
178
+ directory 'recipes' do
179
+ file 'a.rb', ''
180
+ file 'b.json', {}
181
+ file 'c/d.rb', ''
182
+ file 'c/e.json', {}
183
+ end
184
+ directory 'libraries' do
185
+ file 'a.rb', ''
186
+ file 'b.json', {}
187
+ file 'c/d.rb', ''
188
+ file 'c/e.json', {}
189
+ end
190
+ directory 'templates' do
191
+ file 'a.rb', ''
192
+ file 'b.json', {}
193
+ file 'c/d.rb', ''
194
+ file 'c/e.json', {}
195
+ end
196
+ directory 'files' do
197
+ file 'a.rb', ''
198
+ file 'b.json', {}
199
+ file 'c/d.rb', ''
200
+ file 'c/e.json', {}
201
+ end
202
+ directory 'resources' do
203
+ file 'a.rb', ''
204
+ file 'b.json', {}
205
+ file 'c/d.rb', ''
206
+ file 'c/e.json', {}
207
+ end
208
+ directory 'providers' do
209
+ file 'a.rb', ''
210
+ file 'b.json', {}
211
+ file 'c/d.rb', ''
212
+ file 'c/e.json', {}
213
+ end
202
214
  end
203
215
  end
204
216
 
@@ -240,7 +252,7 @@ EOM
240
252
  end
241
253
 
242
254
  when_the_repository "has a file in cookbooks/" do
243
- file 'cookbooks/file', ''
255
+ before { file 'cookbooks/file', '' }
244
256
  it 'does not show up in list -Rfp' do
245
257
  knife('list --local -Rfp /').should_succeed <<EOM
246
258
  /cookbooks/
@@ -249,7 +261,7 @@ EOM
249
261
  end
250
262
 
251
263
  when_the_repository "has a file in data_bags/" do
252
- file 'data_bags/file', ''
264
+ before { file 'data_bags/file', '' }
253
265
  it 'does not show up in list -Rfp' do
254
266
  knife('list --local -Rfp /').should_succeed <<EOM
255
267
  /data_bags/
@@ -259,16 +271,20 @@ EOM
259
271
  end
260
272
 
261
273
  when_the_repository 'has a cookbook starting with .' do
262
- file 'cookbooks/.svn/metadata.rb', ''
263
- file 'cookbooks/a.b/metadata.rb', ''
274
+ before do
275
+ file 'cookbooks/.svn/metadata.rb', ''
276
+ file 'cookbooks/a.b/metadata.rb', ''
277
+ end
264
278
  it 'knife list does not show it' do
265
279
  knife('list --local -fp /cookbooks').should_succeed "/cookbooks/a.b/\n"
266
280
  end
267
281
  end
268
282
 
269
283
  when_the_repository 'has a data bag starting with .' do
270
- file 'data_bags/.svn/x.json', {}
271
- file 'data_bags/a.b/x.json', {}
284
+ before do
285
+ file 'data_bags/.svn/x.json', {}
286
+ file 'data_bags/a.b/x.json', {}
287
+ end
272
288
  it 'knife list does not show it' do
273
289
  knife('list --local -fp /data_bags').should_succeed "/data_bags/a.b/\n"
274
290
  end
@@ -20,23 +20,27 @@ require 'chef/knife/list'
20
20
  require 'chef/knife/show'
21
21
 
22
22
  describe 'chefignore tests' do
23
- extend IntegrationSupport
23
+ include IntegrationSupport
24
24
  include KnifeSupport
25
25
 
26
26
  when_the_repository "has lots of stuff in it" do
27
- file 'roles/x.json', {}
28
- file 'environments/x.json', {}
29
- file 'data_bags/bag1/x.json', {}
30
- file 'cookbooks/cookbook1/x.json', {}
27
+ before do
28
+ file 'roles/x.json', {}
29
+ file 'environments/x.json', {}
30
+ file 'data_bags/bag1/x.json', {}
31
+ file 'cookbooks/cookbook1/x.json', {}
32
+ end
31
33
 
32
34
  context "and has a chefignore everywhere except cookbooks" do
33
- chefignore = "x.json\nroles/x.json\nenvironments/x.json\ndata_bags/bag1/x.json\nbag1/x.json\ncookbooks/cookbook1/x.json\ncookbook1/x.json\n"
34
- file 'chefignore', chefignore
35
- file 'roles/chefignore', chefignore
36
- file 'environments/chefignore', chefignore
37
- file 'data_bags/chefignore', chefignore
38
- file 'data_bags/bag1/chefignore', chefignore
39
- file 'cookbooks/cookbook1/chefignore', chefignore
35
+ before do
36
+ chefignore = "x.json\nroles/x.json\nenvironments/x.json\ndata_bags/bag1/x.json\nbag1/x.json\ncookbooks/cookbook1/x.json\ncookbook1/x.json\n"
37
+ file 'chefignore', chefignore
38
+ file 'roles/chefignore', chefignore
39
+ file 'environments/chefignore', chefignore
40
+ file 'data_bags/chefignore', chefignore
41
+ file 'data_bags/bag1/chefignore', chefignore
42
+ file 'cookbooks/cookbook1/chefignore', chefignore
43
+ end
40
44
 
41
45
  it 'matching files and directories get ignored' do
42
46
  # NOTE: many of the "chefignore" files should probably not show up
@@ -58,9 +62,11 @@ EOM
58
62
  end
59
63
 
60
64
  when_the_repository 'has a cookbook with only chefignored files' do
61
- file 'cookbooks/cookbook1/templates/default/x.rb', ''
62
- file 'cookbooks/cookbook1/libraries/x.rb', ''
63
- file 'cookbooks/chefignore', "libraries/x.rb\ntemplates/default/x.rb\n"
65
+ before do
66
+ file 'cookbooks/cookbook1/templates/default/x.rb', ''
67
+ file 'cookbooks/cookbook1/libraries/x.rb', ''
68
+ file 'cookbooks/chefignore', "libraries/x.rb\ntemplates/default/x.rb\n"
69
+ end
64
70
 
65
71
  it 'the cookbook is not listed' do
66
72
  knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
@@ -70,13 +76,15 @@ EOM
70
76
  end
71
77
 
72
78
  when_the_repository "has multiple cookbooks" do
73
- file 'cookbooks/cookbook1/x.json', {}
74
- file 'cookbooks/cookbook1/y.json', {}
75
- file 'cookbooks/cookbook2/x.json', {}
76
- file 'cookbooks/cookbook2/y.json', {}
79
+ before do
80
+ file 'cookbooks/cookbook1/x.json', {}
81
+ file 'cookbooks/cookbook1/y.json', {}
82
+ file 'cookbooks/cookbook2/x.json', {}
83
+ file 'cookbooks/cookbook2/y.json', {}
84
+ end
77
85
 
78
86
  context 'and has a chefignore with filenames' do
79
- file 'cookbooks/chefignore', "x.json\n"
87
+ before { file 'cookbooks/chefignore', "x.json\n" }
80
88
 
81
89
  it 'matching files and directories get ignored in all cookbooks' do
82
90
  knife('list --local -Rfp /').should_succeed <<EOM
@@ -90,8 +98,10 @@ EOM
90
98
  end
91
99
 
92
100
  context "and has a chefignore with wildcards" do
93
- file 'cookbooks/chefignore', "x.*\n"
94
- file 'cookbooks/cookbook1/x.rb', ''
101
+ before do
102
+ file 'cookbooks/chefignore', "x.*\n"
103
+ file 'cookbooks/cookbook1/x.rb', ''
104
+ end
95
105
 
96
106
  it 'matching files and directories get ignored in all cookbooks' do
97
107
  knife('list --local -Rfp /').should_succeed <<EOM
@@ -105,9 +115,11 @@ EOM
105
115
  end
106
116
 
107
117
  context "and has a chefignore with relative paths" do
108
- file 'cookbooks/cookbook1/recipes/x.rb', ''
109
- file 'cookbooks/cookbook2/recipes/y.rb', ''
110
- file 'cookbooks/chefignore', "recipes/x.rb\n"
118
+ before do
119
+ file 'cookbooks/cookbook1/recipes/x.rb', ''
120
+ file 'cookbooks/cookbook2/recipes/y.rb', ''
121
+ file 'cookbooks/chefignore', "recipes/x.rb\n"
122
+ end
111
123
 
112
124
  it 'matching directories get ignored' do
113
125
  knife('list --local -Rfp /').should_succeed <<EOM
@@ -125,8 +137,10 @@ EOM
125
137
  end
126
138
 
127
139
  context "and has a chefignore with subdirectories" do
128
- file 'cookbooks/cookbook1/recipes/y.rb', ''
129
- file 'cookbooks/chefignore', "recipes\nrecipes/\n"
140
+ before do
141
+ file 'cookbooks/cookbook1/recipes/y.rb', ''
142
+ file 'cookbooks/chefignore', "recipes\nrecipes/\n"
143
+ end
130
144
 
131
145
  it 'matching directories do NOT get ignored' do
132
146
  knife('list --local -Rfp /').should_succeed <<EOM
@@ -144,9 +158,11 @@ EOM
144
158
  end
145
159
 
146
160
  context "and has a chefignore that ignores all files in a subdirectory" do
147
- file 'cookbooks/cookbook1/templates/default/x.rb', ''
148
- file 'cookbooks/cookbook1/libraries/x.rb', ''
149
- file 'cookbooks/chefignore', "libraries/x.rb\ntemplates/default/x.rb\n"
161
+ before do
162
+ file 'cookbooks/cookbook1/templates/default/x.rb', ''
163
+ file 'cookbooks/cookbook1/libraries/x.rb', ''
164
+ file 'cookbooks/chefignore', "libraries/x.rb\ntemplates/default/x.rb\n"
165
+ end
150
166
 
151
167
  it 'ignores the subdirectory entirely' do
152
168
  knife('list --local -Rfp /').should_succeed <<EOM
@@ -162,7 +178,9 @@ EOM
162
178
  end
163
179
 
164
180
  context "and has an empty chefignore" do
165
- file 'cookbooks/chefignore', "\n"
181
+ before do
182
+ file 'cookbooks/chefignore', "\n"
183
+ end
166
184
 
167
185
  it 'nothing is ignored' do
168
186
  knife('list --local -Rfp /').should_succeed <<EOM
@@ -178,7 +196,9 @@ EOM
178
196
  end
179
197
 
180
198
  context "and has a chefignore with comments and empty lines" do
181
- file 'cookbooks/chefignore', "\n\n # blah\n#\nx.json\n\n"
199
+ before do
200
+ file 'cookbooks/chefignore', "\n\n # blah\n#\nx.json\n\n"
201
+ end
182
202
 
183
203
  it 'matching files and directories get ignored in all cookbooks' do
184
204
  knife('list --local -Rfp /').should_succeed <<EOM
@@ -200,14 +220,18 @@ EOM
200
220
  ]
201
221
  end
202
222
 
203
- file 'cookbooks1/mycookbook/metadata.rb', ''
204
- file 'cookbooks1/mycookbook/x.json', {}
205
- file 'cookbooks2/yourcookbook/metadata.rb', ''
206
- file 'cookbooks2/yourcookbook/x.json', ''
223
+ before do
224
+ file 'cookbooks1/mycookbook/metadata.rb', ''
225
+ file 'cookbooks1/mycookbook/x.json', {}
226
+ file 'cookbooks2/yourcookbook/metadata.rb', ''
227
+ file 'cookbooks2/yourcookbook/x.json', ''
228
+ end
207
229
 
208
230
  context "and multiple chefignores" do
209
- file 'cookbooks1/chefignore', "metadata.rb\n"
210
- file 'cookbooks2/chefignore', "x.json\n"
231
+ before do
232
+ file 'cookbooks1/chefignore', "metadata.rb\n"
233
+ file 'cookbooks2/chefignore', "x.json\n"
234
+ end
211
235
  it "chefignores apply only to the directories they are in" do
212
236
  knife('list --local -Rfp /').should_succeed <<EOM
213
237
  /cookbooks/
@@ -219,10 +243,12 @@ EOM
219
243
  end
220
244
 
221
245
  context "and conflicting cookbooks" do
222
- file 'cookbooks1/yourcookbook/metadata.rb', ''
223
- file 'cookbooks1/yourcookbook/x.json', ''
224
- file 'cookbooks1/yourcookbook/onlyincookbooks1.rb', ''
225
- file 'cookbooks2/yourcookbook/onlyincookbooks2.rb', ''
246
+ before do
247
+ file 'cookbooks1/yourcookbook/metadata.rb', ''
248
+ file 'cookbooks1/yourcookbook/x.json', ''
249
+ file 'cookbooks1/yourcookbook/onlyincookbooks1.rb', ''
250
+ file 'cookbooks2/yourcookbook/onlyincookbooks2.rb', ''
251
+ end
226
252
 
227
253
  it "chefignores apply only to the winning cookbook" do
228
254
  knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Child with name 'yourcookbook' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks1/yourcookbook and #{Chef::Config.chef_repo_path}/cookbooks2/yourcookbook\n")
@@ -239,7 +265,9 @@ EOM
239
265
  end
240
266
 
241
267
  when_the_repository 'has a cookbook named chefignore' do
242
- file 'cookbooks/chefignore/metadata.rb', {}
268
+ before do
269
+ file 'cookbooks/chefignore/metadata.rb', {}
270
+ end
243
271
  it 'knife list -Rfp /cookbooks shows it' do
244
272
  knife('list --local -Rfp /cookbooks').should_succeed <<EOM
245
273
  /cookbooks/chefignore/
@@ -249,9 +277,11 @@ EOM
249
277
  end
250
278
 
251
279
  when_the_repository 'has multiple cookbook paths, one with a chefignore file and the other with a cookbook named chefignore' do
252
- file 'cookbooks1/chefignore', ''
253
- file 'cookbooks1/blah/metadata.rb', ''
254
- file 'cookbooks2/chefignore/metadata.rb', ''
280
+ before do
281
+ file 'cookbooks1/chefignore', ''
282
+ file 'cookbooks1/blah/metadata.rb', ''
283
+ file 'cookbooks2/chefignore/metadata.rb', ''
284
+ end
255
285
  before :each do
256
286
  Chef::Config.cookbook_path = [
257
287
  File.join(Chef::Config.chef_repo_path, 'cookbooks1'),