cheffish 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -8
  3. data/Rakefile +24 -12
  4. data/cheffish.gemspec +15 -15
  5. data/lib/chef/resource/chef_acl.rb +63 -63
  6. data/lib/chef/resource/chef_client.rb +9 -9
  7. data/lib/chef/resource/chef_container.rb +9 -9
  8. data/lib/chef/resource/chef_data_bag.rb +9 -9
  9. data/lib/chef/resource/chef_data_bag_item.rb +27 -27
  10. data/lib/chef/resource/chef_environment.rb +21 -22
  11. data/lib/chef/resource/chef_group.rb +19 -19
  12. data/lib/chef/resource/chef_mirror.rb +32 -17
  13. data/lib/chef/resource/chef_node.rb +14 -14
  14. data/lib/chef/resource/chef_organization.rb +29 -30
  15. data/lib/chef/resource/chef_resolved_cookbooks.rb +7 -7
  16. data/lib/chef/resource/chef_role.rb +25 -22
  17. data/lib/chef/resource/chef_user.rb +13 -14
  18. data/lib/chef/resource/private_key.rb +24 -25
  19. data/lib/chef/resource/public_key.rb +6 -7
  20. data/lib/cheffish.rb +17 -17
  21. data/lib/cheffish/array_property.rb +2 -2
  22. data/lib/cheffish/base_properties.rb +3 -3
  23. data/lib/cheffish/base_resource.rb +8 -8
  24. data/lib/cheffish/basic_chef_client.rb +17 -17
  25. data/lib/cheffish/chef_actor_base.rb +8 -8
  26. data/lib/cheffish/chef_run.rb +7 -2
  27. data/lib/cheffish/chef_run_data.rb +2 -2
  28. data/lib/cheffish/chef_run_listener.rb +1 -1
  29. data/lib/cheffish/key_formatter.rb +16 -18
  30. data/lib/cheffish/merged_config.rb +5 -3
  31. data/lib/cheffish/node_properties.rb +11 -7
  32. data/lib/cheffish/recipe_dsl.rb +33 -34
  33. data/lib/cheffish/rspec.rb +3 -3
  34. data/lib/cheffish/rspec/chef_run_support.rb +13 -13
  35. data/lib/cheffish/rspec/matchers.rb +4 -4
  36. data/lib/cheffish/rspec/matchers/be_idempotent.rb +3 -3
  37. data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +3 -3
  38. data/lib/cheffish/rspec/matchers/have_updated.rb +3 -3
  39. data/lib/cheffish/rspec/recipe_run_wrapper.rb +8 -7
  40. data/lib/cheffish/rspec/repository_support.rb +6 -6
  41. data/lib/cheffish/server_api.rb +11 -11
  42. data/lib/cheffish/version.rb +1 -1
  43. data/spec/functional/fingerprint_spec.rb +12 -12
  44. data/spec/functional/merged_config_spec.rb +46 -6
  45. data/spec/functional/server_api_spec.rb +3 -3
  46. data/spec/integration/chef_acl_spec.rb +489 -489
  47. data/spec/integration/chef_client_spec.rb +39 -39
  48. data/spec/integration/chef_container_spec.rb +14 -14
  49. data/spec/integration/chef_data_bag_item_spec.rb +9 -9
  50. data/spec/integration/chef_group_spec.rb +219 -219
  51. data/spec/integration/chef_mirror_spec.rb +228 -228
  52. data/spec/integration/chef_node_spec.rb +511 -511
  53. data/spec/integration/chef_organization_spec.rb +126 -126
  54. data/spec/integration/chef_role_spec.rb +33 -33
  55. data/spec/integration/chef_user_spec.rb +37 -37
  56. data/spec/integration/private_key_spec.rb +154 -154
  57. data/spec/integration/recipe_dsl_spec.rb +10 -10
  58. data/spec/integration/rspec/converge_spec.rb +49 -49
  59. data/spec/support/key_support.rb +6 -6
  60. data/spec/support/spec_support.rb +3 -3
  61. data/spec/unit/get_private_key_spec.rb +19 -19
  62. data/spec/unit/recipe_run_wrapper_spec.rb +4 -4
  63. metadata +3 -3
@@ -1,145 +1,145 @@
1
- require 'support/spec_support'
2
- require 'cheffish/rspec/chef_run_support'
1
+ require "support/spec_support"
2
+ require "cheffish/rspec/chef_run_support"
3
3
 
4
4
  describe Chef::Resource::ChefMirror do
5
5
  extend Cheffish::RSpec::ChefRunSupport
6
6
 
7
- when_the_chef_12_server 'is in multi-org mode' do
8
- organization 'foo'
7
+ when_the_chef_12_server "is in multi-org mode" do
8
+ organization "foo"
9
9
 
10
10
  before :each do
11
- Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
11
+ Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo").to_s
12
12
  end
