chef 11.12.8-x86-mingw32 → 11.14.0.alpha.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -2
  3. data/distro/common/html/_sources/index.txt +6 -0
  4. data/distro/common/html/_sources/knife_ssl_check.txt +41 -0
  5. data/distro/common/html/_sources/knife_ssl_fetch.txt +41 -0
  6. data/distro/common/html/_static/basic.css +2 -5
  7. data/distro/common/html/_static/doctools.js +5 -14
  8. data/distro/common/html/_static/jquery.js +2 -154
  9. data/distro/common/html/_static/pygments.css +2 -2
  10. data/distro/common/html/_static/searchtools.js +212 -150
  11. data/distro/common/html/_static/underscore.js +29 -21
  12. data/distro/common/html/_static/websupport.js +1 -1
  13. data/distro/common/html/ctl_chef_client.html +15 -18
  14. data/distro/common/html/ctl_chef_server.html +7 -7
  15. data/distro/common/html/ctl_chef_shell.html +6 -6
  16. data/distro/common/html/ctl_chef_solo.html +7 -8
  17. data/distro/common/html/index.html +34 -24
  18. data/distro/common/html/knife.html +23 -24
  19. data/distro/common/html/knife_bootstrap.html +13 -9
  20. data/distro/common/html/knife_client.html +10 -11
  21. data/distro/common/html/knife_common_options.html +6 -7
  22. data/distro/common/html/knife_configure.html +3 -4
  23. data/distro/common/html/knife_cookbook.html +18 -11
  24. data/distro/common/html/knife_cookbook_site.html +14 -14
  25. data/distro/common/html/knife_data_bag.html +24 -23
  26. data/distro/common/html/knife_delete.html +4 -5
  27. data/distro/common/html/knife_deps.html +4 -5
  28. data/distro/common/html/knife_diff.html +6 -7
  29. data/distro/common/html/knife_download.html +12 -13
  30. data/distro/common/html/knife_edit.html +4 -5
  31. data/distro/common/html/knife_environment.html +8 -9
  32. data/distro/common/html/knife_exec.html +9 -10
  33. data/distro/common/html/knife_index_rebuild.html +4 -5
  34. data/distro/common/html/knife_list.html +8 -9
  35. data/distro/common/html/knife_node.html +34 -33
  36. data/distro/common/html/knife_raw.html +2 -3
  37. data/distro/common/html/knife_recipe_list.html +3 -4
  38. data/distro/common/html/knife_role.html +30 -29
  39. data/distro/common/html/knife_search.html +7 -7
  40. data/distro/common/html/knife_show.html +4 -5
  41. data/distro/common/html/knife_ssh.html +2 -3
  42. data/distro/common/html/knife_ssl_check.html +148 -0
  43. data/distro/common/html/knife_ssl_fetch.html +152 -0
  44. data/distro/common/html/knife_status.html +4 -5
  45. data/distro/common/html/knife_tag.html +2 -3
  46. data/distro/common/html/knife_upload.html +5 -6
  47. data/distro/common/html/knife_user.html +9 -10
  48. data/distro/common/html/knife_using.html +12 -12
  49. data/distro/common/html/knife_xargs.html +11 -12
  50. data/distro/common/html/search.html +1 -2
  51. data/distro/common/html/searchindex.js +1 -1
  52. data/distro/common/man/man1/chef-shell.1 +19 -11
  53. data/distro/common/man/man1/knife-bootstrap.1 +35 -19
  54. data/distro/common/man/man1/knife-client.1 +111 -28
  55. data/distro/common/man/man1/knife-configure.1 +30 -14
  56. data/distro/common/man/man1/knife-cookbook-site.1 +105 -22
  57. data/distro/common/man/man1/knife-cookbook.1 +164 -23
  58. data/distro/common/man/man1/knife-data-bag.1 +157 -33
  59. data/distro/common/man/man1/knife-delete.1 +21 -17
  60. data/distro/common/man/man1/knife-deps.1 +60 -16
  61. data/distro/common/man/man1/knife-diff.1 +37 -17
  62. data/distro/common/man/man1/knife-download.1 +68 -24
  63. data/distro/common/man/man1/knife-edit.1 +19 -15
  64. data/distro/common/man/man1/knife-environment.1 +105 -17
  65. data/distro/common/man/man1/knife-exec.1 +78 -18
  66. data/distro/common/man/man1/knife-index-rebuild.1 +16 -8
  67. data/distro/common/man/man1/knife-list.1 +39 -23
  68. data/distro/common/man/man1/knife-node.1 +170 -22
  69. data/distro/common/man/man1/knife-raw.1 +33 -13
  70. data/distro/common/man/man1/knife-recipe-list.1 +17 -5
  71. data/distro/common/man/man1/knife-role.1 +86 -18
  72. data/distro/common/man/man1/knife-search.1 +80 -16
  73. data/distro/common/man/man1/knife-show.1 +30 -14
  74. data/distro/common/man/man1/knife-ssh.1 +54 -14
  75. data/distro/common/man/man1/knife-ssl-check.1 +207 -0
  76. data/distro/common/man/man1/knife-ssl-fetch.1 +207 -0
  77. data/distro/common/man/man1/knife-status.1 +48 -12
  78. data/distro/common/man/man1/knife-tag.1 +30 -10
  79. data/distro/common/man/man1/knife-upload.1 +72 -20
  80. data/distro/common/man/man1/knife-user.1 +79 -23
  81. data/distro/common/man/man1/knife-xargs.1 +61 -53
  82. data/distro/common/man/man8/chef-client.8 +87 -29
  83. data/distro/common/man/man8/chef-solo.8 +36 -15
  84. data/lib/chef/application.rb +19 -14
  85. data/lib/chef/application/client.rb +5 -0
  86. data/lib/chef/application/solo.rb +5 -0
  87. data/lib/chef/application/windows_service_manager.rb +3 -0
  88. data/lib/chef/chef_fs/chef_fs_data_store.rb +72 -24
  89. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +20 -4
  90. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +20 -1
  91. data/lib/chef/chef_fs/file_system/file_system_entry.rb +10 -2
  92. data/lib/chef/client.rb +2 -3
  93. data/lib/chef/config.rb +34 -8
  94. data/lib/chef/cookbook/cookbook_version_loader.rb +45 -4
  95. data/lib/chef/cookbook_version.rb +38 -30
  96. data/lib/chef/dsl/recipe.rb +4 -1
  97. data/lib/chef/event_dispatch/base.rb +14 -0
  98. data/lib/chef/event_dispatch/events_output_stream.rb +29 -0
  99. data/lib/chef/exceptions.rb +8 -0
  100. data/lib/chef/formatters/base.rb +16 -45
  101. data/lib/chef/formatters/doc.rb +51 -26
  102. data/lib/chef/formatters/indentable_output_stream.rb +165 -0
  103. data/lib/chef/knife/node_environment_set.rb +54 -0
  104. data/lib/chef/knife/user_create.rb +1 -1
  105. data/lib/chef/monkey_patches/pathname.rb +32 -0
  106. data/lib/chef/node.rb +1 -1
  107. data/lib/chef/platform/provider_mapping.rb +345 -338
  108. data/lib/chef/policy_builder/expand_node_object.rb +1 -1
  109. data/lib/chef/policy_builder/policyfile.rb +1 -1
  110. data/lib/chef/provider.rb +1 -0
  111. data/lib/chef/provider/git.rb +1 -1
  112. data/lib/chef/provider/link.rb +2 -2
  113. data/lib/chef/provider/remote_file/content.rb +1 -1
  114. data/lib/chef/provider/remote_file/local_file.rb +8 -2
  115. data/lib/chef/provider/service/arch.rb +0 -1
  116. data/lib/chef/provider/service/debian.rb +0 -2
  117. data/lib/chef/provider/service/freebsd.rb +2 -1
  118. data/lib/chef/provider/service/gentoo.rb +1 -1
  119. data/lib/chef/provider/service/init.rb +0 -1
  120. data/lib/chef/provider/service/insserv.rb +0 -2
  121. data/lib/chef/provider/service/invokercd.rb +0 -2
  122. data/lib/chef/provider/service/macosx.rb +2 -1
  123. data/lib/chef/provider/service/redhat.rb +0 -1
  124. data/lib/chef/provider/service/simple.rb +1 -0
  125. data/lib/chef/provider/service/solaris.rb +1 -0
  126. data/lib/chef/provider/service/systemd.rb +1 -1
  127. data/lib/chef/provider/service/upstart.rb +1 -1
  128. data/lib/chef/provider/user.rb +9 -9
  129. data/lib/chef/provider/user/solaris.rb +2 -0
  130. data/lib/chef/resource.rb +1 -0
  131. data/lib/chef/resource/remote_file.rb +32 -6
  132. data/lib/chef/run_context.rb +22 -0
  133. data/lib/chef/run_lock.rb +43 -4
  134. data/lib/chef/version.rb +2 -2
  135. data/spec/functional/http/simple_spec.rb +84 -0
  136. data/spec/functional/resource/remote_file_spec.rb +107 -43
  137. data/spec/functional/rest_spec.rb +94 -0
  138. data/spec/functional/run_lock_spec.rb +1 -1
  139. data/spec/functional/win32/service_manager_spec.rb +6 -0
  140. data/spec/integration/knife/chef_fs_data_store_spec.rb +2 -0
  141. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +76 -0
  142. data/spec/spec_helper.rb +2 -0
  143. data/spec/support/mock/platform.rb +7 -0
  144. data/spec/support/pedant/pedant_config.rb +121 -0
  145. data/spec/support/pedant/run_pedant.rb +63 -0
  146. data/spec/support/pedant/stickywicket.pem +27 -0
  147. data/spec/support/shared/functional/http.rb +242 -0
  148. data/spec/support/shared/unit/api_error_inspector.rb +2 -2
  149. data/spec/unit/api_client_spec.rb +2 -2
  150. data/spec/unit/application/client_spec.rb +6 -1
  151. data/spec/unit/application/knife_spec.rb +4 -0
  152. data/spec/unit/application/solo_spec.rb +2 -0
  153. data/spec/unit/application_spec.rb +7 -0
  154. data/spec/unit/client_spec.rb +16 -0
  155. data/spec/unit/config_spec.rb +3 -20
  156. data/spec/unit/cookbook_version_spec.rb +224 -122
  157. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +2 -2
  158. data/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +2 -2
  159. data/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb +2 -2
  160. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +2 -2
  161. data/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +2 -2
  162. data/spec/unit/handler_spec.rb +0 -1
  163. data/spec/unit/knife/client_bulk_delete_spec.rb +3 -0
  164. data/spec/unit/knife/cookbook_bulk_delete_spec.rb +2 -0
  165. data/spec/unit/knife/cookbook_metadata_spec.rb +2 -2
  166. data/spec/unit/knife/cookbook_site_install_spec.rb +3 -1
  167. data/spec/unit/knife/cookbook_upload_spec.rb +10 -10
  168. data/spec/unit/knife/node_environment_set_spec.rb +80 -0
  169. data/spec/unit/knife/user_create_spec.rb +6 -4
  170. data/spec/unit/knife/user_edit_spec.rb +5 -0
  171. data/spec/unit/knife_spec.rb +3 -0
  172. data/spec/unit/mixin/securable_spec.rb +18 -20
  173. data/spec/unit/node/attribute_spec.rb +15 -2
  174. data/spec/unit/node/immutable_collections_spec.rb +4 -4
  175. data/spec/unit/provider/cron_spec.rb +14 -14
  176. data/spec/unit/provider/git_spec.rb +4 -4
  177. data/spec/unit/provider/group_spec.rb +1 -1
  178. data/spec/unit/provider/ohai_spec.rb +2 -2
  179. data/spec/unit/provider/remote_file/content_spec.rb +58 -35
  180. data/spec/unit/provider/remote_file/local_file_spec.rb +23 -0
  181. data/spec/unit/provider/service/solaris_smf_service_spec.rb +13 -13
  182. data/spec/unit/resource/mount_spec.rb +0 -1
  183. data/spec/unit/resource/remote_file_spec.rb +29 -0
  184. data/spec/unit/resource_spec.rb +1 -1
  185. data/spec/unit/run_context_spec.rb +7 -0
  186. data/spec/unit/run_lock_spec.rb +98 -0
  187. data/spec/unit/version_constraint_spec.rb +1 -1
  188. metadata +166 -153
  189. data/distro/common/html/_static/chef.css +0 -507
  190. data/distro/common/html/_static/chef_logo.png +0 -0
  191. data/lib/chef/checksum/storage.rb +0 -18
  192. data/lib/chef/checksum/storage/filesystem.rb +0 -56
  193. data/spec/unit/checksum/storage/filesystem_spec.rb +0 -70
