chef 11.18.12 → 12.0.0.alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +10 -0
- data/README.md +1 -1
- data/distro/common/html/_sources/index.txt +5 -2
- data/distro/common/html/_sources/knife_serve.txt +19 -0
- data/distro/common/html/_sources/knife_ssl_check.txt +2 -2
- data/distro/common/html/_sources/knife_ssl_fetch.txt +2 -2
- data/distro/common/html/_static/basic.css +1 -1
- data/distro/common/html/_static/doctools.js +1 -1
- data/distro/common/html/_static/searchtools.js +1 -1
- data/distro/common/html/_static/websupport.js +1 -1
- data/distro/common/html/ctl_chef_client.html +19 -9
- data/distro/common/html/ctl_chef_server.html +7 -1
- data/distro/common/html/ctl_chef_shell.html +3 -4
- data/distro/common/html/ctl_chef_solo.html +12 -7
- data/distro/common/html/index.html +19 -12
- data/distro/common/html/knife.html +1 -2
- data/distro/common/html/knife_bootstrap.html +16 -5
- data/distro/common/html/knife_client.html +8 -5
- data/distro/common/html/knife_common_options.html +11 -12
- data/distro/common/html/knife_configure.html +2 -3
- data/distro/common/html/knife_cookbook.html +16 -17
- data/distro/common/html/knife_cookbook_site.html +19 -18
- data/distro/common/html/knife_data_bag.html +6 -7
- data/distro/common/html/knife_delete.html +2 -3
- data/distro/common/html/knife_deps.html +2 -3
- data/distro/common/html/knife_diff.html +3 -4
- data/distro/common/html/knife_download.html +6 -7
- data/distro/common/html/knife_edit.html +0 -1
- data/distro/common/html/knife_environment.html +3 -4
- data/distro/common/html/knife_exec.html +0 -1
- data/distro/common/html/knife_index_rebuild.html +0 -1
- data/distro/common/html/knife_list.html +5 -6
- data/distro/common/html/knife_node.html +13 -6
- data/distro/common/html/knife_raw.html +0 -1
- data/distro/common/html/knife_recipe_list.html +0 -1
- data/distro/common/html/knife_role.html +1 -2
- data/distro/common/html/knife_search.html +2 -3
- data/distro/common/html/knife_serve.html +79 -0
- data/distro/common/html/knife_show.html +1 -2
- data/distro/common/html/knife_ssh.html +2 -3
- data/distro/common/html/knife_ssl_check.html +12 -9
- data/distro/common/html/knife_ssl_fetch.html +9 -10
- data/distro/common/html/knife_status.html +2 -3
- data/distro/common/html/knife_tag.html +0 -1
- data/distro/common/html/knife_upload.html +3 -4
- data/distro/common/html/knife_user.html +2 -3
- data/distro/common/html/knife_using.html +0 -1
- data/distro/common/html/knife_xargs.html +3 -4
- data/distro/common/html/search.html +0 -1
- data/distro/common/html/searchindex.js +1 -1
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +24 -67
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/chef_fs/chef_fs_data_store.rb +2 -3
- data/lib/chef/chef_fs/command_line.rb +2 -3
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -5
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -2
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -2
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -3
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -5
- data/lib/chef/config.rb +26 -2
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/synchronizer.rb +50 -8
- data/lib/chef/cookbook_uploader.rb +9 -23
- data/lib/chef/cookbook_version.rb +3 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/dsl/recipe.rb +1 -14
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +2 -24
- data/lib/chef/file_content_management/tempfile.rb +8 -1
- data/lib/chef/formatters/base.rb +0 -7
- data/lib/chef/http.rb +12 -19
- data/lib/chef/http/json_input.rb +12 -1
- data/lib/chef/json_compat.rb +45 -64
- data/lib/chef/knife.rb +2 -5
- data/lib/chef/knife/bootstrap.rb +2 -2
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-aix.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-full.erb +2 -2
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -2
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +10 -34
- data/lib/chef/knife/cookbook_site_list.rb +1 -1
- data/lib/chef/knife/cookbook_site_search.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +3 -3
- data/lib/chef/knife/cookbook_site_show.rb +3 -3
- data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
- data/lib/chef/knife/cookbook_upload.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +0 -24
- data/lib/chef/knife/core/ui.rb +8 -7
- data/lib/chef/knife/deps.rb +2 -3
- data/lib/chef/knife/serve.rb +2 -1
- data/lib/chef/local_mode.rb +105 -0
- data/lib/chef/mixin/file_class.rb +1 -4
- data/lib/chef/mixin/shell_out.rb +15 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +0 -16
- data/lib/chef/node.rb +1 -1
- data/lib/chef/platform/query_helpers.rb +1 -5
- data/lib/chef/policy_builder/expand_node_object.rb +3 -0
- data/lib/chef/provider.rb +2 -0
- data/lib/chef/provider/cookbook_file.rb +0 -1
- data/lib/chef/provider/deploy.rb +0 -1
- data/lib/chef/provider/deploy/revision.rb +1 -1
- data/lib/chef/provider/env.rb +10 -25
- data/lib/chef/provider/env/windows.rb +23 -10
- data/lib/chef/provider/execute.rb +0 -3
- data/lib/chef/provider/file.rb +0 -3
- data/lib/chef/provider/git.rb +0 -6
- data/lib/chef/provider/group/dscl.rb +9 -27
- data/lib/chef/provider/group/gpasswd.rb +0 -3
- data/lib/chef/provider/group/groupmod.rb +0 -4
- data/lib/chef/provider/group/suse.rb +0 -3
- data/lib/chef/provider/group/usermod.rb +0 -3
- data/lib/chef/provider/link.rb +22 -5
- data/lib/chef/provider/log.rb +15 -4
- data/lib/chef/provider/mdadm.rb +0 -3
- data/lib/chef/provider/mount/mount.rb +0 -2
- data/lib/chef/provider/mount/solaris.rb +0 -2
- data/lib/chef/provider/package.rb +0 -1
- data/lib/chef/provider/package/apt.rb +0 -3
- data/lib/chef/provider/package/dpkg.rb +0 -1
- data/lib/chef/provider/package/easy_install.rb +0 -4
- data/lib/chef/provider/package/freebsd/base.rb +0 -3
- data/lib/chef/provider/package/freebsd/pkgng.rb +0 -2
- data/lib/chef/provider/package/freebsd/port.rb +0 -2
- data/lib/chef/provider/package/ips.rb +0 -3
- data/lib/chef/provider/package/paludis.rb +0 -5
- data/lib/chef/provider/package/portage.rb +0 -2
- data/lib/chef/provider/package/rpm.rb +2 -4
- data/lib/chef/provider/package/rubygems.rb +0 -4
- data/lib/chef/provider/package/smartos.rb +0 -3
- data/lib/chef/provider/package/windows/msi.rb +0 -2
- data/lib/chef/provider/package/yum.rb +0 -4
- data/lib/chef/provider/package/zypper.rb +0 -3
- data/lib/chef/provider/registry_key.rb +0 -2
- data/lib/chef/provider/remote_directory.rb +0 -1
- data/lib/chef/provider/remote_file.rb +0 -1
- data/lib/chef/provider/remote_file/cache_control_data.rb +1 -3
- data/lib/chef/provider/remote_file/content.rb +0 -1
- data/lib/chef/provider/remote_file/fetcher.rb +0 -2
- data/lib/chef/provider/remote_file/ftp.rb +0 -1
- data/lib/chef/provider/resource_update.rb +0 -3
- data/lib/chef/provider/service/freebsd.rb +0 -3
- data/lib/chef/provider/service/init.rb +0 -3
- data/lib/chef/provider/service/macosx.rb +0 -1
- data/lib/chef/provider/service/redhat.rb +0 -2
- data/lib/chef/provider/service/simple.rb +0 -3
- data/lib/chef/provider/service/solaris.rb +0 -3
- data/lib/chef/provider/service/systemd.rb +15 -14
- data/lib/chef/provider/service/windows.rb +0 -3
- data/lib/chef/provider/subversion.rb +0 -2
- data/lib/chef/provider/template.rb +0 -2
- data/lib/chef/provider/template/content.rb +0 -1
- data/lib/chef/provider/user/dscl.rb +156 -549
- data/lib/chef/provider/user/solaris.rb +0 -1
- data/lib/chef/provider/user/useradd.rb +0 -3
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
- data/lib/chef/providers.rb +0 -1
- data/lib/chef/resource.rb +1 -4
- data/lib/chef/resource/freebsd_package.rb +2 -10
- data/lib/chef/resource/lwrp_base.rb +1 -12
- data/lib/chef/resource/user.rb +0 -18
- data/lib/chef/resource_collection.rb +1 -1
- data/lib/chef/resource_reporter.rb +10 -10
- data/lib/chef/resources.rb +0 -1
- data/lib/chef/role.rb +3 -3
- data/lib/chef/run_list.rb +1 -1
- data/lib/chef/tasks/chef_repo.rake +131 -264
- data/lib/chef/user.rb +1 -1
- data/lib/chef/util/path_helper.rb +2 -2
- data/lib/chef/version.rb +9 -1
- data/lib/chef/win32/api/system.rb +0 -9
- data/spec/data/bootstrap/test-hints.erb +1 -1
- data/spec/data/bootstrap/test.erb +1 -1
- data/spec/functional/dsl/reboot_pending_spec.rb +53 -58
- data/spec/functional/knife/cookbook_delete_spec.rb +3 -3
- data/spec/functional/knife/exec_spec.rb +1 -1
- data/spec/functional/mixin/shell_out_spec.rb +48 -0
- data/spec/functional/resource/base.rb +0 -10
- data/spec/functional/resource/group_spec.rb +1 -5
- data/spec/functional/resource/link_spec.rb +8 -0
- data/spec/functional/resource/{user/useradd_spec.rb → user_spec.rb} +1 -1
- data/spec/integration/knife/chef_fs_data_store_spec.rb +3 -3
- data/spec/integration/knife/chef_repo_path_spec.rb +1 -6
- data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -1
- data/spec/integration/knife/chefignore_spec.rb +1 -1
- data/spec/integration/knife/common_options_spec.rb +50 -3
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -1
- data/spec/integration/knife/delete_spec.rb +1 -1
- data/spec/integration/knife/deps_spec.rb +1 -1
- data/spec/integration/knife/diff_spec.rb +3 -3
- data/spec/integration/knife/download_spec.rb +3 -3
- data/spec/integration/knife/list_spec.rb +1 -1
- data/spec/integration/knife/raw_spec.rb +1 -11
- data/spec/integration/knife/redirection_spec.rb +1 -1
- data/spec/integration/knife/serve_spec.rb +2 -2
- data/spec/integration/knife/show_spec.rb +1 -1
- data/spec/integration/knife/upload_spec.rb +9 -9
- data/spec/spec_helper.rb +0 -9
- data/spec/support/pedant/pedant_config.rb +2 -1
- data/spec/support/pedant/run_pedant.rb +2 -1
- data/spec/support/platform_helpers.rb +5 -24
- data/spec/support/shared/integration/integration_helper.rb +2 -1
- data/spec/support/shared/matchers.rb +17 -0
- data/spec/tiny_server.rb +1 -2
- data/spec/unit/api_client_spec.rb +3 -3
- data/spec/unit/application_spec.rb +9 -32
- data/spec/unit/config_fetcher_spec.rb +1 -1
- data/spec/unit/cookbook/metadata_spec.rb +3 -7
- data/spec/unit/cookbook/synchronizer_spec.rb +441 -226
- data/spec/unit/cookbook_loader_spec.rb +1 -1
- data/spec/unit/cookbook_uploader_spec.rb +160 -0
- data/spec/unit/cookbook_version_spec.rb +0 -4
- data/spec/unit/data_bag_item_spec.rb +1 -5
- data/spec/unit/data_bag_spec.rb +1 -5
- data/spec/unit/deprecation_spec.rb +1 -1
- data/spec/unit/dsl/recipe_spec.rb +12 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +7 -14
- data/spec/unit/environment_spec.rb +3 -7
- data/spec/unit/exceptions_spec.rb +0 -6
- data/spec/unit/http/json_input_spec.rb +128 -0
- data/spec/unit/json_compat_spec.rb +17 -58
- data/spec/unit/knife/client_create_spec.rb +3 -3
- data/spec/unit/knife/configure_client_spec.rb +6 -5
- data/spec/unit/knife/cookbook_delete_spec.rb +1 -1
- data/spec/unit/knife/cookbook_download_spec.rb +5 -5
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -0
- data/spec/unit/knife/cookbook_metadata_spec.rb +1 -1
- data/spec/unit/knife/cookbook_site_download_spec.rb +10 -11
- data/spec/unit/knife/cookbook_site_install_spec.rb +116 -161
- data/spec/unit/knife/cookbook_site_share_spec.rb +8 -8
- data/spec/unit/knife/cookbook_upload_spec.rb +3 -2
- data/spec/unit/knife/core/bootstrap_context_spec.rb +3 -3
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -66
- data/spec/unit/knife/data_bag_from_file_spec.rb +2 -1
- data/spec/unit/knife/tag_create_spec.rb +3 -3
- data/spec/unit/knife/tag_delete_spec.rb +3 -3
- data/spec/unit/knife/user_create_spec.rb +1 -1
- data/spec/unit/knife_spec.rb +14 -14
- data/spec/unit/lwrp_spec.rb +1 -21
- data/spec/unit/mixin/shell_out_spec.rb +92 -0
- data/spec/unit/node_spec.rb +0 -4
- data/spec/unit/platform/query_helpers_spec.rb +0 -23
- data/spec/unit/provider/env/windows_spec.rb +34 -70
- data/spec/unit/provider/env_spec.rb +11 -76
- data/spec/unit/provider/group/dscl_spec.rb +1 -38
- data/spec/unit/provider/log_spec.rb +18 -0
- data/spec/unit/provider/package/rpm_spec.rb +0 -12
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +1 -1
- data/spec/unit/provider/service/systemd_service_spec.rb +44 -27
- data/spec/unit/provider/user/dscl_spec.rb +264 -660
- data/spec/unit/provider/user/useradd_spec.rb +0 -1
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +2 -2
- data/spec/unit/provider_spec.rb +12 -0
- data/spec/unit/recipe_spec.rb +0 -41
- data/spec/unit/resource_collection_spec.rb +1 -5
- data/spec/unit/resource_reporter_spec.rb +3 -51
- data/spec/unit/resource_spec.rb +3 -14
- data/spec/unit/rest_spec.rb +1 -4
- data/spec/unit/role_spec.rb +0 -10
- data/spec/unit/run_list_spec.rb +1 -5
- data/spec/unit/user_spec.rb +1 -5
- metadata +20 -100
- data/lib/chef/mixin/windows_env_helper.rb +0 -56
- data/lib/chef/provider/dsc_script.rb +0 -175
- data/lib/chef/resource/dsc_script.rb +0 -126
- data/lib/chef/streaming_cookbook_uploader.rb +0 -205
- data/lib/chef/util/dsc/configuration_generator.rb +0 -115
- data/lib/chef/util/dsc/lcm_output_parser.rb +0 -133
- data/lib/chef/util/dsc/local_configuration_manager.rb +0 -141
- data/lib/chef/util/dsc/resource_info.rb +0 -26
- data/lib/chef/util/powershell/cmdlet.rb +0 -136
- data/lib/chef/util/powershell/cmdlet_result.rb +0 -46
- data/spec/data/mac_users/10.7-8.plist.xml +0 -559
- data/spec/data/mac_users/10.7-8.shadow.xml +0 -11
- data/spec/data/mac_users/10.7.plist.xml +0 -559
- data/spec/data/mac_users/10.7.shadow.xml +0 -11
- data/spec/data/mac_users/10.8.plist.xml +0 -559
- data/spec/data/mac_users/10.8.shadow.xml +0 -21
- data/spec/data/mac_users/10.9.plist.xml +0 -560
- data/spec/data/mac_users/10.9.shadow.xml +0 -21
- data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +0 -51
- data/spec/functional/resource/dsc_script_spec.rb +0 -382
- data/spec/functional/resource/env_spec.rb +0 -182
- data/spec/functional/resource/user/dscl_spec.rb +0 -199
- data/spec/functional/util/powershell/cmdlet_spec.rb +0 -113
- data/spec/support/lib/chef/resource/zen_follower.rb +0 -46
- data/spec/support/shared/shared_examples.rb +0 -10
- data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +0 -63
- data/spec/unit/formatters/base_spec.rb +0 -48
- data/spec/unit/provider/dsc_script_spec.rb +0 -174
- data/spec/unit/resource/dsc_script_spec.rb +0 -98
- data/spec/unit/util/dsc/configuration_generator_spec.rb +0 -171
- data/spec/unit/util/dsc/lcm_output_parser_spec.rb +0 -169
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +0 -139
- data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
@@ -21,90 +21,49 @@ require 'chef/json_compat'
|
|
21
21
|
|
22
22
|
describe Chef::JSONCompat do
|
23
23
|
|
24
|
-
describe "
|
25
|
-
let(:json)
|
26
|
-
|
24
|
+
describe "with JSON containing an existing class" do
|
25
|
+
let(:json){'{"json_class": "Chef::Role"}'}
|
27
26
|
it "returns an instance of the class instead of a Hash" do
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#from_json with JSON containing comments" do
|
33
|
-
let(:json) { %Q{{\n/* comment */\n// comment 2\n"json_class": "Chef::Role"}} }
|
34
|
-
|
35
|
-
it "returns an instance of the class instead of a Hash" do
|
36
|
-
expect(Chef::JSONCompat.from_json(json).class).to eq Chef::Role
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "#parse with JSON containing comments" do
|
41
|
-
let(:json) { %Q{{\n/* comment */\n// comment 2\n"json_class": "Chef::Role"}} }
|
42
|
-
|
43
|
-
it "returns a Hash" do
|
44
|
-
expect(Chef::JSONCompat.parse(json).class).to eq Hash
|
27
|
+
Chef::JSONCompat.from_json(json).class.should eq Chef::Role
|
45
28
|
end
|
46
29
|
end
|
47
30
|
|
48
31
|
describe 'with JSON containing "Chef::Sandbox" as a json_class value' do
|
49
32
|
require 'chef/sandbox' # Only needed for this test
|
50
|
-
|
51
|
-
let(:json) { '{"json_class": "Chef::Sandbox", "arbitrary": "data"}' }
|
52
|
-
|
33
|
+
let(:json){'{"json_class": "Chef::Sandbox", "arbitrary": "data"}'}
|
53
34
|
it "returns a Hash, because Chef::Sandbox is a dummy class" do
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "when pretty printing an object that defines #to_json" do
|
59
|
-
class Foo
|
60
|
-
def to_json(*a)
|
61
|
-
Chef::JSONCompat.to_json({'bar' => {'baz' => 5678}}, *a)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should work" do
|
66
|
-
f = Foo.new
|
67
|
-
expect(Chef::JSONCompat.to_json_pretty(f)).to eql("{\n \"bar\": {\n \"baz\": 5678\n }\n}\n")
|
68
|
-
end
|
69
|
-
|
70
|
-
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
|
71
|
-
let(:subject) { Foo.new }
|
35
|
+
Chef::JSONCompat.from_json(json).should eq({"json_class" => "Chef::Sandbox", "arbitrary" => "data"})
|
72
36
|
end
|
73
37
|
end
|
74
38
|
|
75
39
|
describe "with a file with 300 or less nested entries" do
|
76
|
-
|
77
|
-
|
40
|
+
before(:all) do
|
41
|
+
@json = IO.read(File.join(CHEF_SPEC_DATA, 'big_json.json'))
|
42
|
+
@hash = Chef::JSONCompat.from_json(@json)
|
43
|
+
end
|
78
44
|
|
79
45
|
describe "when a big json file is loaded" do
|
80
46
|
it "should create a Hash from the file" do
|
81
|
-
|
47
|
+
@hash.should be_kind_of(Hash)
|
82
48
|
end
|
83
|
-
|
84
49
|
it "should has 'test' as a 300th nested value" do
|
85
|
-
|
50
|
+
@hash['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key'].should == 'test'
|
86
51
|
end
|
87
52
|
end
|
88
53
|
end
|
89
|
-
|
90
54
|
describe "with a file with more than 300 nested entries" do
|
91
|
-
|
92
|
-
|
55
|
+
before(:all) do
|
56
|
+
@json = IO.read(File.join(CHEF_SPEC_DATA, 'big_json_plus_one.json'))
|
57
|
+
@hash = Chef::JSONCompat.from_json(@json, {:max_nesting => 301})
|
58
|
+
end
|
93
59
|
|
94
60
|
describe "when a big json file is loaded" do
|
95
61
|
it "should create a Hash from the file" do
|
96
|
-
|
62
|
+
@hash.should be_kind_of(Hash)
|
97
63
|
end
|
98
|
-
|
99
64
|
it "should has 'test' as a 301st nested value" do
|
100
|
-
|
65
|
+
@hash['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key'].should == 'test'
|
101
66
|
end
|
102
67
|
end
|
103
68
|
end
|
104
|
-
|
105
|
-
it "should define .to_json on all classes" do
|
106
|
-
class SomeClass; end
|
107
|
-
|
108
|
-
expect(SomeClass.new.respond_to?(:to_json)).to eq(true)
|
109
|
-
end
|
110
69
|
end
|
@@ -35,15 +35,15 @@ describe Chef::Knife::ClientCreate do
|
|
35
35
|
@knife.stub(:edit_data).and_return(@client)
|
36
36
|
@knife.stub(:puts)
|
37
37
|
Chef::ApiClient.stub(:new).and_return(@client)
|
38
|
-
@
|
39
|
-
@knife.ui.stub(:
|
38
|
+
@stderr = StringIO.new
|
39
|
+
@knife.ui.stub(:stderr).and_return(@stderr)
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "run" do
|
43
43
|
it "should create a new Client" do
|
44
44
|
Chef::ApiClient.should_receive(:new).and_return(@client)
|
45
45
|
@knife.run
|
46
|
-
@
|
46
|
+
@stderr.string.should match /created client.+adam/i
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should set the Client name" do
|
@@ -25,8 +25,8 @@ describe Chef::Knife::ConfigureClient do
|
|
25
25
|
Chef::Config[:validation_client_name] = 'chef-validator'
|
26
26
|
Chef::Config[:validation_key] = '/etc/chef/validation.pem'
|
27
27
|
|
28
|
-
@
|
29
|
-
@knife.ui.stub(:
|
28
|
+
@stderr = StringIO.new
|
29
|
+
@knife.ui.stub(:stderr).and_return(@stderr)
|
30
30
|
end
|
31
31
|
|
32
32
|
describe 'run' do
|
@@ -73,11 +73,12 @@ describe Chef::Knife::ConfigureClient do
|
|
73
73
|
it 'should print information on what is being configured' do
|
74
74
|
FileUtils.stub(:mkdir_p)
|
75
75
|
@knife.run
|
76
|
-
@
|
77
|
-
@
|
78
|
-
@
|
76
|
+
@stderr.string.should match /creating client configuration/i
|
77
|
+
@stderr.string.should match /writing client\.rb/i
|
78
|
+
@stderr.string.should match /writing validation\.pem/i
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
end
|
84
|
+
|
@@ -204,7 +204,7 @@ describe Chef::Knife::CookbookDelete do
|
|
204
204
|
it 'should output that the cookbook was deleted' do
|
205
205
|
@knife.stub(:delete_request)
|
206
206
|
@knife.delete_version_without_confirmation('1.0.0')
|
207
|
-
@
|
207
|
+
@stderr.string.should match /deleted cookbook\[foobar\]\[1.0.0\]/im
|
208
208
|
end
|
209
209
|
|
210
210
|
describe 'with --print-after' do
|
@@ -21,8 +21,8 @@ require 'spec_helper'
|
|
21
21
|
describe Chef::Knife::CookbookDownload do
|
22
22
|
before(:each) do
|
23
23
|
@knife = Chef::Knife::CookbookDownload.new
|
24
|
-
@
|
25
|
-
@knife.ui.stub(:
|
24
|
+
@stderr = StringIO.new
|
25
|
+
@knife.ui.stub(:stderr).and_return(@stderr)
|
26
26
|
end
|
27
27
|
|
28
28
|
describe 'run' do
|
@@ -121,10 +121,10 @@ describe Chef::Knife::CookbookDownload do
|
|
121
121
|
File.should_receive(:exists?).with('/var/tmp/chef/foobar-1.0.0').and_return(false)
|
122
122
|
@knife.run
|
123
123
|
['attributes', 'recipes', 'templates'].each do |segment|
|
124
|
-
@
|
124
|
+
@stderr.string.should match /downloading #{segment}/im
|
125
125
|
end
|
126
|
-
@
|
127
|
-
@
|
126
|
+
@stderr.string.should match /downloading foobar cookbook version 1\.0\.0/im
|
127
|
+
@stderr.string.should match /cookbook downloaded to \/var\/tmp\/chef\/foobar-1\.0\.0/im
|
128
128
|
end
|
129
129
|
|
130
130
|
describe 'with -f or --force' do
|
@@ -27,6 +27,7 @@ describe Chef::Knife::CookbookMetadataFromFile do
|
|
27
27
|
@tgt = File.expand_path(File.join(CHEF_SPEC_DATA, "metadata", "quick_start", "metadata.json"))
|
28
28
|
@knife = Chef::Knife::CookbookMetadataFromFile.new
|
29
29
|
@knife.name_args = [ @src ]
|
30
|
+
@knife.stub(:to_json_pretty).and_return(true)
|
30
31
|
@md = Chef::Cookbook::Metadata.new
|
31
32
|
Chef::Cookbook::Metadata.stub(:new).and_return(@md)
|
32
33
|
$stdout.stub(:write)
|
@@ -119,7 +119,7 @@ describe Chef::Knife::CookbookMetadata do
|
|
119
119
|
Chef::JSONCompat.should_receive(:to_json_pretty).with(@metadata_mock).
|
120
120
|
and_return(@json_data)
|
121
121
|
@knife.generate_metadata_from_file('foobar', "#{@cookbook_dir}/foobar/metadata.rb")
|
122
|
-
@
|
122
|
+
@stderr.string.should match /generating metadata for foobar from #{@cookbook_dir}\/foobar\/metadata\.rb/im
|
123
123
|
end
|
124
124
|
|
125
125
|
{ Chef::Exceptions::ObsoleteDependencySyntax => 'obsolote dependency',
|
@@ -25,16 +25,15 @@ describe Chef::Knife::CookbookSiteDownload do
|
|
25
25
|
@knife = Chef::Knife::CookbookSiteDownload.new
|
26
26
|
@knife.name_args = ['apache2']
|
27
27
|
@noauth_rest = double('no auth rest')
|
28
|
-
@stdout = StringIO.new
|
29
28
|
@stderr = StringIO.new
|
30
|
-
@cookbook_api_url = '
|
29
|
+
@cookbook_api_url = 'http://cookbooks.opscode.com/api/v1/cookbooks'
|
31
30
|
@version = '1.0.2'
|
32
31
|
@version_us = @version.gsub '.', '_'
|
33
32
|
@current_data = { 'deprecated' => false,
|
34
33
|
'latest_version' => "#{@cookbook_api_url}/apache2/versions/#{@version_us}",
|
35
34
|
'replacement' => 'other_apache2' }
|
36
35
|
|
37
|
-
@knife.ui.stub(:
|
36
|
+
@knife.ui.stub(:stderr).and_return(@stderr)
|
38
37
|
@knife.stub(:noauth_rest).and_return(@noauth_rest)
|
39
38
|
@noauth_rest.should_receive(:get_rest).
|
40
39
|
with("#{@cookbook_api_url}/apache2").
|
@@ -86,8 +85,8 @@ describe Chef::Knife::CookbookSiteDownload do
|
|
86
85
|
with(/.+deprecated.+replaced by other_apache2.+/i)
|
87
86
|
FileUtils.should_receive(:cp).with(@temp_file.path, @file)
|
88
87
|
@knife.run
|
89
|
-
@
|
90
|
-
@
|
88
|
+
@stderr.string.should match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
|
89
|
+
@stderr.string.should match /cookbook save.+#{Regexp.escape(@file)}/i
|
91
90
|
end
|
92
91
|
|
93
92
|
end
|
@@ -95,8 +94,8 @@ describe Chef::Knife::CookbookSiteDownload do
|
|
95
94
|
it 'should download the latest version' do
|
96
95
|
FileUtils.should_receive(:cp).with(@temp_file.path, @file)
|
97
96
|
@knife.run
|
98
|
-
@
|
99
|
-
@
|
97
|
+
@stderr.string.should match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
|
98
|
+
@stderr.string.should match /cookbook save.+#{Regexp.escape(@file)}/i
|
100
99
|
end
|
101
100
|
|
102
101
|
context 'with -f or --file' do
|
@@ -108,8 +107,8 @@ describe Chef::Knife::CookbookSiteDownload do
|
|
108
107
|
|
109
108
|
it 'should download the cookbook to the desired file' do
|
110
109
|
@knife.run
|
111
|
-
@
|
112
|
-
@
|
110
|
+
@stderr.string.should match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
|
111
|
+
@stderr.string.should match /cookbook save.+#{Regexp.escape(@file)}/i
|
113
112
|
end
|
114
113
|
end
|
115
114
|
|
@@ -140,8 +139,8 @@ describe Chef::Knife::CookbookSiteDownload do
|
|
140
139
|
and_return(@temp_file)
|
141
140
|
FileUtils.should_receive(:cp).with(@temp_file.path, @file)
|
142
141
|
@knife.run
|
143
|
-
@
|
144
|
-
@
|
142
|
+
@stderr.string.should match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
|
143
|
+
@stderr.string.should match /cookbook save.+#{Regexp.escape(@file)}/i
|
145
144
|
end
|
146
145
|
end
|
147
146
|
|
@@ -19,177 +19,132 @@
|
|
19
19
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
|
20
20
|
|
21
21
|
describe Chef::Knife::CookbookSiteInstall do
|
22
|
-
let(:knife) { Chef::Knife::CookbookSiteInstall.new }
|
23
|
-
let(:stdout) { StringIO.new }
|
24
|
-
let(:stderr) { StringIO.new }
|
25
|
-
let(:downloader) { Hash.new }
|
26
|
-
let(:repo) { double(:sanity_check => true, :reset_to_default_state => true,
|
27
|
-
:prepare_to_import => true, :finalize_updates_to => true,
|
28
|
-
:merge_updates_from => true) }
|
29
|
-
let(:install_path) { if Chef::Platform.windows?
|
30
|
-
'C:/tmp/chef'
|
31
|
-
else
|
32
|
-
'/var/tmp/chef'
|
33
|
-
end }
|
34
|
-
|
35
22
|
before(:each) do
|
36
23
|
require 'chef/knife/core/cookbook_scm_repo'
|
37
|
-
|
38
|
-
|
39
|
-
knife.
|
40
|
-
knife.config
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
24
|
+
@stdout = StringIO.new
|
25
|
+
@knife = Chef::Knife::CookbookSiteInstall.new
|
26
|
+
@knife.ui.stub(:stdout).and_return(@stdout)
|
27
|
+
@knife.config = {}
|
28
|
+
if Chef::Platform.windows?
|
29
|
+
@install_path = 'C:/tmp/chef'
|
30
|
+
else
|
31
|
+
@install_path = '/var/tmp/chef'
|
32
|
+
end
|
33
|
+
@knife.config[:cookbook_path] = [ @install_path ]
|
34
|
+
|
35
|
+
@stdout = StringIO.new
|
36
|
+
@stderr = StringIO.new
|
37
|
+
@knife.stub(:stderr).and_return(@stdout)
|
38
|
+
@knife.stub(:stdout).and_return(@stdout)
|
39
|
+
|
40
|
+
#Assume all external commands would have succeed. :(
|
41
|
+
File.stub(:unlink)
|
42
|
+
File.stub(:rmtree)
|
43
|
+
@knife.stub(:shell_out!).and_return(true)
|
44
|
+
|
45
|
+
#CookbookSiteDownload Stup
|
46
|
+
@downloader = {}
|
47
|
+
@knife.stub(:download_cookbook_to).and_return(@downloader)
|
48
|
+
@downloader.stub(:version).and_return do
|
49
|
+
if @knife.name_args.size == 2
|
50
|
+
@knife.name_args[1]
|
55
51
|
else
|
56
52
|
"0.3.0"
|
57
53
|
end
|
58
54
|
end
|
59
55
|
|
60
|
-
#
|
61
|
-
|
56
|
+
#Stubs for CookbookSCMRepo
|
57
|
+
@repo = double(:sanity_check => true, :reset_to_default_state => true,
|
58
|
+
:prepare_to_import => true, :finalize_updates_to => true,
|
59
|
+
:merge_updates_from => true)
|
60
|
+
Chef::Knife::CookbookSCMRepo.stub(:new).and_return(@repo)
|
62
61
|
end
|
63
62
|
|
64
|
-
describe "run" do
|
65
|
-
it "raises an error if a cookbook name is not provided" do
|
66
|
-
knife.name_args = []
|
67
|
-
expect(knife.ui).to receive(:error).with("Please specify a cookbook to download and install.")
|
68
|
-
expect { knife.run }.to raise_error(SystemExit)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "raises an error if more than two arguments are given" do
|
72
|
-
knife.name_args = ["foo", "bar", "baz"]
|
73
|
-
expect(knife.ui).to receive(:error).with("Installing multiple cookbooks at once is not supported.")
|
74
|
-
expect { knife.run }.to raise_error(SystemExit)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "raises an error if the second argument is not a version" do
|
78
|
-
knife.name_args = ["getting-started", "1pass"]
|
79
|
-
expect(knife.ui).to receive(:error).with("Installing multiple cookbooks at once is not supported.")
|
80
|
-
expect { knife.run }.to raise_error(SystemExit)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "raises an error if the second argument is a four-digit version" do
|
84
|
-
knife.name_args = ["getting-started", "0.0.0.1"]
|
85
|
-
expect(knife.ui).to receive(:error).with("Installing multiple cookbooks at once is not supported.")
|
86
|
-
expect { knife.run }.to raise_error(SystemExit)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "raises an error if the second argument is a one-digit version" do
|
90
|
-
knife.name_args = ["getting-started", "1"]
|
91
|
-
expect(knife.ui).to receive(:error).with("Installing multiple cookbooks at once is not supported.")
|
92
|
-
expect { knife.run }.to raise_error(SystemExit)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "installs the specified version if second argument is a three-digit version" do
|
96
|
-
knife.name_args = ["getting-started", "0.1.0"]
|
97
|
-
knife.config[:no_deps] = true
|
98
|
-
upstream_file = File.join(install_path, "getting-started.tar.gz")
|
99
|
-
expect(knife).to receive(:download_cookbook_to).with(upstream_file)
|
100
|
-
expect(knife).to receive(:extract_cookbook).with(upstream_file, "0.1.0")
|
101
|
-
expect(knife).to receive(:clear_existing_files).with(File.join(install_path, "getting-started"))
|
102
|
-
expect(repo).to receive(:merge_updates_from).with("getting-started", "0.1.0")
|
103
|
-
knife.run
|
104
|
-
end
|
105
|
-
|
106
|
-
it "installs the specified version if second argument is a two-digit version" do
|
107
|
-
knife.name_args = ["getting-started", "0.1"]
|
108
|
-
knife.config[:no_deps] = true
|
109
|
-
upstream_file = File.join(install_path, "getting-started.tar.gz")
|
110
|
-
expect(knife).to receive(:download_cookbook_to).with(upstream_file)
|
111
|
-
expect(knife).to receive(:extract_cookbook).with(upstream_file, "0.1")
|
112
|
-
expect(knife).to receive(:clear_existing_files).with(File.join(install_path, "getting-started"))
|
113
|
-
expect(repo).to receive(:merge_updates_from).with("getting-started", "0.1")
|
114
|
-
knife.run
|
115
|
-
end
|
116
|
-
|
117
|
-
it "installs the latest version if only a cookbook name is given" do
|
118
|
-
knife.name_args = ["getting-started"]
|
119
|
-
knife.config[:no_deps] = true
|
120
|
-
upstream_file = File.join(install_path, "getting-started.tar.gz")
|
121
|
-
expect(knife).to receive(:download_cookbook_to).with(upstream_file)
|
122
|
-
expect(knife).to receive(:extract_cookbook).with(upstream_file, "0.3.0")
|
123
|
-
expect(knife).to receive(:clear_existing_files).with(File.join(install_path, "getting-started"))
|
124
|
-
expect(repo).to receive(:merge_updates_from).with("getting-started", "0.3.0")
|
125
|
-
knife.run
|
126
|
-
end
|
127
|
-
|
128
|
-
it "does not create/reset git branches if use_current_branch is set" do
|
129
|
-
knife.name_args = ["getting-started"]
|
130
|
-
knife.config[:use_current_branch] = true
|
131
|
-
knife.config[:no_deps] = true
|
132
|
-
upstream_file = File.join(install_path, "getting-started.tar.gz")
|
133
|
-
expect(repo).not_to receive(:prepare_to_import)
|
134
|
-
expect(repo).not_to receive(:reset_to_default_state)
|
135
|
-
knife.run
|
136
|
-
end
|
137
|
-
|
138
|
-
it "does not raise an error if cookbook_path is a string" do
|
139
|
-
knife.config[:cookbook_path] = install_path
|
140
|
-
knife.config[:no_deps] = true
|
141
|
-
knife.name_args = ["getting-started"]
|
142
|
-
upstream_file = File.join(install_path, "getting-started.tar.gz")
|
143
|
-
expect(knife).to receive(:download_cookbook_to).with(upstream_file)
|
144
|
-
expect(knife).to receive(:extract_cookbook).with(upstream_file, "0.3.0")
|
145
|
-
expect(knife).to receive(:clear_existing_files).with(File.join(install_path, "getting-started"))
|
146
|
-
expect(repo).to receive(:merge_updates_from).with("getting-started", "0.3.0")
|
147
|
-
expect { knife.run }.not_to raise_error
|
148
|
-
end
|
149
|
-
end # end of run
|
150
|
-
|
151
|
-
let(:metadata) { Chef::Cookbook::Metadata.new }
|
152
|
-
let(:rb_metadata_path) { File.join(install_path, "post-punk-kitchen", "metadata.rb") }
|
153
|
-
let(:json_metadata_path) { File.join(install_path, "post-punk-kitchen", "metadata.json") }
|
154
|
-
|
155
|
-
describe "preferred_metadata" do
|
156
|
-
before do
|
157
|
-
allow(Chef::Cookbook::Metadata).to receive(:new).and_return(metadata)
|
158
|
-
allow(File).to receive(:exist?).and_return(false)
|
159
|
-
knife.instance_variable_set(:@cookbook_name, "post-punk-kitchen")
|
160
|
-
knife.instance_variable_set(:@install_path, install_path)
|
161
|
-
end
|
162
63
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
knife.
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
knife.
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
}
|
64
|
+
describe "run" do
|
65
|
+
it "should return an error if a cookbook name is not provided" do
|
66
|
+
@knife.name_args = []
|
67
|
+
@knife.ui.should_receive(:error).with("Please specify a cookbook to download and install.")
|
68
|
+
lambda { @knife.run }.should raise_error(SystemExit)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should return an error if more than two arguments are given" do
|
72
|
+
@knife.name_args = ["foo", "bar", "baz"]
|
73
|
+
@knife.ui.should_receive(:error).with("Installing multiple cookbooks at once is not supported.")
|
74
|
+
lambda { @knife.run }.should raise_error(SystemExit)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should return an error if the second argument is not a version" do
|
78
|
+
@knife.name_args = ["getting-started", "1pass"]
|
79
|
+
@knife.ui.should_receive(:error).with("Installing multiple cookbooks at once is not supported.")
|
80
|
+
lambda { @knife.run }.should raise_error(SystemExit)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should return an error if the second argument is a four-digit version" do
|
84
|
+
@knife.name_args = ["getting-started", "0.0.0.1"]
|
85
|
+
@knife.ui.should_receive(:error).with("Installing multiple cookbooks at once is not supported.")
|
86
|
+
lambda { @knife.run }.should raise_error(SystemExit)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return an error if the second argument is a one-digit version" do
|
90
|
+
@knife.name_args = ["getting-started", "1"]
|
91
|
+
@knife.ui.should_receive(:error).with("Installing multiple cookbooks at once is not supported.")
|
92
|
+
lambda { @knife.run }.should raise_error(SystemExit)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should install the specified version if second argument is a three-digit version" do
|
96
|
+
@knife.name_args = ["getting-started", "0.1.0"]
|
97
|
+
@knife.config[:no_deps] = true
|
98
|
+
upstream_file = File.join(@install_path, "getting-started.tar.gz")
|
99
|
+
@knife.should_receive(:download_cookbook_to).with(upstream_file)
|
100
|
+
@knife.should_receive(:extract_cookbook).with(upstream_file, "0.1.0")
|
101
|
+
@knife.should_receive(:clear_existing_files).with(File.join(@install_path, "getting-started"))
|
102
|
+
@repo.should_receive(:merge_updates_from).with("getting-started", "0.1.0")
|
103
|
+
@knife.run
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should install the specified version if second argument is a two-digit version" do
|
107
|
+
@knife.name_args = ["getting-started", "0.1"]
|
108
|
+
@knife.config[:no_deps] = true
|
109
|
+
upstream_file = File.join(@install_path, "getting-started.tar.gz")
|
110
|
+
@knife.should_receive(:download_cookbook_to).with(upstream_file)
|
111
|
+
@knife.should_receive(:extract_cookbook).with(upstream_file, "0.1")
|
112
|
+
@knife.should_receive(:clear_existing_files).with(File.join(@install_path, "getting-started"))
|
113
|
+
@repo.should_receive(:merge_updates_from).with("getting-started", "0.1")
|
114
|
+
@knife.run
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should install the latest version if only a cookbook name is given" do
|
118
|
+
@knife.name_args = ["getting-started"]
|
119
|
+
@knife.config[:no_deps] = true
|
120
|
+
upstream_file = File.join(@install_path, "getting-started.tar.gz")
|
121
|
+
@knife.should_receive(:download_cookbook_to).with(upstream_file)
|
122
|
+
@knife.should_receive(:extract_cookbook).with(upstream_file, "0.3.0")
|
123
|
+
@knife.should_receive(:clear_existing_files).with(File.join(@install_path, "getting-started"))
|
124
|
+
@repo.should_receive(:merge_updates_from).with("getting-started", "0.3.0")
|
125
|
+
@knife.run
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should not create/reset git branches if use_current_branch is set" do
|
129
|
+
@knife.name_args = ["getting-started"]
|
130
|
+
@knife.config[:use_current_branch] = true
|
131
|
+
@knife.config[:no_deps] = true
|
132
|
+
upstream_file = File.join(@install_path, "getting-started.tar.gz")
|
133
|
+
@repo.should_not_receive(:prepare_to_import)
|
134
|
+
@repo.should_not_receive(:reset_to_default_state)
|
135
|
+
@knife.run
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should not raise an error if cookbook_path is a string" do
|
139
|
+
@knife.config[:cookbook_path] = @install_path
|
140
|
+
@knife.config[:no_deps] = true
|
141
|
+
@knife.name_args = ["getting-started"]
|
142
|
+
upstream_file = File.join(@install_path, "getting-started.tar.gz")
|
143
|
+
@knife.should_receive(:download_cookbook_to).with(upstream_file)
|
144
|
+
@knife.should_receive(:extract_cookbook).with(upstream_file, "0.3.0")
|
145
|
+
@knife.should_receive(:clear_existing_files).with(File.join(@install_path, "getting-started"))
|
146
|
+
@repo.should_receive(:merge_updates_from).with("getting-started", "0.3.0")
|
147
|
+
lambda { @knife.run }.should_not raise_error
|
192
148
|
end
|
193
|
-
|
194
149
|
end
|
195
150
|
end
|