13
13
 
14
- describe 'basic download and upload' do
15
- when_the_repository 'is full of stuff' do
16
- file 'nodes/x.json', {}
17
- file 'roles/x.json', {}
18
- directory 'cookbooks/x' do
19
- file 'metadata.rb', 'name "x"; version "2.0.0"'
14
+ describe "basic download and upload" do
15
+ when_the_repository "is full of stuff" do
16
+ file "nodes/x.json", {}
17
+ file "roles/x.json", {}
18
+ directory "cookbooks/x" do
19
+ file "metadata.rb", 'name "x"; version "2.0.0"'
20
20
  end
21
21
 
22
22
  it "Download grabs defaults" do
23
- expect_recipe {
24
- chef_mirror '' do
23
+ expect_recipe do
24
+ chef_mirror "" do
25
25
  action :download
26
26
  end
27
- }.to have_updated('chef_mirror[]', :download)
28
- expect(File.exist?(path_to('groups/admins.json'))).to be true
29
- expect(File.exist?(path_to('environments/_default.json'))).to be true
27
+ end.to have_updated("chef_mirror[]", :download)
28
+ expect(File.exist?(path_to("groups/admins.json"))).to be true
29
+ expect(File.exist?(path_to("environments/_default.json"))).to be true
30
30
  end
31
31
 
32
32
  it "Upload uploads everything" do
33
- expect_recipe {
34
- chef_mirror '' do
33
+ expect_recipe do
34
+ chef_mirror "" do
35
35
  action :upload
36
36
  end
37
- }.to have_updated('chef_mirror[]', :upload)
38
- expect { get('nodes/x') }.not_to raise_error
39
- expect { get('roles/x') }.not_to raise_error
40
- expect { get('cookbooks/x/2.0.0') }.not_to raise_error
37
+ end.to have_updated("chef_mirror[]", :upload)
38
+ expect { get("nodes/x") }.not_to raise_error
39
+ expect { get("roles/x") }.not_to raise_error
40
+ expect { get("cookbooks/x/2.0.0") }.not_to raise_error
41
41
  end
42
42
 
43
- it 'chef_mirror with concurrency 0 fails with a reasonable message' do
44
- expect {
45
- converge {
46
- chef_mirror '' do
43
+ it "chef_mirror with concurrency 0 fails with a reasonable message" do
44
+ expect do
45
+ converge do
46
+ chef_mirror "" do
47
47
  concurrency 0
48
48
  action :download
49
49
  end
50
- }
51
- }.to raise_error /chef_mirror.concurrency must be above 0/
50
+ end
51
+ end.to raise_error /chef_mirror.concurrency must be above 0/
52
52
  end
53
53
  end
54
54
  end
55
55
 
56
- context 'and the Chef server has a node and role in it' do
57
- node 'x', {}
58
- role 'x', {}
56
+ context "and the Chef server has a node and role in it" do
57
+ node "x", {}
58
+ role "x", {}
59
59
 
60
- when_the_repository 'is empty' do
60
+ when_the_repository "is empty" do
61
61
  it "Download grabs the node and role" do
62
- expect_recipe {
63
- chef_mirror '' do
62
+ expect_recipe do
63
+ chef_mirror "" do
64
64
  action :download
65
65
  end
66
- }.to have_updated('chef_mirror[]', :download)
67
- expect(File.exist?(path_to('nodes/x.json'))).to be true
68
- expect(File.exist?(path_to('roles/x.json'))).to be true
66
+ end.to have_updated("chef_mirror[]", :download)
67
+ expect(File.exist?(path_to("nodes/x.json"))).to be true
68
+ expect(File.exist?(path_to("roles/x.json"))).to be true
69
69
  end
70
70
 
71
71
  it "Upload uploads nothing" do
72
- expect_recipe {
73
- chef_mirror '' do
72
+ expect_recipe do
73
+ chef_mirror "" do
74
74
  action :upload
75
75
  end
76
- }.not_to have_updated('chef_mirror[]', :upload)
76
+ end.not_to have_updated("chef_mirror[]", :upload)
77
77
  end
78
78
  end
79
79
  end
80
80
 
81
- context 'and the Chef server has nodes and roles named x' do
82
- node 'x', {}
83
- role 'x', {}
81
+ context "and the Chef server has nodes and roles named x" do
82
+ node "x", {}
83
+ role "x", {}
84
84
 
85
- when_the_repository 'has nodes and roles named y' do
86
- file 'nodes/y.json', {}
87
- file 'roles/y.json', {}
85
+ when_the_repository "has nodes and roles named y" do
86
+ file "nodes/y.json", {}
87
+ file "roles/y.json", {}
88
88
 
89
89
  it "Download grabs the x's" do
