berkshelf 3.1.5 → 3.2.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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/berkshelf.gemspec +6 -5
  4. data/features/commands/search.feature +2 -2
  5. data/features/commands/vendor.feature +6 -2
  6. data/features/commands/verify.feature +29 -0
  7. data/features/config.feature +13 -48
  8. data/features/step_definitions/filesystem_steps.rb +2 -2
  9. data/features/step_definitions/gem_steps.rb +3 -1
  10. data/features/step_definitions/utility_steps.rb +2 -2
  11. data/generator_files/Vagrantfile.erb +30 -30
  12. data/generator_files/metadata.rb.erb +0 -1
  13. data/lib/berkshelf.rb +5 -2
  14. data/lib/berkshelf/berksfile.rb +41 -41
  15. data/lib/berkshelf/cli.rb +11 -1
  16. data/lib/berkshelf/community_rest.rb +1 -0
  17. data/lib/berkshelf/config.rb +18 -4
  18. data/lib/berkshelf/cookbook_store.rb +1 -1
  19. data/lib/berkshelf/downloader.rb +4 -0
  20. data/lib/berkshelf/errors.rb +0 -1
  21. data/lib/berkshelf/file_syncer.rb +134 -0
  22. data/lib/berkshelf/locations/base.rb +6 -1
  23. data/lib/berkshelf/locations/git.rb +2 -2
  24. data/lib/berkshelf/lockfile.rb +14 -2
  25. data/lib/berkshelf/uploader.rb +10 -17
  26. data/lib/berkshelf/validator.rb +37 -0
  27. data/lib/berkshelf/version.rb +1 -1
  28. data/lib/berkshelf/visualizer.rb +13 -6
  29. data/spec/spec_helper.rb +1 -1
  30. data/spec/support/kitchen.rb +3 -1
  31. data/spec/support/matchers/file_system_matchers.rb +1 -1
  32. data/spec/support/matchers/filepath_matchers.rb +38 -2
  33. data/spec/support/shared_examples/formatter.rb +7 -7
  34. data/spec/unit/berkshelf/berksfile_spec.rb +51 -21
  35. data/spec/unit/berkshelf/cached_cookbook_spec.rb +5 -5
  36. data/spec/unit/berkshelf/cli_spec.rb +1 -1
  37. data/spec/unit/berkshelf/community_rest_spec.rb +12 -12
  38. data/spec/unit/berkshelf/config_spec.rb +4 -4
  39. data/spec/unit/berkshelf/cookbook_generator_spec.rb +2 -2
  40. data/spec/unit/berkshelf/cookbook_store_spec.rb +6 -6
  41. data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +3 -3
  42. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +23 -6
  43. data/spec/unit/berkshelf/dependency_spec.rb +4 -4
  44. data/spec/unit/berkshelf/downloader_spec.rb +5 -1
  45. data/spec/unit/berkshelf/errors_spec.rb +1 -1
  46. data/spec/unit/berkshelf/file_syncer_spec.rb +206 -0
  47. data/spec/unit/berkshelf/init_generator_spec.rb +19 -22
  48. data/spec/unit/berkshelf/installer_spec.rb +6 -6
  49. data/spec/unit/berkshelf/locations/base_spec.rb +17 -8
  50. data/spec/unit/berkshelf/locations/git_spec.rb +34 -34
  51. data/spec/unit/berkshelf/locations/path_spec.rb +3 -3
  52. data/spec/unit/berkshelf/lockfile_parser_spec.rb +1 -1
  53. data/spec/unit/berkshelf/lockfile_spec.rb +50 -36
  54. data/spec/unit/berkshelf/packager_spec.rb +6 -4
  55. data/spec/unit/berkshelf/resolver/graph_spec.rb +3 -3
  56. data/spec/unit/berkshelf/resolver_spec.rb +3 -3
  57. data/spec/unit/berkshelf/shell_spec.rb +30 -24
  58. data/spec/unit/berkshelf/uploader_spec.rb +10 -36
  59. data/spec/unit/berkshelf/validator_spec.rb +30 -0
  60. data/spec/unit/berkshelf/visualizer_spec.rb +17 -2
  61. metadata +34 -15
  62. data/lib/berkshelf/mixin/dsl_eval.rb +0 -58
  63. data/spec/unit/berkshelf/mixin/dsl_eval_spec.rb +0 -55
