ridley 4.0.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/Gemfile +1 -1
  4. data/README.md +4 -4
  5. data/Rakefile +1 -0
  6. data/lib/ridley/chef/config.rb +5 -5
  7. data/lib/ridley/chef/cookbook/metadata.rb +59 -14
  8. data/lib/ridley/chef/cookbook/syntax_check.rb +57 -19
  9. data/lib/ridley/chef/cookbook.rb +1 -1
  10. data/lib/ridley/chef/digester.rb +3 -1
  11. data/lib/ridley/client.rb +6 -3
  12. data/lib/ridley/connection.rb +5 -4
  13. data/lib/ridley/errors.rb +1 -0
  14. data/lib/ridley/helpers.rb +10 -0
  15. data/lib/ridley/mixin/params_validate.rb +4 -0
  16. data/lib/ridley/resources/cookbook_resource.rb +14 -2
  17. data/lib/ridley/version.rb +1 -1
  18. data/ridley.gemspec +5 -5
  19. data/spec/acceptance/client_resource_spec.rb +12 -12
  20. data/spec/acceptance/cookbook_resource_spec.rb +15 -15
  21. data/spec/acceptance/data_bag_item_resource_spec.rb +14 -14
  22. data/spec/acceptance/data_bag_resource_spec.rb +4 -4
  23. data/spec/acceptance/environment_resource_spec.rb +14 -14
  24. data/spec/acceptance/node_resource_spec.rb +15 -15
  25. data/spec/acceptance/role_resource_spec.rb +14 -14
  26. data/spec/acceptance/sandbox_resource_spec.rb +3 -3
  27. data/spec/acceptance/search_resource_spec.rb +6 -6
  28. data/spec/acceptance/user_resource_spec.rb +21 -21
  29. data/spec/support/each_matcher.rb +2 -2
  30. data/spec/support/filepath_matchers.rb +2 -2
  31. data/spec/support/shared_examples/ridley_resource.rb +39 -39
  32. data/spec/unit/ridley/chef/cookbook/metadata_spec.rb +8 -8
  33. data/spec/unit/ridley/chef/cookbook/syntax_check_spec.rb +15 -15
  34. data/spec/unit/ridley/chef/cookbook_spec.rb +159 -114
  35. data/spec/unit/ridley/chef/digester_spec.rb +2 -2
  36. data/spec/unit/ridley/chef_object_spec.rb +35 -35
  37. data/spec/unit/ridley/chef_objects/client_object_spec.rb +2 -2
  38. data/spec/unit/ridley/chef_objects/cookbook_object_spec.rb +12 -12
  39. data/spec/unit/ridley/chef_objects/data_bag_item_object_spec.rb +7 -7
  40. data/spec/unit/ridley/chef_objects/data_bag_object_spec.rb +4 -1
  41. data/spec/unit/ridley/chef_objects/environment_object_spec.rb +10 -10
  42. data/spec/unit/ridley/chef_objects/node_object_spec.rb +28 -28
  43. data/spec/unit/ridley/chef_objects/role_object_spec.rb +10 -10
  44. data/spec/unit/ridley/chef_objects/sandbox_object_spec.rb +6 -6
  45. data/spec/unit/ridley/client_spec.rb +59 -21
  46. data/spec/unit/ridley/connection_spec.rb +7 -7
  47. data/spec/unit/ridley/errors_spec.rb +3 -3
  48. data/spec/unit/ridley/middleware/chef_auth_spec.rb +2 -2
  49. data/spec/unit/ridley/middleware/chef_response_spec.rb +29 -29
  50. data/spec/unit/ridley/middleware/parse_json_spec.rb +14 -14
  51. data/spec/unit/ridley/mixins/from_file_spec.rb +3 -3
  52. data/spec/unit/ridley/resource_spec.rb +5 -5
  53. data/spec/unit/ridley/resources/cookbook_resource_spec.rb +21 -21
  54. data/spec/unit/ridley/resources/data_bag_item_resource_spec.rb +1 -1
  55. data/spec/unit/ridley/resources/data_bag_resource_spec.rb +6 -3
  56. data/spec/unit/ridley/resources/environment_resource_spec.rb +4 -4
  57. data/spec/unit/ridley/resources/role_resource_spec.rb +1 -1
  58. data/spec/unit/ridley/resources/sandbox_resource_spec.rb +7 -7
  59. data/spec/unit/ridley/resources/search_resource_spec.rb +22 -22
  60. data/spec/unit/ridley/sandbox_uploader_spec.rb +3 -3
  61. data/spec/unit/ridley_spec.rb +6 -6
  62. metadata +62 -64
  63. data/.ruby-version +0 -1
  64. data/lib/ridley/middleware/gzip.rb +0 -18
  65. data/spec/unit/ridley/middleware/gzip_spec.rb +0 -59
