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
@@ -37,8 +37,8 @@ shared_examples_for "an api error inspector" do
37
37
  :client_key => "/etc/chef/client.pem"
38
38
  }
39
39
  @description = Chef::Formatters::ErrorDescription.new("Error registering the node:")
40
- @outputter = Chef::Formatters::Outputter.new(StringIO.new, STDERR)
41
- #@outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
40
+ @outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR)
41
+ #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
42
42
 
43
43
  end
44
44
 
@@ -197,11 +197,11 @@ describe Chef::ApiClient do
197
197
  end
198
198
 
199
199
  it "preserves the admin status" do
200
- @client.admin.should be_a_kind_of(Chef::TrueClass)
200
+ @client.admin.should be_a_kind_of(TrueClass)
201
201
  end
202
202
 
203
203
  it "preserves the 'validator' status" do
204
- @client.validator.should be_a_kind_of(Chef::TrueClass)
204
+ @client.validator.should be_a_kind_of(TrueClass)
205
205
  end
206
206
 
207
207
  it "includes the private key if present" do
@@ -19,10 +19,13 @@ require 'spec_helper'
19
19
 
20
20
  describe Chef::Application::Client, "reconfigure" do
21
21
  before do
22
+ Kernel.stub(:trap).and_return(:ok)
23
+
22
24
  @original_argv = ARGV.dup
23
25
  ARGV.clear
24
26
 
25
27
  @app = Chef::Application::Client.new
28
+ @app.stub(:trap)
26
29
  @app.stub(:configure_opt_parser).and_return(true)
27
30
  @app.stub(:configure_chef).and_return(true)
28
31
  @app.stub(:configure_logging).and_return(true)
@@ -131,6 +134,8 @@ describe Chef::Application::Client, "run_application", :unix_only do
131
134
  Chef::Config[:daemonize] = true
132
135
  @pipe = IO.pipe
133
136
  @app = Chef::Application::Client.new
137
+ # Default logger doesn't work correctly when logging from a trap handler.
138
+ @app.configure_logging
134
139
  Chef::Daemon.stub(:daemonize).and_return(true)
135
140
  @app.stub(:run_chef_client) do
136
141
  @pipe[1].puts 'started'
@@ -139,7 +144,7 @@ describe Chef::Application::Client, "run_application", :unix_only do
139
144
  end
140
145
  end
141
146
 
142
- it "should exit gracefully when sent SIGTERM" do
147
+ it "should exit gracefully when sent SIGTERM", :volatile_on_solaris do
143
148
  pid = fork do
144
149
  @app.run_application
145
150
  end
@@ -34,8 +34,12 @@ describe Chef::Application::Knife do
34
34
  end
35
35
 
36
36
  before(:each) do
37
+ # Prevent code from getting loaded on every test invocation.
38
+ Chef::Knife.stub(:load_commands)
39
+
37
40
  @knife = Chef::Application::Knife.new
38
41
  @knife.stub(:puts)
42
+ @knife.stub(:trap)
39
43
  Chef::Knife.stub(:list_commands)
40
44
  end
41
45
 
@@ -19,10 +19,12 @@ require 'spec_helper'
19
19
 
20
20
  describe Chef::Application::Solo do
21
21
  before do
22
+ Kernel.stub(:trap).and_return(:ok)
22
23
  @app = Chef::Application::Solo.new
23
24
  @app.stub(:configure_opt_parser).and_return(true)
24
25
  @app.stub(:configure_chef).and_return(true)
25
26
  @app.stub(:configure_logging).and_return(true)
27
+ @app.stub(:trap)
26
28
  Chef::Config[:recipe_url] = false
27
29
  Chef::Config[:json_attribs] = false
28
30
  Chef::Config[:solo] = true
@@ -24,6 +24,7 @@ describe Chef::Application do
24
24
  ARGV.clear
25
25
  Chef::Log.logger = Logger.new(StringIO.new)
26
26
  @app = Chef::Application.new
27
+ @app.stub(:trap)
27
28
  Dir.stub(:chdir).and_return(0)