@@ -6,6 +6,7 @@ end
6
6
 
7
7
  Spork.prefork do
8
8
  require 'rspec'
9
+ require 'cleanroom/rspec'
9
10
  require 'webmock/rspec'
10
11
  require 'berkshelf/api/rspec' unless windows?
11
12
 
@@ -24,7 +25,6 @@ Spork.prefork do
24
25
  end
25
26
 
26
27
  config.mock_with :rspec
27
- config.treat_symbols_as_metadata_keys_with_true_values = true
28
28
  config.filter_run focus: true
29
29
  config.filter_run_excluding not_supported_on_windows: windows?
30
30
  config.run_all_when_everything_filtered = true
@@ -5,7 +5,9 @@ module Berkshelf
5
5
 
6
6
  def stub_kitchen!
7
7
  generator = double('kitchen-generator', invoke_all: nil)
8
- ::Kitchen::Generator::Init.stub(:new).with(any_args()).and_return(generator)
8
+ allow(::Kitchen::Generator::Init).to receive(:new)
9
+ .with(any_args())
10
+ .and_return(generator)
9
11
  end
10
12
  end
11
13
  end
@@ -107,7 +107,7 @@ module Berkshelf
107
107
  end
108
108
  end
109
109
 
110
- def negative_failure_message
110
+ def failure_message_when_negated
111
111
  if @failure.is_a?(Array) && @failure[0] == :not
112
112
  "Structure had #{@failure}, but it shouldn't have"
113
113
  else
@@ -1,3 +1,4 @@
1
+ require 'rspec/expectations'
1
2
  require 'pathname'
2
3
 
3
4
  RSpec::Matchers.define :be_relative_path do
@@ -9,11 +10,46 @@ RSpec::Matchers.define :be_relative_path do
9
10
  end
10
11
  end
11
12
 
12
- failure_message_for_should do |given|
13
+ failure_message do |given|
13
14
  "Expected '#{given}' to be a relative path but got an absolute path."
14
15
  end
15
16
 
16
- failure_message_for_should_not do |given|
17
+ failure_message_when_negated do |given|
17
18
  "Expected '#{given}' to not be a relative path but got an absolute path."
18
19
  end
19
20
  end
21
+
22
+ # expect('/path/to/directory').to be_a_directory
23
+ RSpec::Matchers.define :be_a_directory do
24
+ match do |actual|
25
+ File.directory?(actual)
26
+ end
27
+ end
28
+
29
+ # expect('/path/to/directory').to be_a_file
30
+ RSpec::Matchers.define :be_a_file do
31
+ match do |actual|
32
+ File.file?(actual)
33
+ end
34
+ end
35
+
36
+ # expect('/path/to/directory').to be_a_symlink
37
+ RSpec::Matchers.define :be_a_symlink do
38
+ match do |actual|
39
+ File.symlink?(actual)
40
+ end
41
+ end
42
+
43
+ # expect('/path/to/directory').to be_a_symlink_to
44
+ RSpec::Matchers.define :be_a_symlink_to do |path|
45
+ match do |actual|
46
+ File.symlink?(actual) && File.readlink(actual) == path
47
+ end
48
+ end
49
+
50
+ # expect('/path/to/file').to be_an_executable
51
+ RSpec::Matchers.define :be_an_executable do
52
+ match do |actual|
53
+ File.executable?(actual)
54
+ end
55
+ end
@@ -1,11 +1,11 @@
1
- module Berkshelf
2
- shared_examples 'a formatter object' do
3
- BaseFormatter.instance_methods(false).each do |name|
4
- next if name == :cleanup_hook
1
+ require 'rspec'
5
2
 