@@ -8,18 +8,18 @@ describe Ridley::Chef::Cookbook do
8
8
  let(:cookbook_path) { fixtures_path.join("example_cookbook") }
9
9
 
10
10
  it "returns an instance of Ridley::Chef::Cookbook" do
11
- subject.from_path(cookbook_path).should be_a(described_class)
11
+ expect(subject.from_path(cookbook_path)).to be_a(described_class)
12
12
  end
13
13
 
14
14
  it "has a cookbook_name attribute set to the value of the 'name' attribute in the metadata" do
15
- subject.from_path(cookbook_path).cookbook_name.should eql("example_cookbook")
15
+ expect(subject.from_path(cookbook_path).cookbook_name).to eql("example_cookbook")
16
16
  end
17
17
 
18
18
  context "given a path that does not contain a metadata file" do
19
19
  it "raises an IOError" do
20
- lambda {
20
+ expect {
21
21
  subject.from_path(Dir.mktmpdir)
22
- }.should raise_error(IOError)
22
+ }.to raise_error(IOError)
23
23
  end
24
24
  end
25
25
 
@@ -51,7 +51,7 @@ describe Ridley::Chef::Cookbook do
51
51
  end
52
52
 
53
53
  it "sets the name of the cookbook from the metadata.rb" do
54
- subject.from_path(cookbook_path).cookbook_name.should eql("rspec_test")
54
+ expect(subject.from_path(cookbook_path).cookbook_name).to eql("rspec_test")
55
55
  end
56
56
  end
57
57
 
@@ -73,7 +73,7 @@ describe Ridley::Chef::Cookbook do
73
73
  end
74
74
 
75
75
  it "prefers the metadata.json" do
76
- subject.from_path(cookbook_path).cookbook_name.should eql("json_metadata")
76
+ expect(subject.from_path(cookbook_path).cookbook_name).to eql("json_metadata")
77
77
  end
78
78
  end
79
79
  end
@@ -81,7 +81,7 @@ describe Ridley::Chef::Cookbook do
81
81
  describe "::checksum" do
82
82
  it "delegates to Ridley::Chef::Digester.md5_checksum_for_file" do
83
83
  path = fixtures_path.join("example_cookbook", "metadata.rb")
84
- Ridley::Chef::Digester.should_receive(:md5_checksum_for_file).with(path)
84
+ expect(Ridley::Chef::Digester).to receive(:md5_checksum_for_file).with(path)
85
85
 
86
86
  subject.checksum(path)
87
87
  end
@@ -96,11 +96,11 @@ describe Ridley::Chef::Cookbook do
96
96
 
97
97
  describe "#checksums" do
98
98
  it "returns a Hash" do
99
- subject.checksums.should be_a(Hash)
99
+ expect(subject.checksums).to be_a(Hash)
100
100
  end
101
101
 
102
102
  it "has a key value for every cookbook file" do
103
- subject.checksums.should have(subject.send(:files).length).items
103
+ expect(subject.checksums.size).to eq(subject.send(:files).length)
104
104
  end
105
105
  end
106
106
 
@@ -118,10 +118,10 @@ describe Ridley::Chef::Cookbook do
118
118
  end
119
119
 
120
120
  it "compiles the raw metadata.rb into a metadata.json file in the path of the cookbook" do
121
- expect(subject.compiled_metadata?).to be_false
121
+ expect(subject.compiled_metadata?).to be_falsey
122
122
  subject.compile_metadata
123
123
  subject.reload