90
- expect_recipe {
91
- chef_mirror '' do
90
+ expect_recipe do
91
+ chef_mirror "" do
92
92
  action :download
93
93
  end
94
- }.to have_updated('chef_mirror[]', :download)
95
- expect(File.exist?(path_to('nodes/x.json'))).to be true
96
- expect(File.exist?(path_to('roles/x.json'))).to be true
97
- expect(File.exist?(path_to('nodes/y.json'))).to be true
98
- expect(File.exist?(path_to('roles/y.json'))).to be true
94
+ end.to have_updated("chef_mirror[]", :download)
95
+ expect(File.exist?(path_to("nodes/x.json"))).to be true
96
+ expect(File.exist?(path_to("roles/x.json"))).to be true
97
+ expect(File.exist?(path_to("nodes/y.json"))).to be true
98
+ expect(File.exist?(path_to("roles/y.json"))).to be true
99
99
  end
100
100
 
101
101
  it "Upload uploads the y's" do
102
- expect_recipe {
103
- chef_mirror '' do
102
+ expect_recipe do
103
+ chef_mirror "" do
104
104
  action :upload
105
105
  end
106
- }.to have_updated('chef_mirror[]', :upload)
107
- expect { get('nodes/x') }.not_to raise_error
108
- expect { get('roles/x') }.not_to raise_error
109
- expect { get('nodes/y') }.not_to raise_error
110
- expect { get('roles/y') }.not_to raise_error
106
+ end.to have_updated("chef_mirror[]", :upload)
107
+ expect { get("nodes/x") }.not_to raise_error
108
+ expect { get("roles/x") }.not_to raise_error
109
+ expect { get("nodes/y") }.not_to raise_error
110
+ expect { get("roles/y") }.not_to raise_error
111
111
  end
112
112
 
113
113
  it "Download with purge grabs the x's and deletes the y's" do
114
- expect_recipe {
115
- chef_mirror '' do
114
+ expect_recipe do
115
+ chef_mirror "" do
116
116
  purge true
117
117
  action :download
118
118
  end
119
- }.to have_updated('chef_mirror[]', :download)
120
- expect(File.exist?(path_to('nodes/x.json'))).to be true
121
- expect(File.exist?(path_to('roles/x.json'))).to be true
119
+ end.to have_updated("chef_mirror[]", :download)
120
+ expect(File.exist?(path_to("nodes/x.json"))).to be true
121
+ expect(File.exist?(path_to("roles/x.json"))).to be true
122
122
  end
123
123
 
124
124
  it "Upload with :purge uploads the y's and deletes the x's" do
125
- expect_recipe {
126
- chef_mirror '*/*.json' do
125
+ expect_recipe do
126
+ chef_mirror "*/*.json" do
127
127
  purge true
128
128
  action :upload
129
129
  end
130
- }.to have_updated('chef_mirror[*/*.json]', :upload)
131
- expect { get('nodes/y') }.not_to raise_error
132
- expect { get('roles/y') }.not_to raise_error
130
+ end.to have_updated("chef_mirror[*/*.json]", :upload)
131
+ expect { get("nodes/y") }.not_to raise_error
132
+ expect { get("roles/y") }.not_to raise_error
133
133
  end
134
134
  end
135
135
  end
136
136
 
137
137
  describe "chef_repo_path" do
138
- when_the_repository 'has stuff but no chef_repo_path' do
139
- file 'repo/nodes/x.json', {}
140
- file 'repo/roles/x.json', {}
141
- file 'repo2/nodes/y.json', {}
142
- file 'repo2/roles/y.json', {}
138
+ when_the_repository "has stuff but no chef_repo_path" do
139
+ file "repo/nodes/x.json", {}
140
+ file "repo/roles/x.json", {}
141
+ file "repo2/nodes/y.json", {}
142
+ file "repo2/roles/y.json", {}
143
143
 
144
144
  before do
145
145
  Chef::Config.delete(:chef_repo_path)
@@ -149,120 +149,120 @@ describe Chef::Resource::ChefMirror do
149
149
  end
150
150
 
151
151
  it "Upload with chef_repo_path('repo') uploads everything" do
152
- repo_path = path_to('repo')
153
- expect_recipe {
154
- chef_mirror '' do
152
+ repo_path = path_to("repo")
153
+ expect_recipe do
154
+ chef_mirror "" do
155
155
  chef_repo_path repo_path
156
156
  action :upload
157
157
  end
158
- }.to have_updated('chef_mirror[]', :upload)
159
- expect { get('nodes/x') }.not_to raise_error
160
- expect { get('roles/x') }.not_to raise_error
161
- expect { get('nodes/y') }.to raise_error /404/
162
- expect { get('roles/y') }.to raise_error /404/
158
+ end.to have_updated("chef_mirror[]", :upload)
159
+ expect { get("nodes/x") }.not_to raise_error
160
+ expect { get("roles/x") }.not_to raise_error
161
+ expect { get("nodes/y") }.to raise_error /404/
162
+ expect { get("roles/y") }.to raise_error /404/
163
163
  end
