berkshelf 5.2.0 → 8.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +19 -47
  3. data/Rakefile +14 -4
  4. data/berkshelf.gemspec +61 -40
  5. data/bin/berks +2 -2
  6. data/lib/berkshelf/api-client.rb +1 -0
  7. data/lib/berkshelf/api_client/chef_server_connection.rb +29 -0
  8. data/lib/berkshelf/api_client/connection.rb +57 -0
  9. data/lib/berkshelf/api_client/errors.rb +10 -0
  10. data/lib/berkshelf/api_client/remote_cookbook.rb +56 -0
  11. data/lib/berkshelf/api_client/version.rb +5 -0
  12. data/lib/berkshelf/api_client.rb +24 -0
  13. data/lib/berkshelf/berksfile.rb +149 -122
  14. data/lib/berkshelf/cached_cookbook.rb +127 -24
  15. data/lib/berkshelf/chef_config_compat.rb +51 -0
  16. data/lib/berkshelf/chef_repo_universe.rb +47 -0
  17. data/lib/berkshelf/cli.rb +143 -174
  18. data/lib/berkshelf/commands/shelf.rb +20 -19
  19. data/lib/berkshelf/community_rest.rb +59 -94
  20. data/lib/berkshelf/config.rb +97 -127
  21. data/lib/berkshelf/cookbook_store.rb +7 -6
  22. data/lib/berkshelf/core_ext/file.rb +1 -1
  23. data/lib/berkshelf/core_ext/file_utils.rb +4 -4
  24. data/lib/berkshelf/core_ext.rb +1 -1
  25. data/lib/berkshelf/dependency.rb +25 -32
  26. data/lib/berkshelf/downloader.rb +66 -39
  27. data/lib/berkshelf/errors.rb +23 -17
  28. data/lib/berkshelf/file_syncer.rb +24 -47
  29. data/lib/berkshelf/formatters/human.rb +7 -5
  30. data/lib/berkshelf/formatters/json.rb +6 -6
  31. data/lib/berkshelf/installer.rb +120 -111
  32. data/lib/berkshelf/location.rb +14 -14
  33. data/lib/berkshelf/locations/base.rb +1 -1
  34. data/lib/berkshelf/locations/git.rb +16 -24
  35. data/lib/berkshelf/locations/github.rb +2 -2
  36. data/lib/berkshelf/locations/path.rb +2 -2
  37. data/lib/berkshelf/lockfile.rb +326 -328
  38. data/lib/berkshelf/logger.rb +64 -1
  39. data/lib/berkshelf/mixin/git.rb +6 -5
  40. data/lib/berkshelf/packager.rb +44 -10
  41. data/lib/berkshelf/resolver/graph.rb +1 -1
  42. data/lib/berkshelf/resolver.rb +4 -4
  43. data/lib/berkshelf/ridley_compat.rb +109 -0
  44. data/lib/berkshelf/shell.rb +2 -1
  45. data/lib/berkshelf/shell_out.rb +18 -0
  46. data/lib/berkshelf/source.rb +77 -33
  47. data/lib/berkshelf/source_uri.rb +4 -4
  48. data/lib/berkshelf/ssl_policies.rb +38 -0
  49. data/lib/berkshelf/thor.rb +1 -1
  50. data/lib/berkshelf/thor_ext/hash_with_indifferent_access.rb +1 -1
  51. data/lib/berkshelf/thor_ext.rb +1 -1
  52. data/lib/berkshelf/uploader.rb +106 -70
  53. data/lib/berkshelf/validator.rb +13 -5
  54. data/lib/berkshelf/version.rb +1 -1
  55. data/lib/berkshelf/visualizer.rb +16 -11
  56. data/lib/berkshelf.rb +106 -81
  57. data/spec/config/knife.rb +4 -4
  58. data/spec/data/trusted_certs/example.crt +22 -0
  59. data/spec/fixtures/Berksfile +3 -3
  60. data/spec/fixtures/complex-cookbook-path/cookbooks/app/metadata.rb +2 -0
  61. data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins/metadata.rb +2 -0
  62. data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins-config/metadata.rb +4 -0
  63. data/spec/fixtures/cookbook-path/jenkins-config/metadata.rb +3 -3
  64. data/spec/fixtures/cookbook-path-uploader/apt-2.3.6/metadata.rb +2 -0
  65. data/spec/fixtures/cookbook-path-uploader/build-essential-1.4.2/metadata.rb +2 -0
  66. data/spec/fixtures/cookbook-path-uploader/jenkins-2.0.3/metadata.rb +5 -0
  67. data/spec/fixtures/cookbook-path-uploader/jenkins-config-0.1.0/metadata.rb +4 -0
  68. data/spec/fixtures/cookbook-path-uploader/runit-1.5.8/metadata.rb +5 -0
  69. data/spec/fixtures/cookbook-path-uploader/yum-3.0.6/metadata.rb +2 -0
  70. data/spec/fixtures/cookbook-path-uploader/yum-epel-0.2.0/metadata.rb +3 -0
  71. data/spec/fixtures/cookbook-store/jenkins-2.0.3/metadata.rb +5 -5
  72. data/spec/fixtures/cookbook-store/jenkins-2.0.4/metadata.rb +4 -4
  73. data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +3 -3
  74. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +3 -3
  75. data/spec/spec_helper.rb +56 -64
  76. data/spec/support/chef_api.rb +15 -16
  77. data/spec/support/chef_server.rb +71 -69
  78. data/spec/support/git.rb +59 -58
  79. data/spec/support/kitchen.rb +0 -14
  80. data/spec/support/matchers/file_system_matchers.rb +4 -5
  81. data/spec/support/matchers/filepath_matchers.rb +2 -2
  82. data/spec/support/path_helpers.rb +17 -17
  83. data/spec/support/shared_examples/formatter.rb +1 -1
  84. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/attributes/default.rb +0 -0
  85. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/files/default/file.h +0 -0
  86. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/metadata.rb +2 -0
  87. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/recipes/default.rb +0 -0
  88. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/templates/default/template.erb +0 -0
  89. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/attributes/default.rb +0 -0
  90. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/files/default/file.h +0 -0
  91. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/metadata.rb +2 -0
  92. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/recipes/default.rb +0 -0
  93. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/templates/default/template.erb +0 -0
  94. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/attributes/default.rb +0 -0
  95. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/files/default/file.h +0 -0
  96. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/metadata.rb +2 -0
  97. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/recipes/default.rb +0 -0
  98. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/templates/default/template.erb +0 -0
  99. data/spec/unit/berkshelf/berksfile_spec.rb +84 -105
  100. data/spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb +65 -0
  101. data/spec/unit/berkshelf/berkshelf/api_client/connection_spec.rb +157 -0
  102. data/spec/unit/berkshelf/berkshelf/api_client/remote_cookbook_spec.rb +23 -0
  103. data/spec/unit/berkshelf/berkshelf/api_client_spec.rb +9 -0
  104. data/spec/unit/berkshelf/cached_cookbook_spec.rb +45 -47
  105. data/spec/unit/berkshelf/chef_repo_universe_spec.rb +37 -0
  106. data/spec/unit/berkshelf/cli_spec.rb +7 -8
  107. data/spec/unit/berkshelf/community_rest_spec.rb +82 -90
  108. data/spec/unit/berkshelf/config_spec.rb +51 -22
  109. data/spec/unit/berkshelf/cookbook_store_spec.rb +41 -41
  110. data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +7 -8
  111. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +1 -1
  112. data/spec/unit/berkshelf/dependency_spec.rb +48 -48
  113. data/spec/unit/berkshelf/downloader_spec.rb +191 -34
  114. data/spec/unit/berkshelf/errors_spec.rb +3 -3
  115. data/spec/unit/berkshelf/file_syncer_spec.rb +87 -87
  116. data/spec/unit/berkshelf/formatters/base_spec.rb +23 -23
  117. data/spec/unit/berkshelf/formatters/human_spec.rb +2 -2
  118. data/spec/unit/berkshelf/formatters/json_spec.rb +2 -2
  119. data/spec/unit/berkshelf/formatters/null_spec.rb +3 -3
  120. data/spec/unit/berkshelf/installer_spec.rb +8 -8
  121. data/spec/unit/berkshelf/location_spec.rb +11 -11
  122. data/spec/unit/berkshelf/locations/base_spec.rb +35 -36
  123. data/spec/unit/berkshelf/locations/git_spec.rb +90 -93
  124. data/spec/unit/berkshelf/locations/path_spec.rb +40 -41
  125. data/spec/unit/berkshelf/lockfile_parser_spec.rb +71 -71
  126. data/spec/unit/berkshelf/lockfile_spec.rb +205 -211
  127. data/spec/unit/berkshelf/logger_spec.rb +3 -3
  128. data/spec/unit/berkshelf/mixin/logging_spec.rb +5 -5
  129. data/spec/unit/berkshelf/packager_spec.rb +2 -2
  130. data/spec/unit/berkshelf/resolver/graph_spec.rb +10 -8
  131. data/spec/unit/berkshelf/resolver_spec.rb +17 -17
  132. data/spec/unit/berkshelf/ridley_compat_spec.rb +16 -0
  133. data/spec/unit/berkshelf/shell_spec.rb +34 -34
  134. data/spec/unit/berkshelf/source_spec.rb +186 -20
  135. data/spec/unit/berkshelf/source_uri_spec.rb +1 -1
  136. data/spec/unit/berkshelf/ssl_policies_spec.rb +86 -0
  137. data/spec/unit/berkshelf/uploader_spec.rb +146 -64
  138. data/spec/unit/berkshelf/validator_spec.rb +23 -16
  139. data/spec/unit/berkshelf/visualizer_spec.rb +24 -15
  140. data/spec/unit/berkshelf_spec.rb +18 -18
  141. metadata +138 -289
  142. data/.gitignore +0 -29
  143. data/.travis.yml +0 -64
  144. data/CHANGELOG.legacy.md +0 -307
  145. data/CHANGELOG.md +0 -1358
  146. data/CONTRIBUTING.md +0 -64
  147. data/Gemfile.lock +0 -399
  148. data/Guardfile +0 -23
  149. data/PLUGINS.md +0 -25
  150. data/README.md +0 -70
  151. data/Thorfile +0 -61
  152. data/appveyor.yml +0 -31
  153. data/docs/berkshelf_for_newcomers.md +0 -65
  154. data/features/berksfile.feature +0 -46
  155. data/features/commands/apply.feature +0 -41
  156. data/features/commands/contingent.feature +0 -48
  157. data/features/commands/cookbook.feature +0 -35
  158. data/features/commands/info.feature +0 -99
  159. data/features/commands/init.feature +0 -27
  160. data/features/commands/install.feature +0 -636
  161. data/features/commands/list.feature +0 -78
  162. data/features/commands/outdated.feature +0 -130
  163. data/features/commands/package.feature +0 -17
  164. data/features/commands/search.feature +0 -17
  165. data/features/commands/shelf/list.feature +0 -32
  166. data/features/commands/shelf/show.feature +0 -143
  167. data/features/commands/shelf/uninstall.feature +0 -96
  168. data/features/commands/show.feature +0 -83
  169. data/features/commands/update.feature +0 -142
  170. data/features/commands/upload.feature +0 -426
  171. data/features/commands/vendor.feature +0 -111
  172. data/features/commands/verify.feature +0 -29
  173. data/features/commands/viz.feature +0 -66
  174. data/features/community_site.feature +0 -37
  175. data/features/config.feature +0 -111
  176. data/features/help.feature +0 -11
  177. data/features/json_formatter.feature +0 -161
  178. data/features/lifecycle.feature +0 -378
  179. data/features/lockfile.feature +0 -378
  180. data/features/step_definitions/berksfile_steps.rb +0 -39
  181. data/features/step_definitions/chef/config_steps.rb +0 -12
  182. data/features/step_definitions/chef_server_steps.rb +0 -60
  183. data/features/step_definitions/cli_steps.rb +0 -18
  184. data/features/step_definitions/config_steps.rb +0 -46
  185. data/features/step_definitions/environment_steps.rb +0 -7
  186. data/features/step_definitions/filesystem_steps.rb +0 -269
  187. data/features/step_definitions/gem_steps.rb +0 -13
  188. data/features/step_definitions/json_steps.rb +0 -23
  189. data/features/step_definitions/utility_steps.rb +0 -11
  190. data/features/support/aruba.rb +0 -12
  191. data/features/support/env.rb +0 -82
  192. data/generator_files/Berksfile.erb +0 -11
  193. data/generator_files/CHANGELOG.md.erb +0 -3
  194. data/generator_files/Gemfile.erb +0 -8
  195. data/generator_files/README.md.erb +0 -42
  196. data/generator_files/Thorfile.erb +0 -11
  197. data/generator_files/Vagrantfile.erb +0 -117
  198. data/generator_files/chefignore +0 -94
  199. data/generator_files/default_recipe.erb +0 -6
  200. data/generator_files/default_test.rb.erb +0 -11
  201. data/generator_files/gitignore.erb +0 -23
  202. data/generator_files/helpers.rb.erb +0 -7
  203. data/generator_files/licenses/apachev2.erb +0 -13
  204. data/generator_files/licenses/gplv2.erb +0 -15
  205. data/generator_files/licenses/gplv3.erb +0 -14
  206. data/generator_files/licenses/mit.erb +0 -20
  207. data/generator_files/licenses/reserved.erb +0 -3
  208. data/generator_files/metadata.rb.erb +0 -11
  209. data/lib/berkshelf/base_generator.rb +0 -43
  210. data/lib/berkshelf/commands/test_command.rb +0 -13
  211. data/lib/berkshelf/cookbook_generator.rb +0 -133
  212. data/lib/berkshelf/init_generator.rb +0 -195
  213. data/spec/fixtures/cookbooks/example_cookbook/.gitignore +0 -2
  214. data/spec/fixtures/cookbooks/example_cookbook/.kitchen.yml +0 -26
  215. data/spec/unit/berkshelf/cookbook_generator_spec.rb +0 -110
  216. data/spec/unit/berkshelf/init_generator_spec.rb +0 -263