28
29
  @app.stub(:reconfigure)
29
30
  Chef::Log.init(STDERR)
@@ -84,6 +85,9 @@ describe Chef::Application do
84
85
 
85
86
  describe "configure_chef" do
86
87
  before do
88
+ # Silence warnings when no config file exists
89
+ Chef::Log.stub(:warn)
90
+
87
91
  @app = Chef::Application.new
88
92
  #Chef::Config.stub(:merge!).and_return(true)
89
93
  @app.stub(:parse_options).and_return(true)
@@ -107,6 +111,9 @@ describe Chef::Application do
107
111
 
108
112
  before do
109
113
  @app.config[:config_file] = config_location
114
+
115
+ # force let binding to get evaluated or else we stub Pathname.new before we try to use it.
116
+ config_location_pathname
110
117
  Pathname.stub(:new).with(config_location).and_return(config_location_pathname)
111
118
  File.should_receive(:read).
112
119
  with(config_location).
@@ -488,6 +488,22 @@ describe Chef::Client do
488
488
  node[:recipes].length.should == 1
489
489
  node[:recipes].should include("cookbook1")
490
490
  end
491
+
492
+ it "should set the environment from the specified configuration value" do
493
+ node.chef_environment.should == "_default"
494
+ Chef::Config[:environment] = "A"
495
+
496
+ test_env = Chef::Environment.new
497
+ test_env.name("A")
498
+
499
+ mock_chef_rest = double("Chef::REST")
500
+ mock_chef_rest.should_receive(:get_rest).with("environments/A").and_return(test_env)
501
+ Chef::REST.should_receive(:new).and_return(mock_chef_rest)
502
+ client.policy_builder.stub(:node).and_return(node)
503
+ client.build_node.should == node
504
+
505
+ node.chef_environment.should == "A"
506
+ end
491
507
  end
492
508
 
493
509
  describe "windows_admin_check" do
@@ -21,10 +21,6 @@ require 'spec_helper'
21
21
  require 'chef/exceptions'
22
22
 
23
23
  describe Chef::Config do
24
- before(:all) do
25
- @original_env = { 'HOME' => ENV['HOME'], 'SYSTEMDRIVE' => ENV['SYSTEMDRIVE'], 'HOMEPATH' => ENV['HOMEPATH'], 'USERPROFILE' => ENV['USERPROFILE'] }
26
- end
27
-
28
24
  describe "config attribute writer: chef_server_url" do
29
25
  before do
30
26
  Chef::Config.chef_server_url = "https://junglist.gen.nz"
@@ -132,7 +128,7 @@ describe Chef::Config do
132
128
  it "should return a windows path on windows systems" do
133
129
  platform_mock :windows do
134
130
  path = "/etc/chef/cookbooks"
135
- ENV.stub(:[]).with('SYSTEMDRIVE').and_return('C:')
131
+ Chef::Config.stub(:env).and_return({ 'SYSTEMDRIVE' => 'C:' })
136
132
  # match on a regex that looks for the base path with an optional
137
133
  # system drive at the beginning (c:)
138
134
  # system drive is not hardcoded b/c it can change and b/c it is not present on linux systems
@@ -283,23 +279,14 @@ describe Chef::Config do
283
279
 
284
280
  describe "Chef::Config[:user_home]" do
285
281
  it "should set when HOME is provided" do
286
- ENV['HOME'] = "/home/kitten"
287
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "chef", "config.rb"))
282
+ Chef::Config.stub(:env).and_return({ 'HOME' => "/home/kitten" })
288
283
  Chef::Config[:user_home].should == "/home/kitten"
289
284
  end
290
285
 
291
286
  it "should be set when only USERPROFILE is provided" do
292
- ENV['HOME'], ENV['SYSTEMDRIVE'], ENV['HOMEPATH'] = nil, nil, nil
293
- ENV['USERPROFILE'] = "/users/kitten"
294
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "chef", "config.rb"))
287
+ Chef::Config.stub(:env).and_return({ 'USERPROFILE' => "/users/kitten" })
295
288
  Chef::Config[:user_home].should == "/users/kitten"