6
- it "implements ##{name}" do
7
- expect(subject.method(name).owner).to eq(described_class)
8
- end
3
+ RSpec.shared_examples "a formatter object" do
4
+ Berkshelf::BaseFormatter.instance_methods(false).each do |name|
5
+ next if name == :cleanup_hook
6
+
7
+ it "implements ##{name}" do
8
+ expect(subject.method(name).owner).to eq(described_class)
9
9
  end
10
10
  end
11
11
  end
@@ -53,12 +53,12 @@ describe Berkshelf::Berksfile do
53
53
  let(:default_options) { { group: [] } }
54
54
 
55
55
  it 'sends the add_dependency message with the name, constraint, and options to the instance of the includer' do
56
- subject.should_receive(:add_dependency).with(name, constraint, default_options)
56
+ expect(subject).to receive(:add_dependency).with(name, constraint, default_options)
57
57
  subject.cookbook(name, constraint, default_options)
58
58
  end
59
59
 
60
60
  it 'merges the default options into specified options' do
61
- subject.should_receive(:add_dependency)do |arg_name, arg_constraint, arg_options|
61
+ expect(subject).to receive(:add_dependency)do |arg_name, arg_constraint, arg_options|
62
62
  expect(arg_name).to eq(name)
63
63
  expect(arg_constraint).to eq(constraint)
64
64
  expect(arg_options[:path]).to match(%r{/Users/reset})
@@ -69,23 +69,27 @@ describe Berkshelf::Berksfile do
69
69
  end
70
70
 
71
71
  it 'converts a single specified group option into an array of groups' do
72
- subject.should_receive(:add_dependency).with(name, constraint, group: [:production])
72
+ expect(subject).to receive(:add_dependency).with(name, constraint, group: [:production])
73
73
  subject.cookbook(name, constraint, group: :production)
74
74
  end
75
75
 
76
76
  context 'when no constraint specified' do
77
77
  it 'sends the add_dependency message with a nil value for constraint' do
78
- subject.should_receive(:add_dependency).with(name, nil, default_options)
78
+ expect(subject).to receive(:add_dependency).with(name, nil, default_options)
79
79
  subject.cookbook(name, default_options)
80
80
  end
81
81
  end
82
82
 
83
83
  context 'when no options specified' do
84
84
  it 'sends the add_dependency message with an empty Hash for the value of options' do
85
- subject.should_receive(:add_dependency).with(name, constraint, default_options)
85
+ expect(subject).to receive(:add_dependency).with(name, constraint, default_options)
86
86
  subject.cookbook(name, constraint)
87
87
  end
88
88
  end
89
+
90
+ it "is a DSL method" do
91
+ expect(subject).to have_exposed_method(:cookbook)
92
+ end
89
93
  end
90
94
 
91
95
  describe '#group' do
@@ -93,12 +97,16 @@ describe Berkshelf::Berksfile do
93
97
  let(:group) { 'production' }
94
98
 
95
99
  it 'sends the add_dependency message with an array of groups determined by the parameter to the group block' do
96
- subject.should_receive(:add_dependency).with(name, nil, group: [group])
100
+ expect(subject).to receive(:add_dependency).with(name, nil, group: [group])
97
101
 
98
102
  subject.group(group) do
99
103
  subject.cookbook(name)
100
104
  end
101
105
  end
106
+
107
+ it "is a DSL method" do
108
+ expect(subject).to have_exposed_method(:group)
109
+ end
102
110
  end
103
111
 
104
112
  describe '#metadata' do
@@ -108,14 +116,22 @@ describe Berkshelf::Berksfile do
108
116
  before { Dir.chdir(path) }
109
117
 
110
118
  it 'sends the add_dependency message with an explicit version constraint and the path to the cookbook' do
111
- subject.should_receive(:add_dependency).with('example_cookbook', nil, path: path.to_s, metadata: true)
119
+ expect(subject).to receive(:add_dependency).with('example_cookbook', nil, path: path.to_s, metadata: true)
112
120
  subject.metadata
113
121
  end