124
- expect(subject.compiled_metadata?).to be_true
124
+ expect(subject.compiled_metadata?).to be_truthy
125
125
  expect(subject.cookbook_name).to eql("rspec_test")
126
126
  expect(subject.version).to eql("1.2.3")
127
127
  end
@@ -132,7 +132,7 @@ describe Ridley::Chef::Cookbook do
132
132
 
133
133
  it "writes the compiled metadata to a metadata.json file at the given out path" do
134
134
  subject.compile_metadata(out_path)
135
- expect(File.exist?(File.join(out_path, "metadata.json"))).to be_true
135
+ expect(File.exist?(File.join(out_path, "metadata.json"))).to be_truthy
136
136
  end
137
137
  end
138
138
  end
@@ -152,7 +152,10 @@ describe Ridley::Chef::Cookbook do
152
152
  end
153
153
  end
154
154
 
155
- its(:compiled_metadata?) { should be_true }
155
+ describe '#compiled_metadata?' do
156
+ subject { super().compiled_metadata? }
157
+ it { is_expected.to be_truthy }
158
+ end
156
159
  end
157
160
 
158
161
  context "when a metadata.json file is not present" do
@@ -164,7 +167,10 @@ describe Ridley::Chef::Cookbook do
164
167
  end
165
168
  end
166
169
 
167
- its(:compiled_metadata?) { should be_false }
170
+ describe '#compiled_metadata?' do
171
+ subject { super().compiled_metadata? }
172
+ it { is_expected.to be_falsey }
173
+ end
168
174
  end
169
175
  end
170
176
 
@@ -181,7 +187,7 @@ describe Ridley::Chef::Cookbook do
181
187
  :providers,
182
188
  :root_files
183
189
  ].each do |category|
184
- subject.manifest.should have_key(category)
190
+ expect(subject.manifest).to have_key(category)
185
191
  end
186
192
  end
187
193
  end
@@ -190,31 +196,31 @@ describe Ridley::Chef::Cookbook do
190
196
  let(:syntax_checker) { double('syntax_checker') }
191
197
 
192
198
  before(:each) do
193
- subject.stub(:syntax_checker) { syntax_checker }
199
+ allow(subject).to receive(:syntax_checker) { syntax_checker }
194
200
  end
195
201
 
196
202
  it "asks the syntax_checker to validate the ruby and template files of the cookbook" do
197
- syntax_checker.should_receive(:validate_ruby_files).and_return(true)
198
- syntax_checker.should_receive(:validate_templates).and_return(true)
203
+ expect(syntax_checker).to receive(:validate_ruby_files).and_return(true)
204
+ expect(syntax_checker).to receive(:validate_templates).and_return(true)
199
205
 
200
206
  subject.validate
201
207
  end
202
208
 
203
209
  it "raises CookbookSyntaxError if the cookbook contains invalid ruby files" do
204
- syntax_checker.should_receive(:validate_ruby_files).and_return(false)
210
+ expect(syntax_checker).to receive(:validate_ruby_files).and_return(false)
205
211
 
206
- lambda {
212
+ expect {
207
213
  subject.validate
208
- }.should raise_error(Ridley::Errors::CookbookSyntaxError)
214
+ }.to raise_error(Ridley::Errors::CookbookSyntaxError)
209
215
  end
210
216
 
211
217
  it "raises CookbookSyntaxError if the cookbook contains invalid template files" do
212
- syntax_checker.should_receive(:validate_ruby_files).and_return(true)
213
- syntax_checker.should_receive(:validate_templates).and_return(false)
218
+ expect(syntax_checker).to receive(:validate_ruby_files).and_return(true)
219
+ expect(syntax_checker).to receive(:validate_templates).and_return(false)
214
220
 
215
- lambda {
221
+ expect {
216
222
  subject.validate
217
- }.should raise_error(Ridley::Errors::CookbookSyntaxError)
223
+ }.to raise_error(Ridley::Errors::CookbookSyntaxError)
218
224
  end
219
225
  end
220
226
 
@@ -223,23 +229,23 @@ describe Ridley::Chef::Cookbook do
223
229
  before(:each) { @metadata = subject.file_metadata(:file, file) }
224
230
 