296
289
  end
297
-
298
- after(:each) do
299
- @original_env.each do |env_setting|
300
- ENV[env_setting[0]] = env_setting[1]
301
- end
302
- end
303
290
  end
304
291
 
305
292
  describe "Chef::Config[:encrypted_data_bag_secret]" do
@@ -310,10 +297,6 @@ describe Chef::Config do
310
297
 
311
298
  before do
312
299
  File.stub(:exist?).with(db_secret_default_path).and_return(secret_exists)
313
- # ugh...the only way to properly test this since the conditional
314
- # is evaluated at file load/require time.
315
- $LOADED_FEATURES.delete_if{|f| f =~ /chef\/config\.rb/}
316
- require 'chef/config'
317
300
  end
318
301
 
319
302
  context "#{db_secret_default_path} exists" do
@@ -20,7 +20,7 @@ require 'spec_helper'
20
20
  describe Chef::CookbookVersion do
21
21
  describe "when first created" do
22
22
  before do
23
- @cookbook_version = Chef::CookbookVersion.new("tatft")
23
+ @cookbook_version = Chef::CookbookVersion.new("tatft", '/tmp/blah')
24
24
  end
25
25
 
26
26
  it "has a name" do
@@ -96,156 +96,258 @@ describe Chef::CookbookVersion do
96
96
  end
97
97
  end
98
98
 
99
- describe "after the cookbook has been loaded" do
99
+ describe "with a cookbook directory named tatft" do
100
100
  MD5 = /[0-9a-f]{32}/
101
101
 
102
102
  before do
103
- # Currently the cookbook loader finds all the files then tells CookbookVersion
104
- # where they are.
105
- @cookbook_version = Chef::CookbookVersion.new("tatft")
106
-
107
103
  @cookbook = Hash.new { |hash, key| hash[key] = [] }
108
104
 
109
- cookbook_root = File.join(CHEF_SPEC_DATA, 'cb_version_cookbooks', 'tatft')
105
+ @cookbook_root = File.join(CHEF_SPEC_DATA, 'cb_version_cookbooks', 'tatft')
110
106
 
111
107
  # Dunno if the paths here are representitive of what is set by CookbookLoader...