122
+
123
+ it "is a DSL method" do
124
+ expect(subject).to have_exposed_method(:metadata)
125
+ end
114
126
  end
115
127
 
116
128
  describe "#source" do
117
129
  let(:new_source) { "http://berks.riotgames.com" }
118
130
 
131
+ it "is a DSL method" do
132
+ expect(subject).to have_exposed_method(:source)
133
+ end
134
+
119
135
  it "adds a source to the sources" do
120
136
  subject.source(new_source)
121
137
  expect(subject.sources.map(&:to_s)).to include(new_source)
@@ -179,12 +195,26 @@ describe Berkshelf::Berksfile do
179
195
  it "raises a Berkshelf::Deprecated error" do
180
196
  expect { subject.site }.to raise_error(Berkshelf::DeprecatedError)
181
197
  end
198
+
199
+ it "is a DSL method" do
200
+ expect(subject).to have_exposed_method(:site)
201
+ end
182
202
  end
183
203
 
184
204
  describe "#chef_api" do
185
205
  it "raises a Berkshelf::Deprecated error" do
186
206
  expect { subject.chef_api }.to raise_error(Berkshelf::DeprecatedError)
187
207
  end
208
+
209
+ it "is a DSL method" do
210
+ expect(subject).to have_exposed_method(:chef_api)
211
+ end
212
+ end
213
+
214
+ describe '#extension' do
215
+ it "is a DSL method" do
216
+ expect(subject).to have_exposed_method(:extension)
217
+ end
188
218
  end
189
219
 
190
220
  describe '#dependencies' do
@@ -199,7 +229,7 @@ describe Berkshelf::Berksfile do
199
229
  subject.add_dependency(dependency_one.name)
200
230
  subject.add_dependency(dependency_two.name)
201
231
 
202
- expect(subject.dependencies).to have(2).items
232
+ expect(subject.dependencies.size).to eq(2)
203
233
  expect(subject).to have_dependency(dependency_one.name)
204
234
  expect(subject).to have_dependency(dependency_two.name)
205
235
  end
@@ -214,7 +244,7 @@ describe Berkshelf::Berksfile do
214
244
  it 'retrieves the locked (cached) cookbook for each dependency' do
215
245
  subject.add_dependency('bacon', nil)
216
246
  subject.add_dependency('ham', nil)
217
- subject.stub(:retrive_locked)
247
+ allow(subject).to receive(:retrive_locked)
218
248
 
219
249
  expect(subject).to receive(:retrieve_locked).twice
220
250
  subject.cookbooks
@@ -223,21 +253,21 @@ describe Berkshelf::Berksfile do
223
253
 
224
254
  describe '#groups' do
225
255
  before do
226
- subject.stub(:dependencies) { [dependency_one, dependency_two] }
227
- dependency_one.stub(:groups) { [:nautilus, :skarner] }
228
- dependency_two.stub(:groups) { [:nautilus, :riven] }
256
+ allow(subject).to receive(:dependencies) { [dependency_one, dependency_two] }
257
+ allow(dependency_one).to receive(:groups) { [:nautilus, :skarner] }
258
+ allow(dependency_two).to receive(:groups) { [:nautilus, :riven] }
229
259
  end
230
260
 
231
261
  it 'returns a hash containing keys for every group a dependency is a member of' do
232
- expect(subject.groups.keys).to have(3).items
262
+ expect(subject.groups.keys.size).to eq(3)
233
263
  expect(subject.groups).to have_key(:nautilus)
234
264
  expect(subject.groups).to have_key(:skarner)
235
265
  expect(subject.groups).to have_key(:riven)
236
266
  end
237
267
 
238
268
  it 'returns an Array of Berkshelf::Dependencys who are members of the group for value' do
239
- expect(subject.groups[:nautilus]).to have(2).items
240
- expect(subject.groups[:riven]).to have(1).item
269
+ expect(subject.groups[:nautilus].size).to eq(2)
270
+ expect(subject.groups[:riven].size).to eq(1)
241
271
  end
242
272
  end
243
273
 