@@ -42,8 +42,8 @@ describe Chef::Formatters::ErrorInspectors::CompileErrorInspector do
42
42
  @description = Chef::Formatters::ErrorDescription.new("Error Evaluating File:")
43
43
  @exception = NoMethodError.new("undefined method `this_is_not_a_valid_method' for Chef::Resource::File")
44
44
 
45
- @outputter = Chef::Formatters::Outputter.new(StringIO.new, STDERR)
46
- #@outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
45
+ @outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR)
46
+ #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
47
47
  end
48
48
 
49
49
  describe "when scrubbing backtraces" do
@@ -25,8 +25,8 @@ describe Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector do
25
25
 
26
26
  @description = Chef::Formatters::ErrorDescription.new("Error Resolving Cookbooks for Run List:")
27
27
  @outputter_output = StringIO.new
28
- @outputter = Chef::Formatters::Outputter.new(@outputter_output, STDERR)
29
- # @outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
28
+ @outputter = Chef::Formatters::IndentableOutputStream.new(@outputter_output, STDERR)
29
+ # @outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
30
30
  end
31
31
 
32
32
  describe "when explaining a 403 error" do
@@ -21,8 +21,8 @@ require 'spec_helper'
21
21
  describe Chef::Formatters::ErrorInspectors::CookbookSyncErrorInspector do