112
- @cookbook[:attribute_filenames] = Dir[File.join(cookbook_root, 'attributes', '**', '*.rb')]
113
- @cookbook[:definition_filenames] = Dir[File.join(cookbook_root, 'definitions', '**', '*.rb')]
114
- @cookbook[:file_filenames] = Dir[File.join(cookbook_root, 'files', '**', '*.tgz')]
115
- @cookbook[:recipe_filenames] = Dir[File.join(cookbook_root, 'recipes', '**', '*.rb')]
116
- @cookbook[:template_filenames] = Dir[File.join(cookbook_root, 'templates', '**', '*.erb')]
117
- @cookbook[:library_filenames] = Dir[File.join(cookbook_root, 'libraries', '**', '*.rb')]
118
- @cookbook[:resource_filenames] = Dir[File.join(cookbook_root, 'resources', '**', '*.rb')]
119
- @cookbook[:provider_filenames] = Dir[File.join(cookbook_root, 'providers', '**', '*.rb')]
120
- @cookbook[:root_filenames] = Array(File.join(cookbook_root, 'README.rdoc'))
121
- @cookbook[:metadata_filenames] = Array(File.join(cookbook_root, 'metadata.json'))
122
-
123
- @cookbook_version.attribute_filenames = @cookbook[:attribute_filenames]
124
- @cookbook_version.definition_filenames = @cookbook[:definition_filenames]
125
- @cookbook_version.recipe_filenames = @cookbook[:recipe_filenames]
126
- @cookbook_version.template_filenames = @cookbook[:template_filenames]
127
- @cookbook_version.file_filenames = @cookbook[:file_filenames]
128
- @cookbook_version.library_filenames = @cookbook[:library_filenames]
129
- @cookbook_version.resource_filenames = @cookbook[:resource_filenames]
130
- @cookbook_version.provider_filenames = @cookbook[:provider_filenames]
131
- @cookbook_version.root_filenames = @cookbook[:root_filenames]
132
- @cookbook_version.metadata_filenames = @cookbook[:metadata_filenames]
133
-
134
- # Used to test file-specificity related file lookups
135
- @node = Chef::Node.new
136
- @node.set[:platform] = "ubuntu"
137
- @node.set[:platform_version] = "13.04"
138
- @node.name("testing")
108
+ @cookbook[:attribute_filenames] = Dir[File.join(@cookbook_root, 'attributes', '**', '*.rb')]
109
+ @cookbook[:definition_filenames] = Dir[File.join(@cookbook_root, 'definitions', '**', '*.rb')]
110
+ @cookbook[:file_filenames] = Dir[File.join(@cookbook_root, 'files', '**', '*.tgz')]
111
+ @cookbook[:recipe_filenames] = Dir[File.join(@cookbook_root, 'recipes', '**', '*.rb')]
112
+ @cookbook[:template_filenames] = Dir[File.join(@cookbook_root, 'templates', '**', '*.erb')]
113
+ @cookbook[:library_filenames] = Dir[File.join(@cookbook_root, 'libraries', '**', '*.rb')]
114
+ @cookbook[:resource_filenames] = Dir[File.join(@cookbook_root, 'resources', '**', '*.rb')]
115
+ @cookbook[:provider_filenames] = Dir[File.join(@cookbook_root, 'providers', '**', '*.rb')]
116
+ @cookbook[:root_filenames] = Array(File.join(@cookbook_root, 'README.rdoc'))
117
+ @cookbook[:metadata_filenames] = Array(File.join(@cookbook_root, 'metadata.json'))
118
+
139
119
  end
140
120
 
141
- it "generates a manifest containing the cookbook's files" do
142
- manifest = @cookbook_version.manifest
121
+ describe "and a cookbook with the same name" do
122
+ before do
123
+ # Currently the cookbook loader finds all the files then tells CookbookVersion
124
+ # where they are.
125
+ @cookbook_version = Chef::CookbookVersion.new("tatft", @cookbook_root)
126
+
127
+ @cookbook_version.attribute_filenames = @cookbook[:attribute_filenames]
128
+ @cookbook_version.definition_filenames = @cookbook[:definition_filenames]
129
+ @cookbook_version.recipe_filenames = @cookbook[:recipe_filenames]
130
+ @cookbook_version.template_filenames = @cookbook[:template_filenames]
131
+ @cookbook_version.file_filenames = @cookbook[:file_filenames]
132
+ @cookbook_version.library_filenames = @cookbook[:library_filenames]
133
+ @cookbook_version.resource_filenames = @cookbook[:resource_filenames]
134
+ @cookbook_version.provider_filenames = @cookbook[:provider_filenames]
135
+ @cookbook_version.root_filenames = @cookbook[:root_filenames]
136
+ @cookbook_version.metadata_filenames = @cookbook[:metadata_filenames]
137
+
138
+ # Used to test file-specificity related file lookups
139
+ @node = Chef::Node.new
140
+ @node.set[:platform] = "ubuntu"
141
+ @node.set[:platform_version] = "13.04"
142
+ @node.name("testing")
143
+ end
143
144
 
144
- manifest["metadata"].should == Chef::Cookbook::Metadata.new
145
- manifest["cookbook_name"].should == "tatft"
145
+ it "generates a manifest containing the cookbook's files" do
146
+ manifest = @cookbook_version.manifest
146
147
 
147
- manifest["recipes"].should have(1).recipe_file
148
+ manifest["metadata"].should == Chef::Cookbook::Metadata.new
149
+ manifest["cookbook_name"].should == "tatft"
148
150
 