164
164
 
165
165
  it "Upload with chef_repo_path(:chef_repo_path) with multiple paths uploads everything" do
166
- repo_path = path_to('repo')
167
- repo2_path = path_to('repo2')
168
- expect_recipe {
169
- chef_mirror '' do
166
+ repo_path = path_to("repo")
167
+ repo2_path = path_to("repo2")
168
+ expect_recipe do
169
+ chef_mirror "" do
170
170
  chef_repo_path :chef_repo_path => [ repo_path, repo2_path ]
171
171
  action :upload
172
172
  end
173
- }.to have_updated('chef_mirror[]', :upload)
174
- expect { get('nodes/x') }.not_to raise_error
175
- expect { get('roles/x') }.not_to raise_error
176
- expect { get('nodes/y') }.not_to raise_error
177
- expect { get('roles/y') }.not_to raise_error
173
+ end.to have_updated("chef_mirror[]", :upload)
174
+ expect { get("nodes/x") }.not_to raise_error
175
+ expect { get("roles/x") }.not_to raise_error
176
+ expect { get("nodes/y") }.not_to raise_error
177
+ expect { get("roles/y") }.not_to raise_error
178
178
  end
179
179
 
180
180
  it "Upload with chef_repo_path(:node_path, :role_path) uploads everything" do
181
- repo_path = path_to('repo')
182
- repo2_path = path_to('repo2')
181
+ repo_path = path_to("repo")
182
+ repo2_path = path_to("repo2")
183
183
 
184
- expect_recipe {
185
- chef_mirror '' do
186
- chef_repo_path :chef_repo_path => '/blahblah',
184
+ expect_recipe do
185
+ chef_mirror "" do
186
+ chef_repo_path :chef_repo_path => "/blahblah",
187
187
  :node_path => "#{repo_path}/nodes",
188
188
  :role_path => "#{repo2_path}/roles"
189
189
  action :upload
190
190
  end
191
- }.to have_updated('chef_mirror[]', :upload)
192
- expect { get('nodes/x') }.not_to raise_error
193
- expect { get('roles/x') }.to raise_error /404/
194
- expect { get('nodes/y') }.to raise_error /404/
195
- expect { get('roles/y') }.not_to raise_error
191
+ end.to have_updated("chef_mirror[]", :upload)
192
+ expect { get("nodes/x") }.not_to raise_error
193
+ expect { get("roles/x") }.to raise_error /404/
194
+ expect { get("nodes/y") }.to raise_error /404/
195
+ expect { get("roles/y") }.not_to raise_error
196
196
  end
197
197
 
198
198
  it "Upload with chef_repo_path(:chef_repo_path, :role_path) uploads everything" do
199
- repo_path = path_to('repo')
200
- repo2_path = path_to('repo2')
199
+ repo_path = path_to("repo")
200
+ repo2_path = path_to("repo2")
201
201
 
202
- expect_recipe {
203
- chef_mirror '' do
202
+ expect_recipe do
203
+ chef_mirror "" do
204
204
  chef_repo_path :chef_repo_path => repo_path,
205
205
  :role_path => "#{repo2_path}/roles"
206
206
  action :upload
207
207
  end
208
- }.to have_updated('chef_mirror[]', :upload)
209
- expect { get('nodes/x') }.not_to raise_error
210
- expect { get('roles/x') }.to raise_error /404/
211
- expect { get('nodes/y') }.to raise_error /404/
212
- expect { get('roles/y') }.not_to raise_error
208
+ end.to have_updated("chef_mirror[]", :upload)
209
+ expect { get("nodes/x") }.not_to raise_error
210
+ expect { get("roles/x") }.to raise_error /404/
211
+ expect { get("nodes/y") }.to raise_error /404/
212
+ expect { get("roles/y") }.not_to raise_error
213
213
  end
214
214
 
215
215
  it "Upload with chef_repo_path(:node_path, :role_path) with multiple paths uploads everything" do
216
- repo_path = path_to('repo')
217
- repo2_path = path_to('repo2')
216
+ repo_path = path_to("repo")
217
+ repo2_path = path_to("repo2")
218
218
 