@@ -253,7 +283,7 @@ describe Berkshelf::Berksfile do
253
283
  let(:dependency) { subject.dependencies.first }
254
284
 
255
285
  it 'adds new dependency to the list of dependencies' do
256
- expect(subject.dependencies).to have(1).dependency
286
+ expect(subject.dependencies.size).to eq(1)
257
287
  end
258
288
 
259
289
  it "is a Berkshelf::Dependency" do
@@ -310,7 +340,7 @@ describe Berkshelf::Berksfile do
310
340
  let(:cached) { double('cached') }
311
341
 
312
342
  before do
313
- subject.stub(:lockfile).and_return(lockfile)
343
+ allow(subject).to receive(:lockfile).and_return(lockfile)
314
344
  end
315
345
 
316
346
  it 'delegates to the lockfile' do
@@ -323,11 +353,11 @@ describe Berkshelf::Berksfile do
323
353
  let(:uploader) { double(Berkshelf::Uploader, run: nil) }
324
354
 
325
355
  before do
326
- subject.stub(:validate_lockfile_present!)
327
- subject.stub(:validate_lockfile_trusted!)
328
- subject.stub(:validate_dependencies_installed!)
356
+ allow(subject).to receive(:validate_lockfile_present!)
357
+ allow(subject).to receive(:validate_lockfile_trusted!)
358
+ allow(subject).to receive(:validate_dependencies_installed!)
329
359
 
330
- Berkshelf::Uploader.stub(:new).and_return(uploader)
360
+ allow(Berkshelf::Uploader).to receive(:new).and_return(uploader)
331
361
  end
332
362
 
333
363
  it 'validates the lockfile is present' do
@@ -88,27 +88,27 @@ describe Berkshelf::CachedCookbook do
88
88
  describe '#pretty_hash' do
89
89
  shared_examples 'a pretty_hash cookbook attribute' do |attribute, key|
90
90
  it "is not present when the `#{attribute}` attribute is nil" do
91
- subject.stub(attribute.to_sym).and_return(nil)
91
+ allow(subject).to receive(attribute.to_sym).and_return(nil)
92
92
  expect(subject.pretty_hash).to_not have_key((key || attribute).to_sym)
93
93
  end
94
94
 
95
95
  it "is not present when the `#{attribute}` attribute is an empty string" do
96
- subject.stub(attribute.to_sym).and_return('')
96
+ allow(subject).to receive(attribute.to_sym).and_return('')
97
97
  expect(subject.pretty_hash).to_not have_key((key || attribute).to_sym)
98
98
  end
99
99
 
100
100
  it "is not present when the `#{attribute}` attribute is an empty array" do
101
- subject.stub(attribute.to_sym).and_return([])
101
+ allow(subject).to receive(attribute.to_sym).and_return([])
102
102
  expect(subject.pretty_hash).to_not have_key((key || attribute).to_sym)
103
103
  end
104
104
 
105
105
  it "is not present when the `#{attribute}` attribute is an empty hash" do
106
- subject.stub(attribute.to_sym).and_return([])
106
+ allow(subject).to receive(attribute.to_sym).and_return([])
107
107
  expect(subject.pretty_hash).to_not have_key((key || attribute).to_sym)
108
108
  end
109
109
 
110
110
  it "is present when the `#{attribute}` attribute has a Hash value" do
111
- subject.stub(attribute.to_sym).and_return(foo: 'bar')
111
+ allow(subject).to receive(attribute.to_sym).and_return(foo: 'bar')
112
112
  expect(subject.pretty_hash).to have_key((key || attribute).to_sym)
113
113
  end
114
114
  end
@@ -7,7 +7,7 @@ module Berkshelf
7
7
  let(:cookbooks) { ['mysql'] }
8
8
 
9
9
  before do
10
- Berksfile.stub(:from_options).and_return(berksfile)
10
+ allow(Berksfile).to receive(:from_options).and_return(berksfile)
11
11
  end
12
12
 
13
13
  describe '#upload' do