149
- recipe = manifest["recipes"].first
150
- recipe["name"].should == "default.rb"
151
- recipe["path"].should == "recipes/default.rb"
152
- recipe["checksum"].should match(MD5)
153
- recipe["specificity"].should == "default"
151
+ manifest["recipes"].should have(1).recipe_file
154
152
 
155
- manifest["definitions"].should have(1).definition_file
153
+ recipe = manifest["recipes"].first
154
+ recipe["name"].should == "default.rb"
155
+ recipe["path"].should == "recipes/default.rb"
156
+ recipe["checksum"].should match(MD5)
157
+ recipe["specificity"].should == "default"
156
158
 
157
- definition = manifest["definitions"].first
158
- definition["name"].should == "runit_service.rb"
159
- definition["path"].should == "definitions/runit_service.rb"
160
- definition["checksum"].should match(MD5)
161
- definition["specificity"].should == "default"
159
+ manifest["definitions"].should have(1).definition_file
162
160
 
163
- manifest["libraries"].should have(1).library_file
161
+ definition = manifest["definitions"].first
162
+ definition["name"].should == "runit_service.rb"
163
+ definition["path"].should == "definitions/runit_service.rb"
164
+ definition["checksum"].should match(MD5)
165
+ definition["specificity"].should == "default"
164
166
 
165
- library = manifest["libraries"].first
166
- library["name"].should == "ownage.rb"
167
- library["path"].should == "libraries/ownage.rb"
168
- library["checksum"].should match(MD5)
169
- library["specificity"].should == "default"
167
+ manifest["libraries"].should have(1).library_file
170
168
 
171
- manifest["attributes"].should have(1).attribute_file
169
+ library = manifest["libraries"].first
170
+ library["name"].should == "ownage.rb"
171
+ library["path"].should == "libraries/ownage.rb"
172
+ library["checksum"].should match(MD5)
173
+ library["specificity"].should == "default"
172
174
 
173
- attribute_file = manifest["attributes"].first
174
- attribute_file["name"].should == "default.rb"
175
- attribute_file["path"].should == "attributes/default.rb"
176
- attribute_file["checksum"].should match(MD5)
177
- attribute_file["specificity"].should == "default"
175
+ manifest["attributes"].should have(1).attribute_file
178
176
 
179
- manifest["files"].should have(1).cookbook_file
177
+ attribute_file = manifest["attributes"].first
178
+ attribute_file["name"].should == "default.rb"
179
+ attribute_file["path"].should == "attributes/default.rb"
180
+ attribute_file["checksum"].should match(MD5)
181
+ attribute_file["specificity"].should == "default"
180
182
 
181
- cookbook_file = manifest["files"].first
182
- cookbook_file["name"].should == "giant_blob.tgz"
183
- cookbook_file["path"].should == "files/default/giant_blob.tgz"
184
- cookbook_file["checksum"].should match(MD5)
185
- cookbook_file["specificity"].should == "default"
183
+ manifest["files"].should have(1).cookbook_file
186
184
 
187
- manifest["templates"].should have(1).template
185
+ cookbook_file = manifest["files"].first
186
+ cookbook_file["name"].should == "giant_blob.tgz"
187
+ cookbook_file["path"].should == "files/default/giant_blob.tgz"
188
+ cookbook_file["checksum"].should match(MD5)
189
+ cookbook_file["specificity"].should == "default"
188
190
 
189
- template = manifest["templates"].first
190
- template["name"].should == "configuration.erb"
191
- template["path"].should == "templates/default/configuration.erb"
192
- template["checksum"].should match(MD5)
193
- template["specificity"].should == "default"
191
+ manifest["templates"].should have(1).template
194
192
 
195
- manifest["resources"].should have(1).lwr
193
+ template = manifest["templates"].first
194
+ template["name"].should == "configuration.erb"
195
+ template["path"].should == "templates/default/configuration.erb"
196
+ template["checksum"].should match(MD5)
197
+ template["specificity"].should == "default"
196
198
 