22
22
  before do
23
23
  @description = Chef::Formatters::ErrorDescription.new("Error Expanding RunList:")
24
- @outputter = Chef::Formatters::Outputter.new(StringIO.new, STDERR)
25
- #@outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
24
+ @outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR)
25
+ #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
26
26
  end
27
27
 
28
28
  describe "when explaining a 502 error" do
@@ -39,8 +39,8 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
39
39
  before do
40
40
  @description = Chef::Formatters::ErrorDescription.new("Error Converging Resource:")
41
41
  @stdout = StringIO.new
42
- @outputter = Chef::Formatters::Outputter.new(@stdout, STDERR)
43
- #@outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
42
+ @outputter = Chef::Formatters::IndentableOutputStream.new(@stdout, STDERR)
43
+ #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
44
44
 
45
45
  Chef::Config.stub(:cookbook_path).and_return([ "/var/chef/cache" ])
46
46
  end
@@ -26,8 +26,8 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do
26
26
  end
27
27
 
28
28
  @description = Chef::Formatters::ErrorDescription.new("Error Expanding RunList:")
29
- @outputter = Chef::Formatters::Outputter.new(StringIO.new, STDERR)
30
- #@outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
29
+ @outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR)
30
+ #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
31
31
  end
32
32
 
33
33
  describe "when explaining a missing role error" do