@@ -9,16 +9,16 @@ describe Berkshelf::CommunityREST do
9
9
  let(:gzip_reader) { double('gzip_reader') }
10
10
 
11
11
  before do
12
- File.stub(:open).with(target, 'rb').and_return(file)
13
- Zlib::GzipReader.stub(:new).with(file).and_return(gzip_reader)
14
- Archive::Tar::Minitar.stub(:unpack).with(gzip_reader, destination)
12
+ allow(File).to receive(:open).with(target, 'rb').and_return(file)
13
+ allow(Zlib::GzipReader).to receive(:new).with(file).and_return(gzip_reader)
14
+ allow(Archive::Tar::Minitar).to receive(:unpack).with(gzip_reader, destination)
15
15
  end
16
16
 
17
17
  it 'unpacks the tar' do
18
- File.should_receive(:open).with(target, 'rb')
19
- ::IO.should_receive(:binread).with(target, 2).and_return([0x1F, 0x8B].pack("C*"))
20
- Zlib::GzipReader.should_receive(:new).with(file)
21
- Archive::Tar::Minitar.should_receive(:unpack).with(gzip_reader, destination)
18
+ expect(File).to receive(:open).with(target, 'rb')
19
+ expect(::IO).to receive(:binread).with(target, 2).and_return([0x1F, 0x8B].pack("C*"))
20
+ expect(Zlib::GzipReader).to receive(:new).with(file)
21
+ expect(Archive::Tar::Minitar).to receive(:unpack).with(gzip_reader, destination)
22
22
 
23
23
  expect(Berkshelf::CommunityREST.unpack(target, destination)).to eq(destination)
24
24
  end
@@ -76,8 +76,8 @@ describe Berkshelf::CommunityREST do
76
76
  let(:archive) { double('archive', path: '/foo/bar', unlink: true) }
77
77
 
78
78
  before do
79
- subject.stub(:stream).with(any_args()).and_return(archive)
80
- Berkshelf::CommunityREST.stub(:unpack)
79
+ allow(subject).to receive(:stream).with(any_args()).and_return(archive)
80
+ allow(Berkshelf::CommunityREST).to receive(:unpack)
81
81
  end
82
82
 
83
83
  it 'unpacks the archive' do
@@ -87,8 +87,8 @@ describe Berkshelf::CommunityREST do
87
87
  headers: { 'Content-Type' => 'application/json' },
88
88
  )
89
89
 
90
- Berkshelf::CommunityREST.should_receive(:unpack).with('/foo/bar').once.and_return('/foo/nginx')
91
- archive.should_receive(:unlink).once
90
+ expect(Berkshelf::CommunityREST).to receive(:unpack).with('/foo/bar').once.and_return('/foo/nginx')
91
+ expect(archive).to receive(:unlink).once
92
92
 
93
93
  subject.download('bacon', '1.0.0')
94
94
  end
@@ -215,6 +215,6 @@ describe Berkshelf::CommunityREST do
215
215
  end
216
216
 
217
217
  describe '#stream' do
218
- pending
218
+ skip
219
219
  end
220
220
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Berkshelf::Config do
4
4
  describe '::file' do
5
5
  context 'when the file does not exist' do
6
- before { File.stub(:exists?).and_return(false) }
6
+ before { allow(File).to receive(:exists?).and_return(false) }
7
7
 
8
8
  it 'is nil' do
9
9
  expect(Berkshelf::Config.file).to be_nil
@@ -23,7 +23,7 @@ describe Berkshelf::Config do
23
23
  end
24
24
 
25
25
  before do
26
- File.stub(:exists?).and_return(false)
26
+ allow(File).to receive(:exists?).and_return(false)
27
27
  end
28
28
 
29
29
  after do
@@ -32,8 +32,8 @@ describe Berkshelf::Config do
32
32
 
33
33
  context "when ENV['BERKSHELF_CONFIG'] is used" do
34
34
  before do