219
- expect_recipe {
220
- chef_mirror '' do
221
- chef_repo_path :chef_repo_path => [ 'foo', 'bar' ],
219
+ expect_recipe do
220
+ chef_mirror "" do
221
+ chef_repo_path :chef_repo_path => %w{foo bar},
222
222
  :node_path => [ "#{repo_path}/nodes", "#{repo2_path}/nodes" ],
223
223
  :role_path => [ "#{repo_path}/roles", "#{repo2_path}/roles" ]
224
224
  action :upload
225
225
  end
226
- }.to have_updated('chef_mirror[]', :upload)
227
- expect { get('nodes/x') }.not_to raise_error
228
- expect { get('roles/x') }.not_to raise_error
229
- expect { get('nodes/y') }.not_to raise_error
230
- expect { get('roles/y') }.not_to raise_error
226
+ end.to have_updated("chef_mirror[]", :upload)
227
+ expect { get("nodes/x") }.not_to raise_error
228
+ expect { get("roles/x") }.not_to raise_error
229
+ expect { get("nodes/y") }.not_to raise_error
230
+ expect { get("roles/y") }.not_to raise_error
231
231
  end
232
232
  end
233
233
  end
234
234
 
235
235
  describe "cookbook upload, chef_repo_path and versioned_cookbooks" do
236
- when_the_repository 'has cookbooks in non-versioned format' do
237
- file 'cookbooks/x-1.0.0/metadata.rb', 'name "x-1.0.0"; version "2.0.0"'
238
- file 'cookbooks/y-1.0.0/metadata.rb', 'name "y-3.0.0"; version "4.0.0"'
236
+ when_the_repository "has cookbooks in non-versioned format" do
237
+ file "cookbooks/x-1.0.0/metadata.rb", 'name "x-1.0.0"; version "2.0.0"'
238
+ file "cookbooks/y-1.0.0/metadata.rb", 'name "y-3.0.0"; version "4.0.0"'
239
239
 
240
240
  it "chef_mirror :upload uploads everything" do
241
- expect_recipe {
242
- chef_mirror '' do
241
+ expect_recipe do
242
+ chef_mirror "" do
243
243
  action :upload
244
244
  end
245
- }.to have_updated('chef_mirror[]', :upload)
246
- expect { get('cookbooks/x-1.0.0/2.0.0') }.not_to raise_error
247
- expect { get('cookbooks/y-3.0.0/4.0.0') }.not_to raise_error
245
+ end.to have_updated("chef_mirror[]", :upload)
246
+ expect { get("cookbooks/x-1.0.0/2.0.0") }.not_to raise_error
247
+ expect { get("cookbooks/y-3.0.0/4.0.0") }.not_to raise_error
248
248
  end
249
249
 
250
- context 'and Chef::Config.versioned_cookbooks is false' do
250
+ context "and Chef::Config.versioned_cookbooks is false" do
251
251
  before do
252
252
  Chef::Config.versioned_cookbooks false
253
253
  end
254
254
  it "chef_mirror :upload uploads everything" do
255
- expect_recipe {
256
- chef_mirror '' do
255
+ expect_recipe do
256
+ chef_mirror "" do
257
257
  action :upload
258
258
  end
259
- }.to have_updated('chef_mirror[]', :upload)
260
- expect { get('cookbooks/x-1.0.0/2.0.0') }.not_to raise_error
261
- expect { get('cookbooks/y-3.0.0/4.0.0') }.not_to raise_error
259
+ end.to have_updated("chef_mirror[]", :upload)
260
+ expect { get("cookbooks/x-1.0.0/2.0.0") }.not_to raise_error
261
+ expect { get("cookbooks/y-3.0.0/4.0.0") }.not_to raise_error
262
262
  end
263
263
  end
264
264
 
265
- context 'and Chef::Config.chef_repo_path is not set but versioned_cookbooks is false' do
265
+ context "and Chef::Config.chef_repo_path is not set but versioned_cookbooks is false" do
266
266
  before do
267
267
  Chef::Config.delete(:chef_repo_path)
268
268
  Chef::Config.versioned_cookbooks false
@@ -270,56 +270,56 @@ describe Chef::Resource::ChefMirror do
270
270
 
271
271
  it "chef_mirror :upload with chef_repo_path and versioned_cookbooks false uploads cookbooks with name including version" do
272
272
  repository_dir = @repository_dir
273
- expect_recipe {
274
- chef_mirror '' do
273
+ expect_recipe do
274
+ chef_mirror "" do
275
275
  chef_repo_path repository_dir
276
276
  versioned_cookbooks false
277
277
  action :upload
278
278
  end
279
- }.to have_updated('chef_mirror[]', :upload)
280
- expect { get('cookbooks/x-1.0.0/2.0.0') }.not_to raise_error
281
- expect { get('cookbooks/y-3.0.0/4.0.0') }.not_to raise_error
279
+ end.to have_updated("chef_mirror[]", :upload)
280
+ expect { get("cookbooks/x-1.0.0/2.0.0") }.not_to raise_error
281
+ expect { get("cookbooks/y-3.0.0/4.0.0") }.not_to raise_error
282
282
  end
283
283
  end
284
284
  end
285
285
 