197
- lwr = manifest["resources"].first
198
- lwr["name"].should == "lwr.rb"
199
- lwr["path"].should == "resources/lwr.rb"
200
- lwr["checksum"].should match(MD5)
201
- lwr["specificity"].should == "default"
199
+ manifest["resources"].should have(1).lwr
202
200
 
203
- manifest["providers"].should have(1).lwp
201
+ lwr = manifest["resources"].first
202
+ lwr["name"].should == "lwr.rb"
203
+ lwr["path"].should == "resources/lwr.rb"
204
+ lwr["checksum"].should match(MD5)
205
+ lwr["specificity"].should == "default"
204
206
 
205
- lwp = manifest["providers"].first
206
- lwp["name"].should == "lwp.rb"
207
- lwp["path"].should == "providers/lwp.rb"
208
- lwp["checksum"].should match(MD5)
209
- lwp["specificity"].should == "default"
207
+ manifest["providers"].should have(1).lwp
210
208
 
211
- manifest["root_files"].should have(1).file_in_the_cookbook_root
209
+ lwp = manifest["providers"].first
210
+ lwp["name"].should == "lwp.rb"
211
+ lwp["path"].should == "providers/lwp.rb"
212
+ lwp["checksum"].should match(MD5)
213
+ lwp["specificity"].should == "default"
212
214
 
213
- readme = manifest["root_files"].first
214
- readme["name"].should == "README.rdoc"
215
- readme["path"].should == "README.rdoc"
216
- readme["checksum"].should match(MD5)
217
- readme["specificity"].should == "default"
218
- end
215
+ manifest["root_files"].should have(1).file_in_the_cookbook_root
219
216
 
220
- it "determines whether a template is available for a given node" do
221
- @cookbook_version.should have_template_for_node(@node, "configuration.erb")
222
- @cookbook_version.should_not have_template_for_node(@node, "missing.erb")
223
- end
217
+ readme = manifest["root_files"].first
218
+ readme["name"].should == "README.rdoc"
219
+ readme["path"].should == "README.rdoc"
220
+ readme["checksum"].should match(MD5)
221
+ readme["specificity"].should == "default"
222
+ end
224
223
 
225
- it "determines whether a cookbook_file is available for a given node" do
226
- @cookbook_version.should have_cookbook_file_for_node(@node, "giant_blob.tgz")
227
- @cookbook_version.should_not have_cookbook_file_for_node(@node, "missing.txt")
228
- end
224
+ it "determines whether a template is available for a given node" do
225
+ @cookbook_version.should have_template_for_node(@node, "configuration.erb")
226
+ @cookbook_version.should_not have_template_for_node(@node, "missing.erb")
227
+ end
229
228
 
230
- describe "raises an error when attempting to load a missing cookbook_file and" do
231
- before do
232
- node = Chef::Node.new.tap do |n|
233
- n.name("sample.node")
234
- n.automatic_attrs[:fqdn] = "sample.example.com"
235
- n.automatic_attrs[:platform] = "ubuntu"
236
- n.automatic_attrs[:platform_version] = "10.04"
229
+ it "determines whether a cookbook_file is available for a given node" do
230
+ @cookbook_version.should have_cookbook_file_for_node(@node, "giant_blob.tgz")
231
+ @cookbook_version.should_not have_cookbook_file_for_node(@node, "missing.txt")
232
+ end
233
+
234
+ describe "raises an error when attempting to load a missing cookbook_file and" do
235
+ before do
236
+ node = Chef::Node.new.tap do |n|
237
+ n.name("sample.node")
238
+ n.automatic_attrs[:fqdn] = "sample.example.com"
239
+ n.automatic_attrs[:platform] = "ubuntu"
240
+ n.automatic_attrs[:platform_version] = "10.04"
241
+ end
242
+ @attempt_to_load_file = lambda { @cookbook_version.preferred_manifest_record(node, :files, "no-such-thing.txt") }
243
+ end
244
+
245
+ it "describes the cookbook and version" do
246
+ useful_explanation = Regexp.new(Regexp.escape("Cookbook 'tatft' (0.0.0) does not contain"))
247
+ @attempt_to_load_file.should raise_error(Chef::Exceptions::FileNotFound, useful_explanation)
248
+ end
249
+
250
+ it "lists suggested places to look" do
251
+ useful_explanation = Regexp.new(Regexp.escape("files/default/no-such-thing.txt"))
252
+ @attempt_to_load_file.should raise_error(Chef::Exceptions::FileNotFound, useful_explanation)
237
253
  end