@@ -1,110 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Berkshelf::CookbookGenerator do
4
- let(:name) { 'sparkle_motion' }
5
- let(:license) { 'reserved' }
6
- let(:maintainer) { 'Berkshelf Core' }
7
- let(:maintainer_email) { 'core@berkshelf.com' }
8
-
9
- let(:target) { tmp_path.join(name) }
10
- let(:kitchen_generator) { double('kitchen-generator', invoke_all: nil) }
11
-
12
- before do
13
- allow(Kitchen::Generator::Init)
14
- .to receive(:new)
15
- .with(any_args())
16
- .and_return(kitchen_generator)
17
- end
18
-
19
- context 'with default options' do
20
- before do
21
- capture(:stdout) do
22
- Berkshelf::CookbookGenerator.new([target, name],
23
- license: license,
24
- maintainer: maintainer,
25
- maintainer_email: maintainer_email,
26
- ).invoke_all
27
- end
28
- end
29
-
30
- it "generates a new cookbook" do
31
- expect(target).to have_structure {
32
- directory 'attributes'
33
- directory 'files' do
34
- directory 'default'
35
- end
36
- directory 'libraries'
37
- directory 'providers'
38
- directory 'recipes' do
39
- file 'default.rb' do
40
- contains '# Cookbook Name:: sparkle_motion'
41
- contains '# Recipe:: default'
42
- contains "# Copyright (C) #{Time.now.year} Berkshelf Core"
43
- contains '# All rights reserved - Do Not Redistribute'
44
- end
45
- end
46
- directory 'resources'
47
- directory 'templates' do
48
- directory 'default'
49
- end
50
- file 'LICENSE' do
51
- contains "Copyright (C) #{Time.now.year} Berkshelf Core"
52
- contains 'All rights reserved - Do Not Redistribute'
53
- end
54
- file 'README.md' do
55
- contains '# sparkle_motion-cookbook'
56
- contains '### sparkle_motion::default'
57
- contains " <td><tt>['sparkle_motion']['bacon']</tt></td>"
58
- contains "Include `sparkle_motion` in your node's `run_list`:"
59
- contains ' "recipe[sparkle_motion::default]"'
60
- contains 'Author:: Berkshelf Core (<core@berkshelf.com>)'
61
- end
62
- file 'CHANGELOG.md' do
63
- contains '# 0.1.0'
64
- contains "Initial release of sparkle_motion"
65
- end
66
- file 'metadata.rb' do
67
- contains "name 'sparkle_motion'"
68
- contains "maintainer 'Berkshelf Core'"
69
- contains "maintainer_email 'core@berkshelf.com'"
70
- contains "license 'All rights reserved'"
71
- contains "description 'Installs/Configures sparkle_motion'"
72
- end
73
- file 'Berksfile' do
74
- contains 'source "https://supermarket.chef.io"'
75
- contains 'metadata'
76
- end
77
- file 'Gemfile'
78
- file 'chefignore'
79
- }
80
- end
81
- end
82
-
83
- context "given a 'maintainer_email' option" do
84
- before do
85
- allow(Kitchen::Generator::Init).to receive(:new).with(any_args()).and_return(kitchen_generator)
86
- capture(:stdout) {
87
- Berkshelf::CookbookGenerator.new([target, name], maintainer_email: 'jamie@vialstudios.com').invoke_all
88
- }
89
- end
90
-
91
- it "generates a metadata.rb with the 'maintainer_email' value set" do
92
- email = email
93
- expect(target).to have_structure {
94
- file 'metadata.rb' do
95
- contains "maintainer_email 'jamie@vialstudios.com'"
96
- end
97
- }
98
- end
99
- end
100
-
101
- context "given an invalid option for :license" do
102
- subject(:run) do
103
- capture(:stdout) { described_class.new([target, name], license: 'not-there').invoke_all }
104
- end
105
-
106
- it "raises a LicenseNotFound error" do
107
- expect { run }.to raise_error(Berkshelf::LicenseNotFound)
108
- end
109
- end
110
- end
@@ -1,263 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Berkshelf::InitGenerator do
4
- let(:target) { tmp_path.join("some_cookbook") }
5
- let(:resolver) { double('resolver') }
6
- let(:kitchen_generator) { double('kitchen-generator', invoke_all: nil) }
7
-
8
- before do
9
- allow(Kitchen::Generator::Init).to receive(:new).with(any_args()).and_return(kitchen_generator)
10
- FileUtils.mkdir_p(target)
11
- File.open(File.join(target, 'metadata.rb'), 'w') do |f|
12
- f.write("name 'some_cookbook'")
13
- end
14
- end
15
-
16
- context 'with default options' do
17
- before do
18
- capture(:stdout) {
19
- Berkshelf::InitGenerator.new([target]).invoke_all
20
- }
21
- end
22
-
23
- specify do
24
- expect(target).to have_structure {
25
- file '.gitignore'
26
- file 'Berksfile'
27
- file 'Gemfile'
28
- file 'Vagrantfile' do
29
- contains %(recipe[some_cookbook::default])
30
- contains %(config.omnibus.chef_version = 'latest')
31
- contains %(config.vm.box = 'bento/ubuntu-14.04')
32
- end
33
- file 'chefignore'
34
- }
35
- end
36
- end
37
-
38
- context 'with a chefignore' do
39
- before(:each) do
40
- capture(:stdout) {
41
- Berkshelf::InitGenerator.new([target], chefignore: true).invoke_all
42
- }
43
- end
44
-
45
- specify do
46
- expect(target).to have_structure {
47
- file 'Berksfile'
48
- file 'chefignore'
49
- }
50
- end
51
- end
52
-
53
- context 'with no metadata' do
54
- before do
55
- FileUtils.rm(File.join(target, 'metadata.rb'))
56
- expect {
57
- Berkshelf::InitGenerator.new([target]).invoke_all
58
- }.to raise_error(Berkshelf::NotACookbook)
59
- end
60
- end
61
-
62
- context 'with a metadata entry in the Berksfile' do
63
- before(:each) do
64
- capture(:stdout) {
65
- Berkshelf::InitGenerator.new([target], metadata_entry: true).invoke_all
66
- }
67
- end
68
-
69
- specify do
70
- expect(target).to have_structure {
71
- file 'Berksfile' do
72
- contains 'metadata'
73
- end
74
- }
75
- end
76
- end
77
-
78
- context 'with the foodcritic option true' do
79
- before(:each) do
80
- capture(:stdout) {
81
- Berkshelf::InitGenerator.new([target], foodcritic: true).invoke_all
82
- }
83
- end
84
-
85
- specify do
86
- expect(target).to have_structure {
87
- file 'Thorfile' do
88
- contains "require 'thor/foodcritic'"
89
- end
90
- file 'Gemfile' do
91
- contains "gem 'thor-foodcritic'"
92
- end
93
- }
94
- end
95
- end
96
-
97
- context 'with the scmversion option true' do
98
- before(:each) do
99
- capture(:stdout) {
100
- Berkshelf::InitGenerator.new([target], scmversion: true).invoke_all
101
- }
102
- end
103
-
104
- specify do
105
- expect(target).to have_structure {
106
- file 'Thorfile' do
107
- contains "require 'thor/scmversion'"
108
- end
109
- file 'Gemfile' do
110
- contains "gem 'thor-scmversion'"
111
- end
112
- }
113
- end
114
- end
115
-
116
- context 'with the bundler option true' do
117
- before(:each) do
118
- capture(:stdout) {
119
- Berkshelf::InitGenerator.new([target], no_bundler: true).invoke_all
120
- }
121
- end
122
-
123
- specify do
124
- expect(target).to have_structure {
125
- no_file 'Gemfile'
126
- }
127
- end
128
- end
129
-
130
- context 'given a value for the cookbook_name option' do
131
- it 'sets the value of cookbook_name attribute to the specified option' do
132
- generator = Berkshelf::InitGenerator.new([target], cookbook_name: 'nautilus')
133
- cookbook = generator.send(:cookbook_name)
134
-
135
- expect(cookbook).to eq('nautilus')
136
- end
137
- end
138
-
139
- context 'when no value for cookbook_name option is specified' do
140
- it 'infers the name of the cookbook from the directory name' do
141
- generator = Berkshelf::InitGenerator.new([target])
142
- cookbook = generator.send(:cookbook_name)
143
-
144
- expect(cookbook).to eq('some_cookbook')
145
- end
146
- end
147
-
148
- context 'when skipping git' do
149
- before(:each) do
150
- generator = Berkshelf::InitGenerator.new([target], skip_git: true)
151
- capture(:stdout) { generator.invoke_all }
152
- end
153
-
154
- it 'does not have a .git directory' do
155
- expect(target).to_not have_structure {
156
- directory '.git'
157
- }
158
- end
159
- end
160
-
161
- context 'when skipping vagrant' do
162
- before(:each) do
163
- capture(:stdout) {
164
- Berkshelf::InitGenerator.new([target], skip_vagrant: true).invoke_all
165
- }
166
- end
167
-
168
- it 'does not have a Vagrantfile' do
169
- expect(target).to have_structure {
170
- no_file 'Vagrantfile'
171
- }
172
- end
173
- end
174
-
175
- context "given the 'vagrant.omnibus.version' option set" do
176
- before do
177
- Berkshelf::Config.instance.vagrant.omnibus.version = "11.4.4"
178
- capture(:stdout) {
179
- Berkshelf::InitGenerator.new([target]).invoke_all
180
- }
181
- end
182
-
183
- it "generates a Vagrantfile with the 'config.omnibus.chef_version' value set" do
184
- expect(target).to have_structure {
185
- file 'Vagrantfile' do
186
- contains "config.omnibus.chef_version = '11.4.4'"
187
- end
188
- }
189
- end
190
- end
191
-
192
- context "given the 'vagrant.omnibus.version' option set to 'latest'" do
193
- before do
194
- Berkshelf::Config.instance.vagrant.omnibus.version = "latest"
195
- capture(:stdout) {
196
- Berkshelf::InitGenerator.new([target]).invoke_all
197
- }
198
- end
199
-
200
- it "generates a Vagrantfile with the 'config.omnibus.chef_version' value set to :latest" do
201
- expect(target).to have_structure {
202
- file 'Vagrantfile' do
203
- contains " config.omnibus.chef_version = 'latest'"
204
- end
205
- }
206
- end
207
- end
208
-
209
- context "given the 'vagrant.vm.box_url' option set" do
210
- before do
211
- Berkshelf::Config.instance.vagrant.vm.box_url = "https://vagrantcloud.com/chef/ubuntu-14.04/version/1/provider/virtualbox.box"
212
- capture(:stdout) {
213
- Berkshelf::InitGenerator.new([target]).invoke_all
214
- }
215
- end
216
-
217
- it "generates a Vagrantfile with the 'config.vm.box_url' value set" do
218
- expect(target).to have_structure {
219
- file 'Vagrantfile' do
220
- contains "config.vm.box_url = 'https://vagrantcloud.com/chef/ubuntu-14.04/version/1/provider/virtualbox.box'"
221
- end
222
- }
223
- end
224
- end
225
-
226
- context 'with the chef_minitest option true' do
227
- before(:each) do
228
- allow(Berkshelf::Resolver).to receive(:resolve) { resolver }
229
- skip 'Runs fine with no mock for the HTTP call on the first pass, subsequent passes throw errors'
230
- capture(:stdout) {
231
- Berkshelf::InitGenerator.new([target], chef_minitest: true).invoke_all
232
- }
233
- end
234
-
235
- specify do
236
- expect(target).to have_structure {
237
- file 'Berksfile' do
238
- contains "cookbook 'minitest-handler'"
239
- end
240
- file 'Vagrantfile' do
241
- contains "'recipe[minitest-handler::default]'"
242
- end
243
- directory 'files' do
244
- directory 'default' do
245
- directory 'tests' do
246
- directory 'minitest' do
247
- file 'default_test.rb' do
248
- contains "describe 'some_cookbook::default' do"
249
- contains 'include Helpers::Some_cookbook'
250
- end
251
- directory 'support' do
252
- file 'helpers.rb' do
253
- contains 'module Some_cookbook'
254
- end
255
- end
256
- end
257
- end
258
- end
259
- end
260
- }
261
- end
262
- end
263
- end