chef 10.14.0.beta.3 → 10.14.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/distro/common/html/chef-client.8.html +4 -6
  2. data/distro/common/html/chef-expander.8.html +4 -4
  3. data/distro/common/html/chef-expanderctl.8.html +4 -4
  4. data/distro/common/html/chef-server-webui.8.html +4 -4
  5. data/distro/common/html/chef-server.8.html +4 -4
  6. data/distro/common/html/chef-solo.8.html +4 -4
  7. data/distro/common/html/chef-solr.8.html +4 -4
  8. data/distro/common/html/knife-bootstrap.1.html +4 -4
  9. data/distro/common/html/knife-client.1.html +4 -4
  10. data/distro/common/html/knife-configure.1.html +5 -5
  11. data/distro/common/html/knife-cookbook-site.1.html +7 -7
  12. data/distro/common/html/knife-cookbook.1.html +4 -4
  13. data/distro/common/html/knife-data-bag.1.html +4 -4
  14. data/distro/common/html/knife-environment.1.html +4 -4
  15. data/distro/common/html/knife-exec.1.html +4 -4
  16. data/distro/common/html/knife-index.1.html +4 -4
  17. data/distro/common/html/knife-node.1.html +5 -5
  18. data/distro/common/html/knife-role.1.html +4 -4
  19. data/distro/common/html/knife-search.1.html +4 -4
  20. data/distro/common/html/knife-ssh.1.html +5 -5
  21. data/distro/common/html/knife-status.1.html +4 -4
  22. data/distro/common/html/knife-tag.1.html +4 -4
  23. data/distro/common/html/knife.1.html +5 -5
  24. data/distro/common/html/shef.1.html +4 -4
  25. data/distro/common/man/man1/knife-bootstrap.1 +1 -1
  26. data/distro/common/man/man1/knife-client.1 +1 -1
  27. data/distro/common/man/man1/knife-configure.1 +1 -1
  28. data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
  29. data/distro/common/man/man1/knife-cookbook.1 +1 -1
  30. data/distro/common/man/man1/knife-data-bag.1 +1 -1
  31. data/distro/common/man/man1/knife-environment.1 +1 -1
  32. data/distro/common/man/man1/knife-exec.1 +1 -1
  33. data/distro/common/man/man1/knife-index.1 +1 -1
  34. data/distro/common/man/man1/knife-node.1 +1 -1
  35. data/distro/common/man/man1/knife-role.1 +1 -1
  36. data/distro/common/man/man1/knife-search.1 +1 -1
  37. data/distro/common/man/man1/knife-ssh.1 +1 -1
  38. data/distro/common/man/man1/knife-status.1 +1 -1
  39. data/distro/common/man/man1/knife-tag.1 +1 -1
  40. data/distro/common/man/man1/knife.1 +5 -5
  41. data/distro/common/man/man1/shef.1 +1 -1
  42. data/distro/common/man/man8/chef-client.8 +1 -5
  43. data/distro/common/man/man8/chef-expander.8 +1 -1
  44. data/distro/common/man/man8/chef-expanderctl.8 +1 -1
  45. data/distro/common/man/man8/chef-server-webui.8 +1 -1
  46. data/distro/common/man/man8/chef-server.8 +1 -1
  47. data/distro/common/man/man8/chef-solo.8 +1 -1
  48. data/distro/common/man/man8/chef-solr.8 +1 -1
  49. data/distro/common/markdown/man1/knife.mkd +2 -2
  50. data/distro/common/markdown/man8/chef-client.mkd +0 -3
  51. data/lib/chef/client.rb +13 -3
  52. data/lib/chef/config.rb +29 -0
  53. data/lib/chef/environment.rb +5 -2
  54. data/lib/chef/file_access_control/unix.rb +3 -3
  55. data/lib/chef/knife.rb +11 -5
  56. data/lib/chef/knife/bootstrap.rb +9 -5
  57. data/lib/chef/knife/bootstrap/archlinux-gems.erb +1 -1
  58. data/lib/chef/knife/bootstrap/centos5-gems.erb +1 -1
  59. data/lib/chef/knife/bootstrap/chef-full.erb +1 -1
  60. data/lib/chef/knife/bootstrap/fedora13-gems.erb +1 -1
  61. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +1 -1
  62. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +1 -1
  63. data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +1 -1
  64. data/lib/chef/knife/cookbook_create.rb +24 -1
  65. data/lib/chef/knife/ssh.rb +14 -2
  66. data/lib/chef/platform.rb +22 -2
  67. data/lib/chef/provider/file.rb +9 -3
  68. data/lib/chef/provider/group/usermod.rb +7 -4
  69. data/lib/chef/provider/mdadm.rb +3 -3
  70. data/lib/chef/provider/package/ips.rb +101 -0
  71. data/lib/chef/provider/package/solaris.rb +21 -12
  72. data/lib/chef/provider/service/solaris.rb +0 -3
  73. data/lib/chef/provider/user/dscl.rb +1 -1
  74. data/lib/chef/providers.rb +1 -0
  75. data/lib/chef/resource/ips_package.rb +42 -0
  76. data/lib/chef/resource/package.rb +6 -7
  77. data/lib/chef/resources.rb +1 -0
  78. data/lib/chef/rest/auth_credentials.rb +4 -3
  79. data/lib/chef/scan_access_control.rb +3 -9
  80. data/lib/chef/shef/ext.rb +22 -0
  81. data/lib/chef/version.rb +1 -1
  82. data/spec/functional/knife/cookbook_delete_spec.rb +5 -2
  83. data/spec/functional/knife/exec_spec.rb +5 -2
  84. data/spec/functional/knife/ssh_spec.rb +4 -2
  85. data/spec/functional/resource/link_spec.rb +4 -4
  86. data/spec/functional/resource/remote_file_spec.rb +17 -1
  87. data/spec/support/platform_helpers.rb +8 -0
  88. data/spec/support/shared/functional/securable_resource.rb +2 -2
  89. data/spec/tiny_server.rb +5 -1
  90. data/spec/unit/client_spec.rb +24 -0
  91. data/spec/unit/environment_spec.rb +26 -0
  92. data/spec/unit/knife/bootstrap_spec.rb +34 -11
  93. data/spec/unit/knife/config_file_selection_spec.rb +2 -2
  94. data/spec/unit/knife/configure_spec.rb +6 -0
  95. data/spec/unit/knife/cookbook_create_spec.rb +20 -0
  96. data/spec/unit/knife/ssh_spec.rb +145 -0
  97. data/spec/unit/mixin/command_spec.rb +8 -4
  98. data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +2 -1
  99. data/spec/unit/mixin/securable_spec.rb +2 -2
  100. data/spec/unit/provider/file_spec.rb +6 -4
  101. data/spec/unit/provider/group/usermod_spec.rb +6 -1
  102. data/spec/unit/provider/link_spec.rb +4 -1
  103. data/spec/unit/provider/mdadm_spec.rb +10 -13
  104. data/spec/unit/provider/package/ips_spec.rb +210 -0
  105. data/spec/unit/provider/package/solaris_spec.rb +6 -4
  106. data/spec/unit/provider/subversion_spec.rb +2 -2
  107. data/spec/unit/provider/user/dscl_spec.rb +15 -0
  108. data/spec/unit/resource/ips_package_spec.rb +43 -0
  109. data/spec/unit/rest/auth_credentials_spec.rb +36 -14
  110. data/spec/unit/scan_access_control_spec.rb +20 -0
  111. metadata +13 -8
