diff options
Diffstat (limited to 'spec/unit')
77 files changed, 300 insertions, 300 deletions
diff --git a/spec/unit/audit/control_group_data_spec.rb b/spec/unit/audit/control_group_data_spec.rb index f6935a4c75..a7c8850350 100644 --- a/spec/unit/audit/control_group_data_spec.rb +++ b/spec/unit/audit/control_group_data_spec.rb @@ -360,19 +360,19 @@ describe Chef::Audit::ControlGroupData do context "and it's the first audit" do include_examples "mixed audit results" do - let(:audit_results) { ["failure", "success", "success"] } + let(:audit_results) { %w{failure success success} } end end context "and it's an audit in the middle" do include_examples "mixed audit results" do - let(:audit_results) { ["success", "failure", "success"] } + let(:audit_results) { %w{success failure success} } end end context "and it's the last audit" do include_examples "mixed audit results" do - let(:audit_results) { ["success", "success", "failure"] } + let(:audit_results) { %w{success success failure} } end end end diff --git a/spec/unit/chef_class_spec.rb b/spec/unit/chef_class_spec.rb index 3c1200e04c..3c8411ef2a 100644 --- a/spec/unit/chef_class_spec.rb +++ b/spec/unit/chef_class_spec.rb @@ -61,14 +61,14 @@ describe "Chef class" do end context "#set_provider_priority_array" do it "should delegate to the provider_priority_map" do - expect(provider_priority_map).to receive(:set_priority_array).with(:http_request, ["a", "b"], platform: "debian").and_return("stuff") - expect(Chef.set_provider_priority_array(:http_request, ["a", "b"], platform: "debian")).to eql("stuff") + expect(provider_priority_map).to receive(:set_priority_array).with(:http_request, %w{a b}, platform: "debian").and_return("stuff") + expect(Chef.set_provider_priority_array(:http_request, %w{a b}, platform: "debian")).to eql("stuff") end end context "#set_priority_map_for_resource" do it "should delegate to the resource_priority_map" do - expect(resource_priority_map).to receive(:set_priority_array).with(:http_request, ["a", "b"], platform: "debian").and_return("stuff") - expect(Chef.set_resource_priority_array(:http_request, ["a", "b"], platform: "debian")).to eql("stuff") + expect(resource_priority_map).to receive(:set_priority_array).with(:http_request, %w{a b}, platform: "debian").and_return("stuff") + expect(Chef.set_resource_priority_array(:http_request, %w{a b}, platform: "debian")).to eql("stuff") end end end diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb index da18117bbd..20edbcdcde 100644 --- a/spec/unit/chef_fs/parallelizer.rb +++ b/spec/unit/chef_fs/parallelizer.rb @@ -211,7 +211,7 @@ describe Chef::ChefFS::Parallelizer do occupying_job_finished[0] = true end.wait end - while !started + until started sleep(0.01) end end diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb index ff18333e70..0107667fcd 100644 --- a/spec/unit/cookbook/metadata_spec.rb +++ b/spec/unit/cookbook/metadata_spec.rb @@ -460,7 +460,7 @@ describe Chef::Cookbook::Metadata do attrs = { "display_name" => "MySQL Databases", "description" => "Description of MySQL", - "choice" => ["dedicated", "shared"], + "choice" => %w{dedicated shared}, "calculated" => false, "type" => "string", "required" => "recommended", @@ -523,7 +523,7 @@ describe Chef::Cookbook::Metadata do it "should not accept anything but an array of strings for choice" do expect { - metadata.attribute("db/mysql/databases", :choice => ["dedicated", "shared"]) + metadata.attribute("db/mysql/databases", :choice => %w{dedicated shared}) }.not_to raise_error expect { metadata.attribute("db/mysql/databases", :choice => [10, "shared"]) @@ -651,7 +651,7 @@ describe Chef::Cookbook::Metadata do it "should limit the types allowed in the choice array" do options = { :type => "string", - :choice => [ "test1", "test2" ], + :choice => %w{test1 test2}, :default => "test1", } expect { @@ -706,15 +706,15 @@ describe Chef::Cookbook::Metadata do it "should allow a default that is a choice" do expect { attrs = { - :choice => [ "a", "b", "c"], + :choice => %w{a b c}, :default => "b", } metadata.attribute("db/mysql/databases", attrs) }.not_to raise_error expect { attrs = { - :choice => [ "a", "b", "c", "d", "e"], - :default => ["b", "d"], + :choice => %w{a b c d e}, + :default => %w{b d}, } metadata.attribute("db/mysql/databases", attrs) }.not_to raise_error @@ -723,15 +723,15 @@ describe Chef::Cookbook::Metadata do it "should error if default is not a choice" do expect { attrs = { - :choice => [ "a", "b", "c"], + :choice => %w{a b c}, :default => "d", } metadata.attribute("db/mysql/databases", attrs) }.to raise_error(ArgumentError) expect { attrs = { - :choice => [ "a", "b", "c", "d", "e"], - :default => ["b", "z"], + :choice => %w{a b c d e}, + :default => %w{b z}, } metadata.attribute("db/mysql/databases", attrs) }.to raise_error(ArgumentError) diff --git a/spec/unit/cookbook_spec.rb b/spec/unit/cookbook_spec.rb index f931b43eaa..33b4a3ccd8 100644 --- a/spec/unit/cookbook_spec.rb +++ b/spec/unit/cookbook_spec.rb @@ -39,7 +39,7 @@ describe Chef::CookbookVersion do it "should allow you to set the list of attribute files and create the mapping from short names to paths" do @cookbook.attribute_filenames = [ "attributes/one.rb", "attributes/two.rb" ] expect(@cookbook.attribute_filenames).to eq([ "attributes/one.rb", "attributes/two.rb" ]) - expect(@cookbook.attribute_filenames_by_short_filename.keys.sort).to eql(["one", "two"]) + expect(@cookbook.attribute_filenames_by_short_filename.keys.sort).to eql(%w{one two}) expect(@cookbook.attribute_filenames_by_short_filename["one"]).to eq("attributes/one.rb") expect(@cookbook.attribute_filenames_by_short_filename["two"]).to eq("attributes/two.rb") end @@ -47,7 +47,7 @@ describe Chef::CookbookVersion do it "should allow you to set the list of recipe files and create the mapping of recipe short name to filename" do @cookbook.recipe_filenames = [ "recipes/one.rb", "recipes/two.rb" ] expect(@cookbook.recipe_filenames).to eq([ "recipes/one.rb", "recipes/two.rb" ]) - expect(@cookbook.recipe_filenames_by_name.keys.sort).to eql(["one", "two"]) + expect(@cookbook.recipe_filenames_by_name.keys.sort).to eql(%w{one two}) expect(@cookbook.recipe_filenames_by_name["one"]).to eq("recipes/one.rb") expect(@cookbook.recipe_filenames_by_name["two"]).to eq("recipes/two.rb") end diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb index 66f8b76d7f..5cd7c7794f 100644 --- a/spec/unit/dsl/reboot_pending_spec.rb +++ b/spec/unit/dsl/reboot_pending_spec.rb @@ -92,7 +92,7 @@ describe Chef::DSL::RebootPending do describe "in a resource" do it "responds to reboot_pending?" do - resource = Chef::Resource::new("Crackerjack::Timing", nil) + resource = Chef::Resource.new("Crackerjack::Timing", nil) expect(resource).to respond_to(:reboot_pending?) end end # describe in a resource diff --git a/spec/unit/dsl/regsitry_helper_spec.rb b/spec/unit/dsl/regsitry_helper_spec.rb index d6c2257003..45c7e73979 100644 --- a/spec/unit/dsl/regsitry_helper_spec.rb +++ b/spec/unit/dsl/regsitry_helper_spec.rb @@ -26,7 +26,7 @@ describe Chef::Resource::RegistryKey do node = Chef::Node.new node.consume_external_attrs(OHAI_SYSTEM.data, {}) run_context = Chef::RunContext.new(node, {}, events) - @resource = Chef::Resource::new("foo", run_context) + @resource = Chef::Resource.new("foo", run_context) end context "tests registry dsl" do diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb index 14713682e7..e3b77852b7 100644 --- a/spec/unit/encrypted_data_bag_item_spec.rb +++ b/spec/unit/encrypted_data_bag_item_spec.rb @@ -112,7 +112,7 @@ describe Chef::EncryptedDataBagItem::Encryptor do it "includes the auth_tag in the envelope" do final_data = encryptor.for_encrypted_item - expect(final_data["auth_tag"]).to eq(Base64::encode64(encryptor.auth_tag)) + expect(final_data["auth_tag"]).to eq(Base64.encode64(encryptor.auth_tag)) end it "throws an error if auth tag is read before encrypting the data" do diff --git a/spec/unit/http/validate_content_length_spec.rb b/spec/unit/http/validate_content_length_spec.rb index c054529e48..c852d7b5c7 100644 --- a/spec/unit/http/validate_content_length_spec.rb +++ b/spec/unit/http/validate_content_length_spec.rb @@ -107,7 +107,7 @@ describe Chef::HTTP::ValidateContentLength do describe "without Content-Length header" do let(:response_headers) { {} } - [ "direct", "streaming" ].each do |req_type| + %w{direct streaming}.each do |req_type| describe "when running #{req_type} request" do let(:request_type) { req_type.to_sym } @@ -120,7 +120,7 @@ describe Chef::HTTP::ValidateContentLength do end describe "with correct Content-Length header" do - [ "direct", "streaming" ].each do |req_type| + %w{direct streaming}.each do |req_type| describe "when running #{req_type} request" do let(:request_type) { req_type.to_sym } @@ -134,7 +134,7 @@ describe Chef::HTTP::ValidateContentLength do describe "with wrong Content-Length header" do let(:content_length_value) { 25 } - [ "direct", "streaming" ].each do |req_type| + %w{direct streaming}.each do |req_type| describe "when running #{req_type} request" do let(:request_type) { req_type.to_sym } @@ -161,7 +161,7 @@ describe Chef::HTTP::ValidateContentLength do } } - [ "direct", "streaming" ].each do |req_type| + %w{direct streaming}.each do |req_type| describe "when running #{req_type} request" do let(:request_type) { req_type.to_sym } diff --git a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb index ffc851e2b5..734b27216d 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..3425b94c76 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..991abea776 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..fce6bc9593 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..d60443d779 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..d5e3915896 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..f8b212e271 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..277da14011 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..4ae046cc09 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..37974821d7 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..863cdd4e6e 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..03fc764fd8 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..b94101ef7a 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..4f753d7991 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..b7af9b7d57 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..30743fdc02 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..5c932706af 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..806e8cf400 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 diff --git a/spec/unit/mixin/deep_merge_spec.rb b/spec/unit/mixin/deep_merge_spec.rb index 2850193eb6..2122008616 100644 --- a/spec/unit/mixin/deep_merge_spec.rb +++ b/spec/unit/mixin/deep_merge_spec.rb @@ -41,7 +41,7 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do end it "tests merging an hash w/array into blank hash" do - hash_src = { "region" => { "id" => ["227", "2"] } } + hash_src = { "region" => { "id" => %w{227 2} } } hash_dst = {} @dm.deep_merge!(hash_src, hash_dst) expect(hash_dst).to eq(hash_src) @@ -49,16 +49,16 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do it "tests merge from empty hash" do hash_src = {} - hash_dst = { "property" => ["2", "4"] } + hash_dst = { "property" => %w{2 4} } @dm.deep_merge!(hash_src, hash_dst) - expect(hash_dst).to eq({ "property" => ["2", "4"] }) + expect(hash_dst).to eq({ "property" => %w{2 4} }) end it "tests merge to empty hash" do - hash_src = { "property" => ["2", "4"] } + hash_src = { "property" => %w{2 4} } hash_dst = {} @dm.deep_merge!(hash_src, hash_dst) - expect(hash_dst).to eq({ "property" => ["2", "4"] }) + expect(hash_dst).to eq({ "property" => %w{2 4} }) end it "tests simple string overwrite" do @@ -76,36 +76,36 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do end it "tests hashes holding array" do - hash_src = { "property" => ["1", "3"] } - hash_dst = { "property" => ["2", "4"] } + hash_src = { "property" => %w{1 3} } + hash_dst = { "property" => %w{2 4} } @dm.deep_merge!(hash_src, hash_dst) - expect(hash_dst).to eq({ "property" => ["2", "4", "1", "3"] }) + expect(hash_dst).to eq({ "property" => %w{2 4 1 3} }) end it "tests hashes holding hashes holding arrays (array with duplicate elements is merged with dest then src" do - hash_src = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["1", "4+"] } } - hash_dst = { "property" => { "bedroom_count" => ["3", "2"], "bathroom_count" => ["2"] } } + hash_src = { "property" => { "bedroom_count" => %w{1 2}, "bathroom_count" => ["1", "4+"] } } + hash_dst = { "property" => { "bedroom_count" => %w{3 2}, "bathroom_count" => ["2"] } } @dm.deep_merge!(hash_src, hash_dst) - expect(hash_dst).to eq({ "property" => { "bedroom_count" => ["3", "2", "1"], "bathroom_count" => ["2", "1", "4+"] } }) + expect(hash_dst).to eq({ "property" => { "bedroom_count" => %w{3 2 1}, "bathroom_count" => ["2", "1", "4+"] } }) end it "tests hash holding hash holding array v string (string is overwritten by array)" do - hash_src = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["1", "4+"] } } + hash_src = { "property" => { "bedroom_count" => %w{1 2}, "bathroom_count" => ["1", "4+"] } } hash_dst = { "property" => { "bedroom_count" => "3", "bathroom_count" => ["2"] } } @dm.deep_merge!(hash_src, hash_dst) - expect(hash_dst).to eq({ "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["2", "1", "4+"] } }) + expect(hash_dst).to eq({ "property" => { "bedroom_count" => %w{1 2}, "bathroom_count" => ["2", "1", "4+"] } }) end it "tests hash holding hash holding string v array (array is overwritten by string)" do hash_src = { "property" => { "bedroom_count" => "3", "bathroom_count" => ["1", "4+"] } } - hash_dst = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["2"] } } + hash_dst = { "property" => { "bedroom_count" => %w{1 2}, "bathroom_count" => ["2"] } } @dm.deep_merge!(hash_src, hash_dst) expect(hash_dst).to eq({ "property" => { "bedroom_count" => "3", "bathroom_count" => ["2", "1", "4+"] } }) end it "tests hash holding hash holding hash v array (array is overwritten by hash)" do hash_src = { "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => 1 }, "bathroom_count" => ["1", "4+"] } } - hash_dst = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["2"] } } + hash_dst = { "property" => { "bedroom_count" => %w{1 2}, "bathroom_count" => ["2"] } } @dm.deep_merge!(hash_src, hash_dst) expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => 1 }, "bathroom_count" => ["2", "1", "4+"] } }) end @@ -142,21 +142,21 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do hash_src = { "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => [1] }, "bathroom_count" => ["1"] } } hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } } @dm.deep_merge!(hash_src, hash_dst) - expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => [4, 1] }, "bathroom_count" => ["2", "1"] } }) + expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => [4, 1] }, "bathroom_count" => %w{2 1} } }) end it "tests 3 hash layers holding arrays of int, but source is incomplete." do hash_src = { "property" => { "bedroom_count" => { "king_bed" => [3] }, "bathroom_count" => ["1"] } } hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } } @dm.deep_merge!(hash_src, hash_dst) - expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => [2, 3], "queen_bed" => [4] }, "bathroom_count" => ["2", "1"] } }) + expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => [2, 3], "queen_bed" => [4] }, "bathroom_count" => %w{2 1} } }) end it "tests 3 hash layers holding arrays of int, but source is shorter and has new 2nd level ints." do hash_src = { "property" => { "bedroom_count" => { 2 => 3, "king_bed" => [3] }, "bathroom_count" => ["1"] } } hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } } @dm.deep_merge!(hash_src, hash_dst) - expect(hash_dst).to eq({ "property" => { "bedroom_count" => { 2 => 3, "king_bed" => [2, 3], "queen_bed" => [4] }, "bathroom_count" => ["2", "1"] } }) + expect(hash_dst).to eq({ "property" => { "bedroom_count" => { 2 => 3, "king_bed" => [2, 3], "queen_bed" => [4] }, "bathroom_count" => %w{2 1} } }) end it "tests 3 hash layers holding arrays of int, but source is empty" do @@ -174,10 +174,10 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do end it "tests hash holding arrays of arrays" do - hash_src = { ["1", "2", "3"] => ["1", "2"] } - hash_dst = { ["4", "5"] => ["3"] } + hash_src = { %w{1 2 3} => %w{1 2} } + hash_dst = { %w{4 5} => ["3"] } @dm.deep_merge!(hash_src, hash_dst) - expect(hash_dst).to eq({ ["1", "2", "3"] => ["1", "2"], ["4", "5"] => ["3"] }) + expect(hash_dst).to eq({ %w{1 2 3} => %w{1 2}, %w{4 5} => ["3"] }) end it "tests merging of hash with blank hash, and make sure that source array split does not function when turned off" do @@ -253,7 +253,7 @@ describe Chef::Mixin::DeepMerge do it "should merge a nested hash into an empty hash" do hash_dst = {} - hash_src = { "region" => { "id" => ["227", "2"] } } + hash_src = { "region" => { "id" => %w{227 2} } } expect(@dm.merge(hash_dst, hash_src)).to eq(hash_src) end @@ -264,9 +264,9 @@ describe Chef::Mixin::DeepMerge do end it "should merge arrays within hashes" do - hash_dst = { "property" => ["2", "4"] } - hash_src = { "property" => ["1", "3"] } - expect(@dm.merge(hash_dst, hash_src)).to eq({ "property" => ["2", "4", "1", "3"] }) + hash_dst = { "property" => %w{2 4} } + hash_src = { "property" => %w{1 3} } + expect(@dm.merge(hash_dst, hash_src)).to eq({ "property" => %w{2 4 1 3} }) end it "should merge deeply nested hashes" do @@ -276,12 +276,12 @@ describe Chef::Mixin::DeepMerge do end it "should not modify the source or destination during the merge" do - hash_dst = { "property" => ["1", "2", "3"] } - hash_src = { "property" => ["4", "5", "6"] } + hash_dst = { "property" => %w{1 2 3} } + hash_src = { "property" => %w{4 5 6} } ret = @dm.merge(hash_dst, hash_src) - expect(hash_dst).to eq({ "property" => ["1", "2", "3"] }) - expect(hash_src).to eq({ "property" => ["4", "5", "6"] }) - expect(ret).to eq({ "property" => ["1", "2", "3", "4", "5", "6"] }) + expect(hash_dst).to eq({ "property" => %w{1 2 3} }) + expect(hash_src).to eq({ "property" => %w{4 5 6} }) + expect(ret).to eq({ "property" => %w{1 2 3 4 5 6} }) end it "should not error merging un-dupable objects" do diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb index 259b89032e..b3bd7af159 100644 --- a/spec/unit/mixin/params_validate_spec.rb +++ b/spec/unit/mixin/params_validate_spec.rb @@ -144,7 +144,7 @@ describe Chef::Mixin::ParamsValidate do { :one => @vo }, { :one => { - :respond_to => ["validate", "music"] + :respond_to => %w{validate music} } }, ) @@ -155,7 +155,7 @@ describe Chef::Mixin::ParamsValidate do { :one => @vo }, { :one => { - :respond_to => ["monkey", "validate"] + :respond_to => %w{monkey validate} } }, ) diff --git a/spec/unit/mixin/properties_spec.rb b/spec/unit/mixin/properties_spec.rb index 00e339a221..1af0bc7abd 100644 --- a/spec/unit/mixin/properties_spec.rb +++ b/spec/unit/mixin/properties_spec.rb @@ -9,8 +9,8 @@ module ChefMixinPropertiesSpec class A include Chef::Mixin::Properties property :a, "a", default: "a" - property :ab, ["a", "b"], default: "a" - property :ac, ["a", "c"], default: "a" + property :ab, %w{a b}, default: "a" + property :ac, %w{a c}, default: "a" end context "and a module B with properties b, ab and bc" do @@ -18,7 +18,7 @@ module ChefMixinPropertiesSpec include Chef::Mixin::Properties property :b, "b", default: "b" property :ab, default: "b" - property :bc, ["b", "c"], default: "c" + property :bc, %w{b c}, default: "c" end context "and a derived class C < A with properties c, ac and bc" do @@ -32,22 +32,22 @@ module ChefMixinPropertiesSpec it "A.properties has a, ab, and ac with types 'a', ['a', 'b'], and ['b', 'c']" do expect(A.properties.keys).to eq [ :a, :ab, :ac ] expect(A.properties[:a].validation_options[:is]).to eq "a" - expect(A.properties[:ab].validation_options[:is]).to eq [ "a", "b" ] - expect(A.properties[:ac].validation_options[:is]).to eq [ "a", "c" ] + expect(A.properties[:ab].validation_options[:is]).to eq %w{a b} + expect(A.properties[:ac].validation_options[:is]).to eq %w{a c} end it "B.properties has b, ab, and bc with types 'b', nil and ['b', 'c']" do expect(B.properties.keys).to eq [ :b, :ab, :bc ] expect(B.properties[:b].validation_options[:is]).to eq "b" expect(B.properties[:ab].validation_options[:is]).to be_nil - expect(B.properties[:bc].validation_options[:is]).to eq [ "b", "c" ] + expect(B.properties[:bc].validation_options[:is]).to eq %w{b c} end it "C.properties has a, b, c, ac and bc with merged types" do expect(C.properties.keys).to eq [ :a, :ab, :ac, :b, :bc, :c ] expect(C.properties[:a].validation_options[:is]).to eq "a" expect(C.properties[:b].validation_options[:is]).to eq "b" expect(C.properties[:c].validation_options[:is]).to eq "c" - expect(C.properties[:ac].validation_options[:is]).to eq [ "a", "c" ] - expect(C.properties[:bc].validation_options[:is]).to eq [ "b", "c" ] + expect(C.properties[:ac].validation_options[:is]).to eq %w{a c} + expect(C.properties[:bc].validation_options[:is]).to eq %w{b c} end it "C.properties has ab with a non-merged type (from B)" do expect(C.properties[:ab].validation_options[:is]).to be_nil diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb index 48150f7198..ab7ed5bc5a 100644 --- a/spec/unit/mixin/template_spec.rb +++ b/spec/unit/mixin/template_spec.rb @@ -209,7 +209,7 @@ describe Chef::Mixin::Template, "render_template" do def render_template_from_string end end - ["node", "render", "render_template", "render_template_from_string"].each do |method_name| + %w{node render render_template render_template_from_string}.each do |method_name| expect(Chef::Log).to receive(:warn).with(/^Core template method `#{method_name}' overridden by extension module/) end @template_context._extend_modules([mod]) diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb index aaf9fa4b2b..4559702e1c 100644 --- a/spec/unit/mixin/windows_architecture_helper_spec.rb +++ b/spec/unit/mixin/windows_architecture_helper_spec.rb @@ -59,14 +59,14 @@ describe Chef::Mixin::WindowsArchitectureHelper do it "returns true only for supported desired architecture passed to node_supports_windows_architecture" do with_node_architecture_combinations do |node, desired_arch| - expect(node_supports_windows_architecture?(node, desired_arch)).to be true if (node_windows_architecture(node) == :x86_64 || desired_arch == :i386 ) - expect(node_supports_windows_architecture?(node, desired_arch)).to be false if (node_windows_architecture(node) == :i386 && desired_arch == :x86_64 ) + expect(node_supports_windows_architecture?(node, desired_arch)).to be true if node_windows_architecture(node) == :x86_64 || desired_arch == :i386 + expect(node_supports_windows_architecture?(node, desired_arch)).to be false if node_windows_architecture(node) == :i386 && desired_arch == :x86_64 end end it "returns true only when forced_32bit_override_required? has 64-bit node architecture and 32-bit desired architecture" do with_node_architecture_combinations do |node, desired_arch| - expect(forced_32bit_override_required?(node, desired_arch)).to be true if ((node_windows_architecture(node) == :x86_64) && (desired_arch == :i386) && !is_i386_process_on_x86_64_windows?) + expect(forced_32bit_override_required?(node, desired_arch)).to be true if (node_windows_architecture(node) == :x86_64) && (desired_arch == :i386) && !is_i386_process_on_x86_64_windows? expect(forced_32bit_override_required?(node, desired_arch)).to be false if ! ((node_windows_architecture(node) == :x86_64) && (desired_arch == :i386)) end end diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index c69748ac49..7170f62efb 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -29,7 +29,7 @@ describe Chef::Node::Attribute do "platform" => "mac_os_x", "ipaddress" => "192.168.0.117", "network" => { "default_interface" => "en1", - "interfaces" => { "vmnet1" => { "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], + "interfaces" => { "vmnet1" => { "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, "number" => "1", "addresses" => { "00:50:56:c0:00:01" => { "family" => "lladdr" }, "192.168.110.1" => { "broadcast" => "192.168.110.255", @@ -45,7 +45,7 @@ describe Chef::Node::Attribute do "mtu" => "1280", "type" => "stf", "encapsulation" => "6to4" }, - "lo0" => { "flags" => ["UP", "LOOPBACK", "RUNNING", "MULTICAST"], + "lo0" => { "flags" => %w{UP LOOPBACK RUNNING MULTICAST}, "number" => "0", "addresses" => { "::1" => { "scope" => "Node", "prefixlen" => "128", "family" => "inet6" }, "127.0.0.1" => { "netmask" => "255.0.0.0", "family" => "inet" }, @@ -53,13 +53,13 @@ describe Chef::Node::Attribute do "mtu" => "16384", "type" => "lo", "encapsulation" => "Loopback" }, - "gif0" => { "flags" => ["POINTOPOINT", "MULTICAST"], + "gif0" => { "flags" => %w{POINTOPOINT MULTICAST}, "number" => "0", "addresses" => {}, "mtu" => "1280", "type" => "gif", "encapsulation" => "IPIP" }, - "vmnet8" => { "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], + "vmnet8" => { "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, "number" => "8", "addresses" => { "192.168.4.1" => { "broadcast" => "192.168.4.255", "netmask" => "255.255.255.0", @@ -70,7 +70,7 @@ describe Chef::Node::Attribute do "arp" => { "192.168.4.255" => "ff:ff:ff:ff:ff:ff" }, "encapsulation" => "Ethernet" }, "en0" => { "status" => "inactive", - "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], + "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, "number" => "0", "addresses" => { "00:23:32:b0:32:f2" => { "family" => "lladdr" } }, "mtu" => "1500", @@ -83,7 +83,7 @@ describe Chef::Node::Attribute do "type" => "en", "encapsulation" => "Ethernet" }, "en1" => { "status" => "active", - "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], + "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, "number" => "1", "addresses" => { "fe80::223:6cff:fe7f:676c" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" }, "00:23:6c:7f:67:6c" => { "family" => "lladdr" }, @@ -102,7 +102,7 @@ describe Chef::Node::Attribute do "192.168.0.152" => "0:26:8:7d:2:4c" }, "encapsulation" => "Ethernet" }, "en2" => { "status" => "active", - "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], + "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, "number" => "2", "addresses" => { "169.254.206.152" => { "broadcast" => "169.254.255.255", "netmask" => "255.255.0.0", @@ -115,7 +115,7 @@ describe Chef::Node::Attribute do "type" => "en", "encapsulation" => "Ethernet" }, "fw0" => { "status" => "inactive", - "flags" => ["BROADCAST", "SIMPLEX", "MULTICAST"], + "flags" => %w{BROADCAST SIMPLEX MULTICAST}, "number" => "0", "addresses" => { "00:23:32:ff:fe:b0:32:f2" => { "family" => "lladdr" } }, "mtu" => "4078", @@ -124,7 +124,7 @@ describe Chef::Node::Attribute do "type" => "fw", "encapsulation" => "1394" }, "en3" => { "status" => "active", - "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], + "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, "number" => "3", "addresses" => { "169.254.206.152" => { "broadcast" => "169.254.255.255", "netmask" => "255.255.0.0", @@ -219,16 +219,16 @@ describe Chef::Node::Attribute do it "gives the value at each level of precedence for a path spec" do expected = [["set_unless_enabled?", false], - ["default", "default"], - ["env_default", "env_default"], - ["role_default", "role_default"], - ["force_default", "force_default"], - ["normal", "normal"], - ["override", "override"], - ["role_override", "role_override"], - ["env_override", "env_override"], - ["force_override", "force_override"], - ["automatic", "automatic"], + %w{default default}, + %w{env_default env_default}, + %w{role_default role_default}, + %w{force_default force_default}, + %w{normal normal}, + %w{override override}, + %w{role_override role_override}, + %w{env_override env_override}, + %w{force_override force_override}, + %w{automatic automatic}, ] expect(@attributes.debug_value(:foo, :bar)).to eq(expected) end @@ -457,7 +457,7 @@ describe Chef::Node::Attribute do hash = @attributes["foo"].to_hash expect(hash).to eql({ "bar" => [ "fizz" ] }) hash["bar"].push("buzz") - expect(hash).to eql({ "bar" => [ "fizz", "buzz" ] }) + expect(hash).to eql({ "bar" => %w{fizz buzz} }) expect(@attributes.default["foo"]).to eql({ "bar" => [ "fizz" ] }) end @@ -537,8 +537,8 @@ describe Chef::Node::Attribute do end it "should allow the last method to set a value if it has an = sign on the end" do - @attributes.normal.music.mastodon = [ "dream", "still", "shining" ] - expect(@attributes.normal.music.mastodon).to eq([ "dream", "still", "shining" ]) + @attributes.normal.music.mastodon = %w{dream still shining} + expect(@attributes.normal.music.mastodon).to eq(%w{dream still shining}) end end @@ -999,9 +999,9 @@ describe Chef::Node::Attribute do it "should return a new array of k,v pairs for which the block returns true" do expect(@attributes.select { true }.sort).to eq( [ - ["hut", "three"], - ["one", "six"], - ["snack", "cookies"], + %w{hut three}, + %w{one six}, + %w{snack cookies}, ["snakes", "on a plane"], ] ) diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index d3c58c6f6a..5304ac9f92 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -291,9 +291,9 @@ describe Chef::Node do end it "should let you use tag as a convience method for the tags attribute" do - node.normal["tags"] = ["one", "two"] + node.normal["tags"] = %w{one two} node.tag("three", "four") - expect(node["tags"]).to eq(["one", "two", "three", "four"]) + expect(node["tags"]).to eq(%w{one two three four}) end end @@ -766,15 +766,15 @@ describe Chef::Node do end it "should overwrites the run list with the run list it consumes" do - node.consume_run_list "recipes" => [ "one", "two" ] + node.consume_run_list "recipes" => %w{one two} node.consume_run_list "recipes" => [ "three" ] expect(node.run_list).to eq([ "three" ]) end it "should not add duplicate recipes from the json attributes" do node.run_list << "one" - node.consume_run_list "recipes" => [ "one", "two", "three" ] - expect(node.run_list).to eq([ "one", "two", "three" ]) + node.consume_run_list "recipes" => %w{one two three} + expect(node.run_list).to eq(%w{one two three}) end it "doesn't change the run list if no run_list is specified in the json" do @@ -887,7 +887,7 @@ describe Chef::Node do it "sets the 'roles' automatic attribute to the expanded role list" do @expansion.instance_variable_set(:@applied_roles, { "arf" => nil, "countersnark" => nil }) node.expand! - expect(node.automatic_attrs[:roles].sort).to eq(["arf", "countersnark"]) + expect(node.automatic_attrs[:roles].sort).to eq(%w{arf countersnark}) end it "applies default attributes from the environment as environment defaults" do diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb index 6b71b4d43e..40f4daaf76 100644 --- a/spec/unit/policy_builder/policyfile_spec.rb +++ b/spec/unit/policy_builder/policyfile_spec.rb @@ -660,7 +660,7 @@ describe Chef::PolicyBuilder::Policyfile do expect_any_instance_of(Chef::CookbookCollection).to receive(:validate!) run_context = policy_builder.setup_run_context expect(run_context.node).to eq(node) - expect(run_context.cookbook_collection.keys).to match_array(["example1", "example2"]) + expect(run_context.cookbook_collection.keys).to match_array(%w{example1 example2}) end it "makes the run context available via static method on Chef" do diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb index 0b2a8e0bc9..db3c9fe4f6 100644 --- a/spec/unit/property/validation_spec.rb +++ b/spec/unit/property/validation_spec.rb @@ -292,7 +292,7 @@ describe "Chef::Resource.property validation" do # Regex validation_test "is: /abc/", - [ "abc", "wowabcwow" ], + %w{abc wowabcwow}, [ "", "abac" ] # Property @@ -427,17 +427,17 @@ describe "Chef::Resource.property validation" do :nil_is_valid validation_test "regex: [ /abc/, /z/ ]", - [ "xabcy", "aza" ], + %w{xabcy aza}, [ "gbh", 123 ], :nil_is_valid validation_test "regex: [ /z/, /abc/ ]", - [ "xabcy", "aza" ], + %w{xabcy aza}, [ "gbh", 123 ], :nil_is_valid validation_test "regex: [ [ /z/, /abc/ ], [ /n/ ] ]", - [ "xabcy", "aza", "ana" ], + %w{xabcy aza ana}, [ "gbh", 123 ], :nil_is_valid diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index ecea666072..f5eb361426 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -985,7 +985,7 @@ describe "Chef::Resource.property" do end end - [ "name_attribute", "name_property" ].each do |name| + %w{name_attribute name_property}.each do |name| context "Chef::Resource::Property##{name}" do with_property ":x, #{name}: true" do it "defaults x to resource.name" do diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb index ebef4faa09..9ebcf10dcc 100644 --- a/spec/unit/provider/file/content_spec.rb +++ b/spec/unit/provider/file/content_spec.rb @@ -66,13 +66,13 @@ describe Chef::Provider::File::Content do it "returns a tempfile in the tempdir when :file_staging_uses_destdir is not set" do Chef::Config[:file_staging_uses_destdir] = false - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_truthy + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be_truthy expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_falsey end it "returns a tempfile in the destdir when :file_deployment_uses_destdir is set" do Chef::Config[:file_staging_uses_destdir] = true - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_falsey + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be_falsey expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_truthy end @@ -83,7 +83,7 @@ describe Chef::Provider::File::Content do it "returns a tempfile in the tempdir when :file_deployment_uses_destdir is set to :auto" do Chef::Config[:file_staging_uses_destdir] = :auto - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_truthy + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be_truthy expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_falsey end @@ -93,7 +93,7 @@ describe Chef::Provider::File::Content do end it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_truthy + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be_truthy expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_falsey end end diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb index 52aff87dc5..bc69d7580e 100644 --- a/spec/unit/provider/group/dscl_spec.rb +++ b/spec/unit/provider/group/dscl_spec.rb @@ -184,7 +184,7 @@ describe Chef::Provider::Group::Dscl do before do allow(@new_resource).to receive(:members).and_return([]) allow(@new_resource).to receive(:append).and_return(false) - allow(@current_resource).to receive(:members).and_return(["all", "your", "base"]) + allow(@current_resource).to receive(:members).and_return(%w{all your base}) end it "should log an appropriate message" do @@ -201,7 +201,7 @@ describe Chef::Provider::Group::Dscl do describe "with supplied members in the new resource" do before do - @new_resource.members(["all", "your", "base"]) + @new_resource.members(%w{all your base}) @current_resource.members([]) end @@ -326,6 +326,6 @@ EOF end it "should parse members properly" do allow(File).to receive(:exists?).and_return(true) - expect(@current_resource.members).to eq(["waka", "bar"]) + expect(@current_resource.members).to eq(%w{waka bar}) end end diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb index b4295c9dff..87ab3c3493 100644 --- a/spec/unit/provider/group/groupadd_spec.rb +++ b/spec/unit/provider/group/groupadd_spec.rb @@ -25,12 +25,12 @@ describe Chef::Provider::Group::Groupadd, "set_options" do @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::Group.new("aj") @new_resource.gid(50) - @new_resource.members(["root", "aj"]) + @new_resource.members(%w{root aj}) @new_resource.system false @new_resource.non_unique false @current_resource = Chef::Resource::Group.new("aj") @current_resource.gid(50) - @current_resource.members(["root", "aj"]) + @current_resource.members(%w{root aj}) @current_resource.system false @current_resource.non_unique false @provider = Chef::Provider::Group::Groupadd.new(@new_resource, @run_context) diff --git a/spec/unit/provider/group/pw_spec.rb b/spec/unit/provider/group/pw_spec.rb index 2c563750f3..97ffcb3c31 100644 --- a/spec/unit/provider/group/pw_spec.rb +++ b/spec/unit/provider/group/pw_spec.rb @@ -26,11 +26,11 @@ describe Chef::Provider::Group::Pw do @new_resource = Chef::Resource::Group.new("wheel") @new_resource.gid 50 - @new_resource.members [ "root", "aj"] + @new_resource.members %w{root aj} @current_resource = Chef::Resource::Group.new("aj") @current_resource.gid 50 - @current_resource.members [ "root", "aj"] + @current_resource.members %w{root aj} @provider = Chef::Provider::Group::Pw.new(@new_resource, @run_context) @provider.current_resource = @current_resource end @@ -89,7 +89,7 @@ describe Chef::Provider::Group::Pw do describe "with an empty members array in the new resource and existing members in the current resource" do before do allow(@new_resource).to receive(:members).and_return([]) - allow(@current_resource).to receive(:members).and_return(["all", "your", "base"]) + allow(@current_resource).to receive(:members).and_return(%w{all your base}) end it "should log an appropriate message" do @@ -104,7 +104,7 @@ describe Chef::Provider::Group::Pw do describe "with supplied members array in the new resource and an empty members array in the current resource" do before do - allow(@new_resource).to receive(:members).and_return(["all", "your", "base"]) + allow(@new_resource).to receive(:members).and_return(%w{all your base}) allow(@current_resource).to receive(:members).and_return([]) end diff --git a/spec/unit/provider/group/usermod_spec.rb b/spec/unit/provider/group/usermod_spec.rb index 1a718b1d40..7bd45c4f1b 100644 --- a/spec/unit/provider/group/usermod_spec.rb +++ b/spec/unit/provider/group/usermod_spec.rb @@ -24,7 +24,7 @@ describe Chef::Provider::Group::Usermod do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::Group.new("wheel") - @new_resource.members [ "all", "your", "base" ] + @new_resource.members %w{all your base} @new_resource.excluded_members [ ] @provider = Chef::Provider::Group::Usermod.new(@new_resource, @run_context) allow(@provider).to receive(:run_command) @@ -56,7 +56,7 @@ describe Chef::Provider::Group::Usermod do } before do - allow(@new_resource).to receive(:members).and_return(["all", "your", "base"]) + allow(@new_resource).to receive(:members).and_return(%w{all your base}) allow(File).to receive(:exists?).and_return(true) end diff --git a/spec/unit/provider/group/windows_spec.rb b/spec/unit/provider/group/windows_spec.rb index c331e2b021..c424e35e0e 100644 --- a/spec/unit/provider/group/windows_spec.rb +++ b/spec/unit/provider/group/windows_spec.rb @@ -50,7 +50,7 @@ describe Chef::Provider::Group::Windows do before do @new_resource.members([ "us" ]) @current_resource = Chef::Resource::Group.new("staff") - @current_resource.members [ "all", "your", "base" ] + @current_resource.members %w{all your base} allow(Chef::Util::Windows::NetGroup).to receive(:new).and_return(@net_group) allow(@net_group).to receive(:local_add_members) diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb index d41b0689ee..f056114d89 100644 --- a/spec/unit/provider/group_spec.rb +++ b/spec/unit/provider/group_spec.rb @@ -39,7 +39,7 @@ describe Chef::Provider::User do @pw_group = double("Struct::Group", :name => "wheel", :gid => 20, - :mem => [ "root", "aj" ], + :mem => %w{root aj}, ) allow(Etc).to receive(:getgrnam).with("wheel").and_return(@pw_group) end diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index 50ed356049..52be15b2a8 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -107,7 +107,7 @@ describe Chef::Provider::Mount::Mount do expect { @provider.load_current_resource();@provider.mountable? }.to raise_error(Chef::Exceptions::Mount) end - [ "tmpfs", "fuse", "cgroup" ].each do |fstype| + %w{tmpfs fuse cgroup}.each do |fstype| it "does not expect the device to exist for #{fstype}" do @new_resource.fstype(fstype) @new_resource.device("whatever") diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb index a6d0620df6..51ace83470 100644 --- a/spec/unit/provider/mount/solaris_spec.rb +++ b/spec/unit/provider/mount/solaris_spec.rb @@ -316,7 +316,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do end it "should set the options field on the current_resource" do - expect(provider.current_resource.options).to eql(["rw", "soft"]) + expect(provider.current_resource.options).to eql(%w{rw soft}) end it "should set the pass field on the current_resource" do diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb index aeb420fa7a..a347aa7ebd 100644 --- a/spec/unit/provider/package/chocolatey_spec.rb +++ b/spec/unit/provider/package/chocolatey_spec.rb @@ -95,26 +95,26 @@ munin-node|1.6.1.20130823 end it "should set the candidate_version correctly when there are two packages to install" do - allow_remote_list(["ConEmu", "chocolatey"]) - new_resource.package_name(["ConEmu", "chocolatey"]) + allow_remote_list(%w{ConEmu chocolatey}) + new_resource.package_name(%w{ConEmu chocolatey}) expect(provider.candidate_version).to eql(["15.10.25.1", "0.9.9.11"]) end it "should set the candidate_version correctly when only the first is installable" do - allow_remote_list(["ConEmu", "vim"]) - new_resource.package_name(["ConEmu", "vim"]) + allow_remote_list(%w{ConEmu vim}) + new_resource.package_name(%w{ConEmu vim}) expect(provider.candidate_version).to eql(["15.10.25.1", nil]) end it "should set the candidate_version correctly when only the last is installable" do - allow_remote_list(["vim", "chocolatey"]) - new_resource.package_name(["vim", "chocolatey"]) + allow_remote_list(%w{vim chocolatey}) + new_resource.package_name(%w{vim chocolatey}) expect(provider.candidate_version).to eql([nil, "0.9.9.11"]) end it "should set the candidate_version correctly when neither are is installable" do - allow_remote_list(["vim", "ruby"]) - new_resource.package_name(["vim", "ruby"]) + allow_remote_list(%w{vim ruby}) + new_resource.package_name(%w{vim ruby}) expect(provider.candidate_version).to eql([nil, nil]) end end @@ -156,25 +156,25 @@ munin-node|1.6.1.20130823 end it "should set the current_resource.version when there are two packages that are installed" do - new_resource.package_name(["ConEmu", "chocolatey"]) + new_resource.package_name(%w{ConEmu chocolatey}) provider.load_current_resource expect(provider.current_resource.version).to eql(["15.10.25.0", "0.9.9.11"]) end it "should set the current_resource.version correctly when only the first is installed" do - new_resource.package_name(["ConEmu", "git"]) + new_resource.package_name(%w{ConEmu git}) provider.load_current_resource expect(provider.current_resource.version).to eql(["15.10.25.0", nil]) end it "should set the current_resource.version correctly when only the last is installed" do - new_resource.package_name(["git", "chocolatey"]) + new_resource.package_name(%w{git chocolatey}) provider.load_current_resource expect(provider.current_resource.version).to eql([nil, "0.9.9.11"]) end it "should set the current_resource.version correctly when none are installed" do - new_resource.package_name(["git", "vim"]) + new_resource.package_name(%w{git vim}) provider.load_current_resource expect(provider.current_resource.version).to eql([nil, nil]) end @@ -233,8 +233,8 @@ munin-node|1.6.1.20130823 # chocolatey will be pruned by the superclass out of the args to install_package and we # implicitly test that we correctly pick up new_resource.version[1] instead of # new_version.resource[0] - allow_remote_list(["chocolatey", "ConEmu"]) - new_resource.package_name(["chocolatey", "ConEmu"]) + allow_remote_list(%w{chocolatey ConEmu}) + new_resource.package_name(%w{chocolatey ConEmu}) new_resource.version([nil, "15.10.25.1"]) provider.load_current_resource expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double) @@ -253,8 +253,8 @@ munin-node|1.6.1.20130823 end it "should split up commands when given two packages, one with a version pin" do - allow_remote_list(["ConEmu", "git"]) - new_resource.package_name(["ConEmu", "git"]) + allow_remote_list(%w{ConEmu git}) + new_resource.package_name(%w{ConEmu git}) new_resource.version(["15.10.25.1", nil]) provider.load_current_resource expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double) @@ -371,8 +371,8 @@ munin-node|1.6.1.20130823 end it "upgrading multiple packages uses a single command" do - allow_remote_list(["conemu", "git"]) - new_resource.package_name(["conemu", "git"]) + allow_remote_list(%w{conemu git}) + new_resource.package_name(%w{conemu git}) expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu git", { :timeout => timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action @@ -441,8 +441,8 @@ munin-node|1.6.1.20130823 it "removes a single package when its the only one installed" do pending "this is a bug in the superclass" - allow_remote_list(["git", "conemu"]) - new_resource.package_name(["git", "conemu"]) + allow_remote_list(%w{git conemu}) + new_resource.package_name(%w{git conemu}) provider.load_current_resource expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", { :timeout => timeout }).and_return(double) provider.run_action(:remove) diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb index 98fe9551a6..2b3048bc19 100644 --- a/spec/unit/provider/package/yum_spec.rb +++ b/spec/unit/provider/package/yum_spec.rb @@ -987,7 +987,7 @@ describe Chef::Provider::Package::Yum::RPMUtils do end it "tests isalnum good input" do - [ "a", "z", "A", "Z", "0", "9" ].each do |t| + %w{a z A Z 0 9}.each do |t| expect(@rpmutils.isalnum(t)).to eq(true) end end @@ -999,7 +999,7 @@ describe Chef::Provider::Package::Yum::RPMUtils do end it "tests isalpha good input" do - [ "a", "z", "A", "Z" ].each do |t| + %w{a z A Z}.each do |t| expect(@rpmutils.isalpha(t)).to eq(true) end end @@ -1011,7 +1011,7 @@ describe Chef::Provider::Package::Yum::RPMUtils do end it "tests isdigit good input" do - [ "0", "9" ].each do |t| + %w{0 9}.each do |t| expect(@rpmutils.isdigit(t)).to eq(true) end end @@ -1119,8 +1119,8 @@ describe Chef::Provider::Package::Yum::RPMVersion do "3.3-15.el5" ], [ "alpha9.8", "beta9.8" ], - [ "14jpp", - "15jpp" ], + %w{14jpp +15jpp}, [ "0.9.0-0.6", "0.9.0-0.7" ], [ "0:1.9", @@ -1297,8 +1297,8 @@ describe Chef::Provider::Package::Yum::RPMPackage do "B-test" ], [ "Aa-test", "aA-test" ], - [ "1test", - "2test" ], + %w{1test +2test}, ].each do |smaller, larger| sm = Chef::Provider::Package::Yum::RPMPackage.new(smaller, "0:0.0.1-1", "x86_64", []) lg = Chef::Provider::Package::Yum::RPMPackage.new(larger, "0:0.0.1-1", "x86_64", []) @@ -1310,12 +1310,12 @@ describe Chef::Provider::Package::Yum::RPMPackage do it "should sort alphabetically based on package arch" do [ - [ "i386", - "x86_64" ], - [ "i386", - "noarch" ], - [ "noarch", - "x86_64" ], + %w{i386 +x86_64}, + %w{i386 +noarch}, + %w{noarch +x86_64}, ].each do |smaller, larger| sm = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "0:0.0.1-1", smaller, []) lg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "0:0.0.1-1", larger, []) @@ -2113,7 +2113,7 @@ describe "Chef::Provider::Package::Yum - Multi" do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::Package.new(["cups", "vim"]) + @new_resource = Chef::Resource::Package.new(%w{cups vim}) @status = double("Status", :exitstatus => 0) @yum_cache = double( "Chef::Provider::Yum::YumCache", @@ -2142,7 +2142,7 @@ describe "Chef::Provider::Package::Yum - Multi" do it "should set the current resources package name to the new resources package name" do @provider.load_current_resource - expect(@provider.current_resource.package_name).to eq(["cups", "vim"]) + expect(@provider.current_resource.package_name).to eq(%w{cups vim}) end it "should set the installed version to nil on the current resource if no installed package" do @@ -2196,9 +2196,9 @@ describe "Chef::Provider::Package::Yum - Multi" do expect(Chef::Log).to receive(:debug).exactly(1).times.with(%r{candidate version: \["1.2.4-11.18.el5_2.3", "24.4"\]}) expect(Chef::Log).to receive(:debug).at_least(2).times.with(%r{checking yum info}) @provider.load_current_resource - expect(@provider.new_resource.package_name).to eq(["cups", "emacs"]) + expect(@provider.new_resource.package_name).to eq(%w{cups emacs}) expect(@provider.new_resource.version).to eq(["1.2.4-11.18.el5_2.3", "24.4"]) - expect(@provider.send(:package_name_array)).to eq(["cups", "emacs"]) + expect(@provider.send(:package_name_array)).to eq(%w{cups emacs}) expect(@provider.send(:new_version_array)).to eq(["1.2.4-11.18.el5_2.3", "24.4"]) end end @@ -2213,7 +2213,7 @@ describe "Chef::Provider::Package::Yum - Multi" do expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-1.2.4-11.19.el5 vim-1.0" ) - @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"]) + @provider.install_package(%w{cups vim}, ["1.2.4-11.19.el5", "1.0"]) end it "should run yum install with the package name, version and arch" do @@ -2223,7 +2223,7 @@ describe "Chef::Provider::Package::Yum - Multi" do expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-1.2.4-11.19.el5.i386 vim-1.0.i386" ) - @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"]) + @provider.install_package(%w{cups vim}, ["1.2.4-11.19.el5", "1.0"]) end it "installs the package with the options given in the resource" do @@ -2235,7 +2235,7 @@ describe "Chef::Provider::Package::Yum - Multi" do "-d0 -e0 -y --disablerepo epmd install cups-1.2.4-11.19.el5 vim-1.0" ) allow(@new_resource).to receive(:options).and_return("--disablerepo epmd") - @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"]) + @provider.install_package(%w{cups vim}, ["1.2.4-11.19.el5", "1.0"]) end it "should run yum install with the package name and version when name has arch" do @@ -2260,7 +2260,7 @@ describe "Chef::Provider::Package::Yum - Multi" do expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-1.2.4-11.19.el5.x86_64 vim-1.0" ) - @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"]) + @provider.install_package(%w{cups vim}, ["1.2.4-11.19.el5", "1.0"]) end end diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index c998c93d6e..df0a1da9a2 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -254,7 +254,7 @@ describe Chef::Provider::Package::Zypper do shell_out_expectation!( "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0 vim=2.0" ) - provider.install_package(["emacs", "vim"], ["1.0", "2.0"]) + provider.install_package(%w{emacs vim}, ["1.0", "2.0"]) end it "should remove an array of package names and versions" do @@ -262,7 +262,7 @@ describe Chef::Provider::Package::Zypper do shell_out_expectation!( "zypper --non-interactive --no-gpg-checks remove emacs=1.0 vim=2.0" ) - provider.remove_package(["emacs", "vim"], ["1.0", "2.0"]) + provider.remove_package(%w{emacs vim}, ["1.0", "2.0"]) end end end diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb index 50016c623d..9f2b019a84 100644 --- a/spec/unit/provider/package_spec.rb +++ b/spec/unit/provider/package_spec.rb @@ -44,7 +44,7 @@ describe Chef::Provider::Package do end it "raises a Chef::Exceptions::InvalidResourceSpecification if both multipackage and source are provided" do - new_resource.package_name(["a", "b"]) + new_resource.package_name(%w{a b}) new_resource.source("foo") expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::InvalidResourceSpecification) end @@ -563,8 +563,8 @@ describe "Chef::Provider::Package - Multi" do let(:node) { Chef::Node.new } let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } - let(:new_resource) { Chef::Resource::Package.new(["emacs", "vi"]) } - let(:current_resource) { Chef::Resource::Package.new(["emacs", "vi"]) } + let(:new_resource) { Chef::Resource::Package.new(%w{emacs vi}) } + let(:current_resource) { Chef::Resource::Package.new(%w{emacs vi}) } let(:candidate_version) { [ "1.0", "6.2" ] } let(:provider) do provider = Chef::Provider::Package.new(new_resource, run_context) @@ -581,7 +581,7 @@ describe "Chef::Provider::Package - Multi" do it "installs the candidate versions when none are installed" do expect(provider).to receive(:install_package).with( - ["emacs", "vi"], + %w{emacs vi}, ["1.0", "6.2"], ).and_return(true) provider.run_action(:install) @@ -731,7 +731,7 @@ describe "Chef::Provider::Package - Multi" do it "should remove the packages if all are installed" do expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(["emacs", "vi"], nil) + expect(provider).to receive(:remove_package).with(%w{emacs vi}, nil) provider.run_action(:remove) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action @@ -740,7 +740,7 @@ describe "Chef::Provider::Package - Multi" do it "should remove the packages if some are installed" do current_resource.version ["1.0", nil] expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(["emacs", "vi"], nil) + expect(provider).to receive(:remove_package).with(%w{emacs vi}, nil) provider.run_action(:remove) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action @@ -749,7 +749,7 @@ describe "Chef::Provider::Package - Multi" do it "should remove the packages at a specific version if they are installed at that version" do new_resource.version ["1.0", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(["emacs", "vi"], ["1.0", "6.2"]) + expect(provider).to receive(:remove_package).with(%w{emacs vi}, ["1.0", "6.2"]) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -757,7 +757,7 @@ describe "Chef::Provider::Package - Multi" do it "should remove the packages at a specific version any are is installed at that version" do new_resource.version ["0.5", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(["emacs", "vi"], ["0.5", "6.2"]) + expect(provider).to receive(:remove_package).with(%w{emacs vi}, ["0.5", "6.2"]) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -787,7 +787,7 @@ describe "Chef::Provider::Package - Multi" do it "should purge the packages if all are installed" do expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(["emacs", "vi"], nil) + expect(provider).to receive(:purge_package).with(%w{emacs vi}, nil) provider.run_action(:purge) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action @@ -796,7 +796,7 @@ describe "Chef::Provider::Package - Multi" do it "should purge the packages if some are installed" do current_resource.version ["1.0", nil] expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(["emacs", "vi"], nil) + expect(provider).to receive(:purge_package).with(%w{emacs vi}, nil) provider.run_action(:purge) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action @@ -805,7 +805,7 @@ describe "Chef::Provider::Package - Multi" do it "should purge the packages at a specific version if they are installed at that version" do new_resource.version ["1.0", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(["emacs", "vi"], ["1.0", "6.2"]) + expect(provider).to receive(:purge_package).with(%w{emacs vi}, ["1.0", "6.2"]) provider.run_action(:purge) expect(new_resource).to be_updated_by_last_action end @@ -813,7 +813,7 @@ describe "Chef::Provider::Package - Multi" do it "should purge the packages at a specific version any are is installed at that version" do new_resource.version ["0.5", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(["emacs", "vi"], ["0.5", "6.2"]) + expect(provider).to receive(:purge_package).with(%w{emacs vi}, ["0.5", "6.2"]) provider.run_action(:purge) expect(new_resource).to be_updated_by_last_action end diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb index 47f874cc0e..506a1616c5 100644 --- a/spec/unit/provider/service/arch_service_spec.rb +++ b/spec/unit/provider/service/arch_service_spec.rb @@ -180,7 +180,7 @@ RUNNING_PS it "should add chef to DAEMONS array" do allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network)") - expect(@provider).to receive(:update_daemons).with(["network", "chef"]) + expect(@provider).to receive(:update_daemons).with(%w{network chef}) @provider.enable_service() end end diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb index e64aa517e2..68d4d63991 100644 --- a/spec/unit/provider/service/freebsd_service_spec.rb +++ b/spec/unit/provider/service/freebsd_service_spec.rb @@ -495,7 +495,7 @@ EOF allow(provider).to receive(:service_enable_variable_name).and_return("#{new_resource.service_name}_enable") end - [ "start", "reload", "restart", "enable" ].each do |action| + %w{start reload restart enable}.each do |action| it "should raise an exception when the action is #{action}" do provider.define_resource_requirements provider.action = action @@ -503,7 +503,7 @@ EOF end end - [ "stop", "disable" ].each do |action| + %w{stop disable}.each do |action| it "should not raise an error when the action is #{action}" do provider.define_resource_requirements provider.action = action @@ -518,7 +518,7 @@ EOF allow(provider).to receive(:service_enable_variable_name).and_return(nil) end - [ "start", "reload", "restart", "enable" ].each do |action| + %w{start reload restart enable}.each do |action| it "should raise an exception when the action is #{action}" do provider.action = action provider.define_resource_requirements @@ -526,7 +526,7 @@ EOF end end - [ "stop", "disable" ].each do |action| + %w{stop disable}.each do |action| it "should not raise an error when the action is #{action}" do provider.action = action provider.define_resource_requirements @@ -558,7 +558,7 @@ EOF it "should enable the service if it is not enabled and not already specified in the rc.conf file" do allow(current_resource).to receive(:enabled).and_return(false) - expect(provider).to receive(:read_rc_conf).and_return([ "foo", "bar" ]) + expect(provider).to receive(:read_rc_conf).and_return(%w{foo bar}) expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"YES\""]) provider.enable_service() end diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb index 29ebf2da11..12f97431ba 100644 --- a/spec/unit/provider/service/macosx_spec.rb +++ b/spec/unit/provider/service/macosx_spec.rb @@ -58,7 +58,7 @@ describe Chef::Provider::Service::Macosx do </plist> XML - ["Daemon", "Agent"].each do |service_type| + %w{Daemon Agent}.each do |service_type| ["redis-server", "io.redis.redis-server"].each do |service_name| ["10.9", "10.10", "10.11"].each do |platform_version| let(:plist) { "/Library/LaunchDaemons/io.redis.redis-server.plist" } diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb index 7b64214e65..b11015a63a 100644 --- a/spec/unit/provider/service/openbsd_service_spec.rb +++ b/spec/unit/provider/service/openbsd_service_spec.rb @@ -338,7 +338,7 @@ describe Chef::Provider::Service::Openbsd do allow(provider).to receive(:builtin_service_enable_variable_name).and_return("#{new_resource.service_name}_enable") end - [ "start", "reload", "restart", "enable" ].each do |action| + %w{start reload restart enable}.each do |action| it "should raise an exception when the action is #{action}" do provider.define_resource_requirements provider.action = action @@ -346,7 +346,7 @@ describe Chef::Provider::Service::Openbsd do end end - [ "stop", "disable" ].each do |action| + %w{stop disable}.each do |action| it "should not raise an error when the action is #{action}" do provider.define_resource_requirements provider.action = action @@ -360,7 +360,7 @@ describe Chef::Provider::Service::Openbsd do allow(provider).to receive(:builtin_service_enable_variable_name).and_return(nil) end - [ "start", "reload", "restart", "enable" ].each do |action| + %w{start reload restart enable}.each do |action| it "should raise an exception when the action is #{action}" do provider.action = action provider.define_resource_requirements @@ -368,7 +368,7 @@ describe Chef::Provider::Service::Openbsd do end end - [ "stop", "disable" ].each do |action| + %w{stop disable}.each do |action| it "should not raise an error when the action is #{action}" do provider.action = action provider.define_resource_requirements diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index 5d03c688fc..9b878abcd6 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -150,14 +150,14 @@ describe "Chef::Provider::Service::Redhat" do @provider.define_resource_requirements end - [ "start", "reload", "restart", "enable" ].each do |action| + %w{start reload restart enable}.each do |action| it "should raise an error when the action is #{action}" do @provider.action = action expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end end - [ "stop", "disable" ].each do |action| + %w{stop disable}.each do |action| it "should not raise an error when the action is #{action}" do @provider.action = action expect { @provider.process_resource_requirements }.not_to raise_error diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb index 4f7b4c256c..0f936c8f11 100644 --- a/spec/unit/provider/template/content_spec.rb +++ b/spec/unit/provider/template/content_spec.rb @@ -91,7 +91,7 @@ describe Chef::Provider::Template::Content do it "returns a tempfile in the tempdir when :file_staging_uses_destdir is not set" do Chef::Config[:file_staging_uses_destdir] = false - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be true + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be true expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be false end @@ -107,7 +107,7 @@ describe Chef::Provider::Template::Content do it "returns a tempfile in the tempdir when :file_deployment_uses_destdir is set to :auto" do Chef::Config[:file_staging_uses_destdir] = :auto - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be true + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be true expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be false end @@ -117,7 +117,7 @@ describe Chef::Provider::Template::Content do end it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be true + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be true expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be false end end diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb index 0794ce0328..1cdbe462f7 100644 --- a/spec/unit/provider/user_spec.rb +++ b/spec/unit/provider/user_spec.rb @@ -192,13 +192,13 @@ describe Chef::Provider::User do describe "compare_user" do let(:mapping) { { - "username" => ["adam", "Adam"], + "username" => %w{adam Adam}, "comment" => ["Adam Jacob", "adam jacob"], "uid" => [1000, 1001], "gid" => [1000, 1001], "home" => ["/home/adam", "/Users/adam"], "shell" => ["/usr/bin/zsh", "/bin/bash"], - "password" => ["abcd", "12345"], + "password" => %w{abcd 12345}, } } diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb index 8f43d0cbca..f9b4bd9b9c 100644 --- a/spec/unit/recipe_spec.rb +++ b/spec/unit/recipe_spec.rb @@ -100,7 +100,7 @@ describe Chef::Recipe do end end - expect(run_context.resource_collection.map { |r| r.name }).to eql(["monkey", "dog", "cat"]) + expect(run_context.resource_collection.map { |r| r.name }).to eql(%w{monkey dog cat}) end it "should return the new resource after creating it" do diff --git a/spec/unit/resource/chocolatey_package_spec.rb b/spec/unit/resource/chocolatey_package_spec.rb index dfd6a3e679..e43803a65f 100644 --- a/spec/unit/resource/chocolatey_package_spec.rb +++ b/spec/unit/resource/chocolatey_package_spec.rb @@ -42,13 +42,13 @@ describe Chef::Resource::ChocolateyPackage do end it "the package_name setter should accept arrays" do - resource.package_name(["git", "unzip"]) - expect(resource.package_name).to eql(["git", "unzip"]) + resource.package_name(%w{git unzip}) + expect(resource.package_name).to eql(%w{git unzip}) end it "the name should accept arrays" do - resource = Chef::Resource::ChocolateyPackage.new(["git", "unzip"]) - expect(resource.package_name).to eql(["git", "unzip"]) + resource = Chef::Resource::ChocolateyPackage.new(%w{git unzip}) + expect(resource.package_name).to eql(%w{git unzip}) end it "the default version should be nil" do diff --git a/spec/unit/resource/cron_spec.rb b/spec/unit/resource/cron_spec.rb index 037bbaf733..6e867b75e1 100644 --- a/spec/unit/resource/cron_spec.rb +++ b/spec/unit/resource/cron_spec.rb @@ -106,19 +106,19 @@ describe Chef::Resource::Cron do end it "should allow * for all time and date values" do - [ "minute", "hour", "day", "month", "weekday" ].each do |x| + %w{minute hour day month weekday}.each do |x| expect(@resource.send(x, "*")).to eql("*") end end it "should allow ranges for all time and date values" do - [ "minute", "hour", "day", "month", "weekday" ].each do |x| + %w{minute hour day month weekday}.each do |x| expect(@resource.send(x, "1-2,5")).to eql("1-2,5") end end it "should have a default value of * for all time and date values" do - [ "minute", "hour", "day", "month", "weekday" ].each do |x| + %w{minute hour day month weekday}.each do |x| expect(@resource.send(x)).to eql("*") end end @@ -153,7 +153,7 @@ describe Chef::Resource::Cron do end it "should convert integer schedule values to a string" do - [ "minute", "hour", "day", "month", "weekday" ].each do |x| + %w{minute hour day month weekday}.each do |x| expect(@resource.send(x, 5)).to eql("5") end end diff --git a/spec/unit/resource/dsc_script_spec.rb b/spec/unit/resource/dsc_script_spec.rb index 55473e3146..4892049884 100644 --- a/spec/unit/resource/dsc_script_spec.rb +++ b/spec/unit/resource/dsc_script_spec.rb @@ -77,7 +77,7 @@ describe Chef::Resource::DscScript do context "when calling imports" do let(:module_name) { "FooModule" } let(:module_name_b) { "BarModule" } - let(:dsc_resources) { ["ResourceA", "ResourceB"] } + let(:dsc_resources) { %w{ResourceA ResourceB} } it "allows an arbitrary number of resources to be set for a module to be set" do dsc_test_resource.imports module_name, *dsc_resources diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb index 7cfec23365..2bb4b57e26 100644 --- a/spec/unit/resource/group_spec.rb +++ b/spec/unit/resource/group_spec.rb @@ -111,8 +111,8 @@ describe Chef::Resource::Group, "members" do end it "(#{method}) should allow an array" do - @resource.send(method, [ "aj", "adam" ]) - expect(@resource.send(method)).to eql( ["aj", "adam"] ) + @resource.send(method, %w{aj adam}) + expect(@resource.send(method)).to eql( %w{aj adam} ) end it "(#{method}) should not allow a hash" do @@ -142,12 +142,12 @@ describe Chef::Resource::Group, "append" do describe "when it has members" do before do @resource.group_name("pokemon") - @resource.members(["blastoise", "pikachu"]) + @resource.members(%w{blastoise pikachu}) end it "describes its state" do state = @resource.state - expect(state[:members]).to eql(["blastoise", "pikachu"]) + expect(state[:members]).to eql(%w{blastoise pikachu}) end it "returns the group name as its identity" do diff --git a/spec/unit/resource/mdadm_spec.rb b/spec/unit/resource/mdadm_spec.rb index 6a446a2815..8eceed733e 100644 --- a/spec/unit/resource/mdadm_spec.rb +++ b/spec/unit/resource/mdadm_spec.rb @@ -82,14 +82,14 @@ describe Chef::Resource::Mdadm do describe "when it has devices, level, and chunk" do before do @resource.raid_device("raider") - @resource.devices(["device1", "device2"]) + @resource.devices(%w{device1 device2}) @resource.level(1) @resource.chunk(42) end it "describes its state" do state = @resource.state - expect(state[:devices]).to eql(["device1", "device2"]) + expect(state[:devices]).to eql(%w{device1 device2}) expect(state[:level]).to eq(1) expect(state[:chunk]).to eq(42) end diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb index ea20511990..188eaa67d6 100644 --- a/spec/unit/resource/mount_spec.rb +++ b/spec/unit/resource/mount_spec.rb @@ -87,19 +87,19 @@ describe Chef::Resource::Mount do end it "should allow options attribute as an array" do - @resource.options ["ro", "nosuid"] + @resource.options %w{ro nosuid} expect(@resource.options).to be_a_kind_of(Array) end it "should allow options to be sent as a delayed evaluator" do - @resource.options Chef::DelayedEvaluator.new { ["rw", "noexec"] } - expect(@resource.options).to eql(["rw", "noexec"]) + @resource.options Chef::DelayedEvaluator.new { %w{rw noexec} } + expect(@resource.options).to eql(%w{rw noexec}) end it "should allow options to be sent as a delayed evaluator, and convert to array" do @resource.options Chef::DelayedEvaluator.new { "rw,noexec" } expect(@resource.options).to be_a_kind_of(Array) - expect(@resource.options).to eql(["rw", "noexec"]) + expect(@resource.options).to eql(%w{rw noexec}) end it "should accept true for mounted" do diff --git a/spec/unit/resource/resource_notification_spec.rb b/spec/unit/resource/resource_notification_spec.rb index 5bb3ba95ea..e141e01fcf 100644 --- a/spec/unit/resource/resource_notification_spec.rb +++ b/spec/unit/resource/resource_notification_spec.rb @@ -100,7 +100,7 @@ describe Chef::Resource::Notification do end it "raises a RuntimeError if you try to reference multiple resources" do - notification.resource = { :cat => ["keyboard_cat", "cheez_cat"] } + notification.resource = { :cat => %w{keyboard_cat cheez_cat} } @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") @cheez_cat = Chef::Resource::Cat.new("cheez_cat") @resource_collection = Chef::ResourceCollection.new @@ -112,7 +112,7 @@ describe Chef::Resource::Notification do end it "raises a RuntimeError if you try to reference multiple notifying resources" do - notification.notifying_resource = { :cat => ["long_cat", "cheez_cat"] } + notification.notifying_resource = { :cat => %w{long_cat cheez_cat} } @long_cat = Chef::Resource::Cat.new("long_cat") @cheez_cat = Chef::Resource::Cat.new("cheez_cat") @resource_collection = Chef::ResourceCollection.new diff --git a/spec/unit/resource_collection/resource_set_spec.rb b/spec/unit/resource_collection/resource_set_spec.rb index 2f8ba0e1aa..20f6f70911 100644 --- a/spec/unit/resource_collection/resource_set_spec.rb +++ b/spec/unit/resource_collection/resource_set_spec.rb @@ -84,7 +84,7 @@ describe Chef::ResourceCollection::ResourceSet do it "should find a resource by type symbol and array of names with custom names" do collection.insert_as(zen_master, :zzz, "name1") collection.insert_as(zen_master2, :zzz, "name2") - check_by_names(collection.find( :zzz => ["name1", "name2"]), zen_master_name, zen_master2_name) + check_by_names(collection.find( :zzz => %w{name1 name2}), zen_master_name, zen_master2_name) end it "should find resources of multiple kinds (:zen_master => a, :zen_follower => b)" do @@ -98,7 +98,7 @@ describe Chef::ResourceCollection::ResourceSet do collection.insert_as(zen_master, :zzz, "name1") collection.insert_as(zen_master2, :zzz, "name2") collection.insert_as(zen_follower, :yyy, "name3") - check_by_names(collection.find(:zzz => ["name1", "name2"], :yyy => ["name3"]), + check_by_names(collection.find(:zzz => %w{name1 name2}, :yyy => ["name3"]), zen_master_name, zen_follower_name, zen_master2_name) end diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb index 178d58b303..a6ad895c51 100644 --- a/spec/unit/resource_collection_spec.rb +++ b/spec/unit/resource_collection_spec.rb @@ -171,7 +171,7 @@ describe Chef::ResourceCollection do it "should find a resource by symbol and array of names (:zen_master => [a,b])" do load_up_resources - results = rc.resources(:zen_master => [ "monkey", "dog" ]) + results = rc.resources(:zen_master => %w{monkey dog}) expect(results.length).to eql(2) check_by_names(results, "monkey", "dog") end diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 1297ed6f04..1c3a825ea1 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -205,7 +205,7 @@ describe Chef::Resource do end it "coerces arrays to names" do - expect(resource.name ["a", "b"]).to eql("a, b") + expect(resource.name %w{a b}).to eql("a, b") end it "should coerce objects to a string" do @@ -270,7 +270,7 @@ describe Chef::Resource do end it "notifies a resource with an array for its name via its prettified string name" do - run_context.resource_collection << Chef::Resource::ZenMaster.new(["coffee", "tea"]) + run_context.resource_collection << Chef::Resource::ZenMaster.new(%w{coffee tea}) resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee, tea") expect(resource.delayed_notifications.detect { |e| e.resource.name == "coffee, tea" && e.action == :reload }).not_to be_nil end @@ -859,9 +859,9 @@ describe Chef::Resource do it "adds mappings for multiple platforms" do expect(Chef.resource_handler_map).to receive(:set).with( - :energy, Chef::Resource::Klz, { platform: ["autobots", "decepticons"] } + :energy, Chef::Resource::Klz, { platform: %w{autobots decepticons} } ) - klz.provides :energy, platform: ["autobots", "decepticons"] + klz.provides :energy, platform: %w{autobots decepticons} end it "adds mappings for all platforms" do diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb index 1ff76d7207..1bbbc4c7b0 100644 --- a/spec/unit/role_spec.rb +++ b/spec/unit/role_spec.rb @@ -85,12 +85,12 @@ describe Chef::Role do describe "using the old #recipes API" do it "should let you set the recipe array" do - expect(@role.recipes([ "one", "two" ])).to eq([ "one", "two" ]) + expect(@role.recipes(%w{one two})).to eq(%w{one two}) end it "should let you return the recipe array" do - @role.recipes([ "one", "two" ]) - expect(@role.recipes).to eq([ "one", "two" ]) + @role.recipes(%w{one two}) + expect(@role.recipes).to eq(%w{one two}) end it "should not list roles in the recipe array" do diff --git a/spec/unit/run_list/run_list_expansion_spec.rb b/spec/unit/run_list/run_list_expansion_spec.rb index b0cb978bb1..e1af112dbf 100644 --- a/spec/unit/run_list/run_list_expansion_spec.rb +++ b/spec/unit/run_list/run_list_expansion_spec.rb @@ -119,7 +119,7 @@ describe Chef::RunList::RunListExpansion do it "has the list of all roles applied" do # this is the correct order, but 1.8 hash order is not stable - expect(@expansion.roles).to match_array(["rage", "mollusk"]) + expect(@expansion.roles).to match_array(%w{rage mollusk}) end end diff --git a/spec/unit/run_list/versioned_recipe_list_spec.rb b/spec/unit/run_list/versioned_recipe_list_spec.rb index 2b1c6edebc..8bbd816956 100644 --- a/spec/unit/run_list/versioned_recipe_list_spec.rb +++ b/spec/unit/run_list/versioned_recipe_list_spec.rb @@ -43,23 +43,23 @@ describe Chef::RunList::VersionedRecipeList do it "should append the recipe to the end of the list" do list.add_recipe "rails" - expect(list).to eq(["apt", "god", "apache2", "rails"]) + expect(list).to eq(%w{apt god apache2 rails}) end it "should not duplicate entries" do list.add_recipe "apt" - expect(list).to eq(["apt", "god", "apache2"]) + expect(list).to eq(%w{apt god apache2}) end it "should allow you to specify a version" do list.add_recipe "rails", "1.0.0" - expect(list).to eq(["apt", "god", "apache2", "rails"]) + expect(list).to eq(%w{apt god apache2 rails}) expect(list.with_versions).to include({ :name => "rails", :version => "1.0.0" }) end it "should allow you to specify a version for a recipe that already exists" do list.add_recipe "apt", "1.2.3" - expect(list).to eq(["apt", "god", "apache2"]) + expect(list).to eq(%w{apt god apache2}) expect(list.with_versions).to include({ :name => "apt", :version => "1.2.3" }) end diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb index 6d17e654cd..0dcd349ced 100644 --- a/spec/unit/run_list_spec.rb +++ b/spec/unit/run_list_spec.rb @@ -95,7 +95,7 @@ describe Chef::RunList do it "should believe a RunList is equal to an array named after it's members" do @run_list << "foo" @run_list << "baz" - expect(@run_list).to eq([ "foo", "baz" ]) + expect(@run_list).to eq(%w{foo baz}) end end @@ -199,7 +199,7 @@ describe Chef::RunList do it "should load the role from the chef server" do #@rest.should_receive(:get).with("roles/stubby") expansion = @run_list.expand("_default", "server") - expect(expansion.recipes).to eq(["one", "two", "kitty"]) + expect(expansion.recipes).to eq(%w{one two kitty}) end it "should default to expanding from the server" do diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb index 9652d69783..b23f0277d6 100644 --- a/spec/unit/search/query_spec.rb +++ b/spec/unit/search/query_spec.rb @@ -30,7 +30,7 @@ describe Chef::Search::Query do let(:filter_hash) { { "env" => [ "chef_environment" ], - "ruby_plat" => [ "languages", "ruby", "platform" ], + "ruby_plat" => %w{languages ruby platform}, } } let(:response) { diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb index 3454e07692..8bc68ec160 100644 --- a/spec/unit/util/backup_spec.rb +++ b/spec/unit/util/backup_spec.rb @@ -76,7 +76,7 @@ describe Chef::Util::Backup do end it "should keep only 1 backup copy" do - expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b", "c"]) + expect(@backup).to receive(:sorted_backup_files).and_return(%w{a b c}) expect(@backup).to receive(:delete_backup).with("b") expect(@backup).to receive(:delete_backup).with("c") @backup.backup! @@ -89,13 +89,13 @@ describe Chef::Util::Backup do end it "should not delete anything if we only have one other backup" do - expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b"]) + expect(@backup).to receive(:sorted_backup_files).and_return(%w{a b}) expect(@backup).not_to receive(:delete_backup) @backup.backup! end it "should keep only 2 backup copies" do - expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b", "c", "d"]) + expect(@backup).to receive(:sorted_backup_files).and_return(%w{a b c d}) expect(@backup).to receive(:delete_backup).with("c") expect(@backup).to receive(:delete_backup).with("d") @backup.backup! diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb index d59423e1e5..12f62deb5a 100644 --- a/spec/unit/util/dsc/configuration_generator_spec.rb +++ b/spec/unit/util/dsc/configuration_generator_spec.rb @@ -151,7 +151,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do allow(File).to receive(:join) do |a, b| [a, b].join("++") end - allow(Dir).to receive(:entries).with("tmp++hello") { ["f1", "f2", "f3"] } + allow(Dir).to receive(:entries).with("tmp++hello") { %w{f1 f2 f3} } expect(conf_man.send(:find_configuration_document, "hello")).to be_nil end end @@ -179,12 +179,12 @@ describe Chef::Util::DSC::ConfigurationGenerator do end it "should import specific resources when a module has list without * that is not empty" do - dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => ["FooResource", "BarResource"] }) + dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => %w{FooResource BarResource} }) expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/) end it "should import multiple modules with multiple import statements" do - dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => ["FooResource", "BarResource"], "BazModule" => [] }) + dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => %w{FooResource BarResource}, "BazModule" => [] }) expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/) expect(dsc).to match(/Import-DscResource -ModuleName BazModule\s*\n/) end diff --git a/spec/unit/util/dsc/lcm_output_parser_spec.rb b/spec/unit/util/dsc/lcm_output_parser_spec.rb index 69eb8724ea..d59497de6f 100644 --- a/spec/unit/util/dsc/lcm_output_parser_spec.rb +++ b/spec/unit/util/dsc/lcm_output_parser_spec.rb @@ -24,11 +24,11 @@ describe Chef::Util::DSC::LocalConfigurationManager::Parser do str = <<-EOF EOF - expect { Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) }.to raise_error(Chef::Exceptions::LCMParser) + expect { Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str) }.to raise_error(Chef::Exceptions::LCMParser) end it "raises an exception for a nil input" do - expect { Chef::Util::DSC::LocalConfigurationManager::Parser::parse(nil) }.to raise_error(Chef::Exceptions::LCMParser) + expect { Chef::Util::DSC::LocalConfigurationManager::Parser.parse(nil) }.to raise_error(Chef::Exceptions::LCMParser) end end @@ -40,7 +40,7 @@ logtype: [machinename]: LCM: [ Start Resource ] [name] logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] EOF - resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) + resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str) expect(resources.length).to eq(1) expect(resources[0].name).to eq("[name]") end @@ -54,7 +54,7 @@ logtype: [machinename]: LCM: [ End Set ] [name] logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] EOF - resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) + resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str) expect(resources[0].changes_state?).to be_truthy end @@ -68,7 +68,7 @@ logtype: [machinename]: LCM: [ End Set ] [name] logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] EOF - resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) + resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str) expect(resources[0].change_log).to match_array(["[name]", "[message]", "[name]"]) end @@ -80,7 +80,7 @@ logtype: [machinename]: LCM: [ Skip Set ] [name] logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] EOF - resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) + resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str) expect(resources[0].changes_state?).to be_falsey end @@ -92,7 +92,7 @@ logtype: [machinename]: LCM: [ Skip Set ] [name] logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] EOF - resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) + resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str) expect(resources[0].change_log).to be_empty end end @@ -114,7 +114,7 @@ logtype: [machinename]: LCM: [ End Set ] logtype: [machinename]: LCM: [ End Set ] EOF - resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) + resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str) expect(resources[0].changes_state?).to be_falsey expect(resources[1].changes_state?).to be_truthy end @@ -135,7 +135,7 @@ logtype: [machinename]: LCM: [ End Resource ] logtype: [machinename]: LCM: [ End Set ] EOF - resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) + resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str) expect(resources[0].changes_state?).to be_falsey expect(resources[1].changes_state?).to be_truthy end @@ -154,7 +154,7 @@ logtype: [machinename]: LCM: [ End Set ] logtype: [machinename]: LCM: [ End Resource ] logtype: [machinename]: LCM: [ End Set ] EOF - resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) + resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str) expect(resources[0].changes_state?).to be_truthy expect(resources[0].name).to eql("[name]") expect(resources[1].changes_state?).to be_truthy diff --git a/spec/unit/util/editor_spec.rb b/spec/unit/util/editor_spec.rb index 9db7e85931..7a0ec91533 100644 --- a/spec/unit/util/editor_spec.rb +++ b/spec/unit/util/editor_spec.rb @@ -16,7 +16,7 @@ describe Chef::Util::Editor do end subject(:editor) { described_class.new(input_lines) } - let(:input_lines) { ["one", "two", "two", "three"] } + let(:input_lines) { %w{one two two three} } describe '#append_line_after' do context "when there is no match" do @@ -34,7 +34,7 @@ describe Chef::Util::Editor do it("returns the number of added lines") { is_expected.to eq(2) } it "adds a line after each match" do execute - expect(editor.lines).to be == ["one", "two", "new", "two", "new", "three"] + expect(editor.lines).to be == %w{one two new two new three} end end @@ -51,7 +51,7 @@ describe Chef::Util::Editor do it("returns the number of added lines") { is_expected.to eq(1) } it "adds a line to the end" do execute - expect(editor.lines).to be == ["one", "two", "two", "three", "new"] + expect(editor.lines).to be == %w{one two two three new} end end @@ -86,7 +86,7 @@ describe Chef::Util::Editor do it("returns the number of removed lines") { is_expected.to eq(2) } it "removes the matching lines" do execute - expect(editor.lines).to be == ["one", "three"] + expect(editor.lines).to be == %w{one three} end end @@ -112,14 +112,14 @@ describe Chef::Util::Editor do it("returns the number of changed lines") { is_expected.to eq(2) } it "replaces the matching portions" do execute - expect(editor.lines).to be == ["one", "new", "new", "three"] + expect(editor.lines).to be == %w{one new new three} end end it "matches a Regexp" do expect(editor.replace(/^ee/, "new")).to be == 0 expect(editor.replace(/ee$/, "new")).to be == 1 - expect(editor.lines).to be == ["one", "two", "two", "thrnew"] + expect(editor.lines).to be == %w{one two two thrnew} end end @@ -139,14 +139,14 @@ describe Chef::Util::Editor do it("returns the number of replaced lines") { is_expected.to eq(2) } it "replaces the matching line" do execute - expect(editor.lines).to be == ["one", "new", "new", "three"] + expect(editor.lines).to be == %w{one new new three} end end it "matches a Regexp" do expect(editor.replace_lines(/^ee/, "new")).to be == 0 expect(editor.replace_lines(/ee$/, "new")).to be == 1 - expect(editor.lines).to be == ["one", "two", "two", "new"] + expect(editor.lines).to be == %w{one two two new} end end end |