286
- when_the_repository 'has cookbooks in versioned_cookbook format' do
287
- file 'cookbooks/x-1.0.0/metadata.rb', 'name "x"; version "1.0.0"'
288
- file 'cookbooks/x-2.0.0/metadata.rb', 'name "x"; version "2.0.0"'
286
+ when_the_repository "has cookbooks in versioned_cookbook format" do
287
+ file "cookbooks/x-1.0.0/metadata.rb", 'name "x"; version "1.0.0"'
288
+ file "cookbooks/x-2.0.0/metadata.rb", 'name "x"; version "2.0.0"'
289
289
 
290
- context 'and Chef::Config.versioned_cookbooks is true' do
290
+ context "and Chef::Config.versioned_cookbooks is true" do
291
291
  before do
292
292
  Chef::Config.versioned_cookbooks true
293
293
  end
294
294
  it "chef_mirror :upload uploads everything" do
295
- expect_recipe {
296
- chef_mirror '' do
295
+ expect_recipe do
296
+ chef_mirror "" do
297
297
  action :upload
298
298
  end
299
- }.to have_updated('chef_mirror[]', :upload)
300
- expect { get('cookbooks/x/1.0.0') }.not_to raise_error
301
- expect { get('cookbooks/x/2.0.0') }.not_to raise_error
299
+ end.to have_updated("chef_mirror[]", :upload)
300
+ expect { get("cookbooks/x/1.0.0") }.not_to raise_error
301
+ expect { get("cookbooks/x/2.0.0") }.not_to raise_error
302
302
  end
303
303
  end
304
304
 
305
- context 'and Chef::Config.chef_repo_path set somewhere else' do
305
+ context "and Chef::Config.chef_repo_path set somewhere else" do
306
306
  before do
307
- Chef::Config.chef_repo_path = '/x/y/z'
307
+ Chef::Config.chef_repo_path = "/x/y/z"
308
308
  end
309
309
  it "chef_mirror :upload with chef_repo_path uploads cookbooks" do
310
310
  repository_dir = @repository_dir
311
- expect_recipe {
312
- chef_mirror '' do
311
+ expect_recipe do
312
+ chef_mirror "" do
313
313
  chef_repo_path repository_dir
314
314
  action :upload
315
315
  end
316
- }.to have_updated('chef_mirror[]', :upload)
317
- expect { get('cookbooks/x/1.0.0') }.not_to raise_error
318
- expect { get('cookbooks/x/2.0.0') }.not_to raise_error
316
+ end.to have_updated("chef_mirror[]", :upload)
317
+ expect { get("cookbooks/x/1.0.0") }.not_to raise_error
318
+ expect { get("cookbooks/x/2.0.0") }.not_to raise_error
319
319
  end
320
320
  end
321
321
 
322
- context 'and Chef::Config.chef_repo_path is not set but versioned_cookbooks is false' do
322
+ context "and Chef::Config.chef_repo_path is not set but versioned_cookbooks is false" do
323
323
  before do
324
324
  Chef::Config.delete(:chef_repo_path)
325
325
  Chef::Config.versioned_cookbooks false
@@ -327,158 +327,158 @@ describe Chef::Resource::ChefMirror do
327
327
 
328
328
  it "chef_mirror :upload with chef_repo_path uploads cookbooks with name split from version" do
329
329
  repository_dir = @repository_dir
330
- expect_recipe {
331
- chef_mirror '' do
330
+ expect_recipe do
331
+ chef_mirror "" do
332
332
  chef_repo_path repository_dir
333
333
  action :upload
334
334
  end
335
- }.to have_updated('chef_mirror[]', :upload)
336
- expect { get('cookbooks/x/1.0.0') }.not_to raise_error
337
- expect { get('cookbooks/x/2.0.0') }.not_to raise_error
335
+ end.to have_updated("chef_mirror[]", :upload)
336
+ expect { get("cookbooks/x/1.0.0") }.not_to raise_error
337
+ expect { get("cookbooks/x/2.0.0") }.not_to raise_error
338
338
  end
339
339
 
340
340
  it "chef_mirror :upload with chef_repo_path and versioned_cookbooks uploads cookbooks with name split from version" do
341
341
  repository_dir = @repository_dir
342
- expect_recipe {
343
- chef_mirror '' do
342
+ expect_recipe do
343
+ chef_mirror "" do
344
344
  chef_repo_path repository_dir
345
345
  versioned_cookbooks true
346
346
  action :upload
347
347
  end
348
- }.to have_updated('chef_mirror[]', :upload)
349
- expect { get('cookbooks/x/1.0.0') }.not_to raise_error
350
- expect { get('cookbooks/x/2.0.0') }.not_to raise_error
348
+ end.to have_updated("chef_mirror[]", :upload)
349
+ expect { get("cookbooks/x/1.0.0") }.not_to raise_error
350
+ expect { get("cookbooks/x/2.0.0") }.not_to raise_error
351
351
  end
352
352
  end
353
353
 