@@ -21,6 +21,8 @@ require 'tiny_server'
21
21
 
22
22
  describe Chef::Knife::Exec do
23
23
  before(:all) do
24
+ @original_config = Chef::Config.hash_dup
25
+
24
26
  Thin::Logging.silent = false
25
27
 
26
28
  @server = TinyServer::Manager.new#(:debug => true)
@@ -32,14 +34,15 @@ describe Chef::Knife::Exec do
32
34
  @api = TinyServer::API.instance
33
35
  @api.clear
34
36
 
35
- Chef::Config[:node_name] = false
36
- Chef::Config[:client_key] = false
37
+ Chef::Config[:node_name] = nil
38
+ Chef::Config[:client_key] = nil
37
39
  Chef::Config[:chef_server_url] = 'http://localhost:9000'
38
40
 
39
41
  $output = StringIO.new
40
42
  end
41
43
 
42
44
  after(:all) do
45
+ Chef::Config.configuration = @original_config
43
46
  @server.stop
44
47
  end
45
48
 
@@ -22,6 +22,7 @@ require 'tiny_server'
22
22
  describe Chef::Knife::Ssh do
23
23
 
24
24
  before(:all) do
25
+ @original_config = Chef::Config.hash_dup
25
26
  Chef::Knife::Ssh.load_deps