225
231
  it "has a :path key whose value is a relative path from the CachedCookbook's path" do
226
- @metadata.should have_key(:path)
227
- @metadata[:path].should be_relative_path
228
- @metadata[:path].should eql("files/default/file.h")
232
+ expect(@metadata).to have_key(:path)
233
+ expect(@metadata[:path]).to be_relative_path
234
+ expect(@metadata[:path]).to eql("files/default/file.h")
229
235
  end
230
236
 
231
237
  it "has a :name key whose value is the basename of the target file" do
232
- @metadata.should have_key(:name)
233
- @metadata[:name].should eql("file.h")
238
+ expect(@metadata).to have_key(:name)
239
+ expect(@metadata[:name]).to eql("file.h")
234
240
  end
235
241
 
236
242
  it "has a :checksum key whose value is the checksum of the target file" do
237
- @metadata.should have_key(:checksum)
238
- @metadata[:checksum].should eql("7b1ebd2ff580ca9dc46fb27ec1653bf2")
243
+ expect(@metadata).to have_key(:checksum)
244
+ expect(@metadata[:checksum]).to eql("7b1ebd2ff580ca9dc46fb27ec1653bf2")
239
245
  end
240
246
 
241
247
  it "has a :specificity key" do
242
- @metadata.should have_key(:specificity)
248
+ expect(@metadata).to have_key(:specificity)
243
249
  end
244
250
 
245
251
  context "given a file or template in a 'default' directory" do
@@ -247,7 +253,7 @@ describe Ridley::Chef::Cookbook do
247
253
  before(:each) { @metadata = subject.file_metadata(:files, file) }
248
254
 
249
255
  it "has a specificity of 'default'" do
250
- @metadata[:specificity].should eql("default")
256
+ expect(@metadata[:specificity]).to eql("default")
251
257
  end
252
258
  end
253
259
 
@@ -256,7 +262,46 @@ describe Ridley::Chef::Cookbook do
256
262
  before(:each) { @metadata = subject.file_metadata(:files, file) }
257
263
 
258
264
  it "has a specificity of 'ubuntu'" do
259
- @metadata[:specificity].should eql("ubuntu")
265
+ expect(@metadata[:specificity]).to eql("ubuntu")
266
+ end
267
+ end
268
+ end
269
+
270
+ describe "#file_specificity" do
271
+ let(:category) { :templates }
272
+ let(:relpath) { 'default.rb' }
273
+ let(:file) { subject.path.join(category.to_s, relpath) }
274
+ before(:each) { @specificity = subject.file_specificity(category, file) }
275
+
276
+ context "given a recipe file" do
277
+ let(:category) { :recipes }
278
+
279
+ it "has a specificity of 'default'" do
280
+ expect(@specificity).to eql("default")
281
+ end
282
+ end
283
+
284
+ context "given a template 'default/config.erb'" do
285
+ let(:relpath) { 'default/config.erb' }
286
+
287
+ it "has a specificity of 'default'" do
288
+ expect(@specificity).to eql("default")
289
+ end
290
+ end
291
+
292
+ context "given a template 'centos/config.erb'" do
293
+ let(:relpath) { 'centos/config.erb' }
294
+
295
+ it "has a specificity of 'centos'" do
296
+ expect(@specificity).to eql("centos")
297
+ end
298
+ end
299
+
300
+ context "given a template 'config.erb'" do
301
+ let(:relpath) { 'config.erb' }
302
+
303
+ it "has a specificity of 'root_default'" do
304
+ expect(@specificity).to eql("root_default")
260
305
  end
261
306
  end
262
307
  end
@@ -265,255 +310,255 @@ describe Ridley::Chef::Cookbook do
265
310
  subject { cookbook.to_hash }
266
311
 
267
312
  it "has a :frozen? flag" do
268
- subject.should have_key(:frozen?)
313
+ expect(subject).to have_key(:frozen?)
269
314
  end
270
315
 
271
316
  it "has a :recipes key with a value of an Array Hashes" do
272
- subject.should have_key(:recipes)
273
- subject[:recipes].should be_a(Array)
317
+ expect(subject).to have_key(:recipes)
318
+ expect(subject[:recipes]).to be_a(Array)
274
319
  subject[:recipes].each do |item|
