summaryrefslogtreecommitdiff
path: root/spec/unit/knife
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/knife')
-rw-r--r--spec/unit/knife/bootstrap/chef_vault_handler_spec.rb4
-rw-r--r--spec/unit/knife/bootstrap_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_download_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_list_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_site_install_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_site_share_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_test_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_upload_spec.rb12
-rw-r--r--spec/unit/knife/core/hashed_command_loader_spec.rb2
-rw-r--r--spec/unit/knife/core/ui_spec.rb16
-rw-r--r--spec/unit/knife/environment_compare_spec.rb2
-rw-r--r--spec/unit/knife/node_environment_set_spec.rb2
-rw-r--r--spec/unit/knife/node_list_spec.rb2
-rw-r--r--spec/unit/knife/node_run_list_remove_spec.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_clear_spec.rb4
-rw-r--r--spec/unit/knife/role_list_spec.rb2
-rw-r--r--spec/unit/knife/tag_delete_spec.rb2
-rw-r--r--spec/unit/knife/user_create_spec.rb10
18 files changed, 37 insertions, 37 deletions
diff --git a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
index ffc851e2b5..61aa9d0ae1 100644
--- a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
+++ b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
@@ -69,14 +69,14 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do
end
it "sets two items as an array" do
- knife_config[:bootstrap_vault_item] = { "vault" => [ "item1", "item2" ] }
+ knife_config[:bootstrap_vault_item] = { "vault" => %w(item1 item2) }
expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
it "sets two vaults from different hash keys" do
- knife_config[:bootstrap_vault_item] = { "vault" => [ "item1", "item2" ], "vault2" => [ "item3" ] }
+ knife_config[:bootstrap_vault_item] = { "vault" => %w(item1 item2), "vault2" => [ "item3" ] }
expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item)
expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault2", "item3").and_return(bootstrap_vault_item)
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index e8e75e43b5..357fee3867 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -51,7 +51,7 @@ describe Chef::Knife::Bootstrap do
context "with --bootstrap-vault-item" do
let(:bootstrap_cli_options) { [ "--bootstrap-vault-item", "vault1:item1", "--bootstrap-vault-item", "vault1:item2", "--bootstrap-vault-item", "vault2:item1" ] }
it "sets the knife config cli option correctly" do
- expect(knife.config[:bootstrap_vault_item]).to eq({ "vault1" => ["item1", "item2"], "vault2" => ["item1"] })
+ expect(knife.config[:bootstrap_vault_item]).to eq({ "vault1" => %w(item1 item2), "vault2" => ["item1"] })
end
end
diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb
index a8248a80b9..44a47d8c37 100644
--- a/spec/unit/knife/cookbook_download_spec.rb
+++ b/spec/unit/knife/cookbook_download_spec.rb
@@ -119,7 +119,7 @@ describe Chef::Knife::CookbookDownload do
it "should download the cookbook when the cookbook download directory doesn't exist" do
expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
@knife.run
- ["attributes", "recipes", "templates"].each do |segment|
+ %w(attributes recipes templates).each do |segment|
expect(@stderr.string).to match /downloading #{segment}/im
end
expect(@stderr.string).to match /downloading foobar cookbook version 1\.0\.0/im
diff --git a/spec/unit/knife/cookbook_list_spec.rb b/spec/unit/knife/cookbook_list_spec.rb
index 668f9afa4b..ba834e08e2 100644
--- a/spec/unit/knife/cookbook_list_spec.rb
+++ b/spec/unit/knife/cookbook_list_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Knife::CookbookList do
@knife = Chef::Knife::CookbookList.new
@rest_mock = double("rest")
allow(@knife).to receive(:rest).and_return(@rest_mock)
- @cookbook_names = ["apache2", "mysql"]
+ @cookbook_names = %w(apache2 mysql)
@base_url = "https://server.example.com/cookbooks"
@cookbook_data = {}
@cookbook_names.each do |item|
diff --git a/spec/unit/knife/cookbook_site_install_spec.rb b/spec/unit/knife/cookbook_site_install_spec.rb
index b0b1e8aec2..990e9ae098 100644
--- a/spec/unit/knife/cookbook_site_install_spec.rb
+++ b/spec/unit/knife/cookbook_site_install_spec.rb
@@ -71,7 +71,7 @@ describe Chef::Knife::CookbookSiteInstall do
end
it "raises an error if more than two arguments are given" do
- knife.name_args = ["foo", "bar", "baz"]
+ knife.name_args = %w(foo bar baz)
expect(knife.ui).to receive(:error).with("Installing multiple cookbooks at once is not supported.")
expect { knife.run }.to raise_error(SystemExit)
end
diff --git a/spec/unit/knife/cookbook_site_share_spec.rb b/spec/unit/knife/cookbook_site_share_spec.rb
index 662b53dd29..4b0f82d417 100644
--- a/spec/unit/knife/cookbook_site_share_spec.rb
+++ b/spec/unit/knife/cookbook_site_share_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Knife::CookbookSiteShare do
@knife = Chef::Knife::CookbookSiteShare.new
# Merge default settings in.
@knife.merge_configs
- @knife.name_args = ["cookbook_name", "AwesomeSausage"]
+ @knife.name_args = %w(cookbook_name AwesomeSausage)
@cookbook = Chef::CookbookVersion.new("cookbook_name")
diff --git a/spec/unit/knife/cookbook_test_spec.rb b/spec/unit/knife/cookbook_test_spec.rb
index abb88fe739..7f009f99d2 100644
--- a/spec/unit/knife/cookbook_test_spec.rb
+++ b/spec/unit/knife/cookbook_test_spec.rb
@@ -45,7 +45,7 @@ describe Chef::Knife::CookbookTest do
it "should test multiple cookbooks when provided" do
allow(@knife).to receive(:test_cookbook).and_return(true)
- @knife.name_args = ["tats", "jimmy_johns"]
+ @knife.name_args = %w(tats jimmy_johns)
expect(@knife).to receive(:test_cookbook).with("tats")
expect(@knife).to receive(:test_cookbook).with("jimmy_johns")
expect(@knife).not_to receive(:test_cookbook).with("central_market")
@@ -56,7 +56,7 @@ describe Chef::Knife::CookbookTest do
it "should test both ruby and templates" do
@knife.name_args = ["example"]
expect(@knife.config[:cookbook_path]).not_to be_empty
- Array(@knife.config[:cookbook_path]).reverse.each do |path|
+ Array(@knife.config[:cookbook_path]).reverse_each do |path|
expect(@knife).to receive(:test_ruby).with(an_instance_of(Chef::Cookbook::SyntaxCheck))
expect(@knife).to receive(:test_templates).with(an_instance_of(Chef::Cookbook::SyntaxCheck))
end
diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb
index dc55a709b7..eb2b1f9856 100644
--- a/spec/unit/knife/cookbook_upload_spec.rb
+++ b/spec/unit/knife/cookbook_upload_spec.rb
@@ -96,7 +96,7 @@ describe Chef::Knife::CookbookUpload do
describe "when specifying the same cookbook name twice" do
it "should upload the cookbook only once" do
- knife.name_args = ["test_cookbook", "test_cookbook"]
+ knife.name_args = %w(test_cookbook test_cookbook)
expect(knife).to receive(:upload).once
knife.run
end
@@ -181,10 +181,10 @@ E
it "should upload all dependencies once" do
knife.config[:depends] = true
- allow(knife).to receive(:cookbook_names).and_return(["test_cookbook1", "test_cookbook2", "test_cookbook3"])
+ allow(knife).to receive(:cookbook_names).and_return(%w(test_cookbook1 test_cookbook2 test_cookbook3))
expect(knife).to receive(:upload).exactly(3).times
expect do
- Timeout::timeout(5) do
+ Timeout.timeout(5) do
knife.run
end
end.not_to raise_error
@@ -200,7 +200,7 @@ E
{ "test_cookbook" => cookbook,
"dependency" => cookbook_dependency }[ckbk]
end
- allow(knife).to receive(:cookbook_names).and_return(["cookbook_dependency", "test_cookbook"])
+ allow(knife).to receive(:cookbook_names).and_return(%w(cookbook_dependency test_cookbook))
@stdout, @stderr, @stdin = StringIO.new, StringIO.new, StringIO.new
knife.ui = Chef::Knife::UI.new(@stdout, @stderr, @stdin, {})
end
@@ -227,7 +227,7 @@ E
"dependency" => cookbook_dependency,
"dependency2" => cookbook_dependency2 }[ckbk]
end
- allow(knife).to receive(:cookbook_names).and_return(["dependency", "dependency2", "test_cookbook"])
+ allow(knife).to receive(:cookbook_names).and_return(%w(dependency dependency2 test_cookbook))
expect { knife.run }.to raise_error(SystemExit)
expect(@stderr.string).to include("Cookbook test_cookbook depends on cookbooks which are not currently")
expect(@stderr.string).to include("being uploaded and cannot be found on the server.")
@@ -253,7 +253,7 @@ E
@test_cookbook1 = Chef::CookbookVersion.new("test_cookbook1", "/tmp/blah")
@test_cookbook2 = Chef::CookbookVersion.new("test_cookbook2", "/tmp/blah")
allow(cookbook_loader).to receive(:each).and_yield("test_cookbook1", @test_cookbook1).and_yield("test_cookbook2", @test_cookbook2)
- allow(cookbook_loader).to receive(:cookbook_names).and_return(["test_cookbook1", "test_cookbook2"])
+ allow(cookbook_loader).to receive(:cookbook_names).and_return(%w(test_cookbook1 test_cookbook2))
end
it "should upload all cookbooks" do
diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb
index d9f5e5761c..5c4a33b7e0 100644
--- a/spec/unit/knife/core/hashed_command_loader_spec.rb
+++ b/spec/unit/knife/core/hashed_command_loader_spec.rb
@@ -83,7 +83,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
end
it "finds the right subcommand even when _'s are elided" do
- expect(loader.subcommand_for_args(["cooler", "b"])).to eq("cooler_b")
+ expect(loader.subcommand_for_args(%w(cooler b))).to eq("cooler_b")
end
it "returns nil if the the subcommand isn't in our manifest" do
diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb
index d2381f60cb..b5e4aefab6 100644
--- a/spec/unit/knife/core/ui_spec.rb
+++ b/spec/unit/knife/core/ui_spec.rb
@@ -205,7 +205,7 @@ EOM
end
it "formats arrays appropriately" do
- @ui.output([ "a", "b" ])
+ @ui.output(%w(a b))
expect(@out.string).to eq <<EOM
a
b
@@ -228,7 +228,7 @@ EOM
end
it "formats nested arrays appropriately" do
- @ui.output([ [ "a", "b" ], [ "c", "d" ]])
+ @ui.output([ %w(a b), %w(c d)])
expect(@out.string).to eq <<EOM
a
b
@@ -239,7 +239,7 @@ EOM
end
it "formats nested arrays with single- and empty subarrays appropriately" do
- @ui.output([ [ "a", "b" ], [ "c" ], [], [ "d", "e" ]])
+ @ui.output([ %w(a b), [ "c" ], [], %w(d e)])
expect(@out.string).to eq <<EOM
a
b
@@ -282,7 +282,7 @@ EOM
end
it "formats hashes with array members appropriately" do
- @ui.output({ "a" => [ "foo", "bar" ], "b" => "c" })
+ @ui.output({ "a" => %w(foo bar), "b" => "c" })
expect(@out.string).to eq <<EOM
a:
foo
@@ -301,7 +301,7 @@ EOM
end
it "formats hashes with nested array values appropriately" do
- @ui.output({ "a" => [ [ "foo", "bar" ], [ "baz", "bjork" ] ], "b" => "c" })
+ @ui.output({ "a" => [ %w(foo bar), %w(baz bjork) ], "b" => "c" })
# XXX: using a HEREDOC at this point results in a line with required spaces which auto-whitespace removal settings
# on editors will remove and will break this test.
expect(@out.string).to eq("a:\n foo\n bar\n \n baz\n bjork\nb: c\n")
@@ -353,7 +353,7 @@ EOM
it "should return multiple attributes" do
input = { "gi" => "go", "hi" => "ho", "id" => "sample-data-bag-item" }
- @ui.config[:attribute] = ["gi", "hi"]
+ @ui.config[:attribute] = %w(gi hi)
expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { "gi" => "go", "hi" => "ho" } })
end
@@ -545,7 +545,7 @@ EOM
end
end
- ["Y", "y"].each do |answer|
+ %w(Y y).each do |answer|
describe "with answer #{answer}" do
let(:answer) { answer }
@@ -553,7 +553,7 @@ EOM
end
end
- ["N", "n"].each do |answer|
+ %w(N n).each do |answer|
describe "with answer #{answer}" do
let(:answer) { answer }
diff --git a/spec/unit/knife/environment_compare_spec.rb b/spec/unit/knife/environment_compare_spec.rb
index 7a341192be..9d9a61a32f 100644
--- a/spec/unit/knife/environment_compare_spec.rb
+++ b/spec/unit/knife/environment_compare_spec.rb
@@ -42,7 +42,7 @@ describe Chef::Knife::EnvironmentCompare do
@rest_double = double("rest")
allow(@knife).to receive(:rest).and_return(@rest_double)
- @cookbook_names = ["apache2", "mysql", "foo", "bar", "dummy", "chef_handler"]
+ @cookbook_names = %w(apache2 mysql foo bar dummy chef_handler)
@base_url = "https://server.example.com/cookbooks"
@cookbook_data = {}
@cookbook_names.each do |item|
diff --git a/spec/unit/knife/node_environment_set_spec.rb b/spec/unit/knife/node_environment_set_spec.rb
index 13dd3762a2..ea4112fe87 100644
--- a/spec/unit/knife/node_environment_set_spec.rb
+++ b/spec/unit/knife/node_environment_set_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Knife::NodeEnvironmentSet do
before(:each) do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeEnvironmentSet.new
- @knife.name_args = [ "adam", "bar" ]
+ @knife.name_args = %w(adam bar)
allow(@knife).to receive(:output).and_return(true)
@node = Chef::Node.new()
@node.name("knifetest-node")
diff --git a/spec/unit/knife/node_list_spec.rb b/spec/unit/knife/node_list_spec.rb
index ab17a45795..fbbe6bee06 100644
--- a/spec/unit/knife/node_list_spec.rb
+++ b/spec/unit/knife/node_list_spec.rb
@@ -40,7 +40,7 @@ describe Chef::Knife::NodeList do
it "should pretty print the list" do
expect(Chef::Node).to receive(:list).and_return(@list)
- expect(@knife).to receive(:output).with([ "bar", "foo" ])
+ expect(@knife).to receive(:output).with(%w(bar foo))
@knife.run
end
diff --git a/spec/unit/knife/node_run_list_remove_spec.rb b/spec/unit/knife/node_run_list_remove_spec.rb
index e741f513eb..c5c7696091 100644
--- a/spec/unit/knife/node_run_list_remove_spec.rb
+++ b/spec/unit/knife/node_run_list_remove_spec.rb
@@ -96,7 +96,7 @@ describe Chef::Knife::NodeRunListRemove do
it "should warn even more when the thing to remove is not in the runlist and unqualified" do
@node.run_list << "role[blah]"
@node.run_list << "recipe[duck::type]"
- @knife.name_args = [ "adam", "blork" ]
+ @knife.name_args = %w(adam blork)
expect(@knife.ui).to receive(:warn).with("blork is not in the run list")
expect(@knife.ui).to receive(:warn).with(/did you forget recipe\[\] or role\[\]/)
@knife.run
diff --git a/spec/unit/knife/role_env_run_list_clear_spec.rb b/spec/unit/knife/role_env_run_list_clear_spec.rb
index 1fb2f1f1c7..b843394c29 100644
--- a/spec/unit/knife/role_env_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_env_run_list_clear_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Knife::RoleEnvRunListClear do
@knife.config = {
:print_after => nil
}
- @knife.name_args = [ "will", "QA" ]
+ @knife.name_args = %w(will QA)
allow(@knife).to receive(:output).and_return(true)
@role = Chef::Role.new()
@@ -79,7 +79,7 @@ describe Chef::Knife::RoleEnvRunListClear do
@setup.run
@setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
@setup.run
- @knife.name_args = [ "will", "QA" ]
+ @knife.name_args = %w(will QA)
@knife.run
expect(@role.run_list_for("QA")[0]).to be_nil
expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]")
diff --git a/spec/unit/knife/role_list_spec.rb b/spec/unit/knife/role_list_spec.rb
index bfbba30288..b244039520 100644
--- a/spec/unit/knife/role_list_spec.rb
+++ b/spec/unit/knife/role_list_spec.rb
@@ -38,7 +38,7 @@ describe Chef::Knife::RoleList do
it "should pretty print the list" do
expect(Chef::Role).to receive(:list).and_return(@list)
- expect(@knife).to receive(:output).with([ "bar", "foo" ])
+ expect(@knife).to receive(:output).with(%w(bar foo))
@knife.run
end
diff --git a/spec/unit/knife/tag_delete_spec.rb b/spec/unit/knife/tag_delete_spec.rb
index 3095eda191..43f06de23f 100644
--- a/spec/unit/knife/tag_delete_spec.rb
+++ b/spec/unit/knife/tag_delete_spec.rb
@@ -16,7 +16,7 @@ describe Chef::Knife::TagDelete do
describe "run" do
it "can delete tags on a node" do
- expect(@node.tags).to eq(["sadtag", "happytag"])
+ expect(@node.tags).to eq(%w(sadtag happytag))
@knife.run
expect(@node.tags).to eq(["happytag"])
expect(@stderr.string).to match /deleted.+sadtag/i
diff --git a/spec/unit/knife/user_create_spec.rb b/spec/unit/knife/user_create_spec.rb
index 5ab77d2df6..1a5a394912 100644
--- a/spec/unit/knife/user_create_spec.rb
+++ b/spec/unit/knife/user_create_spec.rb
@@ -79,7 +79,7 @@ describe Chef::Knife::UserCreate do
context "when FIRST_NAME isn't specified" do
# from spec/support/shared/unit/knife_shared.rb
it_should_behave_like "mandatory field missing" do
- let(:name_args) { ["some_user", "some_display_name"] }
+ let(:name_args) { %w(some_user some_display_name) }
let(:fieldname) { "first name" }
end
end
@@ -87,7 +87,7 @@ describe Chef::Knife::UserCreate do
context "when LAST_NAME isn't specified" do
# from spec/support/shared/unit/knife_shared.rb
it_should_behave_like "mandatory field missing" do
- let(:name_args) { ["some_user", "some_display_name", "some_first_name"] }
+ let(:name_args) { %w(some_user some_display_name some_first_name) }
let(:fieldname) { "last name" }
end
end
@@ -95,7 +95,7 @@ describe Chef::Knife::UserCreate do
context "when EMAIL isn't specified" do
# from spec/support/shared/unit/knife_shared.rb
it_should_behave_like "mandatory field missing" do
- let(:name_args) { ["some_user", "some_display_name", "some_first_name", "some_last_name"] }
+ let(:name_args) { %w(some_user some_display_name some_first_name some_last_name) }
let(:fieldname) { "email" }
end
end
@@ -103,14 +103,14 @@ describe Chef::Knife::UserCreate do
context "when PASSWORD isn't specified" do
# from spec/support/shared/unit/knife_shared.rb
it_should_behave_like "mandatory field missing" do
- let(:name_args) { ["some_user", "some_display_name", "some_first_name", "some_last_name", "some_email"] }
+ let(:name_args) { %w(some_user some_display_name some_first_name some_last_name some_email) }
let(:fieldname) { "password" }
end
end
context "when all mandatory fields are validly specified" do
before do
- knife.name_args = ["some_user", "some_display_name", "some_first_name", "some_last_name", "some_email", "some_password"]
+ knife.name_args = %w(some_user some_display_name some_first_name some_last_name some_email some_password)
allow(knife).to receive(:edit_data).and_return(knife.user.to_hash)
allow(knife).to receive(:create_user_from_hash).and_return(knife.user)
end