26
27
  Thin::Logging.silent = true
27
28
  @server = TinyServer::Manager.new
@@ -29,6 +30,7 @@ describe Chef::Knife::Ssh do
29
30
  end
30
31
 
31
32
  after(:all) do
33
+ Chef::Config.configuration = @original_config
32
34
  @server.stop
33
35
  end
34
36
 
@@ -197,8 +199,8 @@ describe Chef::Knife::Ssh do
197
199
  @api = TinyServer::API.instance
198
200
  @api.clear
199
201
 
200
- Chef::Config[:node_name] = false
201
- Chef::Config[:client_key] = false
202
+ Chef::Config[:node_name] = nil
203
+ Chef::Config[:client_key] = nil
202
204
  Chef::Config[:chef_server_url] = 'http://localhost:9000'
203
205
 
204
206
  @api.get("/search/node?q=*:*&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=1000", 200) {
@@ -318,7 +318,7 @@ describe Chef::Resource::Link do
318
318
  it 'create errors out' do
319
319
  if windows?
320
320
  lambda { resource.run_action(:create) }.should raise_error(Errno::EACCES)
321
- elsif os_x?
321
+ elsif os_x? or solaris? or freebsd?
322
322
  lambda { resource.run_action(:create) }.should raise_error(Errno::EPERM)
323
323
  else
324
324
  lambda { resource.run_action(:create) }.should raise_error(Errno::EISDIR)
@@ -473,7 +473,7 @@ describe Chef::Resource::Link do
473
473
  it 'errors out' do
474
474
  if windows?
475
475
  lambda { resource.run_action(:create) }.should raise_error(Errno::EACCES)
476
- elsif os_x?
476
+ elsif os_x? or solaris? or freebsd?
477
477
  lambda { resource.run_action(:create) }.should raise_error(Errno::EPERM)
478
478
  else
479
479
  lambda { resource.run_action(:create) }.should raise_error(Errno::EISDIR)
@@ -525,7 +525,7 @@ describe Chef::Resource::Link do
525
525
  resource.run_action(:create)
526
526
  File.exists?(target_file).should be_true
527
527
  # OS X gets angry about this sort of link. Bug in OS X, IMO.
528
- pending('OS X symlink? and readlink working on hard links to symlinks', :if => os_x?) do
528
+ pending('OS X/FreeBSD symlink? and readlink working on hard links to symlinks', :if => (os_x? or freebsd?)) do
529
529
  symlink?(target_file).should be_true
530
530
  readlink(target_file).should == @other_target
531
531
  end
@@ -542,7 +542,7 @@ describe Chef::Resource::Link do
542
542
  end
543
543
  context 'and the link does not yet exist' do
544
544
  it 'links to the target file' do
545
- pending('OS X fails to create hardlinks to broken symlinks', :if => os_x?) do
545
+ pending('OS X/FreeBSD fails to create hardlinks to broken symlinks', :if => (os_x? or freebsd?)) do
546
546
  resource.run_action(:create)
547
547
  # Windows and Unix have different definitions of exists? here, and that's OK.
548
548
  if windows?
@@ -17,12 +17,13 @@
17
17
  #
18
18
 
19
19
  require 'spec_helper'
20
+ require 'tiny_server'
20
21
 
21
22
  describe Chef::Resource::RemoteFile do
22
23
  include_context Chef::Resource::File
23
24
 
24
25
  let(:file_base) { "remote_file_spec" }
25
- let(:source) { 'http://opscode-chef-spec-data.s3.amazonaws.com/integration/remote_file/nyan_cat.png' }
26
+ let(:source) { 'http://localhost:9000/nyan_cat.png' }
26
27
  let(:expected_content) { IO.read(File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png')) }
27
28
 
28
29
  def create_resource
@@ -38,5 +39,20 @@ describe Chef::Resource::RemoteFile do
38
39
  create_resource
39
40
  end
40
41
 
42
+ before(:all) do
43
+ Thin::Logging.silent = false
44
+ @server = TinyServer::Manager.new
45
+ @server.start
46
+ @api = TinyServer::API.instance
47
+ @api.clear
48
+ @api.get("/nyan_cat.png", 200) {
49
+ IO.read(File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png'))
50
+ }
51
+ end
52
+
53
+ after(:all) do
54
+ @server.stop
55
+ end
56
+
41
57
  it_behaves_like "a file resource"
42
58
  end
@@ -20,4 +20,12 @@ def os_x?
20
20
  !!(RUBY_PLATFORM =~ /darwin/)
21
21
  end
22
22
 
23
+ def solaris?
24
+ !!(RUBY_PLATFORM =~ /solaris/)
25
+ end
26
+
27
+ def freebsd?
28
+ !!(RUBY_PLATFORM =~ /freebsd/)
29
+ end
30
+
23
31
  DEV_NULL = windows? ? 'NUL' : '/dev/null'
@@ -87,7 +87,7 @@ shared_examples_for "a securable resource" do
87
87
  mode_string = '776'
88
88
  resource.mode mode_string
89
89
  resource.run_action(:create)
90
- pending('Linux does not support lchmod', :if => resource.instance_of?(Chef::Resource::Link) && !os_x?) do
90
+ pending('Linux does not support lchmod', :if => resource.instance_of?(Chef::Resource::Link) && !os_x? && !freebsd?) do
91
91
  (File.lstat(path).mode & 007777).should == (mode_string.oct & 007777)
92
92
  end
93
93
  end
@@ -96,7 +96,7 @@ shared_examples_for "a securable resource" do
96
96
  mode_integer = 0776
97
97
  resource.mode mode_integer
98
98
  resource.run_action(:create)
99
- pending('Linux does not support lchmod', :if => resource.instance_of?(Chef::Resource::Link) && !os_x?) do
99
+ pending('Linux does not support lchmod', :if => resource.instance_of?(Chef::Resource::Link) && !os_x? && !freebsd?) do
100
100
  (File.lstat(path).mode & 007777).should == (mode_integer & 007777)
101
101
  end
102
102
  end
@@ -62,7 +62,7 @@ module TinyServer
62
62
  end
63
63
 
64
64
  def block_until_started
65
- 20.times do
65
+ 200.times do
66
66
  return true if started?
67
67
  end
68
68
  raise "TinyServer failed to boot :/"
@@ -74,6 +74,10 @@ module TinyServer
74
74
  rescue OpenURI::HTTPError
75
75
  true
76
76
  rescue Errno::ECONNREFUSED => e
77
+ sleep 0.1
78
+ # If the host has ":::1 localhost" in its hosts file and if IPv6
79
+ # is not enabled we can get NetworkUnreachable exception...
80
+ rescue Errno::ENETUNREACH => e
77
81
  sleep 0.1
78
82
  false
79
83
  end
@@ -51,6 +51,30 @@ shared_examples_for Chef::Client do
51
51
  @client.node = @node
52
52
  end
53
53
 
54
+ describe "authentication protocol selection" do
55
+ after do
56
+ Chef::Config[:authentication_protocol_version] = "1.0"
57
+ end
58
+
59
+ context "when the node name is <= 90 bytes" do
60
+ it "does not force the authentication protocol to 1.1" do
61
+ Chef::Config[:node_name] = ("f" * 90)
62
+ # ugly that this happens as a side effect of a getter :(
63
+ @client.node_name
64
+ Chef::Config[:authentication_protocol_version].should == "1.0"
65
+ end
66
+ end
67
+
68
+ context "when the node name is > 90 bytes" do
69
+ it "sets the authentication protocol to version 1.1" do
70
+ Chef::Config[:node_name] = ("f" * 91)
71
+ # ugly that this happens as a side effect of a getter :(
72
+ @client.node_name
73
+ Chef::Config[:authentication_protocol_version].should == "1.1"
74
+ end
75
+ end
76
+ end
77
+
54
78
  describe "run" do
55
79
 
56
80
  it "should identify the node and run ohai, then register the client" do
@@ -463,4 +463,30 @@ describe Chef::Environment do
463
463
 
464
464
  end
465
465
 
466
+ describe "api model" do
467
+ before(:each) do
468
+ @rest = mock("Chef::REST")
469
+ Chef::REST.stub!(:new).and_return(@rest)
470
+ @query = mock("Chef::Search::Query")
471
+ Chef::Search::Query.stub!(:new).and_return(@query)
472
+ end
473
+
474
+ describe "list" do
475
+ describe "inflated" do
476
+ it "should return a hash of environment names and objects" do
477
+ e1 = mock("Chef::Environment", :name => "one")
478
+ @query.should_receive(:search).with(:environment).and_yield(e1)
479
+ r = Chef::Environment.list(true)
480
+ r["one"].should == e1
481
+ end
482
+ end
483
+
484
+ it "should return a hash of environment names and urls" do
485
+ @rest.should_receive(:get_rest).and_return({ "one" => "http://foo" })
486
+ r = Chef::Environment.list
487
+ r["one"].should == "http://foo"
488
+ end
489
+ end
490
+ end
491
+
466
492
  end
@@ -32,19 +32,31 @@ describe Chef::Knife::Bootstrap do
32
32
  @knife.ui.stub!(:stderr).and_return(@stderr)
33
33
  end
34
34
 
35
- it "should load the default bootstrap template" do
36
- @knife.load_template.should be_a_kind_of(String)
35
+ it "should return a name of default bootstrap template" do
36
+ @knife.find_template.should be_a_kind_of(String)
37
37
  end
38
38
 
39
39
  it "should error if template can not be found" do
40
40
  @knife.config[:template_file] = false
41
41
  @knife.config[:distro] = 'penultimate'
42
- lambda { @knife.load_template }.should raise_error
42
+ lambda { @knife.find_template }.should raise_error
43
+ end
44
+
45
+ it "should look for templates early in the run" do
46
+ File.stub(:exists?).and_return(true)
47
+ @knife.name_args = ['shatner']
48
+ @knife.stub!(:read_template).and_return("")
49
+ @knife.stub!(:knife_ssh).and_return(true)
50
+ @knife_ssh = @knife.knife_ssh
51
+ @knife.should_receive(:find_template).ordered
52
+ @knife.should_receive(:knife_ssh).ordered
53
+ @knife_ssh.should_receive(:run) # rspec appears to keep order per object
54
+ @knife.run
43
55
  end
44
56
 
45
57
  it "should load the specified template" do
46
58
  @knife.config[:distro] = 'fedora13-gems'
47
- lambda { @knife.load_template }.should_not raise_error
59
+ lambda { @knife.find_template }.should_not raise_error
48
60
  end
49
61
 
50
62
  it "should load the specified template from a Ruby gem" do
@@ -53,28 +65,32 @@ describe Chef::Knife::Bootstrap do
53
65
  File.stub(:exists?).and_return(true)
54
66
  IO.stub(:read).and_return('random content')
55
67
  @knife.config[:distro] = 'fake-bootstrap-template'
56
- lambda { @knife.load_template }.should_not raise_error
68
+ lambda { @knife.find_template }.should_not raise_error
57
69
  end
58
70
 
59
71
  it "should return an empty run_list" do
60
- template_string = @knife.load_template(@knife.config[:template_file])
72
+ @knife.instance_variable_set("@template_file", @knife.config[:template_file])
73
+ template_string = @knife.read_template
61
74
  @knife.render_template(template_string).should == '{"run_list":[]}'
62
75
  end
63
76
 
64
77
  it "should have role[base] in the run_list" do
65
- template_string = @knife.load_template(@knife.config[:template_file])
78
+ @knife.instance_variable_set("@template_file", @knife.config[:template_file])
79
+ template_string = @knife.read_template
66
80
  @knife.parse_options(["-r","role[base]"])
67
81
  @knife.render_template(template_string).should == '{"run_list":["role[base]"]}'
68
82
  end
69
83
 
70
84
  it "should have role[base] and recipe[cupcakes] in the run_list" do
71
- template_string = @knife.load_template(@knife.config[:template_file])
85
+ @knife.instance_variable_set("@template_file", @knife.config[:template_file])
86
+ template_string = @knife.read_template
72
87
  @knife.parse_options(["-r", "role[base],recipe[cupcakes]"])
73
88
  @knife.render_template(template_string).should == '{"run_list":["role[base]","recipe[cupcakes]"]}'
74
89
  end
75
90
 
76
91
  it "should have foo => {bar => baz} in the first_boot" do
77
- template_string = @knife.load_template(@knife.config[:template_file])
92
+ @knife.instance_variable_set("@template_file", @knife.config[:template_file])
93
+ template_string = @knife.read_template
78
94
  @knife.parse_options(["-j", '{"foo":{"bar":"baz"}}'])
79
95
  expected_hash = Yajl::Parser.new.parse('{"foo":{"bar":"baz"},"run_list":[]}')
80
96
  actual_hash = Yajl::Parser.new.parse(@knife.render_template(template_string))
@@ -83,15 +99,19 @@ describe Chef::Knife::Bootstrap do
83
99
 
84
100
  it "should create a hint file when told to" do
85
101
  @knife.config[:template_file] = File.expand_path(File.join(CHEF_SPEC_DATA, "bootstrap", "test-hints.erb"))
86
- template_string = @knife.load_template()
102
+ @knife.instance_variable_set("@template_file", @knife.config[:template_file])
103
+ template_string = @knife.read_template
87
104
  @knife.parse_options(["--hint", "openstack"])
88
105
  @knife.render_template(template_string).should match /\/etc\/chef\/ohai\/hints\/openstack.json/
89
106
  end
90
107
 
91
108
  it "should populate a hint file with JSON when given a file to read" do
109
+ @knife.stub(:find_template).and_return(true)
92
110
  @knife.config[:template_file] = File.expand_path(File.join(CHEF_SPEC_DATA, "bootstrap", "test-hints.erb"))
93
111
  ::File.stub!(:read).and_return('{ "foo" : "bar" }')
94
- template_string = @knife.load_template()
112
+ @knife.instance_variable_set("@template_file", @knife.config[:template_file])
113
+ template_string = @knife.read_template
114
+ @knife.stub!(:read_template).and_return('{ "foo" : "bar" }')
95
115
  @knife.parse_options(["--hint", "openstack=hints/openstack.json"])
96
116
  @knife.render_template(template_string).should match /\{\"foo\":\"bar\"\}/
97
117
  end
@@ -109,6 +129,7 @@ describe Chef::Knife::Bootstrap do
109
129
  @knife.config[:ssh_password] = "open_sesame"
110
130
  Chef::Config[:knife][:ssh_port] = "4001"
111
131
  @knife.config[:identity_file] = "~/.ssh/me.rsa"
132
+ @knife.stub!(:read_template).and_return("")
112
133
  @knife_ssh = @knife.knife_ssh
113
134
  end
114
135
 
@@ -138,6 +159,7 @@ describe Chef::Knife::Bootstrap do
138
159
  @knife.name_args = ["foo.example.com"]
139
160
  @knife.config[:ssh_user] = "rooty"
140
161
  @knife.config[:identity_file] = "~/.ssh/me.rsa"
162
+ @knife.stub!(:read_template).and_return("")
141
163
  @knife_ssh = @knife.knife_ssh
142
164
  end
143
165
 
@@ -161,6 +183,7 @@ describe Chef::Knife::Bootstrap do
161
183
  @knife.name_args = ["foo.example.com"]
162
184
  @knife.config[:ssh_user] = "rooty"
163
185
  @knife.config[:identity_file] = "~/.ssh/me.rsa"
186
+ @knife.stub!(:read_template).and_return("")
164
187
  @knife_ssh = @knife.knife_ssh
165
188
  @knife.stub!(:knife_ssh).and_return(@knife_ssh)
166
189
  end
@@ -60,7 +60,7 @@ describe Chef::Knife do
60
60
  end
61
61
 
62
62
  it "configure knife from HOME" do
63
- home_config = File.expand_path "#{ENV['HOME']}/.chef/knife.rb"
63
+ home_config = File.expand_path(File.join("#{ENV['HOME']}", "/.chef/knife.rb"))
64
64
  File.stub!(:exist?).and_return do | arg |
65
65
  [ home_config ].include? arg
66
66
  end
@@ -83,7 +83,7 @@ describe Chef::Knife do
83
83
  pwd_config = "#{Dir.pwd}/knife.rb"
84
84
  upward_dir = File.expand_path "#{Dir.pwd}/.chef"
85
85
  upward_config = File.expand_path "#{upward_dir}/knife.rb"
86
- home_config = File.expand_path "#{ENV['HOME']}/.chef/knife.rb"
86
+ home_config = File.expand_path(File.join("#{ENV['HOME']}", "/.chef/knife.rb"))
87
87
  configs = [ env_config, pwd_config, upward_config, home_config ]
88
88
  File.stub!(:exist?).and_return do | arg |
89
89
  configs.include? arg
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Chef::Knife::Configure do
4
4
  before do
5
+ @original_config = Chef::Config.configuration.dup
6
+
5
7
  Chef::Log.logger = Logger.new(StringIO.new)
6
8
 
7
9
  Chef::Config[:node_name] = "webmonkey.example.com"
@@ -25,6 +27,10 @@ describe Chef::Knife::Configure do
25
27
  Ohai::System.stub!(:new).and_return(@ohai)
26
28
  end
27
29
 
30
+ after do
31
+ Chef::Config.configuration.replace(@original_config)
32
+ end
33
+
28
34
  it "asks the user for the URL of the chef server" do
29
35
  @knife.ask_user_for_config
30
36
  @out.string.should match(Regexp.escape('Please enter the chef server URL: [http://foo.example.org:4000]'))
@@ -37,6 +37,7 @@ describe Chef::Knife::CookbookCreate do
37
37
  @knife.config = {:cookbook_path => "~/tmp/monkeypants"}
38
38
  @knife.stub!(:create_cookbook)
39
39
  @knife.stub!(:create_readme)
40
+ @knife.stub!(:create_changelog)
40
41
  @knife.stub!(:create_metadata)
41
42
  @knife.run
42
43
  end
@@ -46,6 +47,7 @@ describe Chef::Knife::CookbookCreate do
46
47
  @knife.config = {:cookbook_path => @dir}
47
48
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "YOUR_COMPANY_NAME", "none")
48
49
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "md")
50
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
49
51
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "YOUR_COMPANY_NAME", "YOUR_EMAIL", "none", "md")
50
52
  @knife.run
51
53
  end
@@ -59,6 +61,7 @@ describe Chef::Knife::CookbookCreate do
59
61
  @knife.name_args=["foobar"]
60
62
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none")
61
63
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "md")
64
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
62
65
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "YOUR_EMAIL", "none", "md")
63
66
  @knife.run