275
- item.should be_a(Hash)
320
+ expect(item).to be_a(Hash)
276
321
  end
277
322
  end
278
323
 
279
324
  it "has a :name key value pair in a Hash of the :recipes Array of Hashes" do
280
- subject[:recipes].first.should have_key(:name)
325
+ expect(subject[:recipes].first).to have_key(:name)
281
326
  end
282
327
 
283
328
  it "has a :path key value pair in a Hash of the :recipes Array of Hashes" do
284
- subject[:recipes].first.should have_key(:path)
329
+ expect(subject[:recipes].first).to have_key(:path)
285
330
  end
286
331
 
287
332
  it "has a :checksum key value pair in a Hash of the :recipes Array of Hashes" do
288
- subject[:recipes].first.should have_key(:checksum)
333
+ expect(subject[:recipes].first).to have_key(:checksum)
289
334
  end
290
335
 
291
336
  it "has a :specificity key value pair in a Hash of the :recipes Array of Hashes" do
292
- subject[:recipes].first.should have_key(:specificity)
337
+ expect(subject[:recipes].first).to have_key(:specificity)
293
338
  end
294
339
 
295
340
  it "has a :definitions key with a value of an Array Hashes" do
296
- subject.should have_key(:definitions)
297
- subject[:definitions].should be_a(Array)
341
+ expect(subject).to have_key(:definitions)
342
+ expect(subject[:definitions]).to be_a(Array)
298
343
  subject[:definitions].each do |item|
299
- item.should be_a(Hash)
344
+ expect(item).to be_a(Hash)
300
345
  end
301
346
  end
302
347
 
303
348
  it "has a :name key value pair in a Hash of the :definitions Array of Hashes" do
304
- subject[:definitions].first.should have_key(:name)
349
+ expect(subject[:definitions].first).to have_key(:name)
305
350
  end
306
351
 
307
352
  it "has a :path key value pair in a Hash of the :definitions Array of Hashes" do
308
- subject[:definitions].first.should have_key(:path)
353
+ expect(subject[:definitions].first).to have_key(:path)
309
354
  end
310
355
 
311
356
  it "has a :checksum key value pair in a Hash of the :definitions Array of Hashes" do
312
- subject[:definitions].first.should have_key(:checksum)
357
+ expect(subject[:definitions].first).to have_key(:checksum)
313
358
  end
314
359
 
315
360
  it "has a :specificity key value pair in a Hash of the :definitions Array of Hashes" do
316
- subject[:definitions].first.should have_key(:specificity)
361
+ expect(subject[:definitions].first).to have_key(:specificity)
317
362
  end
318
363
 
319
364
  it "has a :libraries key with a value of an Array Hashes" do
320
- subject.should have_key(:libraries)
321
- subject[:libraries].should be_a(Array)
365
+ expect(subject).to have_key(:libraries)
366
+ expect(subject[:libraries]).to be_a(Array)
322
367
  subject[:libraries].each do |item|
323
- item.should be_a(Hash)
368
+ expect(item).to be_a(Hash)
324
369
  end
325
370
  end
326
371
 
327
372
  it "has a :name key value pair in a Hash of the :libraries Array of Hashes" do
328
- subject[:libraries].first.should have_key(:name)
373
+ expect(subject[:libraries].first).to have_key(:name)
329
374
  end
330
375
 
331
376
  it "has a :path key value pair in a Hash of the :libraries Array of Hashes" do
332
- subject[:libraries].first.should have_key(:path)
377
+ expect(subject[:libraries].first).to have_key(:path)
333
378
  end
334
379
 
335
380
  it "has a :checksum key value pair in a Hash of the :libraries Array of Hashes" do
336
- subject[:libraries].first.should have_key(:checksum)
381
+ expect(subject[:libraries].first).to have_key(:checksum)
337
382
  end
338
383
 
339
384
  it "has a :specificity key value pair in a Hash of the :libraries Array of Hashes" do
340
- subject[:libraries].first.should have_key(:specificity)
385
+ expect(subject[:libraries].first).to have_key(:specificity)
341
386
  end