354
- context 'and Chef::Config.chef_repo_path is not set but versioned_cookbooks is true' do
354
+ context "and Chef::Config.chef_repo_path is not set but versioned_cookbooks is true" do
355
355
  before do
356
356
  Chef::Config.delete(:chef_repo_path)
357
357
  Chef::Config.versioned_cookbooks true
358
358
  end
359
359
  it "chef_mirror :upload with chef_repo_path uploads cookbooks with name split from version" do
360
360
  repository_dir = @repository_dir
361
- expect_recipe {
362
- chef_mirror '' do
361
+ expect_recipe do
362
+ chef_mirror "" do
363
363
  chef_repo_path repository_dir
364
364
  action :upload
365
365
  end
366
- }.to have_updated('chef_mirror[]', :upload)
367
- expect { get('cookbooks/x/1.0.0') }.not_to raise_error
368
- expect { get('cookbooks/x/2.0.0') }.not_to raise_error
366
+ end.to have_updated("chef_mirror[]", :upload)
367
+ expect { get("cookbooks/x/1.0.0") }.not_to raise_error
368
+ expect { get("cookbooks/x/2.0.0") }.not_to raise_error
369
369
  end
370
370
  end
371
371
  end
372
372
  end
373
373
 
374
- describe 'cookbook download, chef_repo_path, and versioned_cookbooks' do
375
- context 'when the Chef server has a cookbook with multiple versions' do
376
- cookbook 'x', '1.0.0', 'metadata.rb' => 'name "x"; version "1.0.0"'
377
- cookbook 'x', '2.0.0', 'metadata.rb' => 'name "x"; version "2.0.0"'
374
+ describe "cookbook download, chef_repo_path, and versioned_cookbooks" do
375
+ context "when the Chef server has a cookbook with multiple versions" do
376
+ cookbook "x", "1.0.0", "metadata.rb" => 'name "x"; version "1.0.0"'
377
+ cookbook "x", "2.0.0", "metadata.rb" => 'name "x"; version "2.0.0"'
378
378
 
379
- when_the_repository 'is empty' do
380
- it 'chef_mirror :download downloads the latest version of the cookbook' do
381
- expect_recipe {
382
- chef_mirror '' do
379
+ when_the_repository "is empty" do
380
+ it "chef_mirror :download downloads the latest version of the cookbook" do
381
+ expect_recipe do
382
+ chef_mirror "" do
383
383
  action :download
384
384
  end
385
- }.to have_updated('chef_mirror[]', :download)
386
- expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
385
+ end.to have_updated("chef_mirror[]", :download)
386
+ expect(File.read(path_to("cookbooks/x/metadata.rb"))).to eq('name "x"; version "2.0.0"')
387
387
  end
388
388
 
389
- it 'chef_mirror :download with versioned_cookbooks = true downloads all versions of the cookbook' do
390
- expect_recipe {
391
- chef_mirror '' do
389
+ it "chef_mirror :download with versioned_cookbooks = true downloads all versions of the cookbook" do
390
+ expect_recipe do
391
+ chef_mirror "" do
392
392
  versioned_cookbooks true
393
393
  action :download
394
394
  end
395
- }.to have_updated('chef_mirror[]', :download)
396
- expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
397
- expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
395
+ end.to have_updated("chef_mirror[]", :download)
396
+ expect(File.read(path_to("cookbooks/x-1.0.0/metadata.rb"))).to eq('name "x"; version "1.0.0"')
397
+ expect(File.read(path_to("cookbooks/x-2.0.0/metadata.rb"))).to eq('name "x"; version "2.0.0"')
398
398
  end
399
399
 
400
- context 'and Chef::Config.chef_repo_path is set elsewhere' do
400
+ context "and Chef::Config.chef_repo_path is set elsewhere" do
401
401
  before do
402
- Chef::Config.chef_repo_path = '/x/y/z'
402
+ Chef::Config.chef_repo_path = "/x/y/z"
403
403
  end
404
404
 
405
- it 'chef_mirror :download with chef_repo_path downloads all versions of the cookbook' do
405
+ it "chef_mirror :download with chef_repo_path downloads all versions of the cookbook" do
406
406
  repository_dir = @repository_dir
407
- expect_recipe {
408
- chef_mirror '' do
407
+ expect_recipe do
408
+ chef_mirror "" do
409
409
  chef_repo_path repository_dir
410
410
  action :download
411
411
  end
412
- }.to have_updated('chef_mirror[]', :download)
413
- expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
414
- expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
412
+ end.to have_updated("chef_mirror[]", :download)
413
+ expect(File.read(path_to("cookbooks/x-1.0.0/metadata.rb"))).to eq('name "x"; version "1.0.0"')
414
+ expect(File.read(path_to("cookbooks/x-2.0.0/metadata.rb"))).to eq('name "x"; version "2.0.0"')
415
415
  end
