diff options
author | Tim Smith <tsmith@chef.io> | 2017-04-05 22:01:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-05 22:01:07 -0700 |
commit | 0537474a7c576011b12149725f65da617b3e1ef0 (patch) | |
tree | e768d289a1e60e46102be75d2ca9c3054faec31b /spec | |
parent | 48f6af11a4326b229b7f46df03281c18e904a4f3 (diff) | |
parent | 90337a44f30925ac8621f04216bd82098443e460 (diff) | |
download | chef-0537474a7c576011b12149725f65da617b3e1ef0.tar.gz |
Merge pull request #6024 from chef/create_in_dk
Chef 13: Remove the knife cookbook create command in favor of Chef-DK
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/knife/cookbook_create_spec.rb | 221 |
1 files changed, 1 insertions, 220 deletions
diff --git a/spec/unit/knife/cookbook_create_spec.rb b/spec/unit/knife/cookbook_create_spec.rb index f860a8bce8..ef86a0cd2b 100644 --- a/spec/unit/knife/cookbook_create_spec.rb +++ b/spec/unit/knife/cookbook_create_spec.rb @@ -34,228 +34,9 @@ describe Chef::Knife::CookbookCreate do # Fixes CHEF-2579 it "should expand the path of the cookbook directory" do - expect(File).to receive(:expand_path).with("~/tmp/monkeypants") - @knife.config = { :cookbook_path => "~/tmp/monkeypants" } - allow(@knife).to receive(:create_cookbook) - allow(@knife).to receive(:create_readme) - allow(@knife).to receive(:create_changelog) - allow(@knife).to receive(:create_metadata) + expect(Chef::Log).to receive(:fatal).with("knife cookbook create has been removed. Please use `chef generate cookbook` from the ChefDK") @knife.run end - it "should create a new cookbook with default values to copyright name, email, readme format and license if those are not supplied" do - @dir = Dir.tmpdir - @knife.config = { :cookbook_path => @dir } - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "YOUR_COMPANY_NAME", "none") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "YOUR_COMPANY_NAME", "YOUR_EMAIL", "none", "md") - @knife.run - end - - it "should create a new cookbook with specified company name in the copyright section if one is specified" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "none") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "YOUR_EMAIL", "none", "md") - @knife.run - end - - it "should create a new cookbook with specified copyright name and email if they are specified" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - :cookbook_email => "test@chef.io", - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "none") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "test@chef.io", "none", "md") - @knife.run - end - - it "should create a new cookbook with specified copyright name and email and license information (true) if they are specified" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - :cookbook_email => "test@chef.io", - :cookbook_license => "apachev2", - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "apachev2") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "test@chef.io", "apachev2", "md") - @knife.run - end - - it "should create a new cookbook with specified copyright name and email and license information (false) if they are specified" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - :cookbook_email => "test@chef.io", - :cookbook_license => false, - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "none") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "test@chef.io", "none", "md") - @knife.run - end - - it "should create a new cookbook with specified copyright name and email and license information ('false' as string) if they are specified" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - :cookbook_email => "test@chef.io", - :cookbook_license => "false", - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "none") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "test@chef.io", "none", "md") - @knife.run - end - - it "should allow specifying a gpl2 license" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - :cookbook_email => "test@chef.io", - :cookbook_license => "gplv2", - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "gplv2") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "test@chef.io", "gplv2", "md") - @knife.run - end - - it "should allow specifying a gplv3 license" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - :cookbook_email => "test@chef.io", - :cookbook_license => "gplv3", - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "gplv3") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "test@chef.io", "gplv3", "md") - @knife.run - end - - it "should allow specifying the mit license" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - :cookbook_email => "test@chef.io", - :cookbook_license => "mit", - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "mit") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "test@chef.io", "mit", "md") - @knife.run - end - - it "should allow specifying the rdoc readme format" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - :cookbook_email => "test@chef.io", - :cookbook_license => "mit", - :readme_format => "rdoc", - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "mit") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "rdoc") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "test@chef.io", "mit", "rdoc") - @knife.run - end - - it "should allow specifying the md readme format" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - :cookbook_email => "test@chef.io", - :cookbook_license => "mit", - :readme_format => "mkd", - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "mit") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "mkd") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "test@chef.io", "mit", "mkd") - @knife.run - end - - it "should allow specifying the txt readme format" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - :cookbook_email => "test@chef.io", - :cookbook_license => "mit", - :readme_format => "txt", - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "mit") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "txt") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "test@chef.io", "mit", "txt") - @knife.run - end - - it "should allow specifying an arbitrary readme format" do - @dir = Dir.tmpdir - @knife.config = { - :cookbook_path => @dir, - :cookbook_copyright => "Chef Software, Inc.", - :cookbook_email => "test@chef.io", - :cookbook_license => "mit", - :readme_format => "foo", - } - @knife.name_args = ["foobar"] - expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "mit") - expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "foo") - expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) - expect(@knife).to receive(:create_metadata).with(@dir, @knife.name_args.first, "Chef Software, Inc.", "test@chef.io", "mit", "foo") - @knife.run - end - - context "when the cookbooks path is set to nil" do - before do - Chef::Config[:cookbook_path] = nil - end - - it "should throw an argument error" do - @dir = Dir.tmpdir - expect { @knife.run }.to raise_error(ArgumentError) - end - end - end end |