342
387
 
343
388
  it "has a :attributes key with a value of an Array Hashes" do
344
- subject.should have_key(:attributes)
345
- subject[:attributes].should be_a(Array)
389
+ expect(subject).to have_key(:attributes)
390
+ expect(subject[:attributes]).to be_a(Array)
346
391
  subject[:attributes].each do |item|
347
- item.should be_a(Hash)
392
+ expect(item).to be_a(Hash)
348
393
  end
349
394
  end
350
395
 
351
396
  it "has a :name key value pair in a Hash of the :attributes Array of Hashes" do
352
- subject[:attributes].first.should have_key(:name)
397
+ expect(subject[:attributes].first).to have_key(:name)
353
398
  end
354
399
 
355
400
  it "has a :path key value pair in a Hash of the :attributes Array of Hashes" do
356
- subject[:attributes].first.should have_key(:path)
401
+ expect(subject[:attributes].first).to have_key(:path)
357
402
  end
358
403
 
359
404
  it "has a :checksum key value pair in a Hash of the :attributes Array of Hashes" do
360
- subject[:attributes].first.should have_key(:checksum)
405
+ expect(subject[:attributes].first).to have_key(:checksum)
361
406
  end
362
407
 
363
408
  it "has a :specificity key value pair in a Hash of the :attributes Array of Hashes" do
364
- subject[:attributes].first.should have_key(:specificity)
409
+ expect(subject[:attributes].first).to have_key(:specificity)
365
410
  end
366
411
 
367
412
  it "has a :files key with a value of an Array Hashes" do
368
- subject.should have_key(:files)
369
- subject[:files].should be_a(Array)
413
+ expect(subject).to have_key(:files)
414
+ expect(subject[:files]).to be_a(Array)
370
415
  subject[:files].each do |item|
371
- item.should be_a(Hash)
416
+ expect(item).to be_a(Hash)
372
417
  end
373
418
  end
374
419
 
375
420
  it "has a :name key value pair in a Hash of the :files Array of Hashes" do
376
- subject[:files].first.should have_key(:name)
421
+ expect(subject[:files].first).to have_key(:name)
377
422
  end
378
423
 
379
424
  it "has a :path key value pair in a Hash of the :files Array of Hashes" do
380
- subject[:files].first.should have_key(:path)
425
+ expect(subject[:files].first).to have_key(:path)
381
426
  end
382
427
 
383
428
  it "has a :checksum key value pair in a Hash of the :files Array of Hashes" do
384
- subject[:files].first.should have_key(:checksum)
429
+ expect(subject[:files].first).to have_key(:checksum)
385
430
  end
386
431
 
387
432
  it "has a :specificity key value pair in a Hash of the :files Array of Hashes" do
388
- subject[:files].first.should have_key(:specificity)
433
+ expect(subject[:files].first).to have_key(:specificity)
389
434
  end
390
435
 
391
436
  it "has a :templates key with a value of an Array Hashes" do
392
- subject.should have_key(:templates)
393
- subject[:templates].should be_a(Array)
437
+ expect(subject).to have_key(:templates)
438
+ expect(subject[:templates]).to be_a(Array)
394
439
  subject[:templates].each do |item|
395
- item.should be_a(Hash)
440
+ expect(item).to be_a(Hash)
396
441
  end
397
442
  end
398
443
 
399
444
  it "has a :name key value pair in a Hash of the :templates Array of Hashes" do
400
- subject[:templates].first.should have_key(:name)
445
+ expect(subject[:templates].first).to have_key(:name)
401
446
  end
402
447
 
403
448
  it "has a :path key value pair in a Hash of the :templates Array of Hashes" do
404
- subject[:templates].first.should have_key(:path)
449
+ expect(subject[:templates].first).to have_key(:path)
405
450
  end
406
451
 
407
452
  it "has a :checksum key value pair in a Hash of the :templates Array of Hashes" do
408
- subject[:templates].first.should have_key(:checksum)
453
+ expect(subject[:templates].first).to have_key(:checksum)
409
454
  end
410
455
 
411
456
  it "has a :specificity key value pair in a Hash of the :templates Array of Hashes" do