@@ -107,7 +107,6 @@ describe Chef::Handler do
107
107
  $report_ran = false
108
108
  def @handler.report
109
109
  $report_ran = true
110
- puts "I'm AOK here."
111
110
  end
112
111
  lambda {@handler.run_report_safely(@run_status)}.should_not raise_error
113
112
  $report_ran.should be_true
@@ -21,12 +21,15 @@ require 'spec_helper'
21
21
  describe Chef::Knife::ClientBulkDelete do
22
22
  let(:stdout_io) { StringIO.new }
23
23
  let(:stdout) {stdout_io.string}
24
+ let(:stderr_io) { StringIO.new }
25
+ let(:stderr) { stderr_io.string }
24
26
 
25
27
  let(:knife) {
26
28
  k = Chef::Knife::ClientBulkDelete.new
27
29
  k.name_args = name_args
28
30
  k.config = option_args
29
31
  k.ui.stub(:stdout).and_return(stdout_io)
32
+ k.ui.stub(:stderr).and_return(stderr_io)
30
33
  k.ui.stub(:confirm).and_return(knife_confirm)
31
34
  k.ui.stub(:confirm_without_exit).and_return(knife_confirm)
32
35
  k
@@ -27,7 +27,9 @@ describe Chef::Knife::CookbookBulkDelete do
27
27
  @knife.config = {:print_after => nil}
28
28
  @knife.name_args = ["."]
29
29
  @stdout = StringIO.new
30
+ @stderr = StringIO.new
30
31
  @knife.ui.stub(:stdout).and_return(@stdout)
32
+ @knife.ui.stub(:stderr).and_return(@stderr)
31
33
  @knife.ui.stub(:confirm).and_return(true)
32
34
  @cookbooks = Hash.new
33
35
  %w{cheezburger pizza lasagna}.each do |cookbook_name|
@@ -51,9 +51,9 @@ describe Chef::Knife::CookbookMetadata do
51
51
  describe 'with -a or --all' do
52
52
  before(:each) do
53
53
  @knife.config[:all] = true
54
- @foo = Chef::CookbookVersion.new('foo')
54
+ @foo = Chef::CookbookVersion.new('foo', '/tmp/blah')
55
55
  @foo.version = '1.0.0'
56
- @bar = Chef::CookbookVersion.new('bar')
56
+ @bar = Chef::CookbookVersion.new('bar', '/tmp/blah')
57
57
  @bar.version = '2.0.0'
58
58
  @cookbook_loader = {
59
59
  "foo" => @foo,
@@ -21,7 +21,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_hel
21
21
  describe Chef::Knife::CookbookSiteInstall do
22
22
  before(:each) do
23
23
  require 'chef/knife/core/cookbook_scm_repo'
24
+ @stdout = StringIO.new
24
25
  @knife = Chef::Knife::CookbookSiteInstall.new
26
+ @knife.ui.stub(:stdout).and_return(@stdout)
25
27
  @knife.config = {}
26
28
  if Chef::Platform.windows?
27
29
  @install_path = 'C:/tmp/chef'
@@ -52,7 +54,7 @@ describe Chef::Knife::CookbookSiteInstall do
52
54
  end
53
55
 
54
56
  #Stubs for CookbookSCMRepo
55
- @repo = stub(:sanity_check => true, :reset_to_default_state => true,
57
+ @repo = double(:sanity_check => true, :reset_to_default_state => true,
56
58
  :prepare_to_import => true, :finalize_updates_to => true,
57
59
  :merge_updates_from => true)
58
60
  Chef::Knife::CookbookSCMRepo.stub(:new).and_return(@repo)
@@ -23,7 +23,7 @@ require 'chef/cookbook_uploader'
23
23
  require 'timeout'
24
24
 
25
25
  describe Chef::Knife::CookbookUpload do
26
- let(:cookbook) { Chef::CookbookVersion.new('test_cookbook') }
26
+ let(:cookbook) { Chef::CookbookVersion.new('test_cookbook', '/tmp/blah.txt') }
27
27
 
28
28
  let(:cookbooks_by_name) do
29
29
  {cookbook.name => cookbook}
@@ -39,7 +39,7 @@ describe Chef::Knife::CookbookUpload do
39
39
  let(:cookbook_uploader) { double(:upload_cookbooks => nil) }
40
40
 
41
41
  let(:output) { StringIO.new }
42
-
42
+
43
43
  let(:name_args) { ['test_cookbook'] }
44
44
 
45
45
  let(:knife) do
@@ -58,7 +58,7 @@ describe Chef::Knife::CookbookUpload do
58
58
  it 'should upload cookbooks with predefined concurrency' do
59
59
  Chef::CookbookVersion.stub(:list_all_versions).and_return({})
60
60
  knife.config[:concurrency] = 3
61
- test_cookbook = Chef::CookbookVersion.new('test_cookbook')
61
+ test_cookbook = Chef::CookbookVersion.new('test_cookbook', '/tmp/blah')
62
62
  cookbook_loader.stub(:each).and_yield("test_cookbook", test_cookbook)
63
63
  cookbook_loader.stub(:cookbook_names).and_return(["test_cookbook"])
64
64
  Chef::CookbookUploader.should_receive(:new).with( kind_of(Array), kind_of(Array),
@@ -131,9 +131,9 @@ E
131
131
 
132
132
  let(:cookbooks_by_name) do
133
133
  {
134
- 'test_cookbook1' => Chef::CookbookVersion.new('test_cookbook1'),
135
- 'test_cookbook2' => Chef::CookbookVersion.new('test_cookbook2'),
136
- 'test_cookbook3' => Chef::CookbookVersion.new('test_cookbook3')
134
+ 'test_cookbook1' => Chef::CookbookVersion.new('test_cookbook1', '/tmp/blah'),
135
+ 'test_cookbook2' => Chef::CookbookVersion.new('test_cookbook2', '/tmp/blah'),
136
+ 'test_cookbook3' => Chef::CookbookVersion.new('test_cookbook3', '/tmp/blah')
137
137
  }
138
138
  end
139
139
 
@@ -163,7 +163,7 @@ E
163
163
  "test_cookbook3" => test_cookbook3 }
164
164
  end
165
165
 
166
- let(:test_cookbook1) { Chef::CookbookVersion.new('test_cookbook1') }
166
+ let(:test_cookbook1) { Chef::CookbookVersion.new('test_cookbook1', '/tmp/blah') }
167
167
 
168
168
  let(:test_cookbook2) do
169
169
  c = Chef::CookbookVersion.new('test_cookbook2')
@@ -191,7 +191,7 @@ E
191
191
  end
192
192
 
193
193
  describe 'when specifying a cookbook name with missing dependencies' do
194
- let(:cookbook_dependency) { Chef::CookbookVersion.new('dependency') }
194
+ let(:cookbook_dependency) { Chef::CookbookVersion.new('dependency', '/tmp/blah') }
195
195
 
196
196
  before(:each) do
197
197
  cookbook.metadata.depends("dependency")
@@ -245,8 +245,8 @@ E
245
245
  describe 'with -a or --all' do
246
246
  before(:each) do
247
247
  knife.config[:all] = true
248
- @test_cookbook1 = Chef::CookbookVersion.new('test_cookbook1')
249
- @test_cookbook2 = Chef::CookbookVersion.new('test_cookbook2')
248
+ @test_cookbook1 = Chef::CookbookVersion.new('test_cookbook1', '/tmp/blah')
249
+ @test_cookbook2 = Chef::CookbookVersion.new('test_cookbook2', '/tmp/blah')
250
250
  cookbook_loader.stub(:each).and_yield("test_cookbook1", @test_cookbook1).and_yield("test_cookbook2", @test_cookbook2)
251
251
  cookbook_loader.stub(:cookbook_names).and_return(["test_cookbook1", "test_cookbook2"])
252
252
  end
@@ -0,0 +1,80 @@
1
+ #
2
+ # Author:: Jimmy McCrory (<jimmy.mccrory@gmail.com>)
3
+ # Copyright:: Copyright (c) 2014 Jimmy McCrory
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+
21
+ describe Chef::Knife::NodeEnvironmentSet do
22
+ before(:each) do
23
+ Chef::Config[:node_name] = "webmonkey.example.com"
24
+ @knife = Chef::Knife::NodeEnvironmentSet.new
25
+ @knife.name_args = [ "adam", "bar" ]
26
+ @knife.stub(:output).and_return(true)
27
+ @node = Chef::Node.new()
28
+ @node.name("knifetest-node")
29
+ @node.chef_environment << "foo"
30
+ @node.stub(:save).and_return(true)
31
+ Chef::Node.stub(:load).and_return(@node)
32
+ end
33
+
34
+ describe "run" do
35
+ it "should load the node" do
36
+ Chef::Node.should_receive(:load).with("adam")
37
+ @knife.run
38
+ end
39
+
40
+ it "should update the environment" do
41
+ @knife.run
42
+ @node.chef_environment.should == 'bar'
43
+ end
44
+
45
+ it "should save the node" do
46
+ @node.should_receive(:save)
47
+ @knife.run
48
+ end
49
+
50
+ it "should print the environment" do
51
+ @knife.should_receive(:output).and_return(true)
52
+ @knife.run
53
+ end
54
+
55
+ describe "with no environment" do
56
+ # Set up outputs for inspection later
57
+ before(:each) do
58
+ @stdout = StringIO.new
59
+ @stderr = StringIO.new
60
+
61
+ @knife.ui.stub(:stdout).and_return(@stdout)
62
+ @knife.ui.stub(:stderr).and_return(@stderr)
63
+ end
64
+
65
+ it "should exit" do
66
+ @knife.name_args = [ "adam" ]
67
+ lambda { @knife.run }.should raise_error SystemExit
68
+ end
69
+
70
+ it "should show the user the usage and an error" do
71
+ @knife.name_args = [ "adam" ]
72
+
73
+ begin ; @knife.run ; rescue SystemExit ; end
74
+
75
+ @stdout.string.should eq "USAGE: knife node environment set NODE ENVIRONMENT\n"
76
+ @stderr.string.should eq "FATAL: You must specify a node name and an environment.\n"
77
+ end
78
+ end
79
+ end
80
+ end
@@ -23,6 +23,12 @@ Chef::Knife::UserCreate.load_deps
23
23
  describe Chef::Knife::UserCreate do
24
24
  before(:each) do
25
25
  @knife = Chef::Knife::UserCreate.new
26
+
27
+ @stdout = StringIO.new
28
+ @stderr = StringIO.new
29
+ @knife.ui.stub(:stdout).and_return(@stdout)
30
+ @knife.ui.stub(:stderr).and_return(@stderr)
31
+
26
32
  @knife.name_args = [ 'a_user' ]
27
33
  @knife.config[:user_password] = "foobar"
28
34
  @user = Chef::User.new
@@ -34,10 +40,6 @@ describe Chef::Knife::UserCreate do
34
40
  Chef::User.stub(:new).and_return(@user)
35
41
  Chef::User.stub(:from_hash).and_return(@user)
36
42
  @knife.stub(:edit_data).and_return(@user.to_hash)
37
- @stdout = StringIO.new
38
- @stderr = StringIO.new
39
- @knife.ui.stub(:stdout).and_return(@stdout)
40
- @knife.ui.stub(:stderr).and_return(@stderr)
41
43
  end
42
44
 
43
45
  it "creates a new user" do
@@ -20,8 +20,13 @@ require 'spec_helper'
20
20
 
21
21
  describe Chef::Knife::UserEdit do
22
22
  before(:each) do
23
+ @stderr = StringIO.new
24
+ @stdout = StringIO.new
25
+
23
26
  Chef::Knife::UserEdit.load_deps
24
27
  @knife = Chef::Knife::UserEdit.new
28
+ @knife.ui.stub(:stderr).and_return(@stderr)
29
+ @knife.ui.stub(:stdout).and_return(@stdout)
25
30
  @knife.name_args = [ 'my_user' ]
26
31
  @knife.config[:disable_editing] = true
27
32
  end
@@ -29,6 +29,9 @@ describe Chef::Knife do
29
29
  Chef::Log.logger = Logger.new(StringIO.new)
30
30
 
31
31
  Chef::Config[:node_name] = "webmonkey.example.com"
32
+
33
+ # Prevent gratuitous code reloading:
34
+ Chef::Knife.stub(:load_commands)
32
35
  @knife = Chef::Knife.new
33
36
  @knife.ui.stub(:puts)
34
37
  @knife.ui.stub(:print)
@@ -46,7 +46,6 @@ describe Chef::Mixin::Securable do
46
46
  describe "unix-specific behavior" do
47
47
  before(:each) do
48
48
  platform_mock :unix do
49
- load File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "chef", "config.rb")
50
49
  load File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "chef", "mixin", "securable.rb")
51
50
  @securable = Object.new
52
51
  @securable.send(:extend, Chef::Mixin::Securable)
@@ -156,35 +155,34 @@ describe Chef::Mixin::Securable do
156
155
  end
157
156
 
158
157
  it "should accept a unix file mode in numeric form as a ruby-interpreted integer" do
159
- lambda { @securable.mode 0 }.should_not raise_error
160
- lambda { @securable.mode 0000 }.should_not raise_error
161
- lambda { @securable.mode 444 }.should_not raise_error
162
- lambda { @securable.mode 0444 }.should_not raise_error
163
- lambda { @securable.mode 07777 }.should_not raise_error
164
-
165
- lambda { @securable.mode 292 }.should_not raise_error
166
- lambda { @securable.mode 4095 }.should_not raise_error
167
-
168
- lambda { @securable.mode 0111 }.should_not raise_error
169
- lambda { @securable.mode 73 }.should_not raise_error
170
-
171
- lambda { @securable.mode -01 }.should raise_error(ArgumentError)
172
- lambda { @securable.mode 010000 }.should raise_error(ArgumentError)
173
- lambda { @securable.mode -1 }.should raise_error(ArgumentError)
174
- lambda { @securable.mode 4096 }.should raise_error(ArgumentError)
158
+ lambda { @securable.mode(0) }.should_not raise_error
159
+ lambda { @securable.mode(0000) }.should_not raise_error
160
+ lambda { @securable.mode(444) }.should_not raise_error
161
+ lambda { @securable.mode(0444) }.should_not raise_error
162
+ lambda { @securable.mode(07777) }.should_not raise_error
163
+
164
+ lambda { @securable.mode(292) }.should_not raise_error
165
+ lambda { @securable.mode(4095) }.should_not raise_error
166
+
167
+ lambda { @securable.mode(0111) }.should_not raise_error
168
+ lambda { @securable.mode(73) }.should_not raise_error
169
+
170
+ lambda { @securable.mode(-01) }.should raise_error(ArgumentError)
171
+ lambda { @securable.mode(010000) }.should raise_error(ArgumentError)
172
+ lambda { @securable.mode(-1) }.should raise_error(ArgumentError)
173
+ lambda { @securable.mode(4096) }.should raise_error(ArgumentError)
175
174
  end
176
175
  end
177
176
 
178
177
  describe "windows-specific behavior" do
179
178
  before(:each) do
180
179
  platform_mock :windows do
181
- load File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "chef", "config.rb")
182
180
  load File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "chef", "mixin", "securable.rb")