64
67
  end
@@ -73,6 +76,7 @@ describe Chef::Knife::CookbookCreate do
73
76
  @knife.name_args=["foobar"]
74
77
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none")
75
78
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "md")
79
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
76
80
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "nuo@opscode.com", "none", "md")
77
81
  @knife.run
78
82
  end
@@ -88,6 +92,7 @@ describe Chef::Knife::CookbookCreate do
88
92
  @knife.name_args=["foobar"]
89
93
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "apachev2")
90
94
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "md")
95
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
91
96
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "nuo@opscode.com", "apachev2", "md")
92
97
  @knife.run
93
98
  end
@@ -103,6 +108,7 @@ describe Chef::Knife::CookbookCreate do
103
108
  @knife.name_args=["foobar"]
104
109
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none")
105
110
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "md")
111
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
106
112
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "nuo@opscode.com", "none", "md")
107
113
  @knife.run
108
114
  end
@@ -118,6 +124,7 @@ describe Chef::Knife::CookbookCreate do
118
124
  @knife.name_args=["foobar"]
119
125
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none")
120
126
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "md")
127
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
121
128
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "nuo@opscode.com", "none", "md")
122
129
  @knife.run
123
130
  end
@@ -133,6 +140,7 @@ describe Chef::Knife::CookbookCreate do
133
140
  @knife.name_args=["foobar"]