412
- subject[:templates].first.should have_key(:specificity)
457
+ expect(subject[:templates].first).to have_key(:specificity)
413
458
  end
414
459
 
415
460
  it "has a :resources key with a value of an Array Hashes" do
416
- subject.should have_key(:resources)
417
- subject[:resources].should be_a(Array)
461
+ expect(subject).to have_key(:resources)
462
+ expect(subject[:resources]).to be_a(Array)
418
463
  subject[:resources].each do |item|
419
- item.should be_a(Hash)
464
+ expect(item).to be_a(Hash)
420
465
  end
421
466
  end
422
467
 
423
468
  it "has a :name key value pair in a Hash of the :resources Array of Hashes" do
424
- subject[:resources].first.should have_key(:name)
469
+ expect(subject[:resources].first).to have_key(:name)
425
470
  end
426
471
 
427
472
  it "has a :path key value pair in a Hash of the :resources Array of Hashes" do
428
- subject[:resources].first.should have_key(:path)
473
+ expect(subject[:resources].first).to have_key(:path)
429
474
  end
430
475
 
431
476
  it "has a :checksum key value pair in a Hash of the :resources Array of Hashes" do
432
- subject[:resources].first.should have_key(:checksum)
477
+ expect(subject[:resources].first).to have_key(:checksum)
433
478
  end
434
479
 
435
480
  it "has a :specificity key value pair in a Hash of the :resources Array of Hashes" do
436
- subject[:resources].first.should have_key(:specificity)
481
+ expect(subject[:resources].first).to have_key(:specificity)
437
482
  end
438
483
 
439
484
  it "has a :providers key with a value of an Array Hashes" do
440
- subject.should have_key(:providers)
441
- subject[:providers].should be_a(Array)
485
+ expect(subject).to have_key(:providers)
486
+ expect(subject[:providers]).to be_a(Array)
442
487
  subject[:providers].each do |item|
443
- item.should be_a(Hash)
488
+ expect(item).to be_a(Hash)
444
489
  end
445
490
  end
446
491
 
447
492
  it "has a :name key value pair in a Hash of the :providers Array of Hashes" do
448
- subject[:providers].first.should have_key(:name)
493
+ expect(subject[:providers].first).to have_key(:name)
449
494
  end
450
495
 
451
496
  it "has a :path key value pair in a Hash of the :providers Array of Hashes" do
452
- subject[:providers].first.should have_key(:path)
497
+ expect(subject[:providers].first).to have_key(:path)
453
498
  end
454
499
 
455
500
  it "has a :checksum key value pair in a Hash of the :providers Array of Hashes" do
456
- subject[:providers].first.should have_key(:checksum)
501
+ expect(subject[:providers].first).to have_key(:checksum)
457
502
  end
458
503
 
459
504
  it "has a :specificity key value pair in a Hash of the :providers Array of Hashes" do
460
- subject[:providers].first.should have_key(:specificity)
505
+ expect(subject[:providers].first).to have_key(:specificity)
461
506
  end
462
507
 
463
508
  it "has a :root_files key with a value of an Array Hashes" do
464
- subject.should have_key(:root_files)
465
- subject[:root_files].should be_a(Array)
509
+ expect(subject).to have_key(:root_files)
510
+ expect(subject[:root_files]).to be_a(Array)
466
511
  subject[:root_files].each do |item|
467
- item.should be_a(Hash)
512
+ expect(item).to be_a(Hash)
468
513
  end
469
514
  end
470
515
 
471
516
  it "has a :name key value pair in a Hash of the :root_files Array of Hashes" do
472
- subject[:root_files].first.should have_key(:name)
517
+ expect(subject[:root_files].first).to have_key(:name)
473
518
  end
474
519
 
475
520
  it "has a :path key value pair in a Hash of the :root_files Array of Hashes" do
476
- subject[:root_files].first.should have_key(:path)
521
+ expect(subject[:root_files].first).to have_key(:path)
477
522
  end
478
523
 
479
524
  it "has a :checksum key value pair in a Hash of the :root_files Array of Hashes" do
480
- subject[:root_files].first.should have_key(:checksum)
525
+ expect(subject[:root_files].first).to have_key(:checksum)
481
526
  end