238
- @attempt_to_load_file = lambda { @cookbook_version.preferred_manifest_record(node, :files, "no-such-thing.txt") }
239
254
  end
255
+ end
240
256
 
241
- it "describes the cookbook and version" do
242
- useful_explanation = Regexp.new(Regexp.escape("Cookbook 'tatft' (0.0.0) does not contain"))
243
- @attempt_to_load_file.should raise_error(Chef::Exceptions::FileNotFound, useful_explanation)
257
+ describe "and a cookbook_version with a different name" do
258
+ before do
259
+ # Currently the cookbook loader finds all the files then tells CookbookVersion
260
+ # where they are.
261
+ @cookbook_version = Chef::CookbookVersion.new("blarghle", @cookbook_root)
262
+ @cookbook_version.attribute_filenames = @cookbook[:attribute_filenames]
263
+ @cookbook_version.definition_filenames = @cookbook[:definition_filenames]
264
+ @cookbook_version.recipe_filenames = @cookbook[:recipe_filenames]
265
+ @cookbook_version.template_filenames = @cookbook[:template_filenames]
266
+ @cookbook_version.file_filenames = @cookbook[:file_filenames]
267
+ @cookbook_version.library_filenames = @cookbook[:library_filenames]
268
+ @cookbook_version.resource_filenames = @cookbook[:resource_filenames]
269
+ @cookbook_version.provider_filenames = @cookbook[:provider_filenames]
270
+ @cookbook_version.root_filenames = @cookbook[:root_filenames]
271
+ @cookbook_version.metadata_filenames = @cookbook[:metadata_filenames]
244
272
  end
245
273
 
246
- it "lists suggested places to look" do
247
- useful_explanation = Regexp.new(Regexp.escape("files/default/no-such-thing.txt"))
248
- @attempt_to_load_file.should raise_error(Chef::Exceptions::FileNotFound, useful_explanation)
274
+ it "generates a manifest containing the cookbook's files" do
275
+ manifest = @cookbook_version.manifest
276
+
277
+ manifest["metadata"].should == Chef::Cookbook::Metadata.new
278
+ manifest["cookbook_name"].should == "blarghle"
279
+
280
+ manifest["recipes"].should have(1).recipe_file
281
+
282
+ recipe = manifest["recipes"].first
283
+ recipe["name"].should == "default.rb"
284
+ recipe["path"].should == "recipes/default.rb"
285
+ recipe["checksum"].should match(MD5)
286
+ recipe["specificity"].should == "default"
287
+
288
+ manifest["definitions"].should have(1).definition_file
289
+
290
+ definition = manifest["definitions"].first
291
+ definition["name"].should == "runit_service.rb"
292
+ definition["path"].should == "definitions/runit_service.rb"
293
+ definition["checksum"].should match(MD5)
294
+ definition["specificity"].should == "default"
295
+
296
+ manifest["libraries"].should have(1).library_file
297
+
298
+ library = manifest["libraries"].first
299
+ library["name"].should == "ownage.rb"
300
+ library["path"].should == "libraries/ownage.rb"
301
+ library["checksum"].should match(MD5)
302
+ library["specificity"].should == "default"
303
+
304
+ manifest["attributes"].should have(1).attribute_file
305
+
306
+ attribute_file = manifest["attributes"].first
307
+ attribute_file["name"].should == "default.rb"
308
+ attribute_file["path"].should == "attributes/default.rb"
309
+ attribute_file["checksum"].should match(MD5)
310
+ attribute_file["specificity"].should == "default"
311
+
312
+ manifest["files"].should have(1).cookbook_file
313
+
314
+ cookbook_file = manifest["files"].first
315
+ cookbook_file["name"].should == "giant_blob.tgz"
316
+ cookbook_file["path"].should == "files/default/giant_blob.tgz"
317
+ cookbook_file["checksum"].should match(MD5)
318
+ cookbook_file["specificity"].should == "default"
319
+
320
+ manifest["templates"].should have(1).template
321
+
322
+ template = manifest["templates"].first
323
+ template["name"].should == "configuration.erb"
324
+ template["path"].should == "templates/default/configuration.erb"
325
+ template["checksum"].should match(MD5)
326
+ template["specificity"].should == "default"
327
+
328
+ manifest["resources"].should have(1).lwr
329
+
330
+ lwr = manifest["resources"].first
331
+ lwr["name"].should == "lwr.rb"
332
+ lwr["path"].should == "resources/lwr.rb"
333
+ lwr["checksum"].should match(MD5)
334
+ lwr["specificity"].should == "default"
335
+
336
+ manifest["providers"].should have(1).lwp
337
+
338
+ lwp = manifest["providers"].first
339
+ lwp["name"].should == "lwp.rb"
340
+ lwp["path"].should == "providers/lwp.rb"
341
+ lwp["checksum"].should match(MD5)
342
+ lwp["specificity"].should == "default"
343
+
344
+ manifest["root_files"].should have(1).file_in_the_cookbook_root
345
+
346
+ readme = manifest["root_files"].first
347
+ readme["name"].should == "README.rdoc"
348
+ readme["path"].should == "README.rdoc"
349
+ readme["checksum"].should match(MD5)
350
+ readme["specificity"].should == "default"
249
351
  end