134
141
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "gplv2")
135
142
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "md")
143
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
136
144
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "nuo@opscode.com", "gplv2", "md")
137
145
  @knife.run
138
146
  end
@@ -148,6 +156,7 @@ describe Chef::Knife::CookbookCreate do
148
156
  @knife.name_args=["foobar"]
149
157
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "gplv3")
150
158
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "md")
159
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
151
160
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "nuo@opscode.com", "gplv3", "md")
152
161
  @knife.run
153
162
  end
@@ -163,6 +172,7 @@ describe Chef::Knife::CookbookCreate do
163
172
  @knife.name_args=["foobar"]
164
173
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit")
165
174
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "md")
175
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
166
176
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "nuo@opscode.com", "mit", "md")
167
177
  @knife.run
168
178
  end
@@ -179,6 +189,7 @@ describe Chef::Knife::CookbookCreate do
179
189
  @knife.name_args=["foobar"]
180
190
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit")
181
191
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "rdoc")
192
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
182
193
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "nuo@opscode.com", "mit", "rdoc")
183
194
  @knife.run
184
195
  end
@@ -195,6 +206,7 @@ describe Chef::Knife::CookbookCreate do
195
206
  @knife.name_args=["foobar"]
196
207
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit")
197
208
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "mkd")
209
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
198
210
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "nuo@opscode.com", "mit", "mkd")
199
211
  @knife.run
200
212
  end
@@ -211,6 +223,7 @@ describe Chef::Knife::CookbookCreate do
211
223
  @knife.name_args=["foobar"]
212
224
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit")
213
225
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "txt")
226
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
214
227
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "nuo@opscode.com", "mit", "txt")
215
228
  @knife.run
216
229
  end
@@ -227,10 +240,17 @@ describe Chef::Knife::CookbookCreate do
227
240
  @knife.name_args=["foobar"]
228
241
  @knife.should_receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit")
229
242
  @knife.should_receive(:create_readme).with(@dir, @knife.name_args.first, "foo")
243
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
230
244
  @knife.should_receive(:create_metadata).with(@dir, @knife.name_args.first, "Opscode, Inc", "nuo@opscode.com", "mit", "foo")
231
245
  @knife.run
232
246
  end
233
247
 
248
+ it "should create a CHANGELOG file" do
249
+ @dir = Dir.tmpdir
250
+ @knife.should_receive(:create_changelog).with(@dir, @knife.name_args.first)
251
+ @knife.run
252
+ end
253
+
234
254
  context "when the cookbooks path is not specified in the config file nor supplied via parameter" do
235
255
  before do
236
256
  @old_cookbook_path = Chef::Config[:cookbook_path]