482
527
 
483
528
  it "has a :specificity key value pair in a Hash of the :root_files Array of Hashes" do
484
- subject[:root_files].first.should have_key(:specificity)
529
+ expect(subject[:root_files].first).to have_key(:specificity)
485
530
  end
486
531
 
487
532
  it "has a :cookbook_name key with a String value" do
488
- subject.should have_key(:cookbook_name)
489
- subject[:cookbook_name].should be_a(String)
533
+ expect(subject).to have_key(:cookbook_name)
534
+ expect(subject[:cookbook_name]).to be_a(String)
490
535
  end
491
536
 
492
537
  it "has a :metadata key with a Hashie::Mash value" do
493
- subject.should have_key(:metadata)
494
- subject[:metadata].should be_a(Hashie::Mash)
538
+ expect(subject).to have_key(:metadata)
539
+ expect(subject[:metadata]).to be_a(Hashie::Mash)
495
540
  end
496
541
 
497
542
  it "has a :version key with a String value" do
498
- subject.should have_key(:version)
499
- subject[:version].should be_a(String)
543
+ expect(subject).to have_key(:version)
544
+ expect(subject[:version]).to be_a(String)
500
545
  end
501
546
 
502
547
  it "has a :name key with a String value" do
503
- subject.should have_key(:name)
504
- subject[:name].should be_a(String)
548
+ expect(subject).to have_key(:name)
549
+ expect(subject[:name]).to be_a(String)
505
550
  end
506
551
 
507
552
  it "has a value containing the cookbook name and version separated by a dash for :name" do
508
553
  name, version = subject[:name].split('-')
509
554
 
510
- name.should eql(cookbook.cookbook_name)
511
- version.should eql(cookbook.version)
555
+ expect(name).to eql(cookbook.cookbook_name)
556
+ expect(version).to eql(cookbook.version)
512
557
  end
513
558
 
514
559
  it "has a :chef_type key with Cookbook::CHEF_TYPE as the value" do
515
- subject.should have_key(:chef_type)
516
- subject[:chef_type].should eql(Ridley::Chef::Cookbook::CHEF_TYPE)
560
+ expect(subject).to have_key(:chef_type)
561
+ expect(subject[:chef_type]).to eql(Ridley::Chef::Cookbook::CHEF_TYPE)
517
562
  end
518
563
  end
519
564
 
@@ -523,12 +568,12 @@ describe Ridley::Chef::Cookbook do
523
568
  end
524
569
 
525
570
  it "has a 'json_class' key with Cookbook::CHEF_JSON_CLASS as the value" do
526
- @json.should have_json_path('json_class')
527
- parse_json(@json)['json_class'].should eql(Ridley::Chef::Cookbook::CHEF_JSON_CLASS)
571
+ expect(@json).to have_json_path('json_class')
572
+ expect(parse_json(@json)['json_class']).to eql(Ridley::Chef::Cookbook::CHEF_JSON_CLASS)
528
573
  end
529
574
 
530
575
  it "has a 'frozen?' flag" do
531
- @json.should have_json_path('frozen?')
576
+ expect(@json).to have_json_path('frozen?')
532
577
  end
533
578
  end
534
579
  end
@@ -9,14 +9,14 @@ describe Ridley::Chef::Digester do
9
9
 
10
10
  describe "when computing checksums of cookbook files and templates" do
11
11
  it "proxies the class method checksum_for_file to the instance" do
12
- @cache.should_receive(:checksum_for_file).with("a_file_or_a_fail")
12
+ expect(@cache).to receive(:checksum_for_file).with("a_file_or_a_fail")
13
13
  described_class.checksum_for_file("a_file_or_a_fail")
14
14
  end
15
15
 
16
16
  it "generates a checksum from a non-file IO object" do
17
17
  io = StringIO.new("riseofthemachines\nriseofthechefs\n")
18
18
  expected_md5 = '0e157ac1e2dd73191b76067fb6b4bceb'
19
- @cache.generate_md5_checksum(io).should == expected_md5
19
+ expect(@cache.generate_md5_checksum(io)).to eq(expected_md5)
20
20
  end
21
21
  end
22
22
  end