250
352
  end
251
353
 
@@ -270,8 +372,8 @@ describe Chef::CookbookVersion do
270
372
  ["1.2", "2.1"]
271
373
  ]
272
374
  examples.each do |smaller, larger|
273
- sm = Chef::CookbookVersion.new("foo")
274
- lg = Chef::CookbookVersion.new("foo")
375
+ sm = Chef::CookbookVersion.new("foo", '/tmp/blah')
376
+ lg = Chef::CookbookVersion.new("foo", '/tmp/blah')
275
377
  sm.version = smaller
276
378
  lg.version = larger
277
379
  sm.should be < lg
@@ -281,8 +383,8 @@ describe Chef::CookbookVersion do
281
383
  end
282
384
 
283
385
  it "should equate versions 1.2 and 1.2.0" do
284
- a = Chef::CookbookVersion.new("foo")
285
- b = Chef::CookbookVersion.new("foo")
386
+ a = Chef::CookbookVersion.new("foo", '/tmp/blah')
387
+ b = Chef::CookbookVersion.new("foo", '/tmp/blah')
286
388
  a.version = "1.2"
287
389
  b.version = "1.2.0"
288
390
  a.should == b
@@ -290,9 +392,9 @@ describe Chef::CookbookVersion do
290
392
 
291
393
 
292
394
  it "should not allow you to sort cookbooks with different names" do
293
- apt = Chef::CookbookVersion.new "apt"
395
+ apt = Chef::CookbookVersion.new "apt", '/tmp/blah'
294
396
  apt.version = "1.0"
295
- god = Chef::CookbookVersion.new "god"
397
+ god = Chef::CookbookVersion.new "god", '/tmp/blah'
296
398
  god.version = "2.0"
297
399
  lambda {apt <=> god}.should raise_error(Chef::Exceptions::CookbookVersionNameMismatch)
298
400
  end
@@ -300,7 +402,7 @@ describe Chef::CookbookVersion do
300
402
 
301
403
  describe "when you set a version" do
302
404
  before do
303
- @cbv = Chef::CookbookVersion.new("version validation")
405
+ @cbv = Chef::CookbookVersion.new("version validation", '/tmp/blah')
304
406
  end
305
407
  it "should accept valid cookbook versions" do
306
408
  good_versions = %w(1.2 1.2.3 1000.80.50000 0.300.25)