35
- ENV.stub(:[]).with('BERKSHELF_CONFIG').and_return('/tmp/config.json')
36
- File.stub(:exists?).with('/tmp/config.json').and_return(true)
35
+ allow(ENV).to receive(:[]).with('BERKSHELF_CONFIG').and_return('/tmp/config.json')
36
+ allow(File).to receive(:exists?).with('/tmp/config.json').and_return(true)
37
37
  end
38
38
 
39
39
  it "points to a location within it" do
@@ -6,7 +6,7 @@ describe Berkshelf::CookbookGenerator do
6
6
  let(:kitchen_generator) { double('kitchen-generator', invoke_all: nil) }
7
7
 
8
8
  before do
9
- Kitchen::Generator::Init.stub(:new).with(any_args()).and_return(kitchen_generator)
9
+ allow(Kitchen::Generator::Init).to receive(:new).with(any_args()).and_return(kitchen_generator)
10
10
  end
11
11
 
12
12
  context 'with default options' do
@@ -69,7 +69,7 @@ describe Berkshelf::CookbookGenerator do
69
69
 
70
70
  context "given a 'maintainer_email' option" do
71
71
  before do
72
- Kitchen::Generator::Init.stub(:new).with(any_args()).and_return(kitchen_generator)
72
+ allow(Kitchen::Generator::Init).to receive(:new).with(any_args()).and_return(kitchen_generator)
73
73
  capture(:stdout) {
74
74
  Berkshelf::CookbookGenerator.new([target, name], maintainer_email: 'jamie@vialstudios.com').invoke_all
75
75
  }
@@ -42,17 +42,17 @@ describe Berkshelf::CookbookStore do
42
42
  let(:cached_one) { double('cached-one', name: name, version: Semverse::Version.new(version)) }
43
43
  let(:cached_two) { double('cached-two', name: 'mysql', version: Semverse::Version.new('1.2.6')) }
44
44
 
45
- before { subject.stub(:cookbooks).and_return([cached_one, cached_two]) }
45
+ before { allow(subject).to receive(:cookbooks).and_return([cached_one, cached_two]) }
46
46
 
47
47
  it 'gets and returns the the CachedCookbook best matching the name and constraint' do
48
- subject.should_receive(:cookbook).with(name, version).and_return(cached_one)
48
+ expect(subject).to receive(:cookbook).with(name, version).and_return(cached_one)
49
49
  result = subject.satisfy(name, constraint)
50
50
 
51
51
  expect(result).to eq(cached_one)
52
52
  end
53
53
 
54
54
  context 'when there are no cookbooks in the cookbook store' do
55
- before { subject.stub(:cookbooks).and_return([]) }
55
+ before { allow(subject).to receive(:cookbooks).and_return([]) }
56
56
 
57
57
  it 'returns nil' do
58
58
  result = subject.satisfy(name, constraint)
@@ -64,7 +64,7 @@ describe Berkshelf::CookbookStore do
64
64
  let(:version) { Semverse::Version.new('1.0.0') }
65
65
  let(:constraint) { Semverse::Constraint.new('= 0.1.0') }
66
66
 
67
- before { subject.stub(:cookbooks).and_return([ double('badcache', name: 'none', version: version) ]) }
67
+ before { allow(subject).to receive(:cookbooks).and_return([ double('badcache', name: 'none', version: version) ]) }
68
68
 
69
69
  it 'returns nil if there is no matching cookbook for the name and constraint' do
70
70
  result = subject.satisfy(name, constraint)
@@ -98,12 +98,12 @@ describe Berkshelf::CookbookStore do
98
98
  end
99
99
 
100
100
  it 'contains a CachedCookbook for every cookbook in the storage path' do
101
- expect(subject.cookbooks).to have(2).items
101
+ expect(subject.cookbooks.size).to eq(2)
102
102
  end
103
103
 
104
104
  context 'given a value for the filter parameter' do
105
105
  it 'returns only the CachedCookbooks whose name match the filter' do
106
- expect(subject.cookbooks('mysql')).to have(1).item
106
+ expect(subject.cookbooks('mysql').size).to eq(1)
107
107
  end
108
108
  end
109
109