416
416
 
417
- it 'chef_mirror :download with chef_repo_path and versioned_cookbooks = false downloads the latest version of the cookbook' do
417
+ it "chef_mirror :download with chef_repo_path and versioned_cookbooks = false downloads the latest version of the cookbook" do
418
418
  repository_dir = @repository_dir
419
- expect_recipe {
420
- chef_mirror '' do
419
+ expect_recipe do
420
+ chef_mirror "" do
421
421
  chef_repo_path repository_dir
422
422
  versioned_cookbooks false
423
423
  action :download
424
424
  end
425
- }.to have_updated('chef_mirror[]', :download)
426
- expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
425
+ end.to have_updated("chef_mirror[]", :download)
426
+ expect(File.read(path_to("cookbooks/x/metadata.rb"))).to eq('name "x"; version "2.0.0"')
427
427
  end
428
428
  end
429
429
 
430
- context 'and Chef::Config.versioned_cookbooks is true' do
430
+ context "and Chef::Config.versioned_cookbooks is true" do
431
431
  before do
432
432
  Chef::Config.versioned_cookbooks = true
433
433
  end
434
434
 
435
- it 'chef_mirror :download downloads all versions of the cookbook' do
436
- expect_recipe {
437
- chef_mirror '' do
435
+ it "chef_mirror :download downloads all versions of the cookbook" do
436
+ expect_recipe do
437
+ chef_mirror "" do
438
438
  action :download
439
439
  end
440
- }.to have_updated('chef_mirror[]', :download)
441
- expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
442
- expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
440
+ end.to have_updated("chef_mirror[]", :download)
441
+ expect(File.read(path_to("cookbooks/x-1.0.0/metadata.rb"))).to eq('name "x"; version "1.0.0"')
442
+ expect(File.read(path_to("cookbooks/x-2.0.0/metadata.rb"))).to eq('name "x"; version "2.0.0"')
443
443
  end
444
444
 
445
- it 'chef_mirror :download with versioned_cookbooks = false downloads the latest version of the cookbook' do
446
- expect_recipe {
447
- chef_mirror '' do
445
+ it "chef_mirror :download with versioned_cookbooks = false downloads the latest version of the cookbook" do
446
+ expect_recipe do
447
+ chef_mirror "" do
448
448
  versioned_cookbooks false
449
449
  action :download
450
450
  end
451
- }.to have_updated('chef_mirror[]', :download)
452
- expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
451
+ end.to have_updated("chef_mirror[]", :download)
452
+ expect(File.read(path_to("cookbooks/x/metadata.rb"))).to eq('name "x"; version "2.0.0"')
453
453
  end
454
454
 
455
- context 'and Chef::Config.chef_repo_path is set elsewhere' do
455
+ context "and Chef::Config.chef_repo_path is set elsewhere" do
456
456
  before do
457
- Chef::Config.chef_repo_path = '/x/y/z'
457
+ Chef::Config.chef_repo_path = "/x/y/z"
458
458
  end
459
459
 
460
- it 'chef_mirror :download with chef_repo_path downloads all versions of the cookbook' do
460
+ it "chef_mirror :download with chef_repo_path downloads all versions of the cookbook" do
461
461
  repository_dir = @repository_dir
462
- expect_recipe {
463
- chef_mirror '' do
462
+ expect_recipe do
463
+ chef_mirror "" do
464
464
  chef_repo_path repository_dir
465
465
  action :download
466
466
  end
467
- }.to have_updated('chef_mirror[]', :download)
468
- expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
469
- expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
467
+ end.to have_updated("chef_mirror[]", :download)
468
+ expect(File.read(path_to("cookbooks/x-1.0.0/metadata.rb"))).to eq('name "x"; version "1.0.0"')
469
+ expect(File.read(path_to("cookbooks/x-2.0.0/metadata.rb"))).to eq('name "x"; version "2.0.0"')
470
470
  end
471
471
 
472
- it 'chef_mirror :download with chef_repo_path and versioned_cookbooks = false downloads the latest version of the cookbook' do
472
+ it "chef_mirror :download with chef_repo_path and versioned_cookbooks = false downloads the latest version of the cookbook" do
473
473
  repository_dir = @repository_dir
474
- expect_recipe {
475
- chef_mirror '' do
474
+ expect_recipe do
475
+ chef_mirror "" do
476
476
  chef_repo_path repository_dir
477
477
  versioned_cookbooks false
478
478
  action :download
479
479
  end
480
- }.to have_updated('chef_mirror[]', :download)
481
- expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
480
+ end.to have_updated("chef_mirror[]", :download)
481
+ expect(File.read(path_to("cookbooks/x/metadata.rb"))).to eq('name "x"; version "2.0.0"')
482
482
  end
483
483
  end
484
484
  end