183
- SECURABLE_CLASS = Class.new do
181
+ securable_class = Class.new do
184
182
  include Chef::Mixin::Securable
185
183
  include Chef::Mixin::ParamsValidate
186
184
  end
187
- @securable = SECURABLE_CLASS.new
185
+ @securable = securable_class.new
188
186
  end
189
187
  end
190
188
 
@@ -890,6 +890,15 @@ describe Chef::Node::Attribute do
890
890
  end
891
891
 
892
892
  describe "index" do
893
+ # Hash#index is deprecated and triggers warnings.
894
+ def silence
895
+ old_verbose = $VERBOSE
896
+ $VERBOSE = nil
897
+ yield
898
+ ensure
899
+ $VERBOSE = old_verbose
900
+ end
901
+
893
902
  before do
894
903
  @attributes = Chef::Node::Attribute.new(
895
904
  {
@@ -914,13 +923,17 @@ describe Chef::Node::Attribute do
914
923
 
915
924
  describe "when the value is indexed" do
916
925
  it "should return the index" do
917
- @attributes.index("six").should == "one"
926
+ silence do
927
+ @attributes.index("six").should == "one"
928
+ end
918
929
  end
919
930
  end
920
931
 
921
932
  describe "when the value is not indexed" do
922
933
  it "should return nil" do
923
- @attributes.index("lolol").should == nil
934
+ silence do
935
+ @attributes.index("lolol").should == nil
936
+ end
924
937
  end
925
938
  end
926
939
 
@@ -76,7 +76,7 @@ describe Chef::Node::ImmutableMash do
76
76
  end
77
77
 
78
78
  it 'should allow mutation' do
79
- lambda { @copy['m'] = 'm' }.should_not raise_error(Chef::Exceptions::ImmutableAttributeModification)
79
+ lambda { @copy['m'] = 'm' }.should_not raise_error
80
80
  end
81
81
 
82
82
  end
@@ -97,7 +97,7 @@ describe Chef::Node::ImmutableMash do
97
97
  :shift
98
98
  ].each do |mutator|
99
99
  it "doesn't allow mutation via `#{mutator}'" do
100
- lambda { @immutable_mash.send(mutator) }.should raise_error(Chef::Exceptions::ImmutableAttributeModification)
100
+ lambda { @immutable_mash.send(mutator) }.should raise_error
101
101
  end
102
102
  end
103
103
 
@@ -154,7 +154,7 @@ describe Chef::Node::ImmutableArray do
154
154
  :unshift
155
155
  ].each do |mutator|
156
156
  it "does not allow mutation via `#{mutator}" do
157
- lambda { @immutable_array.send(mutator)}.should raise_error(Chef::Exceptions::ImmutableAttributeModification)
157
+ lambda { @immutable_array.send(mutator)}.should raise_error
158
158
  end
159
159
  end
160
160
 
@@ -190,7 +190,7 @@ describe Chef::Node::ImmutableArray do
190
190
  end
191
191
 
192
192
  it 'should allow mutation' do
193
- lambda { @copy << 'm' }.should_not raise_error(Chef::Exceptions::ImmutableAttributeModification)
193
+ lambda { @copy << 'm' }.should_not raise_error
194
194
  end
195
195
  end
196
196