chef-dk 0.2.0 → 0.2.1

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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/chef-dk/authenticated_http.rb +40 -0
  4. data/lib/chef-dk/chef_runner.rb +5 -0
  5. data/lib/chef-dk/command/exec.rb +4 -1
  6. data/lib/chef-dk/command/generate.rb +11 -0
  7. data/lib/chef-dk/command/generator_commands.rb +20 -365
  8. data/lib/chef-dk/command/generator_commands/app.rb +99 -0
  9. data/lib/chef-dk/command/generator_commands/attribute.rb +37 -0
  10. data/lib/chef-dk/command/generator_commands/base.rb +76 -0
  11. data/lib/chef-dk/command/generator_commands/cookbook.rb +100 -0
  12. data/lib/chef-dk/command/generator_commands/cookbook_code_file.rb +99 -0
  13. data/lib/chef-dk/command/generator_commands/cookbook_file.rb +45 -0
  14. data/lib/chef-dk/command/generator_commands/lwrp.rb +36 -0
  15. data/lib/chef-dk/command/generator_commands/recipe.rb +36 -0
  16. data/lib/chef-dk/command/generator_commands/repo.rb +96 -0
  17. data/lib/chef-dk/command/generator_commands/template.rb +45 -0
  18. data/lib/chef-dk/command/verify.rb +28 -0
  19. data/lib/chef-dk/component_test.rb +16 -3
  20. data/lib/chef-dk/cookbook_omnifetch.rb +2 -0
  21. data/lib/chef-dk/cookbook_profiler/identifiers.rb +3 -15
  22. data/lib/chef-dk/exceptions.rb +15 -0
  23. data/lib/chef-dk/generator.rb +102 -25
  24. data/lib/chef-dk/policyfile/community_cookbook_source.rb +0 -7
  25. data/lib/chef-dk/policyfile/{cookbook_spec.rb → cookbook_location_specification.rb} +35 -6
  26. data/lib/chef-dk/policyfile/cookbook_locks.rb +305 -0
  27. data/lib/chef-dk/policyfile/dsl.rb +26 -12
  28. data/lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb +70 -0
  29. data/lib/chef-dk/policyfile/solution_dependencies.rb +204 -0
  30. data/lib/chef-dk/policyfile/storage_config.rb +77 -0
  31. data/lib/chef-dk/policyfile/uploader.rb +110 -0
  32. data/lib/chef-dk/policyfile_compiler.rb +59 -29
  33. data/lib/chef-dk/policyfile_lock.rb +104 -160
  34. data/lib/chef-dk/skeletons/code_generator/files/default/Berksfile +1 -1
  35. data/lib/chef-dk/skeletons/code_generator/files/default/chefignore +0 -1
  36. data/lib/chef-dk/skeletons/code_generator/files/default/repo/README.md +66 -0
  37. data/lib/chef-dk/skeletons/code_generator/files/default/repo/Rakefile +65 -0
  38. data/lib/chef-dk/skeletons/code_generator/files/default/repo/certificates/README.md +19 -0
  39. data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README-policy.md +9 -0
  40. data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README.md +54 -0
  41. data/lib/chef-dk/skeletons/code_generator/files/default/repo/data_bags/README.md +63 -0
  42. data/lib/chef-dk/skeletons/code_generator/files/default/repo/environments/README.md +5 -0
  43. data/lib/chef-dk/skeletons/code_generator/files/default/repo/roles/README.md +16 -0
  44. data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +7 -1
  45. data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +62 -0
  46. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
  47. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.apache2.erb +201 -0
  48. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
  49. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
  50. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
  51. data/lib/chef-dk/skeletons/code_generator/templates/default/default_recipe.rb.erb +1 -4
  52. data/lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb +3 -3
  53. data/lib/chef-dk/skeletons/code_generator/templates/default/repo/config/rake.rb.erb +38 -0
  54. data/lib/chef-dk/skeletons/code_generator/templates/default/repo/gitignore.erb +11 -0
  55. data/lib/chef-dk/version.rb +1 -1
  56. data/spec/shared/a_file_generator.rb +121 -0
  57. data/spec/shared/a_generated_file.rb +12 -0
  58. data/spec/shared/fixture_cookbook_checksums.rb +47 -0
  59. data/spec/spec_helper.rb +4 -2
  60. data/spec/unit/chef_runner_spec.rb +12 -5
  61. data/spec/unit/cli_spec.rb +4 -4
  62. data/spec/unit/command/base_spec.rb +1 -1
  63. data/spec/unit/command/exec_spec.rb +37 -27
  64. data/spec/unit/command/generate_spec.rb +3 -3
  65. data/spec/unit/command/generator_commands/app_spec.rb +131 -0
  66. data/spec/unit/command/generator_commands/attribute_spec.rb +32 -0
  67. data/spec/unit/command/generator_commands/cookbook_file_spec.rb +32 -0
  68. data/spec/unit/command/generator_commands/cookbook_spec.rb +205 -0
  69. data/spec/unit/command/generator_commands/lwrp_spec.rb +32 -0
  70. data/spec/unit/command/generator_commands/recipe_spec.rb +32 -0
  71. data/spec/unit/command/generator_commands/repo_spec.rb +287 -0
  72. data/spec/unit/command/generator_commands/template_spec.rb +32 -0
  73. data/spec/unit/command/shell_init_spec.rb +4 -4
  74. data/spec/unit/command/verify_spec.rb +9 -9
  75. data/spec/unit/commands_map_spec.rb +1 -1
  76. data/spec/unit/component_test_spec.rb +3 -3
  77. data/spec/unit/cookbook_profiler/git_spec.rb +7 -7
  78. data/spec/unit/cookbook_profiler/identifiers_spec.rb +12 -8
  79. data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/Berksfile +1 -1
  80. data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/Berksfile +1 -1
  81. data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/Berksfile +1 -1
  82. data/spec/unit/fixtures/example_cookbook/Berksfile +1 -1
  83. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/README.md +4 -0
  84. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/chefignore +96 -0
  85. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/metadata.rb +8 -0
  86. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/recipes/default.rb +8 -0
  87. data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/Berksfile +1 -1
  88. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/.kitchen.yml +16 -0
  89. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/README.md +4 -0
  90. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb +8 -0
  91. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb +8 -0
  92. data/spec/unit/generator_spec.rb +120 -0
  93. data/spec/unit/policyfile/{cookbook_spec_spec.rb → cookbook_location_specification_spec.rb} +83 -38
  94. data/spec/unit/policyfile/cookbook_locks_spec.rb +354 -0
  95. data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +85 -0
  96. data/spec/unit/policyfile/solution_dependencies_spec.rb +145 -0
  97. data/spec/unit/policyfile/storage_config_spec.rb +98 -0
  98. data/spec/unit/policyfile/uploader_spec.rb +292 -0
  99. data/spec/unit/policyfile_demands_spec.rb +177 -24
  100. data/spec/unit/policyfile_evaluation_spec.rb +40 -12
  101. data/spec/unit/{policyfile_builder_spec.rb → policyfile_lock_build_spec.rb} +179 -64
  102. data/spec/unit/policyfile_lock_install_spec.rb +138 -0
  103. data/spec/unit/policyfile_lock_validation_spec.rb +610 -0
  104. metadata +103 -59
  105. data/spec/unit/command/generator_commands_spec.rb +0 -504
@@ -0,0 +1,32 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'spec_helper'
19
+ require 'shared/a_file_generator'
20
+ require 'chef-dk/command/generator_commands/recipe'
21
+
22
+ describe ChefDK::Command::GeneratorCommands::Recipe do
23
+
24
+ include_examples "a file generator" do
25
+
26
+ let(:generator_name) { "recipe" }
27
+ let(:generated_files) { [ "recipes/new_recipe.rb" ] }
28
+ let(:new_file_name) { "new_recipe" }
29
+
30
+ end
31
+ end
32
+
@@ -0,0 +1,287 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'spec_helper'
19
+ require 'shared/a_generated_file'
20
+ require 'chef-dk/command/generator_commands/repo'
21
+
22
+ describe ChefDK::Command::GeneratorCommands::Repo do
23
+
24
+ let(:argv) { %w[new_repo] }
25
+
26
+ let(:stdout_io) { StringIO.new }
27
+ let(:stderr_io) { StringIO.new }
28
+
29
+ let(:expected_cookbook_file_relpaths) do
30
+ %w[
31
+ LICENSE
32
+ ]
33
+ end
34
+
35
+ let(:file) { "" }
36
+ let(:file_path) { File.join(repo_path, file) }
37
+ let(:file_contents) { File.read(file_path) }
38
+ let(:repo_path) { File.join(tempdir, "new_repo") }
39
+
40
+ let(:expected_cookbook_files) do
41
+ expected_cookbook_file_relpaths.map do |relpath|
42
+ File.join(tempdir, "new_repo", relpath)
43
+ end
44
+ end
45
+
46
+ subject(:generator) { described_class.new(argv) }
47
+
48
+ def generator_context
49
+ ChefDK::Generator.context
50
+ end
51
+
52
+ before do
53
+ ChefDK::Generator.reset
54
+ end
55
+
56
+ context "when given the name of the repo to generate" do
57
+
58
+ before do
59
+ reset_tempdir
60
+ end
61
+
62
+ it "configures the generator context" do
63
+ generator.read_and_validate_params
64
+ generator.setup_context
65
+ expect(generator_context.repo_root).to eq(Dir.pwd)
66
+ expect(generator_context.repo_name).to eq("new_repo")
67
+ end
68
+
69
+ it "creates a new repo" do
70
+ Dir.chdir(tempdir) do
71
+ allow(generator.chef_runner).to receive(:stdout).and_return(stdout_io)
72
+ generator.run
73
+ end
74
+ generated_files = Dir.glob(File.join(tempdir, "new_repo", "**", "*"), File::FNM_DOTMATCH)
75
+ expected_cookbook_files.each do |expected_file|
76
+ expect(generated_files).to include(expected_file)
77
+ end
78
+ end
79
+
80
+ describe "generated files" do
81
+ before do
82
+ Dir.chdir(tempdir) do
83
+ allow(generator.chef_runner).to receive(:stdout).and_return(stdout_io)
84
+ generator.run
85
+ end
86
+ end
87
+
88
+ describe "LICENSE" do
89
+ let(:file) { "LICENSE" }
90
+
91
+ context "all_rights" do
92
+ it "is the default" do
93
+ expect(file_contents).to match(/Copyright \d\d\d\d/)
94
+ expect(file_contents).to match(/All rights reserved, do not redistribute/)
95
+ end
96
+
97
+ context "with copyright_holder" do
98
+ let(:argv) { ["new_repo", "-C", "Adam Jacob"] }
99
+ it "includes the name" do
100
+ expect(file_contents).to match(/Copyright \d\d\d\d Adam Jacob/)
101
+ end
102
+ end
103
+ end
104
+
105
+ context "apache2" do
106
+ let(:argv) { ["new_repo", "-I", "apache2" ] }
107
+
108
+ it "is the apache license" do
109
+ expect(file_contents).to match(/Apache License/)
110
+ expect(file_contents).to match(/Version 2.0/)
111
+ end
112
+ end
113
+
114
+ context "mit" do
115
+ let(:argv) { ["new_repo", "-I", "mit" ] }
116
+
117
+ it "is the mit license" do
118
+ expect(file_contents).to match(/The MIT License \(MIT\)/)
119
+ end
120
+
121
+ context "with copyright_holder" do
122
+ let(:argv) { ["new_repo", "-I", "mit", "-C", "Adam Jacob"] }
123
+ it "includes the name" do
124
+ expect(file_contents).to match(/Copyright \(c\) \d\d\d\d Adam Jacob/)
125
+ end
126
+ end
127
+ end
128
+
129
+ context "gplv2" do
130
+ let(:argv) { ["new_repo", "-I", "gplv2" ] }
131
+
132
+ it "is the GPL version 2 license" do
133
+ expect(file_contents).to match(/GNU GENERAL PUBLIC LICENSE/)
134
+ expect(file_contents).to match(/Version 2, June 1991/)
135
+ end
136
+ end
137
+
138
+ context "gplv3" do
139
+ let(:argv) { ["new_repo", "-I", "gplv3" ] }
140
+
141
+ it "is the GPL version 2 license" do
142
+ expect(file_contents).to match(/GNU GENERAL PUBLIC LICENSE/)
143
+ expect(file_contents).to match(/Version 3, 29 June 2007/)
144
+ end
145
+ end
146
+ end
147
+
148
+ describe "README.md" do
149
+ let(:file) { "README.md" }
150
+
151
+ it "is the standard readme" do
152
+ expect(file_contents).to match(/Every Chef installation needs a Chef Repository/)
153
+ end
154
+ end
155
+
156
+ describe "Rakefile" do
157
+ let(:file) { "Rakefile" }
158
+
159
+ it "loads the common tasks" do
160
+ expect(file_contents).to match(/load 'chef\/tasks\/chef_repo\.rake'/)
161
+ end
162
+ end
163
+
164
+ describe "chefignore" do
165
+ let(:file) { "chefignore" }
166
+
167
+ it "has the preamble" do
168
+ expect(file_contents).to match(/Put files\/directories that should be ignored in this file when uploading/)
169
+ end
170
+ end
171
+
172
+ describe ".gitignore" do
173
+ let(:file) { ".gitignore" }
174
+
175
+ it "has the right contents" do
176
+ expect(file_contents).to match(/\.rake_test_cache/)
177
+ expect(file_contents).to match(/\.chef\/\*\.pem/)
178
+ expect(file_contents).to match(/\.chef\/encrypted_data_bag_secret/)
179
+ expect(file_contents).to_not match(/cookbooks\/\*\*/)
180
+ end
181
+
182
+ context "with --policy-only" do
183
+ let(:argv) { ["new_repo", "--policy-only" ] }
184
+
185
+ it "blocks cookbooks" do
186
+ expect(file_contents).to match(/cookbooks\/\*\*/)
187
+ expect(file_contents).to match(/cookbooks\/README\.md/)
188
+ end
189
+ end
190
+ end
191
+
192
+ describe "certificates" do
193
+ describe "README.md" do
194
+ let(:file) { "certificates/README.md" }
195
+
196
+ it "has the right contents" do
197
+ expect(file_contents).to match(/rake ssl_cert FQDN=monitoring.example.com/)
198
+ end
199
+ end
200
+ end
201
+
202
+ describe "cookbooks" do
203
+ describe "README.md" do
204
+ let(:file) { "cookbooks/README.md" }
205
+
206
+ it "has the right contents" do
207
+ expect(file_contents).to match(/This directory contains the cookbooks/)
208
+ end
209
+
210
+ context "with --policy-only" do
211
+ let(:argv) { ["new_repo", "--policy-only" ] }
212
+
213
+ it "tells you whats up" do
214
+ expect(file_contents).to match(/This directory typically contains Chef cookbooks/)
215
+ end
216
+ end
217
+ end
218
+ end
219
+
220
+ describe "data_bags" do
221
+ describe "README.md" do
222
+ let(:file) { "data_bags/README.md" }
223
+
224
+ it "has the right contents" do
225
+ expect(file_contents).to match(/This directory contains directories of the various data bags/)
226
+ end
227
+ end
228
+ end
229
+
230
+ describe "environments" do
231
+ describe "README.md" do
232
+ let(:file) { "environments/README.md" }
233
+
234
+ it "has the right contents" do
235
+ expect(file_contents).to match(/This directory is for Ruby DSL and JSON files for environments\./)
236
+ end
237
+ end
238
+ end
239
+
240
+ describe "roles" do
241
+ describe "README.md" do
242
+ let(:file) { "roles/README.md" }
243
+
244
+ it "has the right contents" do
245
+ expect(file_contents).to match(/Create roles here/)
246
+ end
247
+ end
248
+ end
249
+
250
+ describe "config" do
251
+ describe "rake.rb" do
252
+ let(:file) { "config/rake.rb" }
253
+
254
+ it "has the preamble" do
255
+ expect(file_contents).to match(/Configure the Rakefile's tasks\./)
256
+ end
257
+
258
+ it "defaults the copyright to The Authors" do
259
+ expect(file_contents).to match(/COMPANY_NAME = "The Authors"/)
260
+ end
261
+
262
+ it "defaults the license to all_rights" do
263
+ expect(file_contents).to match(/NEW_COOKBOOK_LICENSE = :all_rights/)
264
+ end
265
+
266
+ context "with a license" do
267
+ let(:argv) { ["new_repo", "-I", "gplv3" ] }
268
+
269
+ it "uses the license" do
270
+ expect(file_contents).to match(/NEW_COOKBOOK_LICENSE = :gplv3/)
271
+ end
272
+ end
273
+
274
+ context "with a copyright holder" do
275
+ let(:argv) { ["new_repo", "-C", "GiantCo, Inc." ] }
276
+
277
+ it "uses the copyright holder" do
278
+ expect(file_contents).to match(/COMPANY_NAME = "GiantCo, Inc\."/)
279
+ end
280
+ end
281
+ end
282
+ end
283
+ end
284
+ end
285
+ end
286
+
287
+
@@ -0,0 +1,32 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'spec_helper'
19
+ require 'shared/a_file_generator'
20
+ require 'chef-dk/command/generator_commands/template'
21
+
22
+ describe ChefDK::Command::GeneratorCommands::Template do
23
+
24
+ include_examples "a file generator" do
25
+
26
+ let(:generator_name) { "template" }
27
+ let(:generated_files) { [ "templates/default/new_template.txt.erb" ] }
28
+ let(:new_file_name) { "new_template.txt" }
29
+
30
+ end
31
+ end
32
+
@@ -25,8 +25,8 @@ describe ChefDK::Command::ShellInit do
25
25
 
26
26
  let(:command_instance) do
27
27
  ChefDK::Command::ShellInit.new.tap do |c|
28
- c.stub(:stdout).and_return(stdout_io)
29
- c.stub(:stderr).and_return(stderr_io)
28
+ allow(c).to receive(:stdout).and_return(stdout_io)
29
+ allow(c).to receive(:stderr).and_return(stderr_io)
30
30
  end
31
31
  end
32
32
 
@@ -57,8 +57,8 @@ EOH
57
57
  let(:omnibus_embedded_bin_dir) { "/foo/embedded/bin" }
58
58
 
59
59
  before do
60
- command_instance.stub(:omnibus_embedded_bin_dir).and_return(omnibus_embedded_bin_dir)
61
- command_instance.stub(:omnibus_bin_dir).and_return(omnibus_bin_dir)
60
+ allow(command_instance).to receive(:omnibus_embedded_bin_dir).and_return(omnibus_embedded_bin_dir)
61
+ allow(command_instance).to receive(:omnibus_bin_dir).and_return(omnibus_bin_dir)
62
62
  end
63
63
 
64
64
  it "emits a script to add ChefDK's ruby to the shell environment" do
@@ -40,7 +40,7 @@ describe ChefDK::Command::Verify do
40
40
 
41
41
  it "defines berks, tk, chef and chef-dk components by default" do
42
42
  expect(command_instance.components).not_to be_empty
43
- expect(command_instance.components.map(&:name)).to match_array(%w{berkshelf test-kitchen chef-client chef-dk})
43
+ expect(command_instance.components.map(&:name)).to match_array(%w{berkshelf test-kitchen chef-client chef-dk chefspec})
44
44
  end
45
45
 
46
46
  it "has a usage banner" do
@@ -49,22 +49,22 @@ describe ChefDK::Command::Verify do
49
49
 
50
50
  describe "when locating omnibus directory" do
51
51
  it "should find omnibus app directory from ruby path" do
52
- Gem.stub(:ruby).and_return(File.join(fixtures_path, "eg_omnibus_dir/valid/embedded/bin/ruby"))
52
+ allow(Gem).to receive(:ruby).and_return(File.join(fixtures_path, "eg_omnibus_dir/valid/embedded/bin/ruby"))
53
53
  expect(command_instance.omnibus_apps_dir).to include("eg_omnibus_dir/valid/embedded")
54
54
  end
55
55
 
56
56
  it "should raise OmnibusInstallNotFound if directory is not looking like omnibus" do
57
- Gem.stub(:ruby).and_return(File.join(fixtures_path,".rbenv/versions/2.1.1/bin/ruby"))
57
+ allow(Gem).to receive(:ruby).and_return(File.join(fixtures_path,".rbenv/versions/2.1.1/bin/ruby"))
58
58
  expect{command_instance.omnibus_apps_dir}.to raise_error(ChefDK::OmnibusInstallNotFound)
59
59
  end
60
60
 
61
61
  it "raises OmnibusInstallNotFound if omnibus directory doesn't exist" do
62
- Gem.stub(:ruby).and_return(File.join(fixtures_path,"eg_omnibus_dir/missing_apps/embedded/bin/ruby"))
62
+ allow(Gem).to receive(:ruby).and_return(File.join(fixtures_path,"eg_omnibus_dir/missing_apps/embedded/bin/ruby"))
63
63
  expect{command_instance.omnibus_apps_dir}.to raise_error(ChefDK::OmnibusInstallNotFound)
64
64
  end
65
65
 
66
66
  it "raises MissingComponentError when a component doesn't exist" do
67
- Gem.stub(:ruby).and_return(File.join(fixtures_path,"eg_omnibus_dir/missing_component/embedded/bin/ruby"))
67
+ allow(Gem).to receive(:ruby).and_return(File.join(fixtures_path,"eg_omnibus_dir/missing_component/embedded/bin/ruby"))
68
68
  expect{command_instance.validate_components!}.to raise_error(ChefDK::MissingComponentError)
69
69
  end
70
70
  end
@@ -133,9 +133,9 @@ describe ChefDK::Command::Verify do
133
133
  end
134
134
 
135
135
  before do
136
- Gem.stub(:ruby).and_return(ruby_path)
137
- command_instance.stub(:stdout).and_return(stdout_io)
138
- command_instance.stub(:components).and_return(components)
136
+ allow(Gem).to receive(:ruby).and_return(ruby_path)
137
+ allow(command_instance).to receive(:stdout).and_return(stdout_io)
138
+ allow(command_instance).to receive(:components).and_return(components)
139
139
  end
140
140
 
141
141
  context "when running smoke tests only" do
@@ -268,7 +268,7 @@ describe ChefDK::Command::Verify do
268
268
  it "should report the output of the first verification first" do
269
269
  index_first = stdout.index("you are good to go...")
270
270
  index_second = stdout.index("my friend everything is good...")
271
- expect(index_second > index_first).to be_true
271
+ expect(index_second > index_first).to be true
272
272
  end
273
273
 
274
274
  context "and components are filtered by CLI args" do
@@ -31,7 +31,7 @@ describe ChefDK::CommandsMap do
31
31
  end
32
32
 
33
33
  it "defines a subcommand mapping" do
34
- expect(mapping.have_command?("example")).to be_true
34
+ expect(mapping.have_command?("example")).to be true
35
35
  end
36
36
 
37
37
  it "infers a non-hypenated command's require path" do
@@ -69,17 +69,17 @@ describe ChefDK::ComponentTest do
69
69
 
70
70
  it "defines a unit test block" do
71
71
  component.run_unit_test
72
- expect(result[:unit_test]).to be_true
72
+ expect(result[:unit_test]).to be true
73
73
  end
74
74
 
75
75
  it "defines an integration test block" do
76
76
  component.run_integration_test
77
- expect(result[:integration_test]).to be_true
77
+ expect(result[:integration_test]).to be true
78
78
  end
79
79
 
80
80
  it "defines a smoke test block" do
81
81
  component.run_smoke_test
82
- expect(result[:smoke_test]).to be_true
82
+ expect(result[:smoke_test]).to be true
83
83
  end
84
84
 
85
85
  end