diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-07-02 10:25:16 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2018-07-02 10:25:16 -0700 |
commit | 35603c7ce1bd3ccf35334ed65152140f0ecaf080 (patch) | |
tree | 452c84ce196ce00d672c71a8fa65f86c5a074fac /spec | |
parent | eda2808dce8146bfdb308dd658b1dd565df3562b (diff) | |
download | chef-35603c7ce1bd3ccf35334ed65152140f0ecaf080.tar.gz |
fix Style/HashSyntax
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
297 files changed, 2409 insertions, 2409 deletions
diff --git a/spec/functional/audit/rspec_formatter_spec.rb b/spec/functional/audit/rspec_formatter_spec.rb index 209694ae70..f30f7bbd8a 100644 --- a/spec/functional/audit/rspec_formatter_spec.rb +++ b/spec/functional/audit/rspec_formatter_spec.rb @@ -30,7 +30,7 @@ describe Chef::Audit::RspecFormatter do let(:events) { double("events").as_null_object } let(:audits) { {} } - let(:run_context) { instance_double(Chef::RunContext, :events => events, :audits => audits) } + let(:run_context) { instance_double(Chef::RunContext, events: events, audits: audits) } let(:runner) { Chef::Audit::Runner.new(run_context) } let(:output) { double("output") } diff --git a/spec/functional/audit/runner_spec.rb b/spec/functional/audit/runner_spec.rb index 54f014e28f..f80256fa5c 100644 --- a/spec/functional/audit/runner_spec.rb +++ b/spec/functional/audit/runner_spec.rb @@ -49,7 +49,7 @@ describe Chef::Audit::Runner do describe "#run" do let(:audits) { {} } - let(:run_context) { instance_double(Chef::RunContext, :events => events, :audits => audits) } + let(:run_context) { instance_double(Chef::RunContext, events: events, audits: audits) } let(:control_group_name) { "control_group_name" } # Set cookbook path to include our parent, so that it will recognize this diff --git a/spec/functional/dsl/reboot_pending_spec.rb b/spec/functional/dsl/reboot_pending_spec.rb index c7a93c6822..ff7fd574b1 100644 --- a/spec/functional/dsl/reboot_pending_spec.rb +++ b/spec/functional/dsl/reboot_pending_spec.rb @@ -42,19 +42,19 @@ describe Chef::DSL::RebootPending, :windows_only do describe 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations' do let(:reg_key) { 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager' } - let(:original_set) { registry.value_exists?(reg_key, { :name => "PendingFileRenameOperations" }) } + let(:original_set) { registry.value_exists?(reg_key, { name: "PendingFileRenameOperations" }) } it "returns true if the registry value exists" do skip "found existing registry key" if original_set registry.set_value(reg_key, - { :name => "PendingFileRenameOperations", :type => :multi_string, :data => ['\??\C:\foo.txt|\??\C:\bar.txt'] }) + { name: "PendingFileRenameOperations", type: :multi_string, data: ['\??\C:\foo.txt|\??\C:\bar.txt'] }) expect(recipe.reboot_pending?).to be_truthy end after do unless original_set - registry.delete_value(reg_key, { :name => "PendingFileRenameOperations" }) + registry.delete_value(reg_key, { name: "PendingFileRenameOperations" }) end end end diff --git a/spec/functional/dsl/registry_helper_spec.rb b/spec/functional/dsl/registry_helper_spec.rb index d90d5090e4..7a56ee11cf 100644 --- a/spec/functional/dsl/registry_helper_spec.rb +++ b/spec/functional/dsl/registry_helper_spec.rb @@ -42,7 +42,7 @@ describe Chef::Resource::RegistryKey, :windows_only do end it "returns true if registry has specified value" do values = @resource.registry_get_values("HKCU\\Software\\Root") - expect(values.include?({ :name => "RootType1", :type => :string, :data => "fibrous" })).to eq(true) + expect(values.include?({ name: "RootType1", type: :string, data: "fibrous" })).to eq(true) end it "returns true if specified registry_has_subkey" do expect(@resource.registry_has_subkeys?("HKCU\\Software\\Root")).to eq(true) @@ -52,10 +52,10 @@ describe Chef::Resource::RegistryKey, :windows_only do expect(subkeys.include?("Branch")).to eq(true) end it "returns true if registry_value_exists" do - expect(@resource.registry_value_exists?("HKCU\\Software\\Root", { :name => "RootType1", :type => :string, :data => "fibrous" })).to eq(true) + expect(@resource.registry_value_exists?("HKCU\\Software\\Root", { name: "RootType1", type: :string, data: "fibrous" })).to eq(true) end it "returns true if data_value_exists" do - expect(@resource.registry_data_exists?("HKCU\\Software\\Root", { :name => "RootType1", :type => :string, :data => "fibrous" })).to eq(true) + expect(@resource.registry_data_exists?("HKCU\\Software\\Root", { name: "RootType1", type: :string, data: "fibrous" })).to eq(true) end end end diff --git a/spec/functional/http/simple_spec.rb b/spec/functional/http/simple_spec.rb index fcabd3f308..562c037bb0 100644 --- a/spec/functional/http/simple_spec.rb +++ b/spec/functional/http/simple_spec.rb @@ -24,7 +24,7 @@ describe Chef::HTTP::Simple do include ChefHTTPShared let(:http_client) { described_class.new(source) } - let(:http_client_disable_gzip) { described_class.new(source, { :disable_gzip => true } ) } + let(:http_client_disable_gzip) { described_class.new(source, { disable_gzip: true } ) } before(:all) do start_tiny_server(RequestTimeout: 1) diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb index 3defbe781f..95e7b6454c 100644 --- a/spec/functional/knife/ssh_spec.rb +++ b/spec/functional/knife/ssh_spec.rb @@ -301,7 +301,7 @@ describe Chef::Knife::Ssh do end it "uses the ssh_gateway_identity file" do - expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { :keys => File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), :keys_only => true }) + expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true }) @knife.run expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa") end @@ -315,7 +315,7 @@ describe Chef::Knife::Ssh do end it "uses the ssh_gateway_identity file" do - expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { :keys => File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), :keys_only => true }) + expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true }) @knife.run expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa") end diff --git a/spec/functional/mixin/shell_out_spec.rb b/spec/functional/mixin/shell_out_spec.rb index 48a34762c6..b3e9bf796d 100644 --- a/spec/functional/mixin/shell_out_spec.rb +++ b/spec/functional/mixin/shell_out_spec.rb @@ -40,9 +40,9 @@ describe Chef::Mixin::ShellOut do describe "when environment['LC_ALL'] is set" do it "should use the option's setting" do cmd = if windows? - shell_out_with_systems_locale("echo %LC_ALL%", :environment => { "LC_ALL" => "POSIX" }) + shell_out_with_systems_locale("echo %LC_ALL%", environment: { "LC_ALL" => "POSIX" }) else - shell_out_with_systems_locale("echo $LC_ALL", :environment => { "LC_ALL" => "POSIX" }) + shell_out_with_systems_locale("echo $LC_ALL", environment: { "LC_ALL" => "POSIX" }) end expect(cmd.stdout.chomp).to eq "POSIX" @@ -66,9 +66,9 @@ describe Chef::Mixin::ShellOut do describe "when environment['LC_ALL'] is set" do it "should use the option's setting" do cmd = if windows? - shell_out("echo %LC_ALL%", :environment => { "LC_ALL" => "POSIX" }, default_env: false) + shell_out("echo %LC_ALL%", environment: { "LC_ALL" => "POSIX" }, default_env: false) else - shell_out("echo $LC_ALL", :environment => { "LC_ALL" => "POSIX" }, default_env: false) + shell_out("echo $LC_ALL", environment: { "LC_ALL" => "POSIX" }, default_env: false) end expect(cmd.stdout.chomp).to eq "POSIX" diff --git a/spec/functional/rebooter_spec.rb b/spec/functional/rebooter_spec.rb index 36961593b0..8e5b23f86b 100644 --- a/spec/functional/rebooter_spec.rb +++ b/spec/functional/rebooter_spec.rb @@ -22,9 +22,9 @@ describe Chef::Platform::Rebooter do let(:reboot_info) do { - :delay_mins => 5, - :requested_by => "reboot resource functional test", - :reason => "rebooter spec test", + delay_mins: 5, + requested_by: "reboot resource functional test", + reason: "rebooter spec test", } end @@ -44,9 +44,9 @@ describe Chef::Platform::Rebooter do let(:expected) do { - :windows => "#{ENV['SYSTEMROOT']}/System32/shutdown.exe /r /t 300 /c \"rebooter spec test\"", - :linux => 'shutdown -r +5 "rebooter spec test" &', - :solaris => 'shutdown -i6 -g5 -y "rebooter spec test" &', + windows: "#{ENV['SYSTEMROOT']}/System32/shutdown.exe /r /t 300 /c \"rebooter spec test\"", + linux: 'shutdown -r +5 "rebooter spec test" &', + solaris: 'shutdown -i6 -g5 -y "rebooter spec test" &', } end diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb index bf50046b03..3241a1b3cb 100755 --- a/spec/functional/resource/aixinit_service_spec.rb +++ b/spec/functional/resource/aixinit_service_spec.rb @@ -59,7 +59,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do let(:new_resource) do new_resource = Chef::Resource::Service.new("chefinittest", run_context) new_resource.provider Chef::Provider::Service::AixInit - new_resource.supports({ :status => true, :restart => true, :reload => true }) + new_resource.supports({ status: true, restart: true, reload: true }) new_resource end diff --git a/spec/functional/resource/apt_package_spec.rb b/spec/functional/resource/apt_package_spec.rb index c032bafc92..c1ac51c4b1 100644 --- a/spec/functional/resource/apt_package_spec.rb +++ b/spec/functional/resource/apt_package_spec.rb @@ -50,11 +50,11 @@ module AptServer def apt_server @apt_server ||= WEBrick::HTTPServer.new( - :Port => 9000, - :DocumentRoot => apt_data_dir + "/var/www/apt", + Port: 9000, + DocumentRoot: apt_data_dir + "/var/www/apt", # Make WEBrick quiet, comment out for debug. - :Logger => Logger.new(StringIO.new), - :AccessLog => [ StringIO.new, WEBrick::AccessLog::COMMON_LOG_FORMAT ] + Logger: Logger.new(StringIO.new), + AccessLog: [ StringIO.new, WEBrick::AccessLog::COMMON_LOG_FORMAT ] ) end @@ -86,10 +86,10 @@ module AptServer end end -metadata = { :unix_only => true, - :requires_root => true, - :provider => { :package => Chef::Provider::Package::Apt }, - :arch => "x86_64" # test packages are 64bit +metadata = { unix_only: true, + requires_root: true, + provider: { package: Chef::Provider::Package::Apt }, + arch: "x86_64" # test packages are 64bit } describe Chef::Resource::AptPackage, metadata do @@ -169,13 +169,13 @@ describe Chef::Resource::AptPackage, metadata do it "does nothing for action :remove" do package_resource.run_action(:remove) - shell_out!("dpkg -l chef-integration-test", :returns => [1]) + shell_out!("dpkg -l chef-integration-test", returns: [1]) expect(package_resource).not_to be_updated_by_last_action end it "does nothing for action :purge" do package_resource.run_action(:purge) - shell_out!("dpkg -l chef-integration-test", :returns => [1]) + shell_out!("dpkg -l chef-integration-test", returns: [1]) expect(package_resource).not_to be_updated_by_last_action end @@ -275,7 +275,7 @@ describe Chef::Resource::AptPackage, metadata do r = base_resource r.cookbook_name = "preseed" r.response_file("preseed-template-variables.seed") - r.response_file_variables({ :template_variable => "SUPPORTS VARIABLES" }) + r.response_file_variables({ template_variable: "SUPPORTS VARIABLES" }) r end @@ -300,13 +300,13 @@ describe Chef::Resource::AptPackage, metadata do it "does nothing for action :install" do package_resource.run_action(:install) - shell_out!("dpkg -l chef-integration-test", :returns => [0]) + shell_out!("dpkg -l chef-integration-test", returns: [0]) expect(package_resource).not_to be_updated_by_last_action end it "does nothing for action :upgrade" do package_resource.run_action(:upgrade) - shell_out!("dpkg -l chef-integration-test", :returns => [0]) + shell_out!("dpkg -l chef-integration-test", returns: [0]) expect(package_resource).not_to be_updated_by_last_action end @@ -324,7 +324,7 @@ describe Chef::Resource::AptPackage, metadata do # un chef-integration-test <none> (no description available) def pkg_should_be_removed # will raise if exit code != 0,1 - pkg_check = shell_out!("dpkg -l chef-integration-test", :returns => [0, 1]) + pkg_check = shell_out!("dpkg -l chef-integration-test", returns: [0, 1]) if pkg_check.exitstatus == 0 expect(pkg_check.stdout).to match(/un[\s]+chef-integration-test/) @@ -353,13 +353,13 @@ describe Chef::Resource::AptPackage, metadata do it "does nothing for action :install" do package_resource.run_action(:install) - shell_out!("dpkg -l chef-integration-test", :returns => [0]) + shell_out!("dpkg -l chef-integration-test", returns: [0]) expect(package_resource).not_to be_updated_by_last_action end it "upgrades the package for action :upgrade" do package_resource.run_action(:upgrade) - dpkg_l = shell_out!("dpkg -l chef-integration-test", :returns => [0]) + dpkg_l = shell_out!("dpkg -l chef-integration-test", returns: [0]) expect(dpkg_l.stdout).to match(/chef\-integration\-test[\s]+1\.1\-1/) expect(package_resource).to be_updated_by_last_action end @@ -373,7 +373,7 @@ describe Chef::Resource::AptPackage, metadata do it "upgrades the package for action :install" do package_resource.run_action(:install) - dpkg_l = shell_out!("dpkg -l chef-integration-test", :returns => [0]) + dpkg_l = shell_out!("dpkg -l chef-integration-test", returns: [0]) expect(dpkg_l.stdout).to match(/chef\-integration\-test[\s]+1\.1\-1/) expect(package_resource).to be_updated_by_last_action end diff --git a/spec/functional/resource/bff_spec.rb b/spec/functional/resource/bff_spec.rb index 0b45e097af..9943e821e9 100644 --- a/spec/functional/resource/bff_spec.rb +++ b/spec/functional/resource/bff_spec.rb @@ -20,7 +20,7 @@ require "functional/resource/base" require "chef/mixin/shell_out" # Run the test only for AIX platform. -describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform] != "aix" do +describe Chef::Resource::BffPackage, :requires_root, external: ohai[:platform] != "aix" do include Chef::Mixin::ShellOut let(:new_resource) do diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb index 1bff8bf874..84fe304585 100644 --- a/spec/functional/resource/cron_spec.rb +++ b/spec/functional/resource/cron_spec.rb @@ -105,7 +105,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do end exclude_solaris = %w{solaris opensolaris solaris2 omnios}.include?(ohai[:platform]) - describe "create action with various attributes", :external => exclude_solaris do + describe "create action with various attributes", external: exclude_solaris do def create_and_validate_with_attribute(resource, attribute, value) if ohai[:platform] == "aix" expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron, /Aix cron entry does not support environment variables. Please set them in script and use script in cron./) diff --git a/spec/functional/resource/dnf_package_spec.rb b/spec/functional/resource/dnf_package_spec.rb index 01611ef996..921c48da84 100644 --- a/spec/functional/resource/dnf_package_spec.rb +++ b/spec/functional/resource/dnf_package_spec.rb @@ -21,7 +21,7 @@ require "chef/mixin/shell_out" # run this test only for following platforms. exclude_test = !(%w{rhel fedora}.include?(ohai[:platform_family]) && File.exist?("/usr/bin/dnf")) -describe Chef::Resource::RpmPackage, :requires_root, :external => exclude_test do +describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do include Chef::Mixin::ShellOut def flush_cache diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index ce92c468f0..efda46abbe 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -234,7 +234,7 @@ EOH expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false) dsc_test_resource.run_action(:run) expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true) - expect(dsc_test_resource.registry_value_exists?(test_registry_key, { :name => test_registry_value, :type => :string, :data => test_registry_data })).to eq(true) + expect(dsc_test_resource.registry_value_exists?(test_registry_key, { name: test_registry_value, type: :string, data: test_registry_data })).to eq(true) end it_should_behave_like "a dsc_script resource with configuration affected by cwd" @@ -314,7 +314,7 @@ EOH expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false) dsc_test_resource.run_action(:run) expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true) - expect(dsc_test_resource.registry_value_exists?(test_registry_key, { :name => test_registry_value, :type => :string, :data => test_registry_data })).to eq(true) + expect(dsc_test_resource.registry_value_exists?(test_registry_key, { name: test_registry_value, type: :string, data: test_registry_data })).to eq(true) end end end diff --git a/spec/functional/resource/execute_spec.rb b/spec/functional/resource/execute_spec.rb index 4dd3110629..3ad8762169 100644 --- a/spec/functional/resource/execute_spec.rb +++ b/spec/functional/resource/execute_spec.rb @@ -106,7 +106,7 @@ describe Chef::Resource::Execute do it "guard adds additional values in its :environment and runs" do resource.only_if %{ruby -e 'exit 1 if ENV["SGCE_SECRET"] != "regularsecret"'}, { - :environment => { "SGCE_SECRET" => "regularsecret" }, + environment: { "SGCE_SECRET" => "regularsecret" }, } resource.run_action(:run) expect(resource).to be_updated_by_last_action @@ -114,7 +114,7 @@ describe Chef::Resource::Execute do it "guard adds additional values in its :environment and does not run" do resource.only_if %{ruby -e 'exit 1 if ENV["SGCE_SECRET"] == "regularsecret"'}, { - :environment => { "SGCE_SECRET" => "regularsecret" }, + environment: { "SGCE_SECRET" => "regularsecret" }, } resource.run_action(:run) expect(resource).not_to be_updated_by_last_action @@ -122,7 +122,7 @@ describe Chef::Resource::Execute do it "guard overwrites value with its :environment and runs" do resource.only_if %{ruby -e 'exit 1 if ENV["SAWS_SECRET"] != "regularsecret"'}, { - :environment => { "SAWS_SECRET" => "regularsecret" }, + environment: { "SAWS_SECRET" => "regularsecret" }, } resource.run_action(:run) expect(resource).to be_updated_by_last_action @@ -130,7 +130,7 @@ describe Chef::Resource::Execute do it "guard overwrites value with its :environment and does not runs" do resource.only_if %{ruby -e 'exit 1 if ENV["SAWS_SECRET"] == "regularsecret"'}, { - :environment => { "SAWS_SECRET" => "regularsecret" }, + environment: { "SAWS_SECRET" => "regularsecret" }, } resource.run_action(:run) expect(resource).not_to be_updated_by_last_action diff --git a/spec/functional/resource/file_spec.rb b/spec/functional/resource/file_spec.rb index 0fa1317032..291311f3e2 100644 --- a/spec/functional/resource/file_spec.rb +++ b/spec/functional/resource/file_spec.rb @@ -51,7 +51,7 @@ describe Chef::Resource::File do end let(:resource_with_relative_path) do - create_resource(:use_relative_path => true) + create_resource(use_relative_path: true) end let(:unmanaged_content) do diff --git a/spec/functional/resource/git_spec.rb b/spec/functional/resource/git_spec.rb index 6808898c29..1fa3f54515 100644 --- a/spec/functional/resource/git_spec.rb +++ b/spec/functional/resource/git_spec.rb @@ -22,7 +22,7 @@ require "tmpdir" require "shellwords" # Deploy relies heavily on symlinks, so it doesn't work on windows. -describe Chef::Resource::Git, :requires_git => true do +describe Chef::Resource::Git, requires_git: true do include Chef::Mixin::ShellOut let(:file_cache_path) { Dir.mktmpdir } # Some versions of git complains when the deploy directory is @@ -75,7 +75,7 @@ E before(:each) do Chef::Log.level = :warn # silence git command live streams @old_file_cache_path = Chef::Config[:file_cache_path] - shell_out!("git clone \"#{git_bundle_repo}\" example", :cwd => origin_repo_dir) + shell_out!("git clone \"#{git_bundle_repo}\" example", cwd: origin_repo_dir) File.open("#{origin_repo}/.git/config", "a+") { |f| f.print(git_user_config) } Chef::Config[:file_cache_path] = file_cache_path end @@ -127,10 +127,10 @@ E it "checks out the revision pointed to by the tag commit, not the tag commit itself" do basic_git_resource.run_action(:sync) - head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip expect(head_rev).to eq(v1_commit) # also verify the tag commit itself is what we expect as an extra sanity check - rev = shell_out!("git rev-parse v1.0.0", :cwd => deploy_directory, :returns => [0]).stdout.strip + rev = shell_out!("git rev-parse v1.0.0", cwd: deploy_directory, returns: [0]).stdout.strip expect(rev).to eq(v1_tag) end @@ -138,7 +138,7 @@ E # this used to fail because we didn't resolve the annotated tag # properly to the pointed to commit. basic_git_resource.run_action(:sync) - head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip expect(head_rev).to eq(v1_commit) copy_git_resource.run_action(:sync) @@ -164,14 +164,14 @@ E it "checks out the expected revision ed18" do basic_git_resource.revision rev_foo basic_git_resource.run_action(:sync) - head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip expect(head_rev).to eq(rev_foo) end it "doesn't update if up-to-date" do basic_git_resource.revision rev_foo basic_git_resource.run_action(:sync) - head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip expect(head_rev).to eq(rev_foo) copy_git_resource.revision rev_foo @@ -182,7 +182,7 @@ E it "checks out the expected revision 972d" do basic_git_resource.revision rev_testing basic_git_resource.run_action(:sync) - head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip expect(head_rev).to eq(rev_testing) end end @@ -197,7 +197,7 @@ E it "checks out the expected revision" do basic_git_resource.run_action(:sync) - head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip expect(head_rev).to eq(rev_head) end end @@ -212,7 +212,7 @@ E it "checks out HEAD as the default revision" do basic_git_resource.run_action(:sync) - head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip expect(head_rev).to eq(rev_head) end end @@ -220,7 +220,7 @@ E context "when dealing with a repo with a degenerate tag named 'HEAD'" do before do shell_out!("git tag -m\"degenerate tag\" HEAD ed181b3419b6f489bedab282348162a110d6d3a1", - :cwd => origin_repo) + cwd: origin_repo) end let(:basic_git_resource) do @@ -240,16 +240,16 @@ E it "checks out the (master) HEAD revision and ignores the tag" do basic_git_resource.run_action(:sync) head_rev = shell_out!("git rev-parse HEAD", - :cwd => deploy_directory, - :returns => [0]).stdout.strip + cwd: deploy_directory, + returns: [0]).stdout.strip expect(head_rev).to eq(rev_head) end it "checks out the (master) HEAD revision when no revision is specified (ignores tag)" do git_resource_default_rev.run_action(:sync) head_rev = shell_out!("git rev-parse HEAD", - :cwd => deploy_directory, - :returns => [0]).stdout.strip + cwd: deploy_directory, + returns: [0]).stdout.strip expect(head_rev).to eq(rev_head) end diff --git a/spec/functional/resource/ifconfig_spec.rb b/spec/functional/resource/ifconfig_spec.rb index f32ed069b5..c52a4c0694 100644 --- a/spec/functional/resource/ifconfig_spec.rb +++ b/spec/functional/resource/ifconfig_spec.rb @@ -23,7 +23,7 @@ require "chef/mixin/shell_out" # run this test only for following platforms. include_flag = !(%w{amazon debian aix}.include?(ohai[:platform_family]) || (ohai[:platform_family] == "rhel" && ohai[:platform_version].to_i < 7)) -describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => include_flag do +describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, external: include_flag do # This test does not work in travis because there is no eth0 include Chef::Mixin::ShellOut @@ -122,7 +122,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in end exclude_test = ohai[:platform] != "ubuntu" - describe "#action_add", :external => exclude_test do + describe "#action_add", external: exclude_test do after do new_resource.run_action(:delete) end @@ -134,7 +134,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in end end - describe "#action_enable", :external => exclude_test do + describe "#action_enable", external: exclude_test do after do new_resource.run_action(:disable) end @@ -145,7 +145,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in end end - describe "#action_disable", :external => exclude_test do + describe "#action_disable", external: exclude_test do before do setup_enable_interface(new_resource) new_resource.run_action(:enable) @@ -157,7 +157,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in end end - describe "#action_delete", :external => exclude_test do + describe "#action_delete", external: exclude_test do before do setup_add_interface(new_resource) new_resource.run_action(:add) diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb index c98d6cec25..f4e528c755 100644 --- a/spec/functional/resource/mount_spec.rb +++ b/spec/functional/resource/mount_spec.rb @@ -24,7 +24,7 @@ require "tmpdir" # run this test only for following platforms. include_flag = !(%w{debian rhel amazon aix solaris2}.include?(ohai[:platform_family])) -describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => include_flag do +describe Chef::Resource::Mount, :requires_root, :skip_travis, external: include_flag do # Disabled in travis because it refuses to let us mount a ramdisk. /dev/ramX does not # exist even after loading the kernel module @@ -161,7 +161,7 @@ describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => inclu # don't run the remount tests on solaris2 (tmpfs does not support remount) # Need to make sure the platforms we've already excluded are considered: skip_remount = include_flag || (ohai[:platform] == "solaris2") - describe "when the filesystem should be remounted and the resource supports remounting", :external => skip_remount do + describe "when the filesystem should be remounted and the resource supports remounting", external: skip_remount do it "should remount the filesystem if it is mounted" do new_resource.run_action(:mount) mount_should_exist(new_resource.mount_point, new_resource.device) diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb index bbd304fd06..4828d0fa79 100644 --- a/spec/functional/resource/powershell_script_spec.rb +++ b/spec/functional/resource/powershell_script_spec.rb @@ -474,13 +474,13 @@ configuration LCM it "evaluates a not_if block using the cwd guard parameter" do custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc" - resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd + resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", cwd: custom_cwd expect(resource.should_skip?(:run)).to be_truthy end it "evaluates an only_if block using the cwd guard parameter" do custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc" - resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd + resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", cwd: custom_cwd expect(resource.should_skip?(:run)).to be_falsey end @@ -581,7 +581,7 @@ configuration LCM end it "raises an error when a 32-bit guard is used on Windows Nano Server", :windows_nano_only do - resource.only_if "$true", :architecture => :i386 + resource.only_if "$true", architecture: :i386 expect { resource.run_action(:run) }.to raise_error( Chef::Exceptions::Win32ArchitectureIncorrect, /cannot execute script with requested architecture 'i386' on Windows Nano Server/) diff --git a/spec/functional/resource/reboot_spec.rb b/spec/functional/resource/reboot_spec.rb index c264b122a7..3b8e3efe8a 100644 --- a/spec/functional/resource/reboot_spec.rb +++ b/spec/functional/resource/reboot_spec.rb @@ -22,9 +22,9 @@ describe Chef::Resource::Reboot do let(:expected) do { - :delay_mins => 5, - :requested_by => "reboot resource functional test", - :reason => "reboot resource spec test", + delay_mins: 5, + requested_by: "reboot resource functional test", + reason: "reboot resource spec test", } end diff --git a/spec/functional/resource/registry_spec.rb b/spec/functional/resource/registry_spec.rb index 7318086034..2a11cdb63f 100644 --- a/spec/functional/resource/registry_spec.rb +++ b/spec/functional/resource/registry_spec.rb @@ -34,13 +34,13 @@ describe Chef::Resource::RegistryKey, :unix_only do context "when load_current_resource is run on a non-windows node" do it "throws an exception because you don't have a windows registry (derp)" do @resource.key("HKCU\\Software\\Opscode") - @resource.values([{ :name => "Color", :type => :string, :data => "Orange" }]) + @resource.values([{ name: "Color", type: :string, data: "Orange" }]) expect { @resource.run_action(:create) }.to raise_error(Chef::Exceptions::Win32NotWindows) end end end -describe Chef::Resource::RegistryKey, :windows_only, :broken => true do +describe Chef::Resource::RegistryKey, :windows_only, broken: true do # parent and key must be single keys, not paths let(:parent) { "Opscode" } @@ -123,7 +123,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do @run_id = @resource_reporter.run_id @new_resource.cookbook_name = "monkey" - @cookbook_version = double("Cookbook::Version", :version => "1.2.3") + @cookbook_version = double("Cookbook::Version", version: "1.2.3") @new_resource.cookbook_version(@cookbook_version) end @@ -137,110 +137,110 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do end it "creates registry key, value if the key is missing" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }]) + @new_resource.values([{ name: "Color", type: :string, data: "Orange" }]) @new_resource.run_action(:create) expect(@registry.key_exists?(reg_child)).to eq(true) - expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true) + expect(@registry.data_exists?(reg_child, { name: "Color", type: :string, data: "Orange" })).to eq(true) end it "does not create the key if it already exists with same value, type and data" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }]) + @new_resource.values([{ name: "Color", type: :string, data: "Orange" }]) @new_resource.run_action(:create) expect(@registry.key_exists?(reg_child)).to eq(true) - expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true) + expect(@registry.data_exists?(reg_child, { name: "Color", type: :string, data: "Orange" })).to eq(true) end it "does not create the key if it already exists with same value and type but datatype of data differs" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "number", :type => :dword, :data => "12345" }]) + @new_resource.values([{ name: "number", type: :dword, data: "12345" }]) @new_resource.run_action(:create) expect(@new_resource).not_to be_updated_by_last_action expect(@registry.key_exists?(reg_child)).to eq(true) - expect(@registry.data_exists?(reg_child, { :name => "number", :type => :dword, :data => 12344 })).to eq(true) + expect(@registry.data_exists?(reg_child, { name: "number", type: :dword, data: 12344 })).to eq(true) end it "creates a value if it does not exist" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "Mango", :type => :string, :data => "Yellow" }]) + @new_resource.values([{ name: "Mango", type: :string, data: "Yellow" }]) @new_resource.run_action(:create) - expect(@registry.data_exists?(reg_child, { :name => "Mango", :type => :string, :data => "Yellow" })).to eq(true) + expect(@registry.data_exists?(reg_child, { name: "Mango", type: :string, data: "Yellow" })).to eq(true) end it "modifies the data if the key and value exist and type matches" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "Color", :type => :string, :data => "Not just Orange - OpscodeOrange!" }]) + @new_resource.values([{ name: "Color", type: :string, data: "Not just Orange - OpscodeOrange!" }]) @new_resource.run_action(:create) - expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Not just Orange - OpscodeOrange!" })).to eq(true) + expect(@registry.data_exists?(reg_child, { name: "Color", type: :string, data: "Not just Orange - OpscodeOrange!" })).to eq(true) end it "modifys the type if the key and value exist and the type does not match" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "Color", :type => :multi_string, :data => ["Not just Orange - OpscodeOrange!"] }]) + @new_resource.values([{ name: "Color", type: :multi_string, data: ["Not just Orange - OpscodeOrange!"] }]) @new_resource.run_action(:create) - expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :multi_string, :data => ["Not just Orange - OpscodeOrange!"] })).to eq(true) + expect(@registry.data_exists?(reg_child, { name: "Color", type: :multi_string, data: ["Not just Orange - OpscodeOrange!"] })).to eq(true) end it "creates subkey if parent exists" do @new_resource.key(reg_child + '\OpscodeTest') - @new_resource.values([{ :name => "Chef", :type => :multi_string, :data => %w{OpscodeOrange Rules} }]) + @new_resource.values([{ name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} }]) @new_resource.recursive(false) @new_resource.run_action(:create) expect(@registry.key_exists?(reg_child + '\OpscodeTest')).to eq(true) - expect(@registry.value_exists?(reg_child + '\OpscodeTest', { :name => "Chef", :type => :multi_string, :data => %w{OpscodeOrange Rules} })).to eq(true) + expect(@registry.value_exists?(reg_child + '\OpscodeTest', { name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} })).to eq(true) end it "raises an error if action create and parent does not exist and recursive is set to false" do @new_resource.key(reg_child + '\Missing1\Missing2') - @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }]) + @new_resource.values([{ name: "OC", type: :string, data: "MissingData" }]) @new_resource.recursive(false) expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive) end it "raises an error if action create and type key missing in values hash" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "OC", :data => "my_data" }]) + @new_resource.values([{ name: "OC", data: "my_data" }]) expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing) end it "raises an error if action create and data key missing in values hash" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "OC", :type => :string }]) + @new_resource.values([{ name: "OC", type: :string }]) expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::RegKeyValuesDataMissing) end it "raises an error if action create and only name key present in values hash" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "OC" }]) + @new_resource.values([{ name: "OC" }]) expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing) end it "does not raise an error if action create and all keys are present in values hash" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "OC", :type => :string, :data => "my_data" }]) + @new_resource.values([{ name: "OC", type: :string, data: "my_data" }]) expect { @new_resource.run_action(:create) }.to_not raise_error end it "creates missing keys if action create and parent does not exist and recursive is set to true" do @new_resource.key(reg_child + '\Missing1\Missing2') - @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }]) + @new_resource.values([{ name: "OC", type: :string, data: "MissingData" }]) @new_resource.recursive(true) @new_resource.run_action(:create) expect(@registry.key_exists?(reg_child + '\Missing1\Missing2')).to eq(true) - expect(@registry.value_exists?(reg_child + '\Missing1\Missing2', { :name => "OC", :type => :string, :data => "MissingData" })).to eq(true) + expect(@registry.value_exists?(reg_child + '\Missing1\Missing2', { name: "OC", type: :string, data: "MissingData" })).to eq(true) end it "creates key with multiple value as specified" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "one", :type => :string, :data => "1" }, { :name => "two", :type => :string, :data => "2" }, { :name => "three", :type => :string, :data => "3" }]) + @new_resource.values([{ name: "one", type: :string, data: "1" }, { name: "two", type: :string, data: "2" }, { name: "three", type: :string, data: "3" }]) @new_resource.recursive(true) @new_resource.run_action(:create) @@ -259,12 +259,12 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do end it "creates a key in a 32-bit registry that is not viewable in 64-bit" do @new_resource.key(reg_child + '\Atraxi' ) - @new_resource.values([{ :name => "OC", :type => :string, :data => "Data" }]) + @new_resource.values([{ name: "OC", type: :string, data: "Data" }]) @new_resource.recursive(true) @new_resource.architecture(:i386) @new_resource.run_action(:create) @registry.architecture = :i386 - expect(@registry.data_exists?(reg_child + '\Atraxi', { :name => "OC", :type => :string, :data => "Data" })).to eq(true) + expect(@registry.data_exists?(reg_child + '\Atraxi', { name: "OC", type: :string, data: "Data" })).to eq(true) @registry.architecture = :x86_64 expect(@registry.key_exists?(reg_child + '\Atraxi')).to eq(false) end @@ -272,7 +272,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do it "prepares the reporting data for action :create" do @new_resource.key(reg_child + '\Ood') - @new_resource.values([{ :name => "ReportingVal1", :type => :string, :data => "report1" }, { :name => "ReportingVal2", :type => :string, :data => "report2" }]) + @new_resource.values([{ name: "ReportingVal1", type: :string, data: "report1" }, { name: "ReportingVal2", type: :string, data: "report2" }]) @new_resource.recursive(true) @new_resource.run_action(:create) @report = @resource_reporter.prepare_run_data @@ -281,8 +281,8 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do expect(@report["resources"][0]["type"]).to eq("registry_key") expect(@report["resources"][0]["name"]).to eq(resource_name) expect(@report["resources"][0]["id"]).to eq(reg_child + '\Ood') - expect(@report["resources"][0]["after"][:values]).to eq([{ :name => "ReportingVal1", :type => :string, :data => "report1" }, - { :name => "ReportingVal2", :type => :string, :data => "report2" }]) + expect(@report["resources"][0]["after"][:values]).to eq([{ name: "ReportingVal1", type: :string, data: "report1" }, + { name: "ReportingVal2", type: :string, data: "report2" }]) expect(@report["resources"][0]["before"][:values]).to eq([]) expect(@report["resources"][0]["result"]).to eq("create") expect(@report["status"]).to eq("success") @@ -296,7 +296,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do it "does not raise an exception if the keys do not exist but recursive is set to false" do @new_resource.key(reg_child + '\Slitheen\Raxicoricofallapatorius') - @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }]) + @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }]) @new_resource.recursive(false) @new_resource.run_action(:create) # should not raise_error expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false) @@ -305,7 +305,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do it "does not create key if the action is create" do @new_resource.key(reg_child + '\Slitheen') - @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }]) + @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }]) @new_resource.recursive(false) @new_resource.run_action(:create) expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false) @@ -313,28 +313,28 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do it "does not raise an exception if the action create and type key missing in values hash" do @new_resource.key(reg_child + '\Slitheen') - @new_resource.values([{ :name => "BriskWalk", :data => "my_data" }]) + @new_resource.values([{ name: "BriskWalk", data: "my_data" }]) @new_resource.run_action(:create) # should not raise_error expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false) end it "does not raise an exception if the action create and data key missing in values hash" do @new_resource.key(reg_child + '\Slitheen') - @new_resource.values([{ :name => "BriskWalk", :type => :string }]) + @new_resource.values([{ name: "BriskWalk", type: :string }]) @new_resource.run_action(:create) # should not raise_error expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false) end it "does not raise an exception if the action create and only name key present in values hash" do @new_resource.key(reg_child + '\Slitheen') - @new_resource.values([{ :name => "BriskWalk" }]) + @new_resource.values([{ name: "BriskWalk" }]) @new_resource.run_action(:create) # should not raise_error expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false) end it "does not raise an exception if the action create and all keys are present in values hash" do @new_resource.key(reg_child + '\Slitheen') - @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "my_data" }]) + @new_resource.values([{ name: "BriskWalk", type: :string, data: "my_data" }]) @new_resource.run_action(:create) # should not raise_error expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false) end @@ -348,85 +348,85 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do it "creates registry key, value if the key is missing" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }]) + @new_resource.values([{ name: "Color", type: :string, data: "Orange" }]) @new_resource.run_action(:create_if_missing) expect(@registry.key_exists?(reg_parent)).to eq(true) expect(@registry.key_exists?(reg_child)).to eq(true) - expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true) + expect(@registry.data_exists?(reg_child, { name: "Color", type: :string, data: "Orange" })).to eq(true) end it "does not create the key if it already exists with same value, type and data" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }]) + @new_resource.values([{ name: "Color", type: :string, data: "Orange" }]) @new_resource.run_action(:create_if_missing) expect(@registry.key_exists?(reg_child)).to eq(true) - expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true) + expect(@registry.data_exists?(reg_child, { name: "Color", type: :string, data: "Orange" })).to eq(true) end it "creates a value if it does not exist" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "Mango", :type => :string, :data => "Yellow" }]) + @new_resource.values([{ name: "Mango", type: :string, data: "Yellow" }]) @new_resource.run_action(:create_if_missing) - expect(@registry.data_exists?(reg_child, { :name => "Mango", :type => :string, :data => "Yellow" })).to eq(true) + expect(@registry.data_exists?(reg_child, { name: "Mango", type: :string, data: "Yellow" })).to eq(true) end it "creates subkey if parent exists" do @new_resource.key(reg_child + '\Pyrovile') - @new_resource.values([{ :name => "Chef", :type => :multi_string, :data => %w{OpscodeOrange Rules} }]) + @new_resource.values([{ name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} }]) @new_resource.recursive(false) @new_resource.run_action(:create_if_missing) expect(@registry.key_exists?(reg_child + '\Pyrovile')).to eq(true) - expect(@registry.value_exists?(reg_child + '\Pyrovile', { :name => "Chef", :type => :multi_string, :data => %w{OpscodeOrange Rules} })).to eq(true) + expect(@registry.value_exists?(reg_child + '\Pyrovile', { name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} })).to eq(true) end it "raises an error if action create and parent does not exist and recursive is set to false" do @new_resource.key(reg_child + '\Sontaran\Sontar') - @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }]) + @new_resource.values([{ name: "OC", type: :string, data: "MissingData" }]) @new_resource.recursive(false) expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive) end it "raises an error if action create_if_missing and type key missing in values hash" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "OC", :data => "my_data" }]) + @new_resource.values([{ name: "OC", data: "my_data" }]) expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing) end it "raises an error if action create_if_missing and data key missing in values hash" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "OC", :type => :string }]) + @new_resource.values([{ name: "OC", type: :string }]) expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::RegKeyValuesDataMissing) end it "raises an error if action create_if_missing and only name key present in values hash" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "OC" }]) + @new_resource.values([{ name: "OC" }]) expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing) end it "does not raise an error if action create_if_missing and all keys are present in values hash" do @new_resource.key(reg_child) - @new_resource.values([{ :name => "OC", :type => :string, :data => "my_data" }]) + @new_resource.values([{ name: "OC", type: :string, data: "my_data" }]) expect { @new_resource.run_action(:create_if_missing) }.to_not raise_error end it "creates missing keys if action create and parent does not exist and recursive is set to true" do @new_resource.key(reg_child + '\Sontaran\Sontar') - @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }]) + @new_resource.values([{ name: "OC", type: :string, data: "MissingData" }]) @new_resource.recursive(true) @new_resource.run_action(:create_if_missing) expect(@registry.key_exists?(reg_child + '\Sontaran\Sontar')).to eq(true) - expect(@registry.value_exists?(reg_child + '\Sontaran\Sontar', { :name => "OC", :type => :string, :data => "MissingData" })).to eq(true) + expect(@registry.value_exists?(reg_child + '\Sontaran\Sontar', { name: "OC", type: :string, data: "MissingData" })).to eq(true) end it "creates key with multiple value as specified" do @new_resource.key(reg_child + '\Adipose') - @new_resource.values([{ :name => "one", :type => :string, :data => "1" }, { :name => "two", :type => :string, :data => "2" }, { :name => "three", :type => :string, :data => "3" }]) + @new_resource.values([{ name: "one", type: :string, data: "1" }, { name: "two", type: :string, data: "2" }, { name: "three", type: :string, data: "3" }]) @new_resource.recursive(true) @new_resource.run_action(:create_if_missing) @@ -437,7 +437,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do it "prepares the reporting data for :create_if_missing" do @new_resource.key(reg_child + '\Judoon') - @new_resource.values([{ :name => "ReportingVal3", :type => :string, :data => "report3" }]) + @new_resource.values([{ name: "ReportingVal3", type: :string, data: "report3" }]) @new_resource.recursive(true) @new_resource.run_action(:create_if_missing) @report = @resource_reporter.prepare_run_data @@ -446,7 +446,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do expect(@report["resources"][0]["type"]).to eq("registry_key") expect(@report["resources"][0]["name"]).to eq(resource_name) expect(@report["resources"][0]["id"]).to eq(reg_child + '\Judoon') - expect(@report["resources"][0]["after"][:values]).to eq([{ :name => "ReportingVal3", :type => :string, :data => "report3" }]) + expect(@report["resources"][0]["after"][:values]).to eq([{ name: "ReportingVal3", type: :string, data: "report3" }]) expect(@report["resources"][0]["before"][:values]).to eq([]) expect(@report["resources"][0]["result"]).to eq("create_if_missing") expect(@report["status"]).to eq("success") @@ -460,7 +460,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do it "does not raise an exception if the keys do not exist but recursive is set to false" do @new_resource.key(reg_child + '\Zygons\Zygor') - @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }]) + @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }]) @new_resource.recursive(false) @new_resource.run_action(:create_if_missing) # should not raise_error expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false) @@ -469,7 +469,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do it "does nothing if the action is create_if_missing" do @new_resource.key(reg_child + '\Zygons') - @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }]) + @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }]) @new_resource.recursive(false) @new_resource.run_action(:create_if_missing) expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false) @@ -477,28 +477,28 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do it "does not raise an exception if the action create_if_missing and type key missing in values hash" do @new_resource.key(reg_child + '\Zygons') - @new_resource.values([{ :name => "BriskWalk", :data => "my_data" }]) + @new_resource.values([{ name: "BriskWalk", data: "my_data" }]) @new_resource.run_action(:create_if_missing) # should not raise_error expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false) end it "does not raise an exception if the action create_if_missing and data key missing in values hash" do @new_resource.key(reg_child + '\Zygons') - @new_resource.values([{ :name => "BriskWalk", :type => :string }]) + @new_resource.values([{ name: "BriskWalk", type: :string }]) @new_resource.run_action(:create_if_missing) # should not raise_error expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false) end it "does not raise an exception if the action create_if_missing and only name key present in values hash" do @new_resource.key(reg_child + '\Zygons') - @new_resource.values([{ :name => "BriskWalk" }]) + @new_resource.values([{ name: "BriskWalk" }]) @new_resource.run_action(:create_if_missing) # should not raise_error expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false) end it "does not raise an exception if the action create_if_missing and all keys are present in values hash" do @new_resource.key(reg_child + '\Zygons') - @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "my_data" }]) + @new_resource.values([{ name: "BriskWalk", type: :string, data: "my_data" }]) @new_resource.run_action(:create_if_missing) # should not raise_error expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false) end @@ -522,53 +522,53 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do end it "takes no action if the key exists but the value does not" do - expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true) + expect(@registry.data_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(true) @new_resource.key(reg_parent + '\Opscode') - @new_resource.values([{ :name => "LooksLike", :type => :multi_string, :data => %w{SeattleGrey OCOrange} }]) + @new_resource.values([{ name: "LooksLike", type: :multi_string, data: %w{SeattleGrey OCOrange} }]) @new_resource.recursive(false) @new_resource.run_action(:delete) - expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true) + expect(@registry.data_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(true) end it "deletes only specified values under a key path" do @new_resource.key(reg_parent + '\Opscode') - @new_resource.values([{ :name => "Opscode", :type => :multi_string, :data => %w{Seattle Washington} }, { :name => "AKA", :type => :string, :data => "OC" }]) + @new_resource.values([{ name: "Opscode", type: :multi_string, data: %w{Seattle Washington} }, { name: "AKA", type: :string, data: "OC" }]) @new_resource.recursive(false) @new_resource.run_action(:delete) - expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true) - expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "AKA", :type => :string, :data => "OC" })).to eq(false) - expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "Opscode", :type => :multi_string, :data => %w{Seattle Washington} })).to eq(false) + expect(@registry.data_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(true) + expect(@registry.value_exists?(reg_parent + '\Opscode', { name: "AKA", type: :string, data: "OC" })).to eq(false) + expect(@registry.value_exists?(reg_parent + '\Opscode', { name: "Opscode", type: :multi_string, data: %w{Seattle Washington} })).to eq(false) end it "it deletes the values with the same name irrespective of it type and data" do @new_resource.key(reg_parent + '\Opscode') - @new_resource.values([{ :name => "Color", :type => :multi_string, :data => %w{Black Orange} }]) + @new_resource.values([{ name: "Color", type: :multi_string, data: %w{Black Orange} }]) @new_resource.recursive(false) @new_resource.run_action(:delete) - expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(false) + expect(@registry.value_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(false) end it "prepares the reporting data for action :delete" do @new_resource.key(reg_parent + '\ReportKey') - @new_resource.values([{ :name => "ReportVal4", :type => :string, :data => "report4" }, { :name => "ReportVal5", :type => :string, :data => "report5" }]) + @new_resource.values([{ name: "ReportVal4", type: :string, data: "report4" }, { name: "ReportVal5", type: :string, data: "report5" }]) @new_resource.recursive(true) @new_resource.run_action(:delete) @report = @resource_reporter.prepare_run_data - expect(@registry.value_exists?(reg_parent + '\ReportKey', [{ :name => "ReportVal4", :type => :string, :data => "report4" }, { :name => "ReportVal5", :type => :string, :data => "report5" }])).to eq(false) + expect(@registry.value_exists?(reg_parent + '\ReportKey', [{ name: "ReportVal4", type: :string, data: "report4" }, { name: "ReportVal5", type: :string, data: "report5" }])).to eq(false) expect(@report["action"]).to eq("end") expect(@report["resources"].count).to eq(1) expect(@report["resources"][0]["type"]).to eq("registry_key") expect(@report["resources"][0]["name"]).to eq(resource_name) expect(@report["resources"][0]["id"]).to eq(reg_parent + '\ReportKey') - expect(@report["resources"][0]["before"][:values]).to eq([{ :name => "ReportVal4", :type => :string, :data => "report4" }, - { :name => "ReportVal5", :type => :string, :data => "report5" }]) + expect(@report["resources"][0]["before"][:values]).to eq([{ name: "ReportVal4", type: :string, data: "report4" }, + { name: "ReportVal5", type: :string, data: "report5" }]) #Not testing for after values to match since after -> new_resource values. expect(@report["resources"][0]["result"]).to eq("delete") expect(@report["status"]).to eq("success") @@ -581,7 +581,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do end it "does nothing if the action is delete" do @new_resource.key(reg_parent + '\OpscodeWhyRun') - @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }]) + @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }]) @new_resource.recursive(false) @new_resource.run_action(:delete) @@ -659,13 +659,13 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do it "does not throw an exception if the key has subkeys but recursive is set to false" do @new_resource.key(reg_parent + '\OpscodeWhyRun') - @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }]) + @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }]) @new_resource.recursive(false) @new_resource.run_action(:delete_key) end it "does nothing if the action is delete_key" do @new_resource.key(reg_parent + '\OpscodeWhyRun') - @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }]) + @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }]) @new_resource.recursive(false) @new_resource.run_action(:delete_key) diff --git a/spec/functional/resource/rpm_spec.rb b/spec/functional/resource/rpm_spec.rb index 17d0bf9e3c..fcaf8817eb 100644 --- a/spec/functional/resource/rpm_spec.rb +++ b/spec/functional/resource/rpm_spec.rb @@ -22,7 +22,7 @@ require "chef/mixin/shell_out" # run this test only for following platforms. exclude_test = !%w{aix rhel fedora suse}.include?(ohai[:platform_family]) -describe Chef::Resource::RpmPackage, :requires_root, :external => exclude_test do +describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do include Chef::Mixin::ShellOut let(:new_resource) do diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb index b9a39255f4..243b66311b 100644 --- a/spec/functional/resource/template_spec.rb +++ b/spec/functional/resource/template_spec.rb @@ -68,7 +68,7 @@ describe Chef::Resource::Template do context "when the target file does not exist" do it "creates the template with the rendered content using the variable attribute when the :create action is run" do resource.source("openldap_variable_stuff.conf.erb") - resource.variables(:secret => "nutella") + resource.variables(secret: "nutella") resource.run_action(:create) expect(IO.read(path)).to eq("super secret is nutella") end @@ -213,21 +213,21 @@ describe Chef::Resource::Template do describe "when template variables contain lazy{} calls" do it "resolves the DelayedEvaluator" do resource.source("openldap_variable_stuff.conf.erb") - resource.variables(:secret => Chef::DelayedEvaluator.new { "nutella" }) + resource.variables(secret: Chef::DelayedEvaluator.new { "nutella" }) resource.run_action(:create) expect(IO.read(path)).to eq("super secret is nutella") end it "does not mutate the resource variables" do resource.source("openldap_variable_stuff.conf.erb") - resource.variables(:secret => Chef::DelayedEvaluator.new { "nutella" }) + resource.variables(secret: Chef::DelayedEvaluator.new { "nutella" }) resource.run_action(:create) expect(resource.variables[:secret]).to be_a Chef::DelayedEvaluator end it "resolves the DelayedEvaluator when deeply nested" do resource.source("openldap_nested_variable_stuff.erb") - resource.variables(:secret => [{ "key" => Chef::DelayedEvaluator.new { "nutella" } }]) + resource.variables(secret: [{ "key" => Chef::DelayedEvaluator.new { "nutella" } }]) resource.run_action(:create) expect(IO.read(path)).to eq("super secret is nutella") end diff --git a/spec/functional/resource/user/dscl_spec.rb b/spec/functional/resource/user/dscl_spec.rb index ed96e31bac..78d7f2336e 100644 --- a/spec/functional/resource/user/dscl_spec.rb +++ b/spec/functional/resource/user/dscl_spec.rb @@ -19,9 +19,9 @@ require "spec_helper" require "chef/mixin/shell_out" metadata = { - :mac_osx_only => true, - :requires_root => true, - :not_supported_on_mac_osx_106 => true, + mac_osx_only: true, + requires_root: true, + not_supported_on_mac_osx_106: true, } describe "Chef::Resource::User with Chef::Provider::User::Dscl provider", metadata do diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb index 531f9e9250..f422ac21d6 100644 --- a/spec/functional/resource/windows_service_spec.rb +++ b/spec/functional/resource/windows_service_spec.rb @@ -18,7 +18,7 @@ require "spec_helper" -describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_gem_only, :appveyor_only, :broken => true do +describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_gem_only, :appveyor_only, broken: true do # Marking as broken. This test is causing appveyor tests to exit with 116. include_context "using Win32::Service" diff --git a/spec/functional/resource/yum_package_spec.rb b/spec/functional/resource/yum_package_spec.rb index 7c45a64ae5..5751e92ce5 100644 --- a/spec/functional/resource/yum_package_spec.rb +++ b/spec/functional/resource/yum_package_spec.rb @@ -21,7 +21,7 @@ require "chef/mixin/shell_out" # run this test only for following platforms. exclude_test = !(%w{rhel fedora}.include?(ohai[:platform_family]) && !File.exist?("/usr/bin/dnf")) -describe Chef::Resource::YumPackage, :requires_root, :external => exclude_test do +describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do include Chef::Mixin::ShellOut # NOTE: every single test here either needs to explicitly call flush_cache or needs to explicitly diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb index d270803698..c1942cff50 100644 --- a/spec/functional/run_lock_spec.rb +++ b/spec/functional/run_lock_spec.rb @@ -21,7 +21,7 @@ require "chef/client" describe Chef::RunLock do # This behavior works on windows, but the tests use fork :( - describe "when locking the chef-client run", :unix_only => true do + describe "when locking the chef-client run", unix_only: true do ## # Lockfile location and helpers @@ -150,7 +150,7 @@ describe Chef::RunLock do end end - it "sets FD_CLOEXEC on the lockfile", :supports_cloexec => true do + it "sets FD_CLOEXEC on the lockfile", supports_cloexec: true do run_lock = File.open(lockfile) expect(run_lock.fcntl(Fcntl::F_GETFD, 0) & Fcntl::FD_CLOEXEC).to eq(Fcntl::FD_CLOEXEC) end @@ -197,7 +197,7 @@ describe Chef::RunLock do end end - it "sets FD_CLOEXEC on the lockfile", :supports_cloexec => true do + it "sets FD_CLOEXEC on the lockfile", supports_cloexec: true do run_lock = File.open(lockfile) expect(run_lock.fcntl(Fcntl::F_GETFD, 0) & Fcntl::FD_CLOEXEC).to eq(Fcntl::FD_CLOEXEC) end diff --git a/spec/functional/shell_spec.rb b/spec/functional/shell_spec.rb index 08c791f2d2..3990f1afe0 100644 --- a/spec/functional/shell_spec.rb +++ b/spec/functional/shell_spec.rb @@ -26,7 +26,7 @@ describe Shell do # chef-shell's unit tests are by necessity very mock-heavy, and frequently do # not catch cases where chef-shell fails to boot because of changes in # chef/client.rb - describe "smoke tests", :unix_only => true do + describe "smoke tests", unix_only: true do TIMEOUT = 300 diff --git a/spec/functional/util/powershell/cmdlet_spec.rb b/spec/functional/util/powershell/cmdlet_spec.rb index 19f5e58a49..4be021a60b 100644 --- a/spec/functional/util/powershell/cmdlet_spec.rb +++ b/spec/functional/util/powershell/cmdlet_spec.rb @@ -25,10 +25,10 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do @node.consume_external_attrs(OHAI_SYSTEM.data, {}) end let(:cmd_output_format) { :text } - let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-childitem", cmd_output_format, { :depth => 2 }) } + let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-childitem", cmd_output_format, { depth: 2 }) } let(:invalid_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-idontexist", cmd_output_format) } - let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "get-item", cmd_output_format, { :depth => 2 }) } - let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "alias", cmd_output_format, { :depth => 2 }) } + let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "get-item", cmd_output_format, { depth: 2 }) } + let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "alias", cmd_output_format, { depth: 2 }) } let(:etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" } let(:architecture_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "$env:PROCESSOR_ARCHITECTURE") } @@ -58,7 +58,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do end it "passes command line switches to the command" do - result = cmdlet_alias_requires_switch_or_argument.run({ :name => "ls" }) + result = cmdlet_alias_requires_switch_or_argument.run({ name: "ls" }) expect(result.succeeded?).to eq(true) end @@ -68,7 +68,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do end it "passes command line arguments and switches to the command" do - result = cmdlet_get_item_requires_switch_or_argument.run({ :path => etc_directory }, {}, " | select-object -property fullname | format-table -hidetableheaders") + result = cmdlet_get_item_requires_switch_or_argument.run({ path: etc_directory }, {}, " | select-object -property fullname | format-table -hidetableheaders") expect(result.succeeded?).to eq(true) returned_directory = result.return_value returned_directory.strip! @@ -76,7 +76,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do end it "passes execution options to the command" do - result = cmdlet_get_item_requires_switch_or_argument.run({}, { :cwd => etc_directory }, ". | select-object -property fullname | format-table -hidetableheaders") + result = cmdlet_get_item_requires_switch_or_argument.run({}, { cwd: etc_directory }, ". | select-object -property fullname | format-table -hidetableheaders") expect(result.succeeded?).to eq(true) returned_directory = result.return_value returned_directory.strip! @@ -95,7 +95,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do context "when returning Ruby objects" do let(:cmd_output_format) { :object } it "returns object format data" do - result = simple_cmdlet.run({}, { :cwd => etc_directory }, "hosts") + result = simple_cmdlet.run({}, { cwd: etc_directory }, "hosts") expect(result.succeeded?).to eq(true) data = result.return_value expect(data["Name"]).to eq("hosts") diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb index a45c25ff8c..dc323e9d3a 100644 --- a/spec/functional/version_spec.rb +++ b/spec/functional/version_spec.rb @@ -28,7 +28,7 @@ describe "Chef Versions" do binaries.each do |binary| it "#{binary} version should be sane" do - expect(shell_out!("ruby #{File.join("bin", binary)} -v", :cwd => chef_dir).stdout.chomp).to include("Chef: #{Chef::VERSION}") + expect(shell_out!("ruby #{File.join("bin", binary)} -v", cwd: chef_dir).stdout.chomp).to include("Chef: #{Chef::VERSION}") end end diff --git a/spec/functional/win32/registry_spec.rb b/spec/functional/win32/registry_spec.rb index bcfa0ffd48..c5323d3557 100644 --- a/spec/functional/win32/registry_spec.rb +++ b/spec/functional/win32/registry_spec.rb @@ -102,85 +102,85 @@ describe "Chef::Win32::Registry", :windows_only do describe "value_exists?" do it "throws an exception if the hive does not exist" do - expect { @registry.value_exists?("JKLM\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) + expect { @registry.value_exists?("JKLM\\Software\\Branch\\Flower", { name: "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) end it "throws an exception if the key does not exist" do - expect { @registry.value_exists?("HKCU\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) + expect { @registry.value_exists?("HKCU\\Software\\Branch\\Flower", { name: "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) end it "returns true if the value exists" do - expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals" })).to eq(true) + expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals" })).to eq(true) end it "returns true if the value exists with a case mismatch on the value name" do - expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals" })).to eq(true) + expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "petals" })).to eq(true) end it "returns false if the value does not exist" do - expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "FOOBAR" })).to eq(false) + expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "FOOBAR" })).to eq(false) end end describe "value_exists!" do it "throws an exception if the hive does not exist" do - expect { @registry.value_exists!("JKLM\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) + expect { @registry.value_exists!("JKLM\\Software\\Branch\\Flower", { name: "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) end it "throws an exception if the key does not exist" do - expect { @registry.value_exists!("HKCU\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) + expect { @registry.value_exists!("HKCU\\Software\\Branch\\Flower", { name: "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) end it "returns true if the value exists" do - expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals" })).to eq(true) + expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals" })).to eq(true) end it "returns true if the value exists with a case mismatch on the value name" do - expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals" })).to eq(true) + expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "petals" })).to eq(true) end it "throws an exception if the value does not exist" do - expect { @registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "FOOBAR" }) }.to raise_error(Chef::Exceptions::Win32RegValueMissing) + expect { @registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "FOOBAR" }) }.to raise_error(Chef::Exceptions::Win32RegValueMissing) end end describe "data_exists?" do it "throws an exception if the hive does not exist" do - expect { @registry.data_exists?("JKLM\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) + expect { @registry.data_exists?("JKLM\\Software\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) end it "throws an exception if the key does not exist" do - expect { @registry.data_exists?("HKCU\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) + expect { @registry.data_exists?("HKCU\\Software\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) end it "returns true if all the data matches" do - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} })).to eq(true) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} })).to eq(true) end it "returns true if all the data matches with a case mismatch on the data name" do - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals", :type => :multi_string, :data => %w{Pink Delicate} })).to eq(true) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "petals", type: :multi_string, data: %w{Pink Delicate} })).to eq(true) end it "returns false if the name does not exist" do - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "slateP", :type => :multi_string, :data => %w{Pink Delicate} })).to eq(false) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "slateP", type: :multi_string, data: %w{Pink Delicate} })).to eq(false) end it "returns false if the types do not match" do - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Pink" })).to eq(false) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :string, data: "Pink" })).to eq(false) end it "returns false if the data does not match" do - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Mauve Delicate} })).to eq(false) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Mauve Delicate} })).to eq(false) end end describe "data_exists!" do it "throws an exception if the hive does not exist" do - expect { @registry.data_exists!("JKLM\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) + expect { @registry.data_exists!("JKLM\\Software\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) end it "throws an exception if the key does not exist" do - expect { @registry.data_exists!("HKCU\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) + expect { @registry.data_exists!("HKCU\\Software\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) end it "returns true if all the data matches" do - expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} })).to eq(true) + expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} })).to eq(true) end it "returns true if all the data matches with a case mismatch on the data name" do - expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals", :type => :multi_string, :data => %w{Pink Delicate} })).to eq(true) + expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "petals", type: :multi_string, data: %w{Pink Delicate} })).to eq(true) end it "throws an exception if the name does not exist" do - expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "slateP", :type => :multi_string, :data => %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing) + expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "slateP", type: :multi_string, data: %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing) end it "throws an exception if the types do not match" do - expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Pink" }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing) + expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :string, data: "Pink" }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing) end it "throws an exception if the data does not match" do - expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Mauve Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing) + expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Mauve Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing) end end @@ -188,8 +188,8 @@ describe "Chef::Win32::Registry", :windows_only do it "returns all values for a key if it exists" do values = @registry.get_values("HKCU\\Software\\Root") expect(values).to be_an_instance_of Array - expect(values).to eq([{ :name => "RootType1", :type => :string, :data => "fibrous" }, - { :name => "Roots", :type => :multi_string, :data => ["strong roots", "healthy tree"] }]) + expect(values).to eq([{ name: "RootType1", type: :string, data: "fibrous" }, + { name: "Roots", type: :multi_string, data: ["strong roots", "healthy tree"] }]) end it "throws an exception if the key does not exist" do @@ -203,70 +203,70 @@ describe "Chef::Win32::Registry", :windows_only do describe "set_value" do it "updates a value if the key, value exist and type matches and value different" do - expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true) - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true) + expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(true) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(true) end it "updates a value if the type does match and the values are different" do - expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Yellow" })).to eq(true) - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Yellow" })).to eq(true) - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(false) + expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :string, data: "Yellow" })).to eq(true) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :string, data: "Yellow" })).to eq(true) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(false) end it "creates a value if key exists and value does not" do - expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true) - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true) + expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "Stamen", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(true) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Stamen", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(true) end it "does nothing if data,type and name parameters for the value are same" do - expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(false) - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true) + expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "Stamen", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(false) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Stamen", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(true) end it "throws an exception if the key does not exist" do - expect { @registry.set_value("HKCU\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) + expect { @registry.set_value("HKCU\\Software\\Branch\\Flower", { name: "Petals", type: :multi_string, data: ["Yellow", "Changed Color"] }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) end it "throws an exception if the hive does not exist" do - expect { @registry.set_value("JKLM\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) + expect { @registry.set_value("JKLM\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: ["Yellow", "Changed Color"] }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) end # we are validating that the data gets .to_i called on it when type is a :dword it "casts an integer string given as a dword into an integer" do - expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe32767", :type => :dword, :data => "32767" })).to eq(true) - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe32767", :type => :dword, :data => 32767 })).to eq(true) + expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBe32767", type: :dword, data: "32767" })).to eq(true) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBe32767", type: :dword, data: 32767 })).to eq(true) end it "casts a nonsense string given as a dword into zero" do - expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBeZero", :type => :dword, :data => "whatdoesthisdo" })).to eq(true) - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBeZero", :type => :dword, :data => 0 })).to eq(true) + expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBeZero", type: :dword, data: "whatdoesthisdo" })).to eq(true) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBeZero", type: :dword, data: 0 })).to eq(true) end it "throws an exception when trying to cast an array to an int for a dword" do - expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldThrow", :type => :dword, :data => %w{one two} }) }.to raise_error NoMethodError + expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldThrow", type: :dword, data: %w{one two} }) }.to raise_error NoMethodError end # we are validating that the data gets .to_s called on it when type is a :string it "stores the string representation of an array into a string if you pass it an array" do - expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBePainful", :type => :string, :data => %w{one two} })).to eq(true) - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBePainful", :type => :string, :data => '["one", "two"]' })).to eq(true) + expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBePainful", type: :string, data: %w{one two} })).to eq(true) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBePainful", type: :string, data: '["one", "two"]' })).to eq(true) end it "stores the string representation of a number into a string if you pass it an number" do - expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe65535", :type => :string, :data => 65535 })).to eq(true) - expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe65535", :type => :string, :data => "65535" })).to eq(true) + expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBe65535", type: :string, data: 65535 })).to eq(true) + expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBe65535", type: :string, data: "65535" })).to eq(true) end # we are validating that the data gets .to_a called on it when type is a :multi_string it "throws an exception when a multi-string is passed a number" do - expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldThrow", :type => :multi_string, :data => 65535 }) }.to raise_error NoMethodError + expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldThrow", type: :multi_string, data: 65535 }) }.to raise_error NoMethodError end it "throws an exception when a multi-string is passed a string" do - expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBeWat", :type => :multi_string, :data => "foo" }) }.to raise_error NoMethodError + expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBeWat", type: :multi_string, data: "foo" }) }.to raise_error NoMethodError end end @@ -309,21 +309,21 @@ describe "Chef::Win32::Registry", :windows_only do end it "deletes values if the value exists" do - expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(true) - expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(false) + expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" })).to eq(true) + expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" })).to eq(false) end it "does nothing if value does not exist" do - expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(true) - expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(false) + expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" })).to eq(true) + expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" })).to eq(false) end it "throws an exception if the key does not exist?" do - expect { @registry.delete_value("HKCU\\Software\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) + expect { @registry.delete_value("HKCU\\Software\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) end it "throws an exception if the hive does not exist" do - expect { @registry.delete_value("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) + expect { @registry.delete_value("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing) end end @@ -566,38 +566,38 @@ describe "Chef::Win32::Registry", :windows_only do describe "value_exists?" do it "does not find 64-bit values in the 32-bit registry" do @registry.architecture = :i386 - expect { @registry.value_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) + expect { @registry.value_exists?("HKLM\\Software\\Root\\Mauve", { name: "Alert" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) end it "finds 32-bit values in the 32-bit registry" do @registry.architecture = :i386 - expect(@registry.value_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status" })).to eq(true) + expect(@registry.value_exists?("HKLM\\Software\\Root\\Poosh", { name: "Status" })).to eq(true) end it "does not find 32-bit values in the 64-bit registry" do @registry.architecture = :x86_64 - expect(@registry.value_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert" })).to eq(true) + expect(@registry.value_exists?("HKLM\\Software\\Root\\Mauve", { name: "Alert" })).to eq(true) end it "finds 64-bit values in the 64-bit registry" do @registry.architecture = :x86_64 - expect { @registry.value_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) + expect { @registry.value_exists?("HKLM\\Software\\Root\\Poosh", { name: "Status" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) end end describe "data_exists?" do it "does not find 64-bit keys in the 32-bit registry" do @registry.architecture = :i386 - expect { @registry.data_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert", :type => :string, :data => "Universal" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) + expect { @registry.data_exists?("HKLM\\Software\\Root\\Mauve", { name: "Alert", type: :string, data: "Universal" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) end it "finds 32-bit keys in the 32-bit registry" do @registry.architecture = :i386 - expect(@registry.data_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status", :type => :string, :data => "Lost" })).to eq(true) + expect(@registry.data_exists?("HKLM\\Software\\Root\\Poosh", { name: "Status", type: :string, data: "Lost" })).to eq(true) end it "does not find 32-bit keys in the 64-bit registry" do @registry.architecture = :x86_64 - expect(@registry.data_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert", :type => :string, :data => "Universal" })).to eq(true) + expect(@registry.data_exists?("HKLM\\Software\\Root\\Mauve", { name: "Alert", type: :string, data: "Universal" })).to eq(true) end it "finds 64-bit keys in the 64-bit registry" do @registry.architecture = :x86_64 - expect { @registry.data_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status", :type => :string, :data => "Lost" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) + expect { @registry.data_exists?("HKLM\\Software\\Root\\Poosh", { name: "Status", type: :string, data: "Lost" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing) end end diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index 8f2364d99a..3c4d43aac5 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -59,17 +59,17 @@ local_mode true cookbook_path "#{path_to('cookbooks')}" EOM - shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) end - it "should complete successfully with no other environment variables", :skip => (Chef::Platform.windows?) do + it "should complete successfully with no other environment variables", skip: (Chef::Platform.windows?) do file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM begin - result = shell_out("env -i #{critical_env_vars} #{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + result = shell_out("env -i #{critical_env_vars} #{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) result.error! rescue Chef::Log.info "Bare invocation will have the following load-path." @@ -84,29 +84,29 @@ local_mode true cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out("#{chef_client} --no-listen -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} --no-listen -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) result.error! end it "should be able to node.save with bad utf8 characters in the node data" do file "cookbooks/x/attributes/default.rb", 'default["badutf8"] = "Elan Ruusam\xE4e"' - result = shell_out("#{chef_client} -z -r 'x::default' --disable-config", :cwd => path_to("")) + result = shell_out("#{chef_client} -z -r 'x::default' --disable-config", cwd: path_to("")) result.error! end context "and no config file" do it "should complete with success when cwd is just above cookbooks and paths are not specified" do - result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => path_to("")) + result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", cwd: path_to("")) result.error! end it "should complete with success when cwd is below cookbooks and paths are not specified" do - result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => path_to("cookbooks/x")) + result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", cwd: path_to("cookbooks/x")) result.error! end it "should fail when cwd is below high above and paths are not specified" do - result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => File.expand_path("..", path_to(""))) + result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", cwd: File.expand_path("..", path_to(""))) expect(result.exitstatus).to eq(1) end end @@ -115,7 +115,7 @@ EOM before { file ".chef/knife.rb", "xxx.xxx" } it "should load .chef/knife.rb when -z is specified" do - result = shell_out("#{chef_client} -z -o 'x::default'", :cwd => path_to("")) + result = shell_out("#{chef_client} -z -o 'x::default'", cwd: path_to("")) # FATAL: Configuration error NoMethodError: undefined method `xxx' for nil:NilClass expect(result.stdout).to include("xxx") end @@ -128,7 +128,7 @@ local_mode true cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) result.error! end @@ -172,7 +172,7 @@ client_key #{path_to('mykey.pem').inspect} cookbook_path #{path_to('cookbooks').inspect} EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) result.error! end @@ -195,7 +195,7 @@ file #{path_to('tempfile2.txt').inspect} do end EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" #{path_to('arbitrary.rb')} #{path_to('arbitrary2.rb')}", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" #{path_to('arbitrary.rb')} #{path_to('arbitrary2.rb')}", cwd: chef_dir) result.error! expect(IO.read(path_to("tempfile.txt"))).to eq("1") @@ -215,7 +215,7 @@ file #{path_to('tempfile.txt').inspect} do end EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" arbitrary.rb", :cwd => path_to("")) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" arbitrary.rb", cwd: path_to("")) result.error! expect(IO.read(path_to("tempfile.txt"))).to eq("1") @@ -239,7 +239,7 @@ file #{path_to('tempfile.txt').inspect} do end EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o x::constant_definition arbitrary.rb", :cwd => path_to("")) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o x::constant_definition arbitrary.rb", cwd: path_to("")) result.error! expect(IO.read(path_to("tempfile.txt"))).to eq("1") @@ -253,7 +253,7 @@ chef_server_url 'http://omg.com/blah' cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir) result.error! end @@ -263,7 +263,7 @@ chef_server_url 'http://omg.com/blah' cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", cwd: chef_dir) result.error! end @@ -273,7 +273,7 @@ chef_server_url 'http://omg.com/blah' cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", cwd: chef_dir) expect(result.stdout).not_to include("SSL validation of HTTPS requests is disabled.") result.error! end @@ -284,7 +284,7 @@ chef_server_url 'http://omg.com/blah' cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir) result.error! end @@ -294,7 +294,7 @@ chef_server_url 'http://omg.com/blah' cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -r 'x::default' -z -l info", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -r 'x::default' -z -l info", cwd: chef_dir) expect(result.stdout).not_to include("Overridden Run List") expect(result.stdout).to include("Run List is [recipe[x::default]]") result.error! @@ -305,7 +305,7 @@ EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z --profile-ruby", :cwd => chef_dir) + result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z --profile-ruby", cwd: chef_dir) result.error! expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be true end @@ -315,7 +315,7 @@ EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", :cwd => chef_dir) + result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir) result.error! expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be false end @@ -335,7 +335,7 @@ cookbook_path "#{path_to('cookbooks')}" EOM end it "should fail the chef client run" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) expect(command.exitstatus).to eql(1) expect(command.stdout).to match(/Chef::Exceptions::CookbookChefVersionMismatch/) end @@ -361,7 +361,7 @@ EOM end it "the cheffish DSL is loaded lazily" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) expect(command.exitstatus).to eql(0) end end @@ -380,7 +380,7 @@ EOM it "the cheffish DSL tries to load but fails (because chef-provisioning is not there)" do # we'd need to have a custom bundle to fix this that omitted chef-provisioning, but that would dig our crazy even deeper, so lets not skip "but if chef-provisioning is in our bundle or in our gemset then this test, very annoyingly, always fails" - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) expect(command.exitstatus).to eql(1) expect(command.stdout).to match(/cannot load such file -- chef\/provisioning/) end @@ -415,7 +415,7 @@ EOM ENV.delete("CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS") - result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) expect(result.error?).to be_falsey # Search to the end of the client run in the output @@ -446,7 +446,7 @@ control_group "control group without top level control" do end RECIPE - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::succeed' -l info", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::succeed' -l info", cwd: chef_dir) expect(result.error?).to be_falsey expect(result.stdout).to include("Successfully executed all `control_group` blocks and contained examples") end @@ -460,7 +460,7 @@ control_group "control group without top level control" do end RECIPE - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::fail'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::fail'", cwd: chef_dir) expect(result.error?).to be_truthy expect(result.stdout).to include("Failure/Error: expect(2 - 2).to eq(1)") end @@ -487,7 +487,7 @@ no_lazy_load #{lazy} local_mode true cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) result.error! expect(IO.read(path_to("tempfile.txt")).strip).to eq("this is my file") @@ -522,7 +522,7 @@ EOM end it "should run the ohai plugin" do - result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) result.error! expect(IO.read(path_to("tempfile.txt"))).to eq("2014") @@ -545,18 +545,18 @@ EOM file "config/client.rb", <<EOM chef_repo_path "#{tmp_dir}" EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", :cwd => tmp_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", cwd: tmp_dir) result.error! end it "should fail when passed --recipe-url and not passed -z" do - result = shell_out("#{chef_client} --recipe-url=http://localhost:9000/recipes.tgz", :cwd => tmp_dir) + result = shell_out("#{chef_client} --recipe-url=http://localhost:9000/recipes.tgz", cwd: tmp_dir) expect(result.exitstatus).not_to eq(0) end it "should fail when passed --recipe-url with a file that doesn't exist" do broken_path = File.join(CHEF_SPEC_DATA, "recipes_dont_exist.tgz") - result = shell_out("#{chef_client} --recipe-url=#{broken_path}", :cwd => tmp_dir) + result = shell_out("#{chef_client} --recipe-url=#{broken_path}", cwd: tmp_dir) expect(result.exitstatus).not_to eq(0) end end @@ -583,12 +583,12 @@ EOM end it "the chef client run should succeed" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! end it "a chef-solo run should succeed" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! end end @@ -607,25 +607,25 @@ EOM end it "a chef client run should not log to info by default" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! expect(command.stdout).not_to include("INFO") end it "a chef client run to a pipe should not log to info by default" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", :cwd => chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", cwd: chef_dir) command.error! expect(command.stdout).not_to include("INFO") end it "a chef solo run should not log to info by default" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! expect(command.stdout).not_to include("INFO") end it "a chef solo run to a pipe should not log to info by default" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", :cwd => chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", cwd: chef_dir) command.error! expect(command.stdout).not_to include("INFO") end @@ -643,37 +643,37 @@ EOM end it "chef-client runs by default with no supervisor" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end it "chef-solo runs by default with no supervisor" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end it "chef-client --no-fork does not fork" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end it "chef-solo --no-fork does not fork" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end it "chef-client with --fork uses a supervisor" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", :cwd => chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", cwd: chef_dir) command.error! expect(command.stdout).to include("WITHFORK") end it "chef-solo with --fork uses a supervisor" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", :cwd => chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", cwd: chef_dir) command.error! expect(command.stdout).to include("WITHFORK") end @@ -692,13 +692,13 @@ EOM end it "chef-client uses a supervisor" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("WITHFORK") end it "chef-solo uses a supervisor" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("WITHFORK") end @@ -717,13 +717,13 @@ EOM end it "chef-client uses a supervisor" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end it "chef-solo uses a supervisor" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end diff --git a/spec/integration/client/exit_code_spec.rb b/spec/integration/client/exit_code_spec.rb index 4397426723..939f5ad5b7 100644 --- a/spec/integration/client/exit_code_spec.rb +++ b/spec/integration/client/exit_code_spec.rb @@ -44,8 +44,8 @@ EOM def run_chef_client_and_expect_exit_code(exit_code) shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", - :cwd => chef_dir, - :returns => [exit_code]) + cwd: chef_dir, + returns: [exit_code]) end context "has a cookbook" do diff --git a/spec/integration/client/ipv6_spec.rb b/spec/integration/client/ipv6_spec.rb index 6452db1e39..b6e08e842f 100644 --- a/spec/integration/client/ipv6_spec.rb +++ b/spec/integration/client/ipv6_spec.rb @@ -22,7 +22,7 @@ describe "chef-client" do include IntegrationSupport include Chef::Mixin::ShellOut - let(:chef_zero_opts) { { :host => "::1" } } + let(:chef_zero_opts) { { host: "::1" } } let(:validation_pem) do <<-END_VALIDATION_PEM @@ -93,7 +93,7 @@ END_CLIENT_RB end it "should complete with success" do - result = shell_out("#{chef_client_cmd} -o 'noop::default'", :cwd => chef_dir) + result = shell_out("#{chef_client_cmd} -o 'noop::default'", cwd: chef_dir) result.error! end @@ -125,7 +125,7 @@ END_CLIENT_RB end it "should complete with success" do - result = shell_out("#{chef_client_cmd} -o 'api-smoke-test::default'", :cwd => chef_dir) + result = shell_out("#{chef_client_cmd} -o 'api-smoke-test::default'", cwd: chef_dir) result.error! end diff --git a/spec/integration/knife/chef_fs_data_store_spec.rb b/spec/integration/knife/chef_fs_data_store_spec.rb index 02508b799d..1e9d1c65b4 100644 --- a/spec/integration/knife/chef_fs_data_store_spec.rb +++ b/spec/integration/knife/chef_fs_data_store_spec.rb @@ -190,7 +190,7 @@ EOM end it "knife cookbook upload works" do - knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} x").should_succeed :stderr => <<EOM + knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} x").should_succeed stderr: <<EOM Uploading x [1.0.0] Uploaded 1 cookbook. EOM @@ -218,7 +218,7 @@ EOM knife("list --local /roles").should_succeed "/roles/x.json\n" end - it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", :skip => (RUBY_VERSION < "1.9") do + it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", skip: (RUBY_VERSION < "1.9") do knife("raw -z -i #{path_to('rolestuff.json')} -m PUT /roles/x").should_succeed( /"x"/ ) expect(IO.read(path_to("roles/x.json"))).to eq <<EOM.strip { @@ -247,7 +247,7 @@ EOM end it "knife cookbook upload works" do - knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} z").should_succeed :stderr => <<EOM + knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} z").should_succeed stderr: <<EOM Uploading z [1.0.0] Uploaded 1 cookbook. EOM @@ -281,7 +281,7 @@ EOM knife("list --local /roles").should_succeed "/roles/z.json\n" end - it "After knife raw -z -i rolestuff.json -m POST /roles, the output is pretty", :skip => (RUBY_VERSION < "1.9") do + it "After knife raw -z -i rolestuff.json -m POST /roles, the output is pretty", skip: (RUBY_VERSION < "1.9") do knife("raw -z -i #{path_to('rolestuff.json')} -m POST /roles").should_succeed( /uri/ ) expect(IO.read(path_to("roles/x.json"))).to eq <<EOM.strip { @@ -489,7 +489,7 @@ EOM knife("list --local /users").should_succeed "/users/x.json\n" end - it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", :skip => (RUBY_VERSION < "1.9") do + it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", skip: (RUBY_VERSION < "1.9") do knife("raw -z -i #{path_to('rolestuff.json')} -m PUT /roles/x").should_succeed( /"x"/ ) expect(IO.read(path_to("roles/x.json"))).to eq <<EOM.strip { diff --git a/spec/integration/knife/chef_repo_path_spec.rb b/spec/integration/knife/chef_repo_path_spec.rb index e609fa60b3..9cb093c178 100644 --- a/spec/integration/knife/chef_repo_path_spec.rb +++ b/spec/integration/knife/chef_repo_path_spec.rb @@ -391,7 +391,7 @@ EOM file "cookbooks2/blah/metadata.rb", "" end it "knife list -Rfp cookbooks shows files in blah" do - knife("list --local -Rfp /cookbooks").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'blah' is empty or entirely chefignored at #{Chef::Config.cookbook_path[0]}/blah\n") + knife("list --local -Rfp /cookbooks").should_succeed(<<EOM, stderr: "WARN: Cookbook 'blah' is empty or entirely chefignored at #{Chef::Config.cookbook_path[0]}/blah\n") /cookbooks/blah/ /cookbooks/blah/metadata.rb /cookbooks/cookbook1/ @@ -408,7 +408,7 @@ EOM file "cookbooks2/blah/metadata.rb", "" end it "knife list -Rfp cookbooks shows files in the first cookbook and not the second" do - knife("list --local -Rfp /cookbooks").should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.cookbook_path[0]}/blah and #{Chef::Config.cookbook_path[1]}/blah\n") + knife("list --local -Rfp /cookbooks").should_succeed(<<EOM, stderr: "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.cookbook_path[0]}/blah and #{Chef::Config.cookbook_path[1]}/blah\n") /cookbooks/blah/ /cookbooks/blah/metadata.json /cookbooks/cookbook1/ @@ -442,7 +442,7 @@ EOM file "data_bags2/blah/item2.json", "" end it "knife list -Rfp data_bags shows only items in data_bags1" do - knife("list --local -Rfp /data_bags").should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.data_bag_path[0]}/blah and #{Chef::Config.data_bag_path[1]}/blah\n") + knife("list --local -Rfp /data_bags").should_succeed(<<EOM, stderr: "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.data_bag_path[0]}/blah and #{Chef::Config.data_bag_path[1]}/blah\n") /data_bags/bag/ /data_bags/bag/item.json /data_bags/bag2/ diff --git a/spec/integration/knife/chef_repository_file_system_spec.rb b/spec/integration/knife/chef_repository_file_system_spec.rb index 222d3aee8a..c9aa787bbe 100644 --- a/spec/integration/knife/chef_repository_file_system_spec.rb +++ b/spec/integration/knife/chef_repository_file_system_spec.rb @@ -53,7 +53,7 @@ EOM before { directory "cookbooks/cookbook1" } it "knife list --local -Rfp / does not return it" do - knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + knife("list --local -Rfp /").should_succeed(<<EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end @@ -63,7 +63,7 @@ EOM before { directory "cookbooks/cookbook1/recipes" } it "knife list --local -Rfp / does not return it" do - knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + knife("list --local -Rfp /").should_succeed(<<EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end @@ -90,7 +90,7 @@ EOM before { directory "cookbooks/cookbook1/templates/default" } it "knife list --local -Rfp / does not return it" do - knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + knife("list --local -Rfp /").should_succeed(<<EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end diff --git a/spec/integration/knife/chefignore_spec.rb b/spec/integration/knife/chefignore_spec.rb index aa5a3979cc..e3f1e18f7e 100644 --- a/spec/integration/knife/chefignore_spec.rb +++ b/spec/integration/knife/chefignore_spec.rb @@ -69,7 +69,7 @@ EOM end it "the cookbook is not listed" do - knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + knife("list --local -Rfp /").should_succeed(<<EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end @@ -251,7 +251,7 @@ EOM end it "chefignores apply only to the winning cookbook" do - knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Child with name 'yourcookbook' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks1/yourcookbook and #{Chef::Config.chef_repo_path}/cookbooks2/yourcookbook\n") + knife("list --local -Rfp /").should_succeed(<<EOM, stderr: "WARN: Child with name 'yourcookbook' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks1/yourcookbook and #{Chef::Config.chef_repo_path}/cookbooks2/yourcookbook\n") /cookbooks/ /cookbooks/mycookbook/ /cookbooks/mycookbook/x.json diff --git a/spec/integration/knife/common_options_spec.rb b/spec/integration/knife/common_options_spec.rb index da1409456b..0b090f170e 100644 --- a/spec/integration/knife/common_options_spec.rb +++ b/spec/integration/knife/common_options_spec.rb @@ -125,7 +125,7 @@ EOM context "when the default port (8889) is already bound" do before :each do begin - @server = ChefZero::Server.new(:host => "localhost", :port => 8889) + @server = ChefZero::Server.new(host: "localhost", port: 8889) @server.start_background rescue Errno::EADDRINUSE # OK. Don't care who has it in use, as long as *someone* does. @@ -144,7 +144,7 @@ EOM context "when port 9999 is already bound" do before :each do begin - @server = ChefZero::Server.new(:host => "localhost", :port => 9999) + @server = ChefZero::Server.new(host: "localhost", port: 9999) @server.start_background rescue Errno::EADDRINUSE # OK. Don't care who has it in use, as long as *someone* does. diff --git a/spec/integration/knife/cookbook_api_ipv6_spec.rb b/spec/integration/knife/cookbook_api_ipv6_spec.rb index 0a4a6a6e94..434210c01e 100644 --- a/spec/integration/knife/cookbook_api_ipv6_spec.rb +++ b/spec/integration/knife/cookbook_api_ipv6_spec.rb @@ -23,7 +23,7 @@ describe "Knife cookbook API integration with IPv6", :workstation, :not_supporte include Chef::Mixin::ShellOut when_the_chef_server "is bound to IPv6" do - let(:chef_zero_opts) { { :host => "::1" } } + let(:chef_zero_opts) { { host: "::1" } } let(:client_key) do <<-END_VALIDATION_PEM @@ -89,7 +89,7 @@ END_CLIENT_RB end it "successfully uploads a cookbook" do - shell_out!("#{knife} cookbook upload apache2 #{knife_config_flag}", :cwd => chef_dir) + shell_out!("#{knife} cookbook upload apache2 #{knife_config_flag}", cwd: chef_dir) versions_list_json = Chef::HTTP::Simple.new("http://[::1]:8900").get("/cookbooks/apache2", "accept" => "application/json") versions_list = Chef::JSONCompat.from_json(versions_list_json) expect(versions_list["apache2"]["versions"]).not_to be_empty @@ -97,11 +97,11 @@ END_CLIENT_RB context "and the cookbook has been uploaded to the server" do before do - shell_out!("#{knife} cookbook upload apache2 #{knife_config_flag}", :cwd => chef_dir) + shell_out!("#{knife} cookbook upload apache2 #{knife_config_flag}", cwd: chef_dir) end it "downloads the cookbook" do - shell_out!("knife cookbook download apache2 #{knife_config_flag} -d #{cache_path}", :cwd => chef_dir) + shell_out!("knife cookbook download apache2 #{knife_config_flag} -d #{cache_path}", cwd: chef_dir) expect(Dir["#{cache_path}/*"].map { |entry| File.basename(entry) }).to include("apache2-0.0.1") end end diff --git a/spec/integration/knife/delete_spec.rb b/spec/integration/knife/delete_spec.rb index 1c69fbf9c9..9e0b46fd81 100644 --- a/spec/integration/knife/delete_spec.rb +++ b/spec/integration/knife/delete_spec.rb @@ -413,7 +413,7 @@ EOM end it "knife delete --both /environments/_default.json fails but still deletes the local copy" do - knife("delete --both /environments/_default.json").should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n" + knife("delete --both /environments/_default.json").should_fail stderr: "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", stdout: "Deleted /environments/_default.json\n" knife("list -Rf /").should_succeed server_everything knife("list -Rf --local /").should_succeed <<EOM /clients @@ -600,7 +600,7 @@ EOM end it "knife delete --both /environments/_default.json fails" do - knife("delete --both /environments/_default.json").should_fail "", :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n" + knife("delete --both /environments/_default.json").should_fail "", stderr: "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n" knife("list -Rf /").should_succeed server_everything knife("list -Rf --local /").should_succeed nothing end @@ -643,7 +643,7 @@ EOM context "and cwd is at the top level" do before { cwd "." } it "knife delete fails" do - knife("delete").should_fail "FATAL: You must specify at least one argument. If you want to delete everything in this directory, run \"knife delete --recurse .\"\n", :stdout => /USAGE/ + knife("delete").should_fail "FATAL: You must specify at least one argument. If you want to delete everything in this directory, run \"knife delete --recurse .\"\n", stdout: /USAGE/ knife("list -Rf /").should_succeed <<EOM clients clients/chef-validator.json @@ -796,7 +796,7 @@ EOM end it "knife delete --both /environments/_default.json fails but still deletes the local copy" do - knife("delete --both /environments/_default.json").should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n" + knife("delete --both /environments/_default.json").should_fail stderr: "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", stdout: "Deleted /environments/_default.json\n" knife("list -Rf /").should_succeed server_nothing knife("list -Rf --local /").should_succeed <<EOM /clients @@ -856,7 +856,7 @@ EOM context "and cwd is at the top level" do before { cwd "." } it "knife delete fails" do - knife("delete").should_fail "FATAL: You must specify at least one argument. If you want to delete everything in this directory, run \"knife delete --recurse .\"\n", :stdout => /USAGE/ + knife("delete").should_fail "FATAL: You must specify at least one argument. If you want to delete everything in this directory, run \"knife delete --recurse .\"\n", stdout: /USAGE/ knife("list -Rf /").should_succeed <<EOM clients clients/chef-validator.json @@ -962,7 +962,7 @@ EOM end end - when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do + when_the_chef_server "is in Enterprise mode", osc_compat: false, single_org: false do before do organization "foo" do container "x", {} diff --git a/spec/integration/knife/deps_spec.rb b/spec/integration/knife/deps_spec.rb index 3f200396ba..b8ab6e719c 100644 --- a/spec/integration/knife/deps_spec.rb +++ b/spec/integration/knife/deps_spec.rb @@ -252,44 +252,44 @@ EOM when_the_repository "is empty" do it "knife deps /blah reports an error" do knife("deps /blah").should_fail( - :exit_code => 2, - :stdout => "/blah\n", - :stderr => "ERROR: /blah: No such file or directory\n" + exit_code: 2, + stdout: "/blah\n", + stderr: "ERROR: /blah: No such file or directory\n" ) end it "knife deps /roles/x.json reports an error" do knife("deps /roles/x.json").should_fail( - :exit_code => 2, - :stdout => "/roles/x.json\n", - :stderr => "ERROR: /roles/x.json: No such file or directory\n" + exit_code: 2, + stdout: "/roles/x.json\n", + stderr: "ERROR: /roles/x.json: No such file or directory\n" ) end it "knife deps /nodes/x.json reports an error" do knife("deps /nodes/x.json").should_fail( - :exit_code => 2, - :stdout => "/nodes/x.json\n", - :stderr => "ERROR: /nodes/x.json: No such file or directory\n" + exit_code: 2, + stdout: "/nodes/x.json\n", + stderr: "ERROR: /nodes/x.json: No such file or directory\n" ) end it "knife deps /environments/x.json reports an error" do knife("deps /environments/x.json").should_fail( - :exit_code => 2, - :stdout => "/environments/x.json\n", - :stderr => "ERROR: /environments/x.json: No such file or directory\n" + exit_code: 2, + stdout: "/environments/x.json\n", + stderr: "ERROR: /environments/x.json: No such file or directory\n" ) end it "knife deps /cookbooks/x reports an error" do knife("deps /cookbooks/x").should_fail( - :exit_code => 2, - :stdout => "/cookbooks/x\n", - :stderr => "ERROR: /cookbooks/x: No such file or directory\n" + exit_code: 2, + stdout: "/cookbooks/x\n", + stderr: "ERROR: /cookbooks/x: No such file or directory\n" ) end it "knife deps /data_bags/bag/item.json reports an error" do knife("deps /data_bags/bag/item.json").should_fail( - :exit_code => 2, - :stdout => "/data_bags/bag/item.json\n", - :stderr => "ERROR: /data_bags/bag/item.json: No such file or directory\n" + exit_code: 2, + stdout: "/data_bags/bag/item.json\n", + stderr: "ERROR: /data_bags/bag/item.json: No such file or directory\n" ) end end @@ -299,9 +299,9 @@ EOM end it "knife deps reports the cookbook, along with an error" do knife("deps /roles/starring.json").should_fail( - :exit_code => 2, - :stdout => "/cookbooks/quiche\n/roles/starring.json\n", - :stderr => "ERROR: /cookbooks/quiche: No such file or directory\n" + exit_code: 2, + stdout: "/cookbooks/quiche\n/roles/starring.json\n", + stderr: "ERROR: /cookbooks/quiche: No such file or directory\n" ) end end @@ -311,9 +311,9 @@ EOM end it "knife deps reports the environment, along with an error" do knife("deps /nodes/mort.json").should_fail( - :exit_code => 2, - :stdout => "/environments/desert.json\n/nodes/mort.json\n", - :stderr => "ERROR: /environments/desert.json: No such file or directory\n" + exit_code: 2, + stdout: "/environments/desert.json\n/nodes/mort.json\n", + stderr: "ERROR: /environments/desert.json: No such file or directory\n" ) end end @@ -323,9 +323,9 @@ EOM end it "knife deps reports the role, along with an error" do knife("deps /roles/starring.json").should_fail( - :exit_code => 2, - :stdout => "/roles/minor.json\n/roles/starring.json\n", - :stderr => "ERROR: /roles/minor.json: No such file or directory\n" + exit_code: 2, + stdout: "/roles/minor.json\n/roles/starring.json\n", + stderr: "ERROR: /roles/minor.json: No such file or directory\n" ) end end @@ -337,9 +337,9 @@ EOM end it "knife deps /roles reports an error" do knife("deps /roles").should_fail( - :exit_code => 2, - :stderr => "ERROR: /roles: No such file or directory\n", - :stdout => "/roles\n" + exit_code: 2, + stderr: "ERROR: /roles: No such file or directory\n", + stdout: "/roles\n" ) end end @@ -590,44 +590,44 @@ EOM when_the_chef_server "is empty" do it "knife deps /blah reports an error" do knife("deps --remote /blah").should_fail( - :exit_code => 2, - :stdout => "/blah\n", - :stderr => "ERROR: /blah: No such file or directory\n" + exit_code: 2, + stdout: "/blah\n", + stderr: "ERROR: /blah: No such file or directory\n" ) end it "knife deps /roles/x.json reports an error" do knife("deps --remote /roles/x.json").should_fail( - :exit_code => 2, - :stdout => "/roles/x.json\n", - :stderr => "ERROR: /roles/x.json: No such file or directory\n" + exit_code: 2, + stdout: "/roles/x.json\n", + stderr: "ERROR: /roles/x.json: No such file or directory\n" ) end it "knife deps /nodes/x.json reports an error" do knife("deps --remote /nodes/x.json").should_fail( - :exit_code => 2, - :stdout => "/nodes/x.json\n", - :stderr => "ERROR: /nodes/x.json: No such file or directory\n" + exit_code: 2, + stdout: "/nodes/x.json\n", + stderr: "ERROR: /nodes/x.json: No such file or directory\n" ) end it "knife deps /environments/x.json reports an error" do knife("deps --remote /environments/x.json").should_fail( - :exit_code => 2, - :stdout => "/environments/x.json\n", - :stderr => "ERROR: /environments/x.json: No such file or directory\n" + exit_code: 2, + stdout: "/environments/x.json\n", + stderr: "ERROR: /environments/x.json: No such file or directory\n" ) end it "knife deps /cookbooks/x reports an error" do knife("deps --remote /cookbooks/x").should_fail( - :exit_code => 2, - :stdout => "/cookbooks/x\n", - :stderr => "ERROR: /cookbooks/x: No such file or directory\n" + exit_code: 2, + stdout: "/cookbooks/x\n", + stderr: "ERROR: /cookbooks/x: No such file or directory\n" ) end it "knife deps /data_bags/bag/item reports an error" do knife("deps --remote /data_bags/bag/item.json").should_fail( - :exit_code => 2, - :stdout => "/data_bags/bag/item.json\n", - :stderr => "ERROR: /data_bags/bag/item.json: No such file or directory\n" + exit_code: 2, + stdout: "/data_bags/bag/item.json\n", + stderr: "ERROR: /data_bags/bag/item.json: No such file or directory\n" ) end end @@ -637,9 +637,9 @@ EOM end it "knife deps reports the cookbook, along with an error" do knife("deps --remote /roles/starring.json").should_fail( - :exit_code => 2, - :stdout => "/cookbooks/quiche\n/roles/starring.json\n", - :stderr => "ERROR: /cookbooks/quiche: No such file or directory\n" + exit_code: 2, + stdout: "/cookbooks/quiche\n/roles/starring.json\n", + stderr: "ERROR: /cookbooks/quiche: No such file or directory\n" ) end end @@ -649,9 +649,9 @@ EOM end it "knife deps reports the environment, along with an error" do knife("deps --remote /nodes/mort.json").should_fail( - :exit_code => 2, - :stdout => "/environments/desert.json\n/nodes/mort.json\n", - :stderr => "ERROR: /environments/desert.json: No such file or directory\n" + exit_code: 2, + stdout: "/environments/desert.json\n/nodes/mort.json\n", + stderr: "ERROR: /environments/desert.json: No such file or directory\n" ) end end @@ -661,9 +661,9 @@ EOM end it "knife deps reports the role, along with an error" do knife("deps --remote /roles/starring.json").should_fail( - :exit_code => 2, - :stdout => "/roles/minor.json\n/roles/starring.json\n", - :stderr => "ERROR: /roles/minor.json: No such file or directory\n" + exit_code: 2, + stdout: "/roles/minor.json\n/roles/starring.json\n", + stderr: "ERROR: /roles/minor.json: No such file or directory\n" ) end end diff --git a/spec/integration/knife/diff_spec.rb b/spec/integration/knife/diff_spec.rb index b3bd23f48e..839dcafe49 100644 --- a/spec/integration/knife/diff_spec.rb +++ b/spec/integration/knife/diff_spec.rb @@ -247,7 +247,7 @@ EOM end when_the_chef_server "has an environment with a different value" do before { environment "x", { "description" => "hi" } } - it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do knife("diff /environments/x.json").should_succeed(/ { - "name": "x", @@ -277,7 +277,7 @@ EOM environment "x", {} end - it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do knife("diff /environments/x.json").should_succeed(/ { - "name": "x" @@ -291,7 +291,7 @@ EOM before do environment "x", { "description" => "lo" } end - it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do knife("diff /environments/x.json").should_succeed(/ { "name": "x", @@ -311,7 +311,7 @@ EOM it "knife diff reports an error and does a textual diff" do error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF" error_match = Regexp.new(Regexp.escape(error_text)) - knife("diff /environments/x.json").should_succeed(/- "name": "x"/, :stderr => error_match) + knife("diff /environments/x.json").should_succeed(/- "name": "x"/, stderr: error_match) end end end @@ -533,7 +533,7 @@ EOM end when_the_chef_server "has an environment with a different value" do before { environment "x", { "description" => "hi" } } - it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do knife("diff /environments/x.json").should_succeed(/ { - "name": "x", @@ -560,7 +560,7 @@ EOM end when_the_chef_server "has an environment with no value" do before { environment "x", {} } - it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do knife("diff /environments/x.json").should_succeed(/ { - "name": "x" @@ -574,7 +574,7 @@ EOM before do environment "x", { "description" => "lo" } end - it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do knife("diff /environments/x.json").should_succeed(/ { "name": "x", @@ -594,7 +594,7 @@ EOM it "knife diff reports an error and does a textual diff" do error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF" error_match = Regexp.new(Regexp.escape(error_text)) - knife("diff /environments/x.json").should_succeed(/- "name": "x"/, :stderr => error_match) + knife("diff /environments/x.json").should_succeed(/- "name": "x"/, stderr: error_match) end end end diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb index be0fc9d708..68762ec58e 100644 --- a/spec/integration/knife/download_spec.rb +++ b/spec/integration/knife/download_spec.rb @@ -255,7 +255,7 @@ EOM end it "knife download with no parameters reports an error" do - knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", :stdout => /USAGE/ + knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", stdout: /USAGE/ end end end @@ -383,7 +383,7 @@ EOM cwd "data_bags" end it "knife download fails" do - knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", :stdout => /USAGE/ + knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", stdout: /USAGE/ end it "knife download --purge . downloads everything" do knife("download --purge .").should_succeed <<EOM @@ -545,7 +545,7 @@ EOM end it "knife download refuses to change the role" do - knife("download /roles/x.json").should_succeed "", :stderr => "WARNING: /roles/x.rb cannot be updated (can't safely update ruby files).\n" + knife("download /roles/x.json").should_succeed "", stderr: "WARNING: /roles/x.rb cannot be updated (can't safely update ruby files).\n" knife("diff --name-status /roles/x.json").should_succeed "M\t/roles/x.rb\n" end end @@ -566,7 +566,7 @@ WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error (right here) ------^ EOH - knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n", :stderr => warning + knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n", stderr: warning knife("diff --name-status /environments/x.json").should_succeed "" end end @@ -779,7 +779,7 @@ EOM cwd "." end it "knife download with no parameters reports an error" do - knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", :stdout => /USAGE/ + knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", stdout: /USAGE/ end end end @@ -898,7 +898,7 @@ EOM cwd "data_bags" end it "knife download fails" do - knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", :stdout => /USAGE/ + knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", stdout: /USAGE/ end it "knife download --purge . downloads everything" do knife("download --purge .").should_succeed <<EOM @@ -1111,7 +1111,7 @@ EOM end end - when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do + when_the_chef_server "is in Enterprise mode", osc_compat: false, single_org: false do before do user "foo", {} user "bar", {} diff --git a/spec/integration/knife/list_spec.rb b/spec/integration/knife/list_spec.rb index 4aa74f3f0e..bcafd40e9b 100644 --- a/spec/integration/knife/list_spec.rb +++ b/spec/integration/knife/list_spec.rb @@ -466,7 +466,7 @@ EOM end end - when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", :skip => (Chef::Platform.windows?) do + when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", skip: (Chef::Platform.windows?) do before do directory "cookbooks" symlink "symlinked", "cookbooks" @@ -503,7 +503,7 @@ EOM end end - when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", :skip => (Chef::Platform.windows?) do + when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", skip: (Chef::Platform.windows?) do before do directory "real_cookbooks" symlink "cookbooks", "real_cookbooks" @@ -638,7 +638,7 @@ EOM end end - when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do + when_the_chef_server "is in Enterprise mode", osc_compat: false, single_org: false do before do organization "foo" end diff --git a/spec/integration/knife/raw_spec.rb b/spec/integration/knife/raw_spec.rb index 5e0d3a3d11..27e425717b 100644 --- a/spec/integration/knife/raw_spec.rb +++ b/spec/integration/knife/raw_spec.rb @@ -38,7 +38,7 @@ describe "knife raw", :workstation do user "x", "{}" end - it "knife raw /nodes/x returns the node", :skip => (RUBY_VERSION < "1.9") do + it "knife raw /nodes/x returns the node", skip: (RUBY_VERSION < "1.9") do knife("raw /nodes/x").should_succeed <<EOM { "name": "x", @@ -70,7 +70,7 @@ EOM knife("raw /blarghle").should_fail(/ERROR: Server responded with error 404 "Not Found\s*"/) end - it "knife raw -m DELETE /roles/x succeeds", :skip => (RUBY_VERSION < "1.9") do + it "knife raw -m DELETE /roles/x succeeds", skip: (RUBY_VERSION < "1.9") do knife("raw -m DELETE /roles/x").should_succeed <<EOM { "name": "x", @@ -94,7 +94,7 @@ EOM knife("show /roles/x.json").should_fail "ERROR: /roles/x.json: No such file or directory\n" end - it "knife raw -m PUT -i blah.txt /roles/x succeeds", :skip => (RUBY_VERSION < "1.9") do + it "knife raw -m PUT -i blah.txt /roles/x succeeds", skip: (RUBY_VERSION < "1.9") do Tempfile.open("raw_put_input") do |file| file.write <<EOM { @@ -148,7 +148,7 @@ EOM end end - it "knife raw -m POST -i blah.txt /roles succeeds", :skip => (RUBY_VERSION < "1.9") do + it "knife raw -m POST -i blah.txt /roles succeeds", skip: (RUBY_VERSION < "1.9") do Tempfile.open("raw_put_input") do |file| file.write <<EOM { @@ -198,7 +198,7 @@ EOM @raw_server_thread.kill if @raw_server_thread end - it "knife raw /blah returns the prettified json", :skip => (RUBY_VERSION < "1.9") do + it "knife raw /blah returns the prettified json", skip: (RUBY_VERSION < "1.9") do knife("raw /blah").should_succeed <<EOM { "x": "y", diff --git a/spec/integration/knife/show_spec.rb b/spec/integration/knife/show_spec.rb index ed4802fef9..3d7dfe68e2 100644 --- a/spec/integration/knife/show_spec.rb +++ b/spec/integration/knife/show_spec.rb @@ -76,7 +76,7 @@ EOM } EOM end - it "knife show /environments/x.json shows the remote version", :skip => (RUBY_VERSION < "1.9") do + it "knife show /environments/x.json shows the remote version", skip: (RUBY_VERSION < "1.9") do knife("show /environments/x.json").should_succeed <<EOM /environments/x.json: { @@ -92,7 +92,7 @@ EOM } EOM end - it "knife show /roles/x.json shows the remote version", :skip => (RUBY_VERSION < "1.9") do + it "knife show /roles/x.json shows the remote version", skip: (RUBY_VERSION < "1.9") do knife("show /roles/x.json").should_succeed <<EOM /roles/x.json: { @@ -135,7 +135,7 @@ EOM "name" => "x", } end - it "knife show shows the attributes in a predetermined order", :skip => (RUBY_VERSION < "1.9") do + it "knife show shows the attributes in a predetermined order", skip: (RUBY_VERSION < "1.9") do knife("show /environments/x.json").should_succeed <<EOM /environments/x.json: { diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb index dc713d02b3..f478e6da01 100644 --- a/spec/integration/knife/upload_spec.rb +++ b/spec/integration/knife/upload_spec.rb @@ -68,7 +68,7 @@ EOM end it "knife upload --purge deletes everything" do - knife("upload --purge /").should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") + knife("upload --purge /").should_succeed(<<EOM, stderr: "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") Deleted extra entry /clients/chef-validator.json (purge is on) Deleted extra entry /clients/chef-webui.json (purge is on) Deleted extra entry /clients/x.json (purge is on) @@ -271,7 +271,7 @@ EOM end it "knife upload with no parameters reports an error" do - knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", :stdout => /USAGE/ + knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", stdout: /USAGE/ end end end @@ -291,7 +291,7 @@ Created /data_bags/x/y.json EOM knife("diff --name-status /data_bags").should_succeed <<EOM EOM - expect(Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, :create_additions => false).keys.sort).to eq(%w{foo id}) + expect(Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, create_additions: false).keys.sort).to eq(%w{foo id}) end it "knife upload /data_bags/x /data_bags/x/y.json uploads x once" do @@ -314,7 +314,7 @@ Created /data_bags/x Created /data_bags/x/y.json EOM knife("diff --name-status /data_bags").should_succeed "" - result = Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, :create_additions => false) + result = Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, create_additions: false) expect(result.keys.sort).to eq(%w{chef_type data_bag id}) expect(result["chef_type"]).to eq("aaa") expect(result["data_bag"]).to eq("bbb") @@ -419,7 +419,7 @@ EOM end it "knife upload fails" do - knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", :stdout => /USAGE/ + knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", stdout: /USAGE/ end it "knife upload --purge . uploads everything" do @@ -525,7 +525,7 @@ EOM when_the_chef_server "has a frozen cookbook" do before do - cookbook "frozencook", "1.0.0", {}, :frozen => true + cookbook "frozencook", "1.0.0", {}, frozen: true end when_the_repository "has an update to said cookbook" do @@ -652,7 +652,7 @@ WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error EOH knife("upload /environments/x.json").should_fail(error1) - knife("diff --name-status /environments/x.json").should_succeed("M\t/environments/x.json\n", :stderr => warn) + knife("diff --name-status /environments/x.json").should_succeed("M\t/environments/x.json\n", stderr: warn) end end @@ -767,7 +767,7 @@ EOM end it "knife upload --purge deletes everything" do - knife("upload --purge /").should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") + knife("upload --purge /").should_succeed(<<EOM, stderr: "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") Deleted extra entry /clients/chef-validator.json (purge is on) Deleted extra entry /clients/chef-webui.json (purge is on) Deleted extra entry /clients/x.json (purge is on) @@ -922,7 +922,7 @@ EOM cwd "." end it "knife upload with no parameters reports an error" do - knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", :stdout => /USAGE/ + knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", stdout: /USAGE/ end end end @@ -1024,7 +1024,7 @@ EOM cwd "data_bags" end it "knife upload fails" do - knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", :stdout => /USAGE/ + knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", stdout: /USAGE/ end it "knife upload --purge . uploads everything" do knife("upload --purge .").should_succeed <<EOM @@ -1274,7 +1274,7 @@ EOM end end - when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do + when_the_chef_server "is in Enterprise mode", osc_compat: false, single_org: false do before do user "foo", {} user "bar", {} @@ -1472,7 +1472,7 @@ EOM end it "knife upload / emits a warning for bar and invites foobar" do - knife("upload /").should_succeed "Updated /invitations.json\n", :stderr => "WARN: Could not invite bar to organization foo: User bar is already in organization foo\n" + knife("upload /").should_succeed "Updated /invitations.json\n", stderr: "WARN: Could not invite bar to organization foo: User bar is already in organization foo\n" expect(api.get("association_requests").map { |a| a["username"] }).to eq(%w{foo foobar}) expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar" ]) end diff --git a/spec/integration/recipes/accumulator_spec.rb b/spec/integration/recipes/accumulator_spec.rb index 4a193bd7f0..65a05fcdc5 100644 --- a/spec/integration/recipes/accumulator_spec.rb +++ b/spec/integration/recipes/accumulator_spec.rb @@ -119,7 +119,7 @@ describe "Accumulators" do log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) result.error! # runs only a single template resource (in the outer run context, as a delayed resource) expect(result.stdout.scan(/template\S+ action create/).size).to eql(1) @@ -221,7 +221,7 @@ describe "Accumulators" do log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) result.error! # runs only a single template resource (in the outer run context, as a delayed resource) expect(result.stdout.scan(/template\S+ action create/).size).to eql(1) diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb index 54ce94f263..a9832fe6b0 100644 --- a/spec/integration/recipes/lwrp_inline_resources_spec.rb +++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb @@ -151,7 +151,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) actual = result.stdout.lines.map { |l| l.chomp }.join("\n") expected = <<EOM * x_my_machine[me] action create diff --git a/spec/integration/recipes/lwrp_spec.rb b/spec/integration/recipes/lwrp_spec.rb index 3bc008d4f8..3494924a8f 100644 --- a/spec/integration/recipes/lwrp_spec.rb +++ b/spec/integration/recipes/lwrp_spec.rb @@ -44,7 +44,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'l-w-r-p::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'l-w-r-p::default'", cwd: chef_dir) expect(result.stdout).to match(/\* l_w_r_p_foo\[me\] action create \(up to date\)/) expect(result.stdout).not_to match(/WARN: You are overriding l_w_r_p_foo/) result.error! diff --git a/spec/integration/recipes/notifies_spec.rb b/spec/integration/recipes/notifies_spec.rb index b008e4ade7..2aa02554b9 100644 --- a/spec/integration/recipes/notifies_spec.rb +++ b/spec/integration/recipes/notifies_spec.rb @@ -32,7 +32,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) # our delayed notification should run at the end of the parent run_context after the baz resource expect(result.stdout).to match(/\* apt_update\[\] action nothing \(skipped due to action :nothing\)\s+\* log\[foo\] action write\s+\* log\[bar\] action write\s+\* apt_update\[\] action nothing \(skipped due to action :nothing\)/) result.error! @@ -73,7 +73,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) # our delayed notification should run at the end of the parent run_context after the baz resource expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/) result.error! @@ -116,7 +116,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) # our delayed notification should run at the end of the parent run_context after the baz resource expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/) # and only run once @@ -163,7 +163,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) # the delayed notification from the sub-resource is de-duplicated by the notification already in the parent run_context expect(result.stdout).to match(/\* log\[quux\] action write\s+\* notifying_test\[whatever\] action run\s+\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/) # and only run once @@ -197,7 +197,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) # the delayed notification from the sub-resource is de-duplicated by the notification already in the parent run_context expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/) # and only run once @@ -240,7 +240,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/) result.error! end @@ -280,7 +280,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/) result.error! end @@ -317,7 +317,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match(/Chef::Exceptions::ResourceNotFound/) expect(result.exitstatus).not_to eql(0) end @@ -357,7 +357,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).not_to match(/CHEF-3694/) result.error! end @@ -385,7 +385,7 @@ cookbook_path "#{path_to('cookbooks')}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match /\* log\[a, b\] action write/ result.error! end diff --git a/spec/integration/recipes/notifying_block_spec.rb b/spec/integration/recipes/notifying_block_spec.rb index 6a1287c7b1..6c50854038 100644 --- a/spec/integration/recipes/notifying_block_spec.rb +++ b/spec/integration/recipes/notifying_block_spec.rb @@ -55,7 +55,7 @@ describe "notifying_block" do # 2. delayed notifications are de-dup'd in the subcontext # 3. delayed notifications (to resources inside the subcontext) are run at the end of the subcontext it "should run alpha, beta, gamma, and delta in that order" do - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match(/\* log\[alpha\] action write\s+\* log\[beta\] action write\s+\* log\[gamma\] action write\s+Converging 1 resources\s+\* log\[delta\] action write/) result.error! end @@ -103,7 +103,7 @@ describe "notifying_block" do # 1. notifying block will correctly update wrapping new_resource updated_by_last_action status # 2. delayed notifications from a subcontext inside a resource will notify resources in their outer run_context it "should run foo, quux, bar, and baz in that order" do - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match(/\* log\[foo\] action write\s+\* log\[quux\] action write\s+\* log\[bar\] action write\s+\* log\[baz\] action write/) result.error! end diff --git a/spec/integration/recipes/remote_directory.rb b/spec/integration/recipes/remote_directory.rb index 77fe183136..a0e3e23ef3 100644 --- a/spec/integration/recipes/remote_directory.rb +++ b/spec/integration/recipes/remote_directory.rb @@ -50,7 +50,7 @@ describe Chef::Resource::RemoteDirectory do end EOM end - shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'test::default'", :cwd => chef_dir) + shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'test::default'", cwd: chef_dir) end def mode_of(path) diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb index 63525f0081..36fabd232d 100644 --- a/spec/integration/solo/solo_spec.rb +++ b/spec/integration/solo/solo_spec.rb @@ -26,7 +26,7 @@ describe "chef-solo" do file "config/solo.rb", <<EOM chef_repo_path "#{@repository_dir}" EOM - result = shell_out("ruby bin/chef-solo -c \"#{path_to('config/solo.rb')}\" -l debug", :cwd => chef_dir) + result = shell_out("ruby bin/chef-solo -c \"#{path_to('config/solo.rb')}\" -l debug", cwd: chef_dir) result.error! end @@ -78,7 +78,7 @@ EOM cookbook_path "#{path_to('cookbooks')}" file_cache_path "#{path_to('config/cache')}" EOM - result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", :cwd => chef_dir) + result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir) result.error! expect(result.stdout).to include("ITWORKS") end @@ -93,7 +93,7 @@ EOM {"run_list":["x::default"]} E - result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -j '#{path_to('config/node.json')}' -l debug", :cwd => chef_dir) + result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -j '#{path_to('config/node.json')}' -l debug", cwd: chef_dir) result.error! expect(result.stdout).to include("ITWORKS") end @@ -114,7 +114,7 @@ E cookbook_path "#{path_to('cookbooks')}" file_cache_path "#{path_to('config/cache')}" EOM - result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", :cwd => chef_dir) + result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir) expect(result.exitstatus).to eq(0) # For CHEF-5120 this becomes 1 expect(result.stdout).to include("WARN: MissingCookbookDependency") end @@ -131,7 +131,7 @@ EOM end it "should exit with an error" do - result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", :cwd => chef_dir) + result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir) expect(result.exitstatus).to eq(1) expect(result.stdout).to include("Chef::Exceptions::CookbookChefVersionMismatch") end @@ -148,7 +148,7 @@ EOM end it "should exit with an error" do - result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", :cwd => chef_dir) + result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir) expect(result.exitstatus).to eq(1) expect(result.stdout).to include("Chef::Exceptions::CookbookOhaiVersionMismatch") end @@ -187,13 +187,13 @@ EOM # Instantiate the first chef-solo run threads << Thread.new do - s1 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir) + s1 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", chdir: chef_dir) Process.waitpid(s1) end # Instantiate the second chef-solo run threads << Thread.new do - s2 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir) + s2 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", chdir: chef_dir) Process.waitpid(s2) end diff --git a/spec/scripts/ssl-serve.rb b/spec/scripts/ssl-serve.rb index 3f4e343926..5677e94d0a 100644 --- a/spec/scripts/ssl-serve.rb +++ b/spec/scripts/ssl-serve.rb @@ -20,26 +20,26 @@ key = OpenSSL::PKey::RSA.new(key_text) server_opts = {} if $ssl - server_opts.merge!( { :SSLEnable => true, - :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, - :SSLCertificate => cert, - :SSLPrivateKey => key }) + server_opts.merge!( { SSLEnable: true, + SSLVerifyClient: OpenSSL::SSL::VERIFY_NONE, + SSLCertificate: cert, + SSLPrivateKey: key }) end # 5 == debug, 3 == warning LOGGER = WEBrick::Log.new(STDOUT, 5) DEFAULT_OPTIONS = { - :server => "webrick", - :Port => 9000, - :Host => "localhost", - :environment => :none, - :Logger => LOGGER, - :DocumentRoot => File.expand_path("#{Dir.tmpdir}/chef-118-sampledata") + server: "webrick", + Port: 9000, + Host: "localhost", + environment: :none, + Logger: LOGGER, + DocumentRoot: File.expand_path("#{Dir.tmpdir}/chef-118-sampledata") #:AccessLog => [] # Remove this option to enable the access log when debugging. } webrick_opts = DEFAULT_OPTIONS.merge(server_opts) -pp :webrick_opts => webrick_opts +pp webrick_opts: webrick_opts server = WEBrick::HTTPServer.new(webrick_opts) trap("INT") { server.shutdown } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b4d337eecd..c9ba059ddb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -119,8 +119,8 @@ resource_handler_map ||= nil RSpec.configure do |config| config.include(Matchers) config.include(MockShellout::RSpec) - config.filter_run :focus => true - config.filter_run_excluding :external => true + config.filter_run focus: true + config.filter_run_excluding external: true # Explicitly disable :should syntax config.expect_with :rspec do |c| @@ -134,83 +134,83 @@ RSpec.configure do |config| config.filter_run_excluding :workstation if solaris? || aix? # Tests that randomly fail, but may have value. - config.filter_run_excluding :volatile => true - config.filter_run_excluding :volatile_on_solaris => true if solaris? - config.filter_run_excluding :volatile_from_verify => false - - config.filter_run_excluding :skip_appveyor => true if ENV["APPVEYOR"] - config.filter_run_excluding :appveyor_only => true unless ENV["APPVEYOR"] - config.filter_run_excluding :skip_travis => true if ENV["TRAVIS"] - - config.filter_run_excluding :windows_only => true unless windows? - config.filter_run_excluding :not_supported_on_mac_osx_106 => true if mac_osx_106? - config.filter_run_excluding :not_supported_on_mac_osx => true if mac_osx? - config.filter_run_excluding :mac_osx_only => true if !mac_osx? - config.filter_run_excluding :not_supported_on_aix => true if aix? - config.filter_run_excluding :not_supported_on_solaris => true if solaris? - config.filter_run_excluding :not_supported_on_gce => true if gce? - config.filter_run_excluding :not_supported_on_nano => true if windows_nano_server? - config.filter_run_excluding :win2012r2_only => true unless windows_2012r2? - config.filter_run_excluding :windows_2008r2_or_later => true unless windows_2008r2_or_later? - config.filter_run_excluding :windows64_only => true unless windows64? - config.filter_run_excluding :windows32_only => true unless windows32? - config.filter_run_excluding :windows_nano_only => true unless windows_nano_server? - config.filter_run_excluding :windows_gte_10 => true unless windows_gte_10? - config.filter_run_excluding :windows_lt_10 => true if windows_gte_10? - config.filter_run_excluding :ruby64_only => true unless ruby_64bit? - config.filter_run_excluding :ruby32_only => true unless ruby_32bit? - config.filter_run_excluding :windows_powershell_dsc_only => true unless windows_powershell_dsc? - config.filter_run_excluding :windows_powershell_no_dsc_only => true unless ! windows_powershell_dsc? - config.filter_run_excluding :windows_domain_joined_only => true unless windows_domain_joined? - config.filter_run_excluding :windows_not_domain_joined_only => true if windows_domain_joined? + config.filter_run_excluding volatile: true + config.filter_run_excluding volatile_on_solaris: true if solaris? + config.filter_run_excluding volatile_from_verify: false + + config.filter_run_excluding skip_appveyor: true if ENV["APPVEYOR"] + config.filter_run_excluding appveyor_only: true unless ENV["APPVEYOR"] + config.filter_run_excluding skip_travis: true if ENV["TRAVIS"] + + config.filter_run_excluding windows_only: true unless windows? + config.filter_run_excluding not_supported_on_mac_osx_106: true if mac_osx_106? + config.filter_run_excluding not_supported_on_mac_osx: true if mac_osx? + config.filter_run_excluding mac_osx_only: true if !mac_osx? + config.filter_run_excluding not_supported_on_aix: true if aix? + config.filter_run_excluding not_supported_on_solaris: true if solaris? + config.filter_run_excluding not_supported_on_gce: true if gce? + config.filter_run_excluding not_supported_on_nano: true if windows_nano_server? + config.filter_run_excluding win2012r2_only: true unless windows_2012r2? + config.filter_run_excluding windows_2008r2_or_later: true unless windows_2008r2_or_later? + config.filter_run_excluding windows64_only: true unless windows64? + config.filter_run_excluding windows32_only: true unless windows32? + config.filter_run_excluding windows_nano_only: true unless windows_nano_server? + config.filter_run_excluding windows_gte_10: true unless windows_gte_10? + config.filter_run_excluding windows_lt_10: true if windows_gte_10? + config.filter_run_excluding ruby64_only: true unless ruby_64bit? + config.filter_run_excluding ruby32_only: true unless ruby_32bit? + config.filter_run_excluding windows_powershell_dsc_only: true unless windows_powershell_dsc? + config.filter_run_excluding windows_powershell_no_dsc_only: true unless ! windows_powershell_dsc? + config.filter_run_excluding windows_domain_joined_only: true unless windows_domain_joined? + config.filter_run_excluding windows_not_domain_joined_only: true if windows_domain_joined? # We think this line was causing rspec tests to not run on the Jenkins windows # testers. If we ever fix it we should restore it. # config.filter_run_excluding :windows_service_requires_assign_token => true if !STDOUT.isatty && !windows_user_right?("SeAssignPrimaryTokenPrivilege") - config.filter_run_excluding :windows_service_requires_assign_token => true - config.filter_run_excluding :solaris_only => true unless solaris? - config.filter_run_excluding :system_windows_service_gem_only => true unless system_windows_service_gem? - config.filter_run_excluding :unix_only => true unless unix? - config.filter_run_excluding :linux_only => true unless linux? - config.filter_run_excluding :aix_only => true unless aix? - config.filter_run_excluding :debian_family_only => true unless debian_family? - config.filter_run_excluding :supports_cloexec => true unless supports_cloexec? - config.filter_run_excluding :selinux_only => true unless selinux_enabled? - config.filter_run_excluding :requires_root => true unless root? - config.filter_run_excluding :requires_root_or_running_windows => true unless root? || windows? - config.filter_run_excluding :requires_unprivileged_user => true if root? - config.filter_run_excluding :uses_diff => true unless has_diff? - config.filter_run_excluding :openssl_gte_101 => true unless openssl_gte_101? - config.filter_run_excluding :openssl_lt_101 => true unless openssl_lt_101? - config.filter_run_excluding :aes_256_gcm_only => true unless aes_256_gcm? - config.filter_run_excluding :broken => true - config.filter_run_excluding :not_wpar => true unless wpar? - config.filter_run_excluding :not_supported_under_fips => true if fips? - config.filter_run_excluding :rhel => true unless rhel? - config.filter_run_excluding :rhel5 => true unless rhel5? - config.filter_run_excluding :rhel6 => true unless rhel6? - config.filter_run_excluding :rhel7 => true unless rhel7? - config.filter_run_excluding :intel_64bit => true unless intel_64bit? - config.filter_run_excluding :not_rhel => true if rhel? - config.filter_run_excluding :not_rhel5 => true if rhel5? - config.filter_run_excluding :not_rhel6 => true if rhel6? - config.filter_run_excluding :not_rhel7 => true if rhel7? - config.filter_run_excluding :not_intel_64bit => true if intel_64bit? + config.filter_run_excluding windows_service_requires_assign_token: true + config.filter_run_excluding solaris_only: true unless solaris? + config.filter_run_excluding system_windows_service_gem_only: true unless system_windows_service_gem? + config.filter_run_excluding unix_only: true unless unix? + config.filter_run_excluding linux_only: true unless linux? + config.filter_run_excluding aix_only: true unless aix? + config.filter_run_excluding debian_family_only: true unless debian_family? + config.filter_run_excluding supports_cloexec: true unless supports_cloexec? + config.filter_run_excluding selinux_only: true unless selinux_enabled? + config.filter_run_excluding requires_root: true unless root? + config.filter_run_excluding requires_root_or_running_windows: true unless root? || windows? + config.filter_run_excluding requires_unprivileged_user: true if root? + config.filter_run_excluding uses_diff: true unless has_diff? + config.filter_run_excluding openssl_gte_101: true unless openssl_gte_101? + config.filter_run_excluding openssl_lt_101: true unless openssl_lt_101? + config.filter_run_excluding aes_256_gcm_only: true unless aes_256_gcm? + config.filter_run_excluding broken: true + config.filter_run_excluding not_wpar: true unless wpar? + config.filter_run_excluding not_supported_under_fips: true if fips? + config.filter_run_excluding rhel: true unless rhel? + config.filter_run_excluding rhel5: true unless rhel5? + config.filter_run_excluding rhel6: true unless rhel6? + config.filter_run_excluding rhel7: true unless rhel7? + config.filter_run_excluding intel_64bit: true unless intel_64bit? + config.filter_run_excluding not_rhel: true if rhel? + config.filter_run_excluding not_rhel5: true if rhel5? + config.filter_run_excluding not_rhel6: true if rhel6? + config.filter_run_excluding not_rhel7: true if rhel7? + config.filter_run_excluding not_intel_64bit: true if intel_64bit? # these let us use chef: ">= 13" or ruby: "~> 2.0.0" or any other Gem::Dependency-style constraint config.filter_run_excluding chef: DependencyProc.with(Chef::VERSION) config.filter_run_excluding ruby: DependencyProc.with(RUBY_VERSION) - config.filter_run_excluding :choco_installed => true unless choco_installed? + config.filter_run_excluding choco_installed: true unless choco_installed? running_platform_arch = `uname -m`.strip unless windows? - config.filter_run_excluding :arch => lambda { |target_arch| + config.filter_run_excluding arch: lambda { |target_arch| running_platform_arch != target_arch } # Functional Resource tests that are provider-specific: # context "on platforms that use useradd", :provider => {:user => Chef::Provider::User::Useradd}} do #... - config.filter_run_excluding :provider => lambda { |criteria| + config.filter_run_excluding provider: lambda { |criteria| type, target_provider = criteria.first node = TEST_NODE.dup diff --git a/spec/stress/win32/file_spec.rb b/spec/stress/win32/file_spec.rb index f1c81eb9c6..49dd8694f5 100644 --- a/spec/stress/win32/file_spec.rb +++ b/spec/stress/win32/file_spec.rb @@ -26,12 +26,12 @@ describe "Chef::ReservedNames::Win32::File", :windows_only do it "should not leak significant memory", :volatile do test = lambda { Chef::ReservedNames::Win32::File.symlink?(@path) } - expect(test).not_to leak_memory(:warmup => 50000, :iterations => 50000) + expect(test).not_to leak_memory(warmup: 50000, iterations: 50000) end it "should not leak handles", :volatile do test = lambda { Chef::ReservedNames::Win32::File.symlink?(@path) } - expect(test).not_to leak_handles(:warmup => 50, :iterations => 100) + expect(test).not_to leak_handles(warmup: 50, iterations: 100) end end diff --git a/spec/stress/win32/security_spec.rb b/spec/stress/win32/security_spec.rb index 3c03a657b2..0280398ad5 100644 --- a/spec/stress/win32/security_spec.rb +++ b/spec/stress/win32/security_spec.rb @@ -52,7 +52,7 @@ describe "Chef::ReservedNames::Win32::Security", :windows_only do expect do sids = Chef::ReservedNames::Win32::Security::SecurableObject.new(@monkeyfoo).security_descriptor.dacl.select { |ace| ace.sid } GC.start - end.not_to leak_memory(:warmup => 50, :iterations => 100) + end.not_to leak_memory(warmup: 50, iterations: 100) end it "should not leak when creating a new ACL and setting it on a file", :volatile do @@ -63,7 +63,7 @@ describe "Chef::ReservedNames::Win32::Security", :windows_only do Chef::ReservedNames::Win32::Security::ACE.access_denied(Chef::ReservedNames::Win32::Security::SID.from_account("Users"), Chef::ReservedNames::Win32::API::Security::GENERIC_ALL), ]) GC.start - end.not_to leak_memory(:warmup => 50, :iterations => 100) + end.not_to leak_memory(warmup: 50, iterations: 100) end end diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb index 8569523e05..6ae052ba1d 100644 --- a/spec/support/platform_helpers.rb +++ b/spec/support/platform_helpers.rb @@ -202,7 +202,7 @@ def selinux_enabled? # specs independent of product. selinuxenabled_path = which("selinuxenabled") if selinuxenabled_path - cmd = Mixlib::ShellOut.new(selinuxenabled_path, :returns => [0, 1]) + cmd = Mixlib::ShellOut.new(selinuxenabled_path, returns: [0, 1]) cmd_result = cmd.run_command case cmd_result.exitstatus when 1 diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb index 4b90fcaedd..6797a4ad22 100644 --- a/spec/support/shared/context/client.rb +++ b/spec/support/shared/context/client.rb @@ -11,16 +11,16 @@ shared_context "client" do let(:ohai_data) do { - :fqdn => fqdn, - :hostname => hostname, - :machinename => machinename, - :platform => platform, - :platform_version => platform_version, + fqdn: fqdn, + hostname: hostname, + machinename: machinename, + platform: platform, + platform_version: platform_version, } end let(:ohai_system) do - ohai = instance_double("Ohai::System", :all_plugins => true, :data => ohai_data, logger: logger) + ohai = instance_double("Ohai::System", all_plugins: true, data: ohai_data, logger: logger) allow(ohai).to receive(:[]) do |k| ohai_data[k] end @@ -80,7 +80,7 @@ shared_context "a client run" do let(:reporting_rest_client) { double("Chef::ServerAPI (reporting client)") } let(:runner) { instance_double("Chef::Runner") } - let(:audit_runner) { instance_double("Chef::Audit::Runner", :failed? => false) } + let(:audit_runner) { instance_double("Chef::Audit::Runner", failed?: false) } def stub_for_register # --Client.register @@ -136,7 +136,7 @@ shared_context "a client run" do expect_any_instance_of(Chef::CookbookSynchronizer).to receive(:sync_cookbooks) expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], version_class: Chef::CookbookManifestVersions).and_return(http_cookbook_sync) expect(http_cookbook_sync).to receive(:post). - with("environments/_default/cookbook_versions", { :run_list => [] }). + with("environments/_default/cookbook_versions", { run_list: [] }). and_return({}) end @@ -250,8 +250,8 @@ end shared_context "audit phase completed with failed controls" do let(:audit_runner) do - instance_double("Chef::Audit::Runner", :failed? => true, - :num_failed => 1, :num_total => 3) end + instance_double("Chef::Audit::Runner", failed?: true, + num_failed: 1, num_total: 3) end let(:audit_error) do err = Chef::Exceptions::AuditsFailed.new(audit_runner.num_failed, audit_runner.num_total) diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb index 65f512b5bf..0df006cccc 100644 --- a/spec/support/shared/functional/securable_resource.rb +++ b/spec/support/shared/functional/securable_resource.rb @@ -95,7 +95,7 @@ shared_context "use Windows permissions", :windows_only do def extract_ace_properties(aces) hashes = [] aces.each do |ace| - hashes << { :mask => ace.mask, :type => ace.type, :flags => ace.flags } + hashes << { mask: ace.mask, type: ace.type, flags: ace.flags } end hashes end @@ -103,36 +103,36 @@ shared_context "use Windows permissions", :windows_only do # Standard expected rights let(:expected_read_perms) do { - :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ, - :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ, + generic: Chef::ReservedNames::Win32::API::Security::GENERIC_READ, + specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ, } end let(:expected_read_execute_perms) do { - :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE, - :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE, + generic: Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE, + specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE, } end let(:expected_write_perms) do { - :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE, - :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE, + generic: Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE, + specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE, } end let(:expected_modify_perms) do { - :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE, - :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE, + generic: Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE, + specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE, } end let(:expected_full_control_perms) do { - :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_ALL, - :specific => Chef::ReservedNames::Win32::API::Security::FILE_ALL_ACCESS, + generic: Chef::ReservedNames::Win32::API::Security::GENERIC_ALL, + specific: Chef::ReservedNames::Win32::API::Security::FILE_ALL_ACCESS, } end diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb index 0bec29783a..cd2b83fda1 100644 --- a/spec/support/shared/functional/securable_resource_with_reporting.rb +++ b/spec/support/shared/functional/securable_resource_with_reporting.rb @@ -36,7 +36,7 @@ shared_examples_for "a securable resource with reporting" do # umask # let(:default_mode) { (0666 & ~File.umask).to_s(8) } - describe "reading file security metadata for reporting on unix", :unix_only => true do + describe "reading file security metadata for reporting on unix", unix_only: true do # According to POSIX standard created files get either the # effective gid of the process or inherits the gid of the parent # directory based on file system. Since it's hard to guess what @@ -70,7 +70,7 @@ shared_examples_for "a securable resource with reporting" do end end - context "and owner is specified with a String (username) in new_resource", :requires_root => true do + context "and owner is specified with a String (username) in new_resource", requires_root: true do # TODO/bug: duplicated from the "securable resource" tests @@ -91,7 +91,7 @@ shared_examples_for "a securable resource with reporting" do end - context "and owner is specified with an Integer (uid) in new_resource", :requires_root => true do + context "and owner is specified with an Integer (uid) in new_resource", requires_root: true do # TODO: duplicated from "securable resource" if ohai[:platform] == "aix" @@ -113,7 +113,7 @@ shared_examples_for "a securable resource with reporting" do end end - context "and group is specified with a String (group name)", :requires_root => true do + context "and group is specified with a String (group name)", requires_root: true do let(:expected_group_name) { Etc.getgrent.name } @@ -128,7 +128,7 @@ shared_examples_for "a securable resource with reporting" do end - context "and group is specified with an Integer (gid)", :requires_root => true do + context "and group is specified with an Integer (gid)", requires_root: true do let(:expected_gid) { Etc.getgrent.gid } before do diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb index 3199caa34f..a528db4a53 100644 --- a/spec/support/shared/functional/win32_service.rb +++ b/spec/support/shared/functional/win32_service.rb @@ -39,11 +39,11 @@ shared_context "using Win32::Service" do let(:test_service) do { - :service_name => "spec-service", - :service_display_name => "Spec Test Service", - :service_description => "Service for testing Chef::Application::WindowsServiceManager.", - :service_file_path => File.expand_path(File.join(File.dirname(__FILE__), "../../platforms/win32/spec_service.rb")), - :delayed_start => true, + service_name: "spec-service", + service_display_name: "Spec Test Service", + service_description: "Service for testing Chef::Application::WindowsServiceManager.", + service_file_path: File.expand_path(File.join(File.dirname(__FILE__), "../../platforms/win32/spec_service.rb")), + delayed_start: true, } end diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb index e5ac0741bd..5eb68952d7 100644 --- a/spec/support/shared/functional/windows_script.rb +++ b/spec/support/shared/functional/windows_script.rb @@ -93,7 +93,7 @@ shared_context Chef::Resource::WindowsScript do context "when the guard's architecture is specified as 64-bit" do let (:guard_architecture) { :x86_64 } it "executes a 64-bit guard", :windows64_only do - resource.only_if resource_guard_command, :architecture => guard_architecture + resource.only_if resource_guard_command, architecture: guard_architecture resource.run_action(:run) expect(get_guard_process_architecture).to eq("amd64") end @@ -102,7 +102,7 @@ shared_context Chef::Resource::WindowsScript do context "when the guard's architecture is specified as 32-bit", :not_supported_on_nano do let (:guard_architecture) { :i386 } it "executes a 32-bit guard" do - resource.only_if resource_guard_command, :architecture => guard_architecture + resource.only_if resource_guard_command, architecture: guard_architecture resource.run_action(:run) expect(get_guard_process_architecture).to eq("x86") end @@ -111,7 +111,7 @@ shared_context Chef::Resource::WindowsScript do context "when the guard's architecture is specified as 32-bit", :windows_nano_only do let (:guard_architecture) { :i386 } it "raises an error" do - resource.only_if resource_guard_command, :architecture => guard_architecture + resource.only_if resource_guard_command, architecture: guard_architecture expect { resource.run_action(:run) }.to raise_error( Chef::Exceptions::Win32ArchitectureIncorrect, /cannot execute script with requested architecture 'i386' on Windows Nano Server/) diff --git a/spec/support/shared/integration/app_server_support.rb b/spec/support/shared/integration/app_server_support.rb index e2bb3812ea..c0b24d9443 100644 --- a/spec/support/shared/integration/app_server_support.rb +++ b/spec/support/shared/integration/app_server_support.rb @@ -25,9 +25,9 @@ module AppServerSupport server = nil thread = Thread.new do Rack::Handler::WEBrick.run(app, - :Port => 9018, - :AccessLog => [], - :Logger => WEBrick::Log.new(StringIO.new, 7) + Port: 9018, + AccessLog: [], + Logger: WEBrick::Log.new(StringIO.new, 7) ) do |found_server| server = found_server end diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index 29f2eef50f..5fc9de4de7 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -140,12 +140,12 @@ module IntegrationSupport # Versioned cookbooks - RSpec.shared_context "with versioned cookbooks", :versioned_cookbooks => true do + RSpec.shared_context "with versioned cookbooks", versioned_cookbooks: true do before(:each) { Chef::Config[:versioned_cookbooks] = true } after(:each) { Chef::Config.delete(:versioned_cookbooks) } end - RSpec.shared_context "without versioned cookbooks", :versioned_cookbooks => false do + RSpec.shared_context "without versioned cookbooks", versioned_cookbooks: false do # Just make sure this goes back to default before(:each) { Chef::Config[:versioned_cookbooks] = false } after(:each) { Chef::Config.delete(:versioned_cookbooks) } diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb index 86764cad66..5058b7b278 100644 --- a/spec/support/shared/integration/knife_support.rb +++ b/spec/support/shared/integration/knife_support.rb @@ -40,8 +40,8 @@ module KnifeSupport # Work on machines where we can't access /var Dir.mktmpdir("checksums") do |checksums_cache_dir| Chef::Config[:cache_options] = { - :path => checksums_cache_dir, - :skip_expires => true, + path: checksums_cache_dir, + skip_expires: true, } # This is Chef::Knife.run without load_commands--we'll load stuff diff --git a/spec/support/shared/unit/api_error_inspector.rb b/spec/support/shared/unit/api_error_inspector.rb index 45bfcc67da..06f2e4bb57 100644 --- a/spec/support/shared/unit/api_error_inspector.rb +++ b/spec/support/shared/unit/api_error_inspector.rb @@ -28,11 +28,11 @@ shared_examples_for "an api error inspector" do before do @node_name = "test-node.example.com" @config = { - :validation_client_name => "testorg-validator", - :validation_key => "/etc/chef/testorg-validator.pem", - :chef_server_url => "https://chef-api.example.com", - :node_name => "testnode-name", - :client_key => "/etc/chef/client.pem", + validation_client_name: "testorg-validator", + validation_key: "/etc/chef/testorg-validator.pem", + chef_server_url: "https://chef-api.example.com", + node_name: "testnode-name", + client_key: "/etc/chef/client.pem", } @description = Chef::Formatters::ErrorDescription.new("Error registering the node:") @outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR) diff --git a/spec/support/shared/unit/api_versioning.rb b/spec/support/shared/unit/api_versioning.rb index 28141b73b1..9c179efa82 100644 --- a/spec/support/shared/unit/api_versioning.rb +++ b/spec/support/shared/unit/api_versioning.rb @@ -19,7 +19,7 @@ require "chef/exceptions" shared_examples_for "version handling" do - let(:response_406) { OpenStruct.new(:code => "406") } + let(:response_406) { OpenStruct.new(code: "406") } let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) } before do @@ -38,7 +38,7 @@ shared_examples_for "version handling" do end # version handling shared_examples_for "user and client reregister" do - let(:response_406) { OpenStruct.new(:code => "406") } + let(:response_406) { OpenStruct.new(code: "406") } let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) } let(:generic_exception) { Exception.new } let(:min_version) { "2" } diff --git a/spec/support/shared/unit/execute_resource.rb b/spec/support/shared/unit/execute_resource.rb index c97577107e..05c2fc4a9a 100644 --- a/spec/support/shared/unit/execute_resource.rb +++ b/spec/support/shared/unit/execute_resource.rb @@ -57,7 +57,7 @@ shared_examples_for "an execute resource" do end it "should accept a hash for the environment" do - test_hash = { :one => :two } + test_hash = { one: :two } @resource.environment(test_hash) expect(@resource.environment).to eql(test_hash) end @@ -155,7 +155,7 @@ shared_examples_for "an execute resource" do before do @resource.command("grep") @resource.cwd("/tmp/") - @resource.environment({ :one => :two }) + @resource.environment({ one: :two }) @resource.group("legos") @resource.returns(1) @resource.user("root") diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb index d508e76b24..a7c7af92f6 100644 --- a/spec/support/shared/unit/provider/file.rb +++ b/spec/support/shared/unit/provider/file.rb @@ -258,11 +258,11 @@ shared_examples_for Chef::Provider::File do allow(ChefConfig).to receive(:windows?).and_return(false) # mock up the filesystem to behave like unix setup_normal_file - stat_struct = double("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000) + stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000) resource_real_path = File.realpath(resource.path) expect(File).to receive(:stat).with(resource_real_path).at_least(:once).and_return(stat_struct) - allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", :name => "wheel")) - allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", :name => "root")) + allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", name: "wheel")) + allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", name: "root")) end context "when the new_resource does not specify any state" do @@ -383,11 +383,11 @@ shared_examples_for Chef::Provider::File do allow(ChefConfig).to receive(:windows?).and_return(false) # mock up the filesystem to behave like unix setup_normal_file - stat_struct = double("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000) + stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000) resource_real_path = File.realpath(resource.path) allow(File).to receive(:stat).with(resource_real_path).and_return(stat_struct) - allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", :name => "wheel")) - allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", :name => "root")) + allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", name: "wheel")) + allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", name: "root")) provider.send(:load_resource_attributes_from_file, resource) end @@ -460,7 +460,7 @@ shared_examples_for Chef::Provider::File do before { setup_normal_file } let(:tempfile) do - t = double("Tempfile", :path => "/tmp/foo-bar-baz", :closed? => true) + t = double("Tempfile", path: "/tmp/foo-bar-baz", closed?: true) allow(content).to receive(:tempfile).and_return(t) t end @@ -515,7 +515,7 @@ shared_examples_for Chef::Provider::File do before do setup_normal_file provider.load_current_resource - tempfile = double("Tempfile", :path => "/tmp/foo-bar-baz") + tempfile = double("Tempfile", path: "/tmp/foo-bar-baz") allow(content).to receive(:tempfile).and_return(tempfile) expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(true) expect(tempfile).to receive(:close).once @@ -528,8 +528,8 @@ shared_examples_for Chef::Provider::File do let(:diff_for_reporting) { "+++\n---\n+foo\n-bar\n" } before do allow(provider).to receive(:contents_changed?).and_return(true) - diff = double("Diff", :for_output => ["+++", "---", "+foo", "-bar"], - :for_reporting => diff_for_reporting ) + diff = double("Diff", for_output: ["+++", "---", "+foo", "-bar"], + for_reporting: diff_for_reporting ) allow(diff).to receive(:diff).with(resource_path, tempfile_path).and_return(true) expect(provider).to receive(:diff).at_least(:once).and_return(diff) expect(provider).to receive(:checksum).with(tempfile_path).and_return(tempfile_sha256) @@ -592,13 +592,13 @@ shared_examples_for Chef::Provider::File do end it "raises an exception when the content object returns a tempfile with a nil path" do - tempfile = double("Tempfile", :path => nil) + tempfile = double("Tempfile", path: nil) expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile) expect { provider.send(:do_contents_changes) }.to raise_error(RuntimeError) end it "raises an exception when the content object returns a tempfile that does not exist" do - tempfile = double("Tempfile", :path => "/tmp/foo-bar-baz") + tempfile = double("Tempfile", path: "/tmp/foo-bar-baz") expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile) expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(false) expect { provider.send(:do_contents_changes) }.to raise_error(RuntimeError) diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb index caa76e4ad6..a6301f9ae7 100644 --- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb +++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb @@ -68,8 +68,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option end it "should set the option for #{attribute} if the new resources #{attribute} is not nil, without homedir management" do - allow(@new_resource).to receive(:supports).and_return({ :manage_home => false, - :non_unique => false }) + allow(@new_resource).to receive(:supports).and_return({ manage_home: false, + non_unique: false }) allow(@new_resource).to receive(attribute).and_return("hola") expect(provider.universal_options).to eql([option, "hola"]) end @@ -257,7 +257,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option describe "when checking the lock" do # lazy initialize so we can modify stdout and stderr strings let(:passwd_s_status) do - double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => @stdout, :stderr => @stderr, :error! => nil) + double("Mixlib::ShellOut command", exitstatus: 0, stdout: @stdout, stderr: @stderr, error!: nil) end before(:each) do @@ -273,7 +273,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option it "should return false if status begins with P" do expect(provider).to receive(:shell_out). - with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }). + with("passwd", "-S", @new_resource.username, { returns: [0, 1] }). and_return(passwd_s_status) expect(provider.check_lock).to eql(false) end @@ -281,7 +281,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option it "should return false if status begins with N" do @stdout = "root N" expect(provider).to receive(:shell_out). - with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }). + with("passwd", "-S", @new_resource.username, { returns: [0, 1] }). and_return(passwd_s_status) expect(provider.check_lock).to eql(false) end @@ -289,7 +289,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option it "should return true if status begins with L" do @stdout = "root L" expect(provider).to receive(:shell_out). - with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }). + with("passwd", "-S", @new_resource.username, { returns: [0, 1] }). and_return(passwd_s_status) expect(provider.check_lock).to eql(true) end @@ -297,7 +297,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option it "should raise a ShellCommandFailed exception if passwd -S exits with something other than 0 or 1" do expect(passwd_s_status).to receive(:error!).and_raise(Mixlib::ShellOut::ShellCommandFailed) expect(provider).to receive(:shell_out). - with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }). + with("passwd", "-S", @new_resource.username, { returns: [0, 1] }). and_return(passwd_s_status) expect { provider.check_lock }.to raise_error(Mixlib::ShellOut::ShellCommandFailed) end @@ -306,16 +306,16 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option expect(passwd_s_status).to receive(:stdout).and_return("") expect(passwd_s_status).to receive(:stderr).and_return("") expect(provider).to receive(:shell_out). - with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }). + with("passwd", "-S", @new_resource.username, { returns: [0, 1] }). and_return(passwd_s_status) expect { provider.check_lock }.to raise_error(Chef::Exceptions::User) end context "when in why run mode" do before do - passwd_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "", :stderr => "passwd: user 'chef-test' does not exist\n") + passwd_status = double("Mixlib::ShellOut command", exitstatus: 0, stdout: "", stderr: "passwd: user 'chef-test' does not exist\n") expect(provider).to receive(:shell_out). - with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }). + with("passwd", "-S", @new_resource.username, { returns: [0, 1] }). and_return(passwd_status) # ubuntu returns 252 on user-does-not-exist so will raise if #error! is called or if # shell_out! is used diff --git a/spec/support/shared/unit/user_and_client_shared.rb b/spec/support/shared/unit/user_and_client_shared.rb index 6c31ca22d1..40042933e2 100644 --- a/spec/support/shared/unit/user_and_client_shared.rb +++ b/spec/support/shared/unit/user_and_client_shared.rb @@ -27,7 +27,7 @@ shared_examples_for "user or client create" do it "creates a new object via the API with a public_key when it exists" do object.public_key "some_public_key" - expect(rest_v1).to receive(:post).with(url, payload.merge({ :public_key => "some_public_key" })).and_return({}) + expect(rest_v1).to receive(:post).with(url, payload.merge({ public_key: "some_public_key" })).and_return({}) object.create end @@ -49,7 +49,7 @@ shared_examples_for "user or client create" do end it "creates a new object via the API with create_key" do - expect(rest_v1).to receive(:post).with(url, payload.merge({ :create_key => true })).and_return({}) + expect(rest_v1).to receive(:post).with(url, payload.merge({ create_key: true })).and_return({}) object.create end end @@ -104,7 +104,7 @@ shared_examples_for "user or client create" do it "creates a new object via the API with a public_key when it exists" do object.public_key "some_public_key" - expect(rest_v0).to receive(:post).with(url, payload.merge({ :public_key => "some_public_key" })).and_return({}) + expect(rest_v0).to receive(:post).with(url, payload.merge({ public_key: "some_public_key" })).and_return({}) object.create end diff --git a/spec/tiny_server.rb b/spec/tiny_server.rb index 83c5bf4a42..c3eab76d8e 100644 --- a/spec/tiny_server.rb +++ b/spec/tiny_server.rb @@ -136,8 +136,8 @@ module TinyServer if response = response_for_request(env) response.call else - debug_info = { :message => "no data matches the request for #{env['REQUEST_URI']}", - :available_routes => @routes, :request => env } + debug_info = { message: "no data matches the request for #{env['REQUEST_URI']}", + available_routes: @routes, request: env } # Uncomment me for glorious debugging # pp :not_found => debug_info [404, { "Content-Type" => "application/json" }, [ Chef::JSONCompat.to_json(debug_info) ]] diff --git a/spec/unit/api_client/registration_spec.rb b/spec/unit/api_client/registration_spec.rb index 0f036766da..b2b74b1c58 100644 --- a/spec/unit/api_client/registration_spec.rb +++ b/spec/unit/api_client/registration_spec.rb @@ -38,11 +38,11 @@ describe Chef::ApiClient::Registration do let(:http_mock) { double("Chef::ServerAPI mock") } let(:expected_post_data) do - { :name => client_name, :admin => false, :public_key => generated_public_key.to_pem } + { name: client_name, admin: false, public_key: generated_public_key.to_pem } end let(:expected_put_data) do - { :name => client_name, :admin => false, :public_key => generated_public_key.to_pem } + { name: client_name, admin: false, public_key: generated_public_key.to_pem } end let(:server_v10_response) do @@ -148,11 +148,11 @@ describe Chef::ApiClient::Registration do context "when local key generation is disabled" do let(:expected_post_data) do - { :name => client_name, :admin => false } + { name: client_name, admin: false } end let(:expected_put_data) do - { :name => client_name, :admin => false, :private_key => true } + { name: client_name, admin: false, private_key: true } end before do diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb index a8ac4f747b..c3c674ecf7 100644 --- a/spec/unit/api_client_spec.rb +++ b/spec/unit/api_client_spec.rb @@ -303,7 +303,7 @@ describe Chef::ApiClient do @api_client_with_key.name("lost-my-key") @api_client_with_key.private_key("the new private key") expect(@http_client).to receive(:put). - with("clients/lost-my-key", :name => "lost-my-key", :admin => false, :validator => false, :private_key => true). + with("clients/lost-my-key", name: "lost-my-key", admin: false, validator: false, private_key: true). and_return(@api_client_with_key) end @@ -321,7 +321,7 @@ describe Chef::ApiClient do before do @api_client_with_key = { "name" => "lost-my-key", "private_key" => "the new private key" } expect(@http_client).to receive(:put). - with("clients/lost-my-key", :name => "lost-my-key", :admin => false, :validator => false, :private_key => true). + with("clients/lost-my-key", name: "lost-my-key", admin: false, validator: false, private_key: true). and_return(@api_client_with_key) end diff --git a/spec/unit/api_client_v1_spec.rb b/spec/unit/api_client_v1_spec.rb index 9c643fa492..802384534b 100644 --- a/spec/unit/api_client_v1_spec.rb +++ b/spec/unit/api_client_v1_spec.rb @@ -324,13 +324,13 @@ describe Chef::ApiClientV1 do end describe "Versioned API Interactions" do - let(:response_406) { OpenStruct.new(:code => "406") } + let(:response_406) { OpenStruct.new(code: "406") } let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) } let(:payload) do { - :name => "some_name", - :validator => true, - :admin => true, + name: "some_name", + validator: true, + admin: true, } end @@ -389,7 +389,7 @@ describe Chef::ApiClientV1 do end it "updates the client with only the name" do - expect(rest). to receive(:put).with("clients/some_name", { :name => "some_name" }).and_return({ :name => "some_name" }) + expect(rest). to receive(:put).with("clients/some_name", { name: "some_name" }).and_return({ name: "some_name" }) @client.update end end @@ -437,7 +437,7 @@ describe Chef::ApiClientV1 do describe "reregister" do context "when server API V0 is valid on the Chef Server receiving the request" do it "creates a new object via the API" do - expect(@client.chef_rest_v0).to receive(:put).with("clients/#{@client.name}", payload.merge({ :private_key => true })).and_return({}) + expect(@client.chef_rest_v0).to receive(:put).with("clients/#{@client.name}", payload.merge({ private_key: true })).and_return({}) @client.reregister end end # when server API V0 is valid on the Chef Server receiving the request diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb index 0af3916134..b9e474ef08 100644 --- a/spec/unit/application/apply_spec.rb +++ b/spec/unit/application/apply_spec.rb @@ -37,7 +37,7 @@ describe Chef::Application::Apply do before do @recipe_file_name = "foo.rb" @recipe_path = File.expand_path(@recipe_file_name) - @recipe_file = double("Tempfile (mock)", :read => @recipe_text) + @recipe_file = double("Tempfile (mock)", read: @recipe_text) allow(@app).to receive(:open).with(@recipe_path).and_return(@recipe_file) allow(File).to receive(:exist?).with(@recipe_path).and_return(true) allow(Chef::Application).to receive(:fatal!).and_return(true) @@ -96,7 +96,7 @@ describe Chef::Application::Apply do end describe "when the json_attribs configuration option is specified" do let(:json_attribs) { { "a" => "b" } } - let(:config_fetcher) { double(Chef::ConfigFetcher, :fetch_json => json_attribs) } + let(:config_fetcher) { double(Chef::ConfigFetcher, fetch_json: json_attribs) } let(:json_source) { "https://foo.com/foo.json" } before do diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb index de6972b625..a1f96e1d43 100644 --- a/spec/unit/application/client_spec.rb +++ b/spec/unit/application/client_spec.rb @@ -121,27 +121,27 @@ describe Chef::Application::Client, "reconfigure" do describe "--named-run-list" do it_behaves_like "sets the configuration", "--named-run-list arglebargle-example", - :named_run_list => "arglebargle-example" + named_run_list: "arglebargle-example" end describe "--no-listen" do - it_behaves_like "sets the configuration", "--no-listen", :listen => false + it_behaves_like "sets the configuration", "--no-listen", listen: false end describe "--daemonize", :unix_only do context "with no value" do it_behaves_like "sets the configuration", "--daemonize", - :daemonize => true + daemonize: true end context "with an integer value" do it_behaves_like "sets the configuration", "--daemonize 5", - :daemonize => 5 + daemonize: 5 end context "with a non-integer value" do it_behaves_like "sets the configuration", "--daemonize foo", - :daemonize => true + daemonize: true end end @@ -178,17 +178,17 @@ describe Chef::Application::Client, "reconfigure" do describe "--config-option" do context "with a single value" do it_behaves_like "sets the configuration", "--config-option chef_server_url=http://example", - :chef_server_url => "http://example" + chef_server_url: "http://example" end context "with two values" do it_behaves_like "sets the configuration", "--config-option chef_server_url=http://example --config-option policy_name=web", - :chef_server_url => "http://example", :policy_name => "web" + chef_server_url: "http://example", policy_name: "web" end context "with a boolean value" do it_behaves_like "sets the configuration", "--config-option minimal_ohai=true", - :minimal_ohai => true + minimal_ohai: true end context "with an empty value" do @@ -321,7 +321,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config describe "when the json_attribs configuration option is specified" do let(:json_attribs) { { "a" => "b" } } - let(:config_fetcher) { double(Chef::ConfigFetcher, :fetch_json => json_attribs) } + let(:config_fetcher) { double(Chef::ConfigFetcher, fetch_json: json_attribs) } let(:json_source) { "https://foo.com/foo.json" } before do diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb index 90ecde608e..8a574b4d0f 100644 --- a/spec/unit/application/knife_spec.rb +++ b/spec/unit/application/knife_spec.rb @@ -24,9 +24,9 @@ describe Chef::Application::Knife do before(:all) do class NoopKnifeCommand < Chef::Knife option :opt_with_default, - :short => "-D VALUE", - :long => "-optwithdefault VALUE", - :default => "default-value" + short: "-D VALUE", + long: "-optwithdefault VALUE", + default: "default-value" def run end diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb index 5b9dbeaafd..c4c4c3b252 100644 --- a/spec/unit/application/solo_spec.rb +++ b/spec/unit/application/solo_spec.rb @@ -93,7 +93,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config describe "when the json_attribs configuration option is specified" do let(:json_attribs) { { "a" => "b" } } - let(:config_fetcher) { double(Chef::ConfigFetcher, :fetch_json => json_attribs) } + let(:config_fetcher) { double(Chef::ConfigFetcher, fetch_json: json_attribs) } let(:json_source) { "https://foo.com/foo.json" } before do @@ -130,7 +130,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config it "fetches the recipe_url first when both json_attribs and recipe_url are specified" do json_attribs = { "a" => "b" } - config_fetcher = instance_double("Chef::ConfigFetcher", :fetch_json => json_attribs) + config_fetcher = instance_double("Chef::ConfigFetcher", fetch_json: json_attribs) Chef::Config[:json_attribs] = "https://foo.com/foo.json" Chef::Config[:recipe_url] = "http://icanhas.cheezburger.com/lolcats" diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index 76be387c22..8b2d0cb114 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -447,7 +447,7 @@ describe Chef::Application do ARGV.replace(@original_argv) end - let(:fake_config_fetcher) { instance_double(Chef::ConfigFetcher, expanded_path: "/thisbetternotexist", :"config_missing?" => false, read_config: "" ) } + let(:fake_config_fetcher) { instance_double(Chef::ConfigFetcher, expanded_path: "/thisbetternotexist", "config_missing?": false, read_config: "" ) } it "reading a mixlib-config default works" do @app.parse_options diff --git a/spec/unit/audit/audit_event_proxy_spec.rb b/spec/unit/audit/audit_event_proxy_spec.rb index 0e35343352..ec9960aff4 100644 --- a/spec/unit/audit/audit_event_proxy_spec.rb +++ b/spec/unit/audit/audit_event_proxy_spec.rb @@ -35,9 +35,9 @@ describe Chef::Audit::AuditEventProxy do let(:description) { "poots" } let(:group) do - double("ExampleGroup", :parent_groups => parents, - :description => description) end - let(:notification) { double("Notification", :group => group) } + double("ExampleGroup", parent_groups: parents, + description: description) end + let(:notification) { double("Notification", group: group) } context "when notified from a top-level example group" do @@ -66,9 +66,9 @@ describe Chef::Audit::AuditEventProxy do describe "#stop" do let(:examples) { [] } - let(:notification) { double("Notification", :examples => examples) } + let(:notification) { double("Notification", examples: examples) } let(:exception) { nil } - let(:example) { double("Example", :exception => exception) } + let(:example) { double("Example", exception: exception) } let(:control_group_name) { "audit test" } let(:control_data) { double("ControlData") } @@ -122,29 +122,29 @@ describe Chef::Audit::AuditEventProxy do let(:examples) { [example] } let(:example) do - double("Example", :metadata => metadata, - :description => example_description, - :full_description => full_description, :exception => nil) end + double("Example", metadata: metadata, + description: example_description, + full_description: full_description, exception: nil) end let(:metadata) do { - :described_class => described_class, - :example_group => example_group, - :line_number => line, + described_class: described_class, + example_group: example_group, + line_number: line, } end let(:example_group) do { - :description => group_description, - :parent_example_group => parent_group, + description: group_description, + parent_example_group: parent_group, } end let(:parent_group) do { - :description => control_group_name, - :parent_example_group => nil, + description: control_group_name, + parent_example_group: nil, } end @@ -152,12 +152,12 @@ describe Chef::Audit::AuditEventProxy do let(:control_data) do { - :name => example_description, - :desc => full_description, - :resource_type => resource_type, - :resource_name => resource_name, - :context => context, - :line_number => line, + name: example_description, + desc: full_description, + resource_type: resource_type, + resource_name: resource_name, + context: context, + line_number: line, } end @@ -227,7 +227,7 @@ describe Chef::Audit::AuditEventProxy do # Metadata fields let(:described_class) do double("Serverspec::Type::Port", - :class => "Serverspec::Type::Port", :name => resource_name) end + class: "Serverspec::Type::Port", name: resource_name) end # Control data fields let(:resource_type) { "Port" } @@ -288,20 +288,20 @@ describe Chef::Audit::AuditEventProxy do # Metadata parts let(:described_class) do double("Serverspec::Type::File", - :class => "Serverspec::Type::File", :name => resource_name) end + class: "Serverspec::Type::File", name: resource_name) end # Example group parts let(:parent_group) do { - :description => outer_group_description, - :parent_example_group => control_group, + description: outer_group_description, + parent_example_group: control_group, } end let(:control_group) do { - :description => control_group_name, - :parent_example_group => nil, + description: control_group_name, + parent_example_group: nil, } end diff --git a/spec/unit/audit/audit_reporter_spec.rb b/spec/unit/audit/audit_reporter_spec.rb index 3edee46932..f6707825cf 100644 --- a/spec/unit/audit/audit_reporter_spec.rb +++ b/spec/unit/audit/audit_reporter_spec.rb @@ -24,13 +24,13 @@ describe Chef::Audit::AuditReporter do let(:rest) { double("rest") } let(:reporter) { described_class.new(rest) } - let(:node) { double("node", :name => "sofreshsoclean") } + let(:node) { double("node", name: "sofreshsoclean") } let(:run_id) { 0 } let(:start_time) { Time.new(2014, 12, 3, 9, 31, 05, "-08:00") } let(:end_time) { Time.new(2014, 12, 3, 9, 36, 14, "-08:00") } let(:run_status) do - instance_double(Chef::RunStatus, :node => node, :run_id => run_id, - :start_time => start_time, :end_time => end_time) end + instance_double(Chef::RunStatus, node: node, run_id: run_id, + start_time: start_time, end_time: end_time) end describe "#audit_phase_start" do @@ -87,9 +87,9 @@ describe Chef::Audit::AuditReporter do context "when audit phase failed" do let(:audit_error) do - double("AuditError", :class => "Chef::Exceptions::AuditError", - :message => "Audit phase failed with error message: derpderpderp", - :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) end + double("AuditError", class: "Chef::Exceptions::AuditError", + message: "Audit phase failed with error message: derpderpderp", + backtrace: ["/path/recipe.rb:57", "/path/library.rb:106"]) end before do reporter.instance_variable_set(:@audit_phase_error, audit_error) @@ -123,7 +123,7 @@ EOM context "the error is an http error" do - let(:response) { double("response", :code => code) } + let(:response) { double("response", code: code) } before do expect(Chef::Log).to receive(:trace).with(/Sending audit report/) @@ -236,14 +236,14 @@ EOM let(:run_data) { audit_data.to_hash } let(:audit_error) do - double("AuditError", :class => "Chef::Exceptions::AuditError", - :message => "Audit phase failed with error message: derpderpderp", - :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) end + double("AuditError", class: "Chef::Exceptions::AuditError", + message: "Audit phase failed with error message: derpderpderp", + backtrace: ["/path/recipe.rb:57", "/path/library.rb:106"]) end let(:run_error) do - double("RunError", :class => "Chef::Exceptions::RunError", - :message => "This error shouldn't be reported.", - :backtrace => ["fix it", "fix it", "fix it"]) end + double("RunError", class: "Chef::Exceptions::RunError", + message: "This error shouldn't be reported.", + backtrace: ["fix it", "fix it", "fix it"]) end before do allow(reporter).to receive(:auditing_enabled?).and_return(true) @@ -282,10 +282,10 @@ EOM let(:control_group_foo) do instance_double(Chef::Audit::ControlGroupData, - :metadata => double("foo metadata")) end + metadata: double("foo metadata")) end let(:control_group_bar) do instance_double(Chef::Audit::ControlGroupData, - :metadata => double("bar metadata")) end + metadata: double("bar metadata")) end let(:ordered_control_groups) do { @@ -296,11 +296,11 @@ EOM let(:audit_data) do instance_double(Chef::Audit::AuditData, - :add_control_group => true) end + add_control_group: true) end let(:run_context) do instance_double(Chef::RunContext, - :audits => ordered_control_groups) end + audits: ordered_control_groups) end before do allow(reporter).to receive(:ordered_control_groups).and_return(ordered_control_groups) @@ -350,7 +350,7 @@ EOM let(:name) { "bat" } let(:control_group) do instance_double(Chef::Audit::ControlGroupData, - :metadata => double("metadata")) end + metadata: double("metadata")) end before do allow(Chef::Audit::ControlGroupData).to receive(:new). @@ -397,7 +397,7 @@ EOM let(:name) { "bar" } let(:example_data) { double("example data") } - let(:error) { double("Exception", :message => "oopsie") } + let(:error) { double("Exception", message: "oopsie") } it "notifies the control group the example failed" do expect(control_group_bar).to receive(:example_failure). diff --git a/spec/unit/audit/control_group_data_spec.rb b/spec/unit/audit/control_group_data_spec.rb index ea4ac260f9..c56e824d4c 100644 --- a/spec/unit/audit/control_group_data_spec.rb +++ b/spec/unit/audit/control_group_data_spec.rb @@ -72,8 +72,8 @@ describe Chef::Audit::AuditData do describe ":control_groups" do - let(:control_hash_1) { { :name => "control group 1" } } - let(:control_hash_2) { { :name => "control group 2" } } + let(:control_hash_1) { { name: "control group 1" } } + let(:control_hash_2) { { name: "control group 2" } } let(:control_groups) { audit_data_hash[:control_groups] } @@ -174,11 +174,11 @@ describe Chef::Audit::ControlGroupData do let(:control_data) do { - :name => name, - :resource_type => resource_type, - :resource_name => resource_name, - :context => context, - :line_number => line_number, + name: name, + resource_type: resource_type, + resource_name: resource_name, + context: context, + line_number: line_number, } end @@ -434,22 +434,22 @@ describe Chef::Audit::ControlGroupData do context "with multiple controls added" do - let(:control_hash_1) { { :line_number => 27 } } - let(:control_hash_2) { { :line_number => 13 } } - let(:control_hash_3) { { :line_number => 35 } } + let(:control_hash_1) { { line_number: 27 } } + let(:control_hash_2) { { line_number: 13 } } + let(:control_hash_3) { { line_number: 35 } } let(:control_1) do double("control 1", - :line_number => control_hash_1[:line_number], - :to_hash => control_hash_1) end + line_number: control_hash_1[:line_number], + to_hash: control_hash_1) end let(:control_2) do double("control 2", - :line_number => control_hash_2[:line_number], - :to_hash => control_hash_2) end + line_number: control_hash_2[:line_number], + to_hash: control_hash_2) end let(:control_3) do double("control 3", - :line_number => control_hash_3[:line_number], - :to_hash => control_hash_3) end + line_number: control_hash_3[:line_number], + to_hash: control_hash_3) end let(:control_list) { [control_1, control_2, control_3] } let(:ordered_control_hashes) { [control_hash_2, control_hash_1, control_hash_3] } diff --git a/spec/unit/audit/runner_spec.rb b/spec/unit/audit/runner_spec.rb index 4c03cab1d3..902ede62ed 100644 --- a/spec/unit/audit/runner_spec.rb +++ b/spec/unit/audit/runner_spec.rb @@ -28,7 +28,7 @@ describe Chef::Audit::Runner do include RSpec::Support::InSubProcess let(:events) { double("events") } - let(:run_context) { instance_double(Chef::RunContext, :events => events) } + let(:run_context) { instance_double(Chef::RunContext, events: events) } let(:runner) { Chef::Audit::Runner.new(run_context) } around(:each) do |ex| @@ -89,7 +89,7 @@ describe Chef::Audit::Runner do describe "#register_control_groups" do let(:audits) { [] } - let(:run_context) { instance_double(Chef::RunContext, :audits => audits) } + let(:run_context) { instance_double(Chef::RunContext, audits: audits) } it "adds the control group aliases" do runner.send(:register_control_groups) diff --git a/spec/unit/chef_fs/diff_spec.rb b/spec/unit/chef_fs/diff_spec.rb index d946fcb9e7..229a48c2db 100644 --- a/spec/unit/chef_fs/diff_spec.rb +++ b/spec/unit/chef_fs/diff_spec.rb @@ -28,62 +28,62 @@ def remove_os_differences(diff) diff.gsub(/^@@ -\d(,\d)? \+\d(,\d)? @@/, "CONTEXT_LINE_NUMBERS") end -describe "diff", :uses_diff => true do +describe "diff", uses_diff: true do include FileSystemSupport context "with two filesystems with all types of difference" do let(:a) do memory_fs("a", { - :both_dirs => { - :sub_both_dirs => { :subsub => nil }, - :sub_both_files => nil, - :sub_both_files_different => "a\n", - :sub_both_dirs_empty => {}, - :sub_dirs_empty_in_a_filled_in_b => {}, - :sub_dirs_empty_in_b_filled_in_a => { :subsub => nil }, - :sub_a_only_dir => { :subsub => nil }, - :sub_a_only_file => nil, - :sub_dir_in_a_file_in_b => {}, - :sub_file_in_a_dir_in_b => nil, + both_dirs: { + sub_both_dirs: { subsub: nil }, + sub_both_files: nil, + sub_both_files_different: "a\n", + sub_both_dirs_empty: {}, + sub_dirs_empty_in_a_filled_in_b: {}, + sub_dirs_empty_in_b_filled_in_a: { subsub: nil }, + sub_a_only_dir: { subsub: nil }, + sub_a_only_file: nil, + sub_dir_in_a_file_in_b: {}, + sub_file_in_a_dir_in_b: nil, }, - :both_files => nil, - :both_files_different => "a\n", - :both_dirs_empty => {}, - :dirs_empty_in_a_filled_in_b => {}, - :dirs_empty_in_b_filled_in_a => { :subsub => nil }, - :dirs_in_a_cannot_be_in_b => {}, - :file_in_a_cannot_be_in_b => nil, - :a_only_dir => { :subsub => nil }, - :a_only_file => nil, - :dir_in_a_file_in_b => {}, - :file_in_a_dir_in_b => nil, + both_files: nil, + both_files_different: "a\n", + both_dirs_empty: {}, + dirs_empty_in_a_filled_in_b: {}, + dirs_empty_in_b_filled_in_a: { subsub: nil }, + dirs_in_a_cannot_be_in_b: {}, + file_in_a_cannot_be_in_b: nil, + a_only_dir: { subsub: nil }, + a_only_file: nil, + dir_in_a_file_in_b: {}, + file_in_a_dir_in_b: nil, }, /cannot_be_in_a/) end let(:b) do memory_fs("b", { - :both_dirs => { - :sub_both_dirs => { :subsub => nil }, - :sub_both_files => nil, - :sub_both_files_different => "b\n", - :sub_both_dirs_empty => {}, - :sub_dirs_empty_in_a_filled_in_b => { :subsub => nil }, - :sub_dirs_empty_in_b_filled_in_a => {}, - :sub_b_only_dir => { :subsub => nil }, - :sub_b_only_file => nil, - :sub_dir_in_a_file_in_b => nil, - :sub_file_in_a_dir_in_b => {}, + both_dirs: { + sub_both_dirs: { subsub: nil }, + sub_both_files: nil, + sub_both_files_different: "b\n", + sub_both_dirs_empty: {}, + sub_dirs_empty_in_a_filled_in_b: { subsub: nil }, + sub_dirs_empty_in_b_filled_in_a: {}, + sub_b_only_dir: { subsub: nil }, + sub_b_only_file: nil, + sub_dir_in_a_file_in_b: nil, + sub_file_in_a_dir_in_b: {}, }, - :both_files => nil, - :both_files_different => "b\n", - :both_dirs_empty => {}, - :dirs_empty_in_a_filled_in_b => { :subsub => nil }, - :dirs_empty_in_b_filled_in_a => {}, - :dirs_in_b_cannot_be_in_a => {}, - :file_in_b_cannot_be_in_a => nil, - :b_only_dir => { :subsub => nil }, - :b_only_file => nil, - :dir_in_a_file_in_b => nil, - :file_in_a_dir_in_b => {}, + both_files: nil, + both_files_different: "b\n", + both_dirs_empty: {}, + dirs_empty_in_a_filled_in_b: { subsub: nil }, + dirs_empty_in_b_filled_in_a: {}, + dirs_in_b_cannot_be_in_a: {}, + file_in_b_cannot_be_in_a: nil, + b_only_dir: { subsub: nil }, + b_only_file: nil, + dir_in_a_file_in_b: nil, + file_in_a_dir_in_b: {}, }, /cannot_be_in_b/) end it "Chef::ChefFS::CommandLine.diff_print(/)" do diff --git a/spec/unit/chef_fs/file_pattern_spec.rb b/spec/unit/chef_fs/file_pattern_spec.rb index c4d076ef90..58cdbb28c2 100644 --- a/spec/unit/chef_fs/file_pattern_spec.rb +++ b/spec/unit/chef_fs/file_pattern_spec.rb @@ -157,7 +157,7 @@ describe Chef::ChefFS::FilePattern do end end - context 'with simple pattern "a\*\b"', :skip => (Chef::Platform.windows?) do + context 'with simple pattern "a\*\b"', skip: (Chef::Platform.windows?) do let(:pattern) { Chef::ChefFS::FilePattern.new('a\*\b') } it "match?" do expect(pattern.match?("a*b")).to be_truthy @@ -264,7 +264,7 @@ describe Chef::ChefFS::FilePattern do end end - context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', :skip => (Chef::Platform.windows?) do + context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', skip: (Chef::Platform.windows?) do let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/d[a-z][0-9]f/ghi") } it "match?" do expect(pattern.match?("/abc/de1f/ghi")).to be_truthy diff --git a/spec/unit/chef_fs/file_system/repository/directory_spec.rb b/spec/unit/chef_fs/file_system/repository/directory_spec.rb index e44cc15167..efd17204e0 100644 --- a/spec/unit/chef_fs/file_system/repository/directory_spec.rb +++ b/spec/unit/chef_fs/file_system/repository/directory_spec.rb @@ -88,7 +88,7 @@ describe Chef::ChefFS::FileSystem::Repository::Directory do end it "returns a non existent object otherwise" do - file_double = instance_double(TestFile, :name_valid? => false) + file_double = instance_double(TestFile, name_valid?: false) expect(TestFile).to receive(:new).with("test_child", test_directory).and_return(file_double) expect(test_directory.child("test_child")).to be_an_instance_of(Chef::ChefFS::FileSystem::NonexistentFSObject) end diff --git a/spec/unit/chef_fs/file_system_spec.rb b/spec/unit/chef_fs/file_system_spec.rb index c7ed83524b..fed468f2cd 100644 --- a/spec/unit/chef_fs/file_system_spec.rb +++ b/spec/unit/chef_fs/file_system_spec.rb @@ -57,17 +57,17 @@ describe Chef::ChefFS::FileSystem do context "with a populated filesystem" do let(:fs) do memory_fs("", { - :a => { - :aa => { - :c => "", - :zz => "", + a: { + aa: { + c: "", + zz: "", }, - :ab => { - :c => "", + ab: { + c: "", }, }, - :x => "", - :y => {}, + x: "", + y: {}, }) end context "list" do diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb index 84637f7283..cbfa3402fa 100644 --- a/spec/unit/chef_fs/parallelizer.rb +++ b/spec/unit/chef_fs/parallelizer.rb @@ -20,7 +20,7 @@ describe Chef::ChefFS::Parallelizer do end def parallelize(inputs, options = {}, &block) - parallelizer.parallelize(inputs, { :main_thread_processing => false }.merge(options), &block) + parallelizer.parallelize(inputs, { main_thread_processing: false }.merge(options), &block) end it "parallel_do creates unordered output as soon as it is available" do @@ -35,14 +35,14 @@ describe Chef::ChefFS::Parallelizer do context "With :ordered => false (unordered output)" do it "An empty input produces an empty output" do - expect(parallelize([], :ordered => false) do + expect(parallelize([], ordered: false) do sleep 10 end.to_a).to eql([]) expect(elapsed_time).to be < 0.1 end it "10 sleep(0.2)s complete within 0.5 seconds" do - expect(parallelize(1.upto(10), :ordered => false) do |i| + expect(parallelize(1.upto(10), ordered: false) do |i| sleep 0.2 "x" end.to_a).to eq(%w{x x x x x x x x x x}) @@ -50,7 +50,7 @@ describe Chef::ChefFS::Parallelizer do end it "The output comes as soon as it is available" do - enum = parallelize([0.5, 0.3, 0.1], :ordered => false) do |val| + enum = parallelize([0.5, 0.3, 0.1], ordered: false) do |val| sleep val val end @@ -64,7 +64,7 @@ describe Chef::ChefFS::Parallelizer do input = TestEnumerable.new(0.5, 0.3, 0.1) do raise "hi" end - enum = parallelize(input, :ordered => false) { |x| sleep(x); x } + enum = parallelize(input, ordered: false) { |x| sleep(x); x } results = [] expect { enum.each { |value| results << value } }.to raise_error "hi" expect(results).to eq([ 0.1, 0.3, 0.5 ]) @@ -73,7 +73,7 @@ describe Chef::ChefFS::Parallelizer do it "Exceptions in output are raised after all processing is done" do processed = 0 - enum = parallelize([1, 2, "x", 3], :ordered => false) do |x| + enum = parallelize([1, 2, "x", 3], ordered: false) do |x| if x == "x" sleep 0.1 raise "hi" @@ -91,7 +91,7 @@ describe Chef::ChefFS::Parallelizer do it "Exceptions with :stop_on_exception are raised after all processing is done" do processed = 0 - parallelized = parallelize([0.3, 0.3, "x", 0.3, 0.3, 0.3, 0.3, 0.3], :ordered => false, :stop_on_exception => true) do |x| + parallelized = parallelize([0.3, 0.3, "x", 0.3, 0.3, 0.3, 0.3, 0.3], ordered: false, stop_on_exception: true) do |x| if x == "x" sleep(0.1) raise "hi" @@ -114,7 +114,7 @@ describe Chef::ChefFS::Parallelizer do end it "10 sleep(0.2)s complete within 0.5 seconds" do - expect(parallelize(1.upto(10), :ordered => true) do |i| + expect(parallelize(1.upto(10), ordered: true) do |i| sleep 0.2 "x" end.to_a).to eq(%w{x x x x x x x x x x}) @@ -163,7 +163,7 @@ describe Chef::ChefFS::Parallelizer do it "Exceptions with :stop_on_exception are raised after all processing is done" do processed = 0 - parallelized = parallelize([0.3, 0.3, "x", 0.3, 0.3, 0.3, 0.3, 0.3], :ordered => false, :stop_on_exception => true) do |x| + parallelized = parallelize([0.3, 0.3, "x", 0.3, 0.3, 0.3, 0.3, 0.3], ordered: false, stop_on_exception: true) do |x| if x == "x" sleep(0.1) raise "hi" @@ -205,7 +205,7 @@ describe Chef::ChefFS::Parallelizer do started = false @occupying_job_finished = occupying_job_finished = [ false ] @thread = Thread.new do - parallelizer.parallelize([0], :main_thread_processing => false) do |x| + parallelizer.parallelize([0], main_thread_processing: false) do |x| started = true sleep(0.3) occupying_job_finished[0] = true @@ -229,7 +229,7 @@ describe Chef::ChefFS::Parallelizer do end it "parallelize with :main_thread_processing = false waits for the job to finish" do - expect(parallelizer.parallelize([1], :main_thread_processing => false) do |x| + expect(parallelizer.parallelize([1], main_thread_processing: false) do |x| sleep(0.1) x + 1 end.to_a).to eq([ 2 ]) @@ -434,7 +434,7 @@ describe Chef::ChefFS::Parallelizer do end it "does not have contention issues with large numbers of inputs with ordering off" do - expect(parallelizer.parallelize(1.upto(500), :ordered => false) { |x| x + 1 }.to_a.sort).to eq(2.upto(501).to_a) + expect(parallelizer.parallelize(1.upto(500), ordered: false) { |x| x + 1 }.to_a.sort).to eq(2.upto(501).to_a) end it "does not have contention issues with large numbers of jobs and inputs with ordering off" do diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index 001be10e0b..0e72a285af 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -179,12 +179,12 @@ describe Chef::Client do context "when an override run list is given" do it "permits spaces in overriding run list" do - Chef::Client.new(nil, :override_runlist => "role[a], role[b]") + Chef::Client.new(nil, override_runlist: "role[a], role[b]") end describe "calling run" do include_examples "a successful client run" do - let(:client_opts) { { :override_runlist => "recipe[override_recipe]" } } + let(:client_opts) { { override_runlist: "recipe[override_recipe]" } } def stub_for_sync_cookbooks # --Client#setup_run_context @@ -193,7 +193,7 @@ describe Chef::Client do expect_any_instance_of(Chef::CookbookSynchronizer).to receive(:sync_cookbooks) expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], version_class: Chef::CookbookManifestVersions).and_return(http_cookbook_sync) expect(http_cookbook_sync).to receive(:post). - with("environments/_default/cookbook_versions", { :run_list => ["override_recipe"] }). + with("environments/_default/cookbook_versions", { run_list: ["override_recipe"] }). and_return({}) end @@ -218,7 +218,7 @@ describe Chef::Client do include_examples "a successful client run" do let(:new_runlist) { "recipe[new_run_list_recipe]" } - let(:client_opts) { { :runlist => new_runlist } } + let(:client_opts) { { runlist: new_runlist } } def stub_for_sync_cookbooks # --Client#setup_run_context @@ -227,7 +227,7 @@ describe Chef::Client do expect_any_instance_of(Chef::CookbookSynchronizer).to receive(:sync_cookbooks) expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], version_class: Chef::CookbookManifestVersions).and_return(http_cookbook_sync) expect(http_cookbook_sync).to receive(:post). - with("environments/_default/cookbook_versions", { :run_list => ["new_run_list_recipe"] }). + with("environments/_default/cookbook_versions", { run_list: ["new_run_list_recipe"] }). and_return({}) end @@ -293,7 +293,7 @@ describe Chef::Client do describe "when handling run failures" do it "should remove the run_lock on failure of #load_node" do - @run_lock = double("Chef::RunLock", :acquire => true) + @run_lock = double("Chef::RunLock", acquire: true) allow(Chef::RunLock).to receive(:new).and_return(@run_lock) @events = double("Chef::EventDispatch::Dispatcher").as_null_object diff --git a/spec/unit/config_fetcher_spec.rb b/spec/unit/config_fetcher_spec.rb index a674d4de33..c91b043160 100644 --- a/spec/unit/config_fetcher_spec.rb +++ b/spec/unit/config_fetcher_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" require "chef/config_fetcher" describe Chef::ConfigFetcher do - let(:valid_json) { Chef::JSONCompat.to_json({ :a => "b" }) } + let(:valid_json) { Chef::JSONCompat.to_json({ a: "b" }) } let(:invalid_json) { %q[{"syntax-error": "missing quote}] } let(:http) { double("Chef::HTTP::Simple") } diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb index a2cb35e60d..7d7b6137bb 100644 --- a/spec/unit/cookbook/metadata_spec.rb +++ b/spec/unit/cookbook/metadata_spec.rb @@ -175,15 +175,15 @@ describe Chef::Cookbook::Metadata do describe "meta-data attributes" do params = { - :maintainer => "Adam Jacob", - :maintainer_email => "adam@opscode.com", - :license => "Apache v2.0", - :description => "Foobar!", - :long_description => "Much Longer\nSeriously", - :version => "0.6.0", - :source_url => "http://example.com", - :issues_url => "http://example.com/issues", - :privacy => true, + maintainer: "Adam Jacob", + maintainer_email: "adam@opscode.com", + license: "Apache v2.0", + description: "Foobar!", + long_description: "Much Longer\nSeriously", + version: "0.6.0", + source_url: "http://example.com", + issues_url: "http://example.com/issues", + privacy: true, } params.sort_by(&:to_s).each do |field, field_value| describe field do @@ -212,8 +212,8 @@ describe Chef::Cookbook::Metadata do describe "describing dependencies" do dep_types = { - :depends => [ :dependencies, "foo::bar", "> 0.2" ], - :provides => [ :providing, "foo::bar", "<= 0.2" ], + depends: [ :dependencies, "foo::bar", "> 0.2" ], + provides: [ :providing, "foo::bar", "<= 0.2" ], } dep_types.sort_by(&:to_s).each do |dep, dep_args| check_with = dep_args.shift @@ -229,8 +229,8 @@ describe Chef::Cookbook::Metadata do end dep_types = { - :depends => [ :dependencies, "foo::bar", ">0.2", "> 0.2" ], - :provides => [ :providing, "foo::bar", "<=0.2", "<= 0.2" ], + depends: [ :dependencies, "foo::bar", ">0.2", "> 0.2" ], + provides: [ :providing, "foo::bar", "<=0.2", "<= 0.2" ], } dep_types.sort_by(&:to_s).each do |dep, dep_args| check_with = dep_args.shift @@ -248,8 +248,8 @@ describe Chef::Cookbook::Metadata do describe "in the obsoleted format" do dep_types = { - :depends => [ "foo::bar", "> 0.2", "< 1.0" ], - :provides => [ "foo::bar", "> 0.2", "< 1.0" ], + depends: [ "foo::bar", "> 0.2", "< 1.0" ], + provides: [ "foo::bar", "> 0.2", "< 1.0" ], } dep_types.each do |dep, dep_args| @@ -261,8 +261,8 @@ describe Chef::Cookbook::Metadata do describe "with obsolete operators" do dep_types = { - :depends => [ "foo::bar", ">> 0.2"], - :provides => [ "foo::bar", ">> 0.2"], + depends: [ "foo::bar", ">> 0.2"], + provides: [ "foo::bar", ">> 0.2"], } dep_types.each do |dep, dep_args| @@ -435,61 +435,61 @@ describe Chef::Cookbook::Metadata do it "should not accept anything but a string for display_name" do expect do - metadata.attribute("db/mysql/databases", :display_name => "foo") + metadata.attribute("db/mysql/databases", display_name: "foo") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :display_name => Hash.new) + metadata.attribute("db/mysql/databases", display_name: Hash.new) end.to raise_error(ArgumentError) end it "should not accept anything but a string for the description" do expect do - metadata.attribute("db/mysql/databases", :description => "foo") + metadata.attribute("db/mysql/databases", description: "foo") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :description => Hash.new) + metadata.attribute("db/mysql/databases", description: Hash.new) end.to raise_error(ArgumentError) end it "should not accept anything but a string for the source_url" do expect do - metadata.attribute("db/mysql/databases", :source_url => "foo") + metadata.attribute("db/mysql/databases", source_url: "foo") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :source_url => Hash.new) + metadata.attribute("db/mysql/databases", source_url: Hash.new) end.to raise_error(ArgumentError) end it "should not accept anything but a string for the issues_url" do expect do - metadata.attribute("db/mysql/databases", :issues_url => "foo") + metadata.attribute("db/mysql/databases", issues_url: "foo") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :issues_url => Hash.new) + metadata.attribute("db/mysql/databases", issues_url: Hash.new) end.to raise_error(ArgumentError) end it "should not accept anything but true or false for the privacy flag" do expect do - metadata.attribute("db/mysql/databases", :privacy => true) + metadata.attribute("db/mysql/databases", privacy: true) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :privacy => false) + metadata.attribute("db/mysql/databases", privacy: false) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :privacy => "true") + metadata.attribute("db/mysql/databases", privacy: "true") end.to raise_error(ArgumentError) end it "should not accept anything but an array of strings for choice" do expect do - metadata.attribute("db/mysql/databases", :choice => %w{dedicated shared}) + metadata.attribute("db/mysql/databases", choice: %w{dedicated shared}) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :choice => [10, "shared"]) + metadata.attribute("db/mysql/databases", choice: [10, "shared"]) end.to raise_error(ArgumentError) expect do - metadata.attribute("db/mysql/databases", :choice => Hash.new) + metadata.attribute("db/mysql/databases", choice: Hash.new) end.to raise_error(ArgumentError) end @@ -500,13 +500,13 @@ describe Chef::Cookbook::Metadata do it "should let calculated be true or false" do expect do - metadata.attribute("db/mysql/databases", :calculated => true) + metadata.attribute("db/mysql/databases", calculated: true) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :calculated => false) + metadata.attribute("db/mysql/databases", calculated: false) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :calculated => Hash.new) + metadata.attribute("db/mysql/databases", calculated: Hash.new) end.to raise_error(ArgumentError) end @@ -517,53 +517,53 @@ describe Chef::Cookbook::Metadata do it "accepts String for the attribute type" do expect do - metadata.attribute("db/mysql/databases", :type => "string") + metadata.attribute("db/mysql/databases", type: "string") end.not_to raise_error end it "accepts Array for the attribute type" do expect do - metadata.attribute("db/mysql/databases", :type => "array") + metadata.attribute("db/mysql/databases", type: "array") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :type => Array.new) + metadata.attribute("db/mysql/databases", type: Array.new) end.to raise_error(ArgumentError) end it "accepts symbol for the attribute type" do expect do - metadata.attribute("db/mysql/databases", :type => "symbol") + metadata.attribute("db/mysql/databases", type: "symbol") end.not_to raise_error end it "should let type be hash (backwards compatibility only)" do expect do - metadata.attribute("db/mysql/databases", :type => "hash") + metadata.attribute("db/mysql/databases", type: "hash") end.not_to raise_error end it "should let required be required, recommended or optional" do expect do - metadata.attribute("db/mysql/databases", :required => "required") + metadata.attribute("db/mysql/databases", required: "required") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :required => "recommended") + metadata.attribute("db/mysql/databases", required: "recommended") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :required => "optional") + metadata.attribute("db/mysql/databases", required: "optional") end.not_to raise_error end it "should convert required true to required" do expect do - metadata.attribute("db/mysql/databases", :required => true) + metadata.attribute("db/mysql/databases", required: true) end.not_to raise_error #attrib = metadata.attributes["db/mysql/databases"][:required].should == "required" end it "should convert required false to optional" do expect do - metadata.attribute("db/mysql/databases", :required => false) + metadata.attribute("db/mysql/databases", required: false) end.not_to raise_error #attrib = metadata.attributes["db/mysql/databases"][:required].should == "optional" end @@ -575,10 +575,10 @@ describe Chef::Cookbook::Metadata do it "should make sure recipes is an array" do expect do - metadata.attribute("db/mysql/databases", :recipes => []) + metadata.attribute("db/mysql/databases", recipes: []) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :required => Hash.new) + metadata.attribute("db/mysql/databases", required: Hash.new) end.to raise_error(ArgumentError) end @@ -589,57 +589,57 @@ describe Chef::Cookbook::Metadata do it "should allow the default value to be a string, array, hash, boolean or numeric" do expect do - metadata.attribute("db/mysql/databases", :default => []) + metadata.attribute("db/mysql/databases", default: []) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :default => {}) + metadata.attribute("db/mysql/databases", default: {}) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :default => "alice in chains") + metadata.attribute("db/mysql/databases", default: "alice in chains") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :default => 1337) + metadata.attribute("db/mysql/databases", default: 1337) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :default => true) + metadata.attribute("db/mysql/databases", default: true) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", :required => :not_gonna_do_it) + metadata.attribute("db/mysql/databases", required: :not_gonna_do_it) end.to raise_error(ArgumentError) end it "should limit the types allowed in the choice array" do options = { - :type => "string", - :choice => %w{test1 test2}, - :default => "test1", + type: "string", + choice: %w{test1 test2}, + default: "test1", } expect do metadata.attribute("test_cookbook/test", options) end.not_to raise_error options = { - :type => "boolean", - :choice => [ true, false ], - :default => true, + type: "boolean", + choice: [ true, false ], + default: true, } expect do metadata.attribute("test_cookbook/test", options) end.not_to raise_error options = { - :type => "numeric", - :choice => [ 1337, 420 ], - :default => 1337, + type: "numeric", + choice: [ 1337, 420 ], + default: 1337, } expect do metadata.attribute("test_cookbook/test", options) end.not_to raise_error options = { - :type => "numeric", - :choice => [ true, "false" ], - :default => false, + type: "numeric", + choice: [ true, "false" ], + default: false, } expect do metadata.attribute("test_cookbook/test", options) @@ -649,15 +649,15 @@ describe Chef::Cookbook::Metadata do it "should error if default used with calculated" do expect do attrs = { - :calculated => true, - :default => [ "I thought you said calculated" ], + calculated: true, + default: [ "I thought you said calculated" ], } metadata.attribute("db/mysql/databases", attrs) end.to raise_error(ArgumentError) expect do attrs = { - :calculated => true, - :default => "I thought you said calculated", + calculated: true, + default: "I thought you said calculated", } metadata.attribute("db/mysql/databases", attrs) end.to raise_error(ArgumentError) @@ -666,15 +666,15 @@ describe Chef::Cookbook::Metadata do it "should allow a default that is a choice" do expect do attrs = { - :choice => %w{a b c}, - :default => "b", + choice: %w{a b c}, + default: "b", } metadata.attribute("db/mysql/databases", attrs) end.not_to raise_error expect do attrs = { - :choice => %w{a b c d e}, - :default => %w{b d}, + choice: %w{a b c d e}, + default: %w{b d}, } metadata.attribute("db/mysql/databases", attrs) end.not_to raise_error @@ -683,15 +683,15 @@ describe Chef::Cookbook::Metadata do it "should error if default is not a choice" do expect do attrs = { - :choice => %w{a b c}, - :default => "d", + choice: %w{a b c}, + default: "d", } metadata.attribute("db/mysql/databases", attrs) end.to raise_error(ArgumentError) expect do attrs = { - :choice => %w{a b c d e}, - :default => %w{b z}, + choice: %w{a b c d e}, + default: %w{b z}, } metadata.attribute("db/mysql/databases", attrs) end.to raise_error(ArgumentError) @@ -743,7 +743,7 @@ describe Chef::Cookbook::Metadata do metadata.provides "foo(:bar, :baz)" metadata.recipe "test_cookbook::enlighten", "is your buddy" metadata.attribute "bizspark/has_login", - :display_name => "You have nothing" + display_name: "You have nothing" metadata.version "1.2.3" metadata.gem "foo", "~> 1.2" metadata.gem "bar", ">= 2.2", "< 4.0" diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb index 1e6c9ef48c..cabcb57ea4 100644 --- a/spec/unit/cookbook/synchronizer_spec.rb +++ b/spec/unit/cookbook/synchronizer_spec.rb @@ -198,22 +198,22 @@ describe Chef::CookbookSynchronizer do let(:cookbook_a_default_recipe_tempfile) do double("Tempfile for cookbook_a default.rb recipe", - :path => "/tmp/cookbook_a_recipes_default_rb") + path: "/tmp/cookbook_a_recipes_default_rb") end let(:cookbook_a_default_attribute_tempfile) do double("Tempfile for cookbook_a default.rb attr file", - :path => "/tmp/cookbook_a_attributes_default_rb") + path: "/tmp/cookbook_a_attributes_default_rb") end let(:cookbook_a_file_default_tempfile) do double("Tempfile for cookbook_a megaman.conf file", - :path => "/tmp/cookbook_a_file_default_tempfile") + path: "/tmp/cookbook_a_file_default_tempfile") end let(:cookbook_a_template_default_tempfile) do double("Tempfile for cookbook_a apache.conf.erb template", - :path => "/tmp/cookbook_a_template_default_tempfile") + path: "/tmp/cookbook_a_template_default_tempfile") end def setup_common_files_missing_expectations diff --git a/spec/unit/cookbook_site_streaming_uploader_spec.rb b/spec/unit/cookbook_site_streaming_uploader_spec.rb index 0e9c277b11..87ff7abdd7 100644 --- a/spec/unit/cookbook_site_streaming_uploader_spec.rb +++ b/spec/unit/cookbook_site_streaming_uploader_spec.rb @@ -102,22 +102,22 @@ describe Chef::CookbookSiteStreamingUploader do it "should be able to receive files to attach as argument" do Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, { - :myfile => File.new(File.join(CHEF_SPEC_DATA, "config.rb")), # a dummy file + myfile: File.new(File.join(CHEF_SPEC_DATA, "config.rb")), # a dummy file }) end it "should be able to receive strings to attach as argument" do Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, { - :mystring => "Lorem ipsum", + mystring: "Lorem ipsum", }) end it "should be able to receive strings and files as argument at the same time" do Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, { - :myfile1 => File.new(File.join(CHEF_SPEC_DATA, "config.rb")), - :mystring1 => "Lorem ipsum", - :myfile2 => File.new(File.join(CHEF_SPEC_DATA, "config.rb")), - :mystring2 => "Dummy text", + myfile1: File.new(File.join(CHEF_SPEC_DATA, "config.rb")), + mystring1: "Lorem ipsum", + myfile2: File.new(File.join(CHEF_SPEC_DATA, "config.rb")), + mystring2: "Dummy text", }) end diff --git a/spec/unit/cookbook_uploader_spec.rb b/spec/unit/cookbook_uploader_spec.rb index 2c36c2c9c7..0c4fb6cda7 100644 --- a/spec/unit/cookbook_uploader_spec.rb +++ b/spec/unit/cookbook_uploader_spec.rb @@ -86,7 +86,7 @@ describe Chef::CookbookUploader do def expect_sandbox_create expect(http_client).to receive(:post). - with("sandboxes", { :checksums => checksums_set }). + with("sandboxes", { checksums: checksums_set }). and_return(sandbox_response) end @@ -111,7 +111,7 @@ describe Chef::CookbookUploader do end def expect_sandbox_commit - expect(http_client).to receive(:put).with(sandbox_commit_uri, { :is_completed => true }) + expect(http_client).to receive(:put).with(sandbox_commit_uri, { is_completed: true }) end def expect_cookbook_create diff --git a/spec/unit/cookbook_version_file_specificity_spec.rb b/spec/unit/cookbook_version_file_specificity_spec.rb index ba7aaa59f5..b7d5a9b288 100644 --- a/spec/unit/cookbook_version_file_specificity_spec.rb +++ b/spec/unit/cookbook_version_file_specificity_spec.rb @@ -27,202 +27,202 @@ describe Chef::CookbookVersion, "file specificity" do [ # afile.rb { - :name => "files/afile.rb", - :path => "files/host-examplehost.example.org/afile.rb", - :full_path => "/cookbook-folder/files/host-examplehost.example.org/afile.rb", - :checksum => "csum-host", - :specificity => "host-examplehost.example.org", + name: "files/afile.rb", + path: "files/host-examplehost.example.org/afile.rb", + full_path: "/cookbook-folder/files/host-examplehost.example.org/afile.rb", + checksum: "csum-host", + specificity: "host-examplehost.example.org", }, { - :name => "files/afile.rb", - :path => "files/ubuntu-9.10/afile.rb", - :full_path => "/cookbook-folder/files/ubuntu-9.10/afile.rb", - :checksum => "csum-platver-full", - :specificity => "ubuntu-9.10", + name: "files/afile.rb", + path: "files/ubuntu-9.10/afile.rb", + full_path: "/cookbook-folder/files/ubuntu-9.10/afile.rb", + checksum: "csum-platver-full", + specificity: "ubuntu-9.10", }, { - :name => "files/afile.rb", - :path => "files/newubuntu-9/afile.rb", - :full_path => "/cookbook-folder/files/newubuntu-9/afile.rb", - :checksum => "csum-platver-partial", - :specificity => "newubuntu-9", + name: "files/afile.rb", + path: "files/newubuntu-9/afile.rb", + full_path: "/cookbook-folder/files/newubuntu-9/afile.rb", + checksum: "csum-platver-partial", + specificity: "newubuntu-9", }, { - :name => "files/afile.rb", - :path => "files/ubuntu/afile.rb", - :full_path => "/cookbook-folder/files/ubuntu/afile.rb", - :checksum => "csum-plat", - :specificity => "ubuntu", + name: "files/afile.rb", + path: "files/ubuntu/afile.rb", + full_path: "/cookbook-folder/files/ubuntu/afile.rb", + checksum: "csum-plat", + specificity: "ubuntu", }, { - :name => "files/afile.rb", - :path => "files/default/afile.rb", - :full_path => "/cookbook-folder/files/default/afile.rb", - :checksum => "csum-default", - :specificity => "default", + name: "files/afile.rb", + path: "files/default/afile.rb", + full_path: "/cookbook-folder/files/default/afile.rb", + checksum: "csum-default", + specificity: "default", }, # for different/odd platform_versions { - :name => "files/bfile.rb", - :path => "files/fakeos-2.0.rc.1/bfile.rb", - :full_path => "/cookbook-folder/files/fakeos-2.0.rc.1/bfile.rb", - :checksum => "csum2-platver-full", - :specificity => "fakeos-2.0.rc.1", + name: "files/bfile.rb", + path: "files/fakeos-2.0.rc.1/bfile.rb", + full_path: "/cookbook-folder/files/fakeos-2.0.rc.1/bfile.rb", + checksum: "csum2-platver-full", + specificity: "fakeos-2.0.rc.1", }, { - :name => "files/bfile.rb", - :path => "files/newfakeos-2.0.rc/bfile.rb", - :full_path => "/cookbook-folder/files/newfakeos-2.0.rc/bfile.rb", - :checksum => "csum2-platver-partial", - :specificity => "newfakeos-2.0.rc", + name: "files/bfile.rb", + path: "files/newfakeos-2.0.rc/bfile.rb", + full_path: "/cookbook-folder/files/newfakeos-2.0.rc/bfile.rb", + checksum: "csum2-platver-partial", + specificity: "newfakeos-2.0.rc", }, { - :name => "files/bfile.rb", - :path => "files/fakeos-maple tree/bfile.rb", - :full_path => "/cookbook-folder/files/fakeos-maple tree/bfile.rb", - :checksum => "csum3-platver-full", - :specificity => "maple tree", + name: "files/bfile.rb", + path: "files/fakeos-maple tree/bfile.rb", + full_path: "/cookbook-folder/files/fakeos-maple tree/bfile.rb", + checksum: "csum3-platver-full", + specificity: "maple tree", }, { - :name => "files/bfile.rb", - :path => "files/fakeos-1/bfile.rb", - :full_path => "/cookbook-folder/files/fakeos-1/bfile.rb", - :checksum => "csum4-platver-full", - :specificity => "fakeos-1", + name: "files/bfile.rb", + path: "files/fakeos-1/bfile.rb", + full_path: "/cookbook-folder/files/fakeos-1/bfile.rb", + checksum: "csum4-platver-full", + specificity: "fakeos-1", }, # directory adirectory { - :name => "files/anotherfile1.rb", - :path => "files/host-examplehost.example.org/adirectory/anotherfile1.rb.host", - :full_path => "/cookbook-folder/files/host-examplehost.example.org/adirectory/anotherfile1.rb.host", - :checksum => "csum-host-1", - :specificity => "host-examplehost.example.org", + name: "files/anotherfile1.rb", + path: "files/host-examplehost.example.org/adirectory/anotherfile1.rb.host", + full_path: "/cookbook-folder/files/host-examplehost.example.org/adirectory/anotherfile1.rb.host", + checksum: "csum-host-1", + specificity: "host-examplehost.example.org", }, { - :name => "files/anotherfile2.rb", - :path => "files/host-examplehost.example.org/adirectory/anotherfile2.rb.host", - :full_path => "/cookbook-folder/files/host-examplehost.example.org/adirectory/anotherfile2.rb.host", - :checksum => "csum-host-2", - :specificity => "host-examplehost.example.org", + name: "files/anotherfile2.rb", + path: "files/host-examplehost.example.org/adirectory/anotherfile2.rb.host", + full_path: "/cookbook-folder/files/host-examplehost.example.org/adirectory/anotherfile2.rb.host", + checksum: "csum-host-2", + specificity: "host-examplehost.example.org", }, { - :name => "files/anotherfile1.rb", - :path => "files/ubuntu-9.10/adirectory/anotherfile1.rb.platform-full-version", - :full_path => "/cookbook-folder/files/ubuntu-9.10/adirectory/anotherfile1.rb.platform-full-version", - :checksum => "csum-platver-full-1", - :specificity => "ubuntu-9.10", + name: "files/anotherfile1.rb", + path: "files/ubuntu-9.10/adirectory/anotherfile1.rb.platform-full-version", + full_path: "/cookbook-folder/files/ubuntu-9.10/adirectory/anotherfile1.rb.platform-full-version", + checksum: "csum-platver-full-1", + specificity: "ubuntu-9.10", }, { - :name => "files/anotherfile2.rb", - :path => "files/ubuntu-9.10/adirectory/anotherfile2.rb.platform-full-version", - :full_path => "/cookbook-folder/files/ubuntu-9.10/adirectory/anotherfile2.rb.platform-full-version", - :checksum => "csum-platver-full-2", - :specificity => "ubuntu-9.10", + name: "files/anotherfile2.rb", + path: "files/ubuntu-9.10/adirectory/anotherfile2.rb.platform-full-version", + full_path: "/cookbook-folder/files/ubuntu-9.10/adirectory/anotherfile2.rb.platform-full-version", + checksum: "csum-platver-full-2", + specificity: "ubuntu-9.10", }, { - :name => "files/anotherfile1.rb", - :path => "files/newubuntu-9/adirectory/anotherfile1.rb.platform-partial-version", - :full_path => "/cookbook-folder/files/newubuntu-9/adirectory/anotherfile1.rb.platform-partial-version", - :checksum => "csum-platver-partial-1", - :specificity => "newubuntu-9", + name: "files/anotherfile1.rb", + path: "files/newubuntu-9/adirectory/anotherfile1.rb.platform-partial-version", + full_path: "/cookbook-folder/files/newubuntu-9/adirectory/anotherfile1.rb.platform-partial-version", + checksum: "csum-platver-partial-1", + specificity: "newubuntu-9", }, { - :name => "files/anotherfile2.rb", - :path => "files/newubuntu-9/adirectory/anotherfile2.rb.platform-partial-version", - :full_path => "/cookbook-folder/files/newubuntu-9/adirectory/anotherfile2.rb.platform-partial-version", - :checksum => "csum-platver-partial-2", - :specificity => "nweubuntu-9", + name: "files/anotherfile2.rb", + path: "files/newubuntu-9/adirectory/anotherfile2.rb.platform-partial-version", + full_path: "/cookbook-folder/files/newubuntu-9/adirectory/anotherfile2.rb.platform-partial-version", + checksum: "csum-platver-partial-2", + specificity: "nweubuntu-9", }, { - :name => "files/anotherfile1.rb", - :path => "files/ubuntu/adirectory/anotherfile1.rb.platform", - :full_path => "/cookbook-folder/files/ubuntu/adirectory/anotherfile1.rb.platform", - :checksum => "csum-plat-1", - :specificity => "ubuntu", + name: "files/anotherfile1.rb", + path: "files/ubuntu/adirectory/anotherfile1.rb.platform", + full_path: "/cookbook-folder/files/ubuntu/adirectory/anotherfile1.rb.platform", + checksum: "csum-plat-1", + specificity: "ubuntu", }, { - :name => "files/anotherfile2.rb", - :path => "files/ubuntu/adirectory/anotherfile2.rb.platform", - :full_path => "/cookbook-folder/files/ubuntu/adirectory/anotherfile2.rb.platform", - :checksum => "csum-plat-2", - :specificity => "ubuntu", + name: "files/anotherfile2.rb", + path: "files/ubuntu/adirectory/anotherfile2.rb.platform", + full_path: "/cookbook-folder/files/ubuntu/adirectory/anotherfile2.rb.platform", + checksum: "csum-plat-2", + specificity: "ubuntu", }, { - :name => "files/anotherfile1.rb", - :path => "files/default/adirectory/anotherfile1.rb.default", - :full_path => "/cookbook-folder/files/default/adirectory/anotherfile1.rb.default", - :checksum => "csum-default-1", - :specificity => "default", + name: "files/anotherfile1.rb", + path: "files/default/adirectory/anotherfile1.rb.default", + full_path: "/cookbook-folder/files/default/adirectory/anotherfile1.rb.default", + checksum: "csum-default-1", + specificity: "default", }, { - :name => "files/anotherfile2.rb", - :path => "files/default/adirectory/anotherfile2.rb.default", - :full_path => "/cookbook-folder/files/default/adirectory/anotherfile2.rb.default", - :checksum => "csum-default-2", - :specificity => "default", + name: "files/anotherfile2.rb", + path: "files/default/adirectory/anotherfile2.rb.default", + full_path: "/cookbook-folder/files/default/adirectory/anotherfile2.rb.default", + checksum: "csum-default-2", + specificity: "default", }, # for different/odd platform_versions { - :name => "files/anotherfile1.rb", - :path => "files/fakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-full-version", - :full_path => "/cookbook-folder/files/fakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-full-version", - :checksum => "csum2-platver-full-1", - :specificity => "fakeos-2.0.rc.1", + name: "files/anotherfile1.rb", + path: "files/fakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-full-version", + full_path: "/cookbook-folder/files/fakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-full-version", + checksum: "csum2-platver-full-1", + specificity: "fakeos-2.0.rc.1", }, { - :name => "files/anotherfile2.rb", - :path => "files/fakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-full-version", - :full_path => "/cookbook-folder/files/fakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-full-version", - :checksum => "csum2-platver-full-2", - :specificity => "fakeos-2.0.rc.1", + name: "files/anotherfile2.rb", + path: "files/fakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-full-version", + full_path: "/cookbook-folder/files/fakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-full-version", + checksum: "csum2-platver-full-2", + specificity: "fakeos-2.0.rc.1", }, { - :name => "files/anotherfile1.rb", - :path => "files/newfakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-partial-version", - :full_path => "/cookbook-folder/files/newfakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-partial-version", - :checksum => "csum2-platver-partial-1", - :specificity => "newfakeos-2.0.rc", + name: "files/anotherfile1.rb", + path: "files/newfakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-partial-version", + full_path: "/cookbook-folder/files/newfakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-partial-version", + checksum: "csum2-platver-partial-1", + specificity: "newfakeos-2.0.rc", }, { - :name => "files/anotherfile2.rb", - :path => "files/newfakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-partial-version", - :full_path => "/cookbook-folder/files/newfakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-partial-version", - :checksum => "csum2-platver-partial-2", - :specificity => "newfakeos-2.0.rc", + name: "files/anotherfile2.rb", + path: "files/newfakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-partial-version", + full_path: "/cookbook-folder/files/newfakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-partial-version", + checksum: "csum2-platver-partial-2", + specificity: "newfakeos-2.0.rc", }, { - :name => "files/anotherfile1.rb", - :path => "files/fakeos-maple tree/adirectory/anotherfile1.rb.platform-full-version", - :full_path => "/cookbook-folder/files/fakeos-maple tree/adirectory/anotherfile1.rb.platform-full-version", - :checksum => "csum3-platver-full-1", - :specificity => "fakeos-maple tree", + name: "files/anotherfile1.rb", + path: "files/fakeos-maple tree/adirectory/anotherfile1.rb.platform-full-version", + full_path: "/cookbook-folder/files/fakeos-maple tree/adirectory/anotherfile1.rb.platform-full-version", + checksum: "csum3-platver-full-1", + specificity: "fakeos-maple tree", }, { - :name => "files/anotherfile2.rb", - :path => "files/fakeos-maple tree/adirectory/anotherfile2.rb.platform-full-version", - :full_path => "/cookbook-folder/files/fakeos-maple tree/adirectory/anotherfile2.rb.platform-full-version", - :checksum => "csum3-platver-full-2", - :specificity => "fakeos-maple tree", + name: "files/anotherfile2.rb", + path: "files/fakeos-maple tree/adirectory/anotherfile2.rb.platform-full-version", + full_path: "/cookbook-folder/files/fakeos-maple tree/adirectory/anotherfile2.rb.platform-full-version", + checksum: "csum3-platver-full-2", + specificity: "fakeos-maple tree", }, { - :name => "files/anotherfile1.rb", - :path => "files/fakeos-1/adirectory/anotherfile1.rb.platform-full-version", - :full_path => "/cookbook-folder/files/fakeos-1/adirectory/anotherfile1.rb.platform-full-version", - :checksum => "csum4-platver-full-1", - :specificity => "fakeos-1", + name: "files/anotherfile1.rb", + path: "files/fakeos-1/adirectory/anotherfile1.rb.platform-full-version", + full_path: "/cookbook-folder/files/fakeos-1/adirectory/anotherfile1.rb.platform-full-version", + checksum: "csum4-platver-full-1", + specificity: "fakeos-1", }, { - :name => "files/anotherfile2.rb", - :path => "files/fakeos-1/adirectory/anotherfile2.rb.platform-full-version", - :full_path => "/cookbook-folder/files/fakeos-1/adirectory/anotherfile2.rb.platform-full-version", - :checksum => "csum4-platver-full-2", - :specificity => "fakeos-1", + name: "files/anotherfile2.rb", + path: "files/fakeos-1/adirectory/anotherfile2.rb.platform-full-version", + full_path: "/cookbook-folder/files/fakeos-1/adirectory/anotherfile2.rb.platform-full-version", + checksum: "csum4-platver-full-2", + specificity: "fakeos-1", }, ], } diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb index 02736a1daf..ffcdb71259 100644 --- a/spec/unit/daemon_spec.rb +++ b/spec/unit/daemon_spec.rb @@ -25,7 +25,7 @@ describe Chef::Daemon do before do if windows? mock_struct = #Struct::Passwd.new(nil, nil, 111, 111) - mock_struct = OpenStruct.new(:uid => 2342, :gid => 2342) + mock_struct = OpenStruct.new(uid: 2342, gid: 2342) allow(Etc).to receive(:getpwnam).and_return mock_struct allow(Etc).to receive(:getgrnam).and_return mock_struct # mock unimplemented methods @@ -126,8 +126,8 @@ describe Chef::Daemon do allow(Process::UID).to receive(:change_privilege).and_return(nil) allow(Process::GID).to receive(:change_privilege).and_return(nil) - @pw_user = double("Struct::Passwd", :uid => 501) - @pw_group = double("Struct::Group", :gid => 20) + @pw_user = double("Struct::Passwd", uid: 501) + @pw_group = double("Struct::Group", gid: 20) allow(Process).to receive(:initgroups).and_return(true) diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb index 7094a7b1f7..a32ba147f8 100644 --- a/spec/unit/data_bag_item_spec.rb +++ b/spec/unit/data_bag_item_spec.rb @@ -53,7 +53,7 @@ describe Chef::DataBagItem do end it "should let you set the raw_data with a hash containing symbols" do - expect { data_bag_item.raw_data = { :id => "octahedron" } }.not_to raise_error + expect { data_bag_item.raw_data = { id: "octahedron" } }.not_to raise_error end it "should let you set the raw_data from a mash" do @@ -297,7 +297,7 @@ describe Chef::DataBagItem do end it "should create if the item is not found" do - exception = double("404 error", :code => "404") + exception = double("404 error", code: "404") expect(server).to receive(:put).and_raise(Net::HTTPServerException.new("foo", exception)) expect(server).to receive(:post).with("data/books", data_bag_item) data_bag_item.save diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb index cadd60936e..f20148de72 100644 --- a/spec/unit/data_bag_spec.rb +++ b/spec/unit/data_bag_spec.rb @@ -88,7 +88,7 @@ describe Chef::DataBag do end it "should silently proceed when the data bag already exists" do - exception = double("409 error", :code => "409") + exception = double("409 error", code: "409") expect(@rest).to receive(:post).and_raise(Net::HTTPServerException.new("foo", exception)) @data_bag.save end diff --git a/spec/unit/data_collector/resource_report_spec.rb b/spec/unit/data_collector/resource_report_spec.rb index 278e94b53b..1a5eab796e 100644 --- a/spec/unit/data_collector/resource_report_spec.rb +++ b/spec/unit/data_collector/resource_report_spec.rb @@ -133,7 +133,7 @@ describe Chef::DataCollector::ResourceReport do } end let(:conditional) do - double("Chef::Resource::Conditional", :to_text => "because") + double("Chef::Resource::Conditional", to_text: "because") end it "should handle any Exception and throw a helpful message by mocking the identity" do diff --git a/spec/unit/data_collector_spec.rb b/spec/unit/data_collector_spec.rb index f8a9e374e5..87729d8652 100644 --- a/spec/unit/data_collector_spec.rb +++ b/spec/unit/data_collector_spec.rb @@ -805,14 +805,14 @@ describe Chef::DataCollector::Reporter do context "when valid output_locations are provided" do it "does not raise an exception" do expect(reporter).to receive(:open).with("data_collection.json", "a") - Chef::Config[:data_collector][:output_locations] = { :urls => ["http://data_collector"], :files => ["data_collection.json"] } + Chef::Config[:data_collector][:output_locations] = { urls: ["http://data_collector"], files: ["data_collection.json"] } expect { reporter.send(:validate_data_collector_output_locations!) }.not_to raise_error(Chef::Exceptions::ConfigurationError) end end context "when output_locations contains an invalid URI" do it "raises an exception" do - Chef::Config[:data_collector][:output_locations] = { :urls => ["this is not a url"], :files => ["/tmp/data_collection.json"] } + Chef::Config[:data_collector][:output_locations] = { urls: ["this is not a url"], files: ["/tmp/data_collection.json"] } expect { reporter.send(:validate_data_collector_output_locations!) }.to raise_error(Chef::Exceptions::ConfigurationError) end end diff --git a/spec/unit/dsl/audit_spec.rb b/spec/unit/dsl/audit_spec.rb index 42e543fdb2..e24fbc4589 100644 --- a/spec/unit/dsl/audit_spec.rb +++ b/spec/unit/dsl/audit_spec.rb @@ -12,7 +12,7 @@ end describe Chef::DSL::Audit do let(:auditor) { AuditDSLTester.new("cookbook_name", "recipe_name", run_context) } - let(:run_context) { instance_double(Chef::RunContext, :audits => audits, :cookbook_collection => cookbook_collection) } + let(:run_context) { instance_double(Chef::RunContext, audits: audits, cookbook_collection: cookbook_collection) } let(:audits) { {} } let(:cookbook_collection) { {} } diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb index fd1f9b23b5..51123ba930 100644 --- a/spec/unit/dsl/platform_introspection_spec.rb +++ b/spec/unit/dsl/platform_introspection_spec.rb @@ -39,8 +39,8 @@ end describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do before do platform_hash = { - :openbsd => { :default => "free, functional, secure" }, - [:redhat, :centos, :fedora, :scientific] => { :default => '"stable"' }, + :openbsd => { default: "free, functional, secure" }, + [:redhat, :centos, :fedora, :scientific] => { default: '"stable"' }, :ubuntu => { "10.04" => "using upstart more", :default => "using init more" }, :default => "bork da bork", } @@ -48,24 +48,24 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do end it "returns the default value when the platform doesn't match" do - expect(@platform_specific_value.value_for_node(:platform => :dos)).to eq("bork da bork") + expect(@platform_specific_value.value_for_node(platform: :dos)).to eq("bork da bork") end it "returns a value for a platform set as a group" do - expect(@platform_specific_value.value_for_node(:platform => :centos)).to eq('"stable"') + expect(@platform_specific_value.value_for_node(platform: :centos)).to eq('"stable"') end it "returns a value for the platform when it was set as a symbol but fetched as a string" do - expect(@platform_specific_value.value_for_node(:platform => "centos")).to eq('"stable"') + expect(@platform_specific_value.value_for_node(platform: "centos")).to eq('"stable"') end it "returns a value for a specific platform version" do - node = { :platform => "ubuntu", :platform_version => "10.04" } + node = { platform: "ubuntu", platform_version: "10.04" } expect(@platform_specific_value.value_for_node(node)).to eq("using upstart more") end it "returns a platform-default value if the platform version doesn't match an explicit one" do - node = { :platform => "ubuntu", :platform_version => "9.10" } + node = { platform: "ubuntu", platform_version: "9.10" } expect(@platform_specific_value.value_for_node(node)).to eq("using init more") end @@ -73,11 +73,11 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do # this matches the behavior in the original implementation. # whether or not it's correct is another matter. platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformDependentValue.new({}) - expect(platform_specific_value.value_for_node(:platform => "foo")).to be_nil + expect(platform_specific_value.value_for_node(platform: "foo")).to be_nil end it "raises an argument error if the platform hash is not correctly structured" do - bad_hash = { :ubuntu => :foo } # should be :ubuntu => {:default => 'foo'} + bad_hash = { ubuntu: :foo } # should be :ubuntu => {:default => 'foo'} expect { Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(bad_hash) }.to raise_error(ArgumentError) end @@ -98,32 +98,32 @@ describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do end it "returns the default value when the platform family doesn't match" do - expect(@platform_family_value.value_for_node(:platform_family => :os2)).to eq("default value") + expect(@platform_family_value.value_for_node(platform_family: :os2)).to eq("default value") end it "returns a value for the platform family when it was set as a string but fetched as a symbol" do - expect(@platform_family_value.value_for_node(:platform_family => :debian)).to eq("debian value") + expect(@platform_family_value.value_for_node(platform_family: :debian)).to eq("debian value") end it "returns a value for the platform family when it was set as a symbol but fetched as a string" do - expect(@platform_family_value.value_for_node(:platform_family => "gentoo")).to eq("gentoo value") + expect(@platform_family_value.value_for_node(platform_family: "gentoo")).to eq("gentoo value") end it "returns an array value stored for a platform family" do - expect(@platform_family_value.value_for_node(:platform_family => "suse")).to eq(@array_values) + expect(@platform_family_value.value_for_node(platform_family: "suse")).to eq(@array_values) end it "returns a value for the platform family when it was set within an array hash key as a symbol" do - expect(@platform_family_value.value_for_node(:platform_family => :rhel)).to eq("redhatty value") + expect(@platform_family_value.value_for_node(platform_family: :rhel)).to eq("redhatty value") end it "returns a value for the platform family when it was set within an array hash key as a string" do - expect(@platform_family_value.value_for_node(:platform_family => "fedora")).to eq("redhatty value") + expect(@platform_family_value.value_for_node(platform_family: "fedora")).to eq("redhatty value") end it "returns nil if there is no default and no platforms match" do platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue.new({}) - expect(platform_specific_value.value_for_node(:platform_family => "foo")).to be_nil + expect(platform_specific_value.value_for_node(platform_family: "foo")).to be_nil end end diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb index 2a12e27610..4f9e0b764b 100644 --- a/spec/unit/dsl/reboot_pending_spec.rb +++ b/spec/unit/dsl/reboot_pending_spec.rb @@ -36,7 +36,7 @@ describe Chef::DSL::RebootPending do end it 'should return true if "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations" exists' do - allow(recipe).to receive(:registry_value_exists?).with('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { :name => "PendingFileRenameOperations" }).and_return(true) + allow(recipe).to receive(:registry_value_exists?).with('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { name: "PendingFileRenameOperations" }).and_return(true) expect(recipe.reboot_pending?).to be_truthy end diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb index c604148ec8..a342d6d7cd 100644 --- a/spec/unit/environment_spec.rb +++ b/spec/unit/environment_spec.rb @@ -73,12 +73,12 @@ describe Chef::Environment do describe "default attributes" do it "should let you set the attributes hash explicitly" do - expect(@environment.default_attributes({ :one => "two" })).to eq({ :one => "two" }) + expect(@environment.default_attributes({ one: "two" })).to eq({ one: "two" }) end it "should let you return the attributes hash" do - @environment.default_attributes({ :one => "two" }) - expect(@environment.default_attributes).to eq({ :one => "two" }) + @environment.default_attributes({ one: "two" }) + expect(@environment.default_attributes).to eq({ one: "two" }) end it "should throw an ArgumentError if we aren't a kind of hash" do @@ -88,12 +88,12 @@ describe Chef::Environment do describe "override attributes" do it "should let you set the attributes hash explicitly" do - expect(@environment.override_attributes({ :one => "two" })).to eq({ :one => "two" }) + expect(@environment.override_attributes({ one: "two" })).to eq({ one: "two" }) end it "should let you return the attributes hash" do - @environment.override_attributes({ :one => "two" }) - expect(@environment.override_attributes).to eq({ :one => "two" }) + @environment.override_attributes({ one: "two" }) + expect(@environment.override_attributes).to eq({ one: "two" }) end it "should throw an ArgumentError if we aren't a kind of hash" do @@ -167,7 +167,7 @@ describe Chef::Environment do before(:each) do @environment.name("spec") @environment.description("Where we run the spec tests") - @environment.cookbook_versions({ :apt => "= 1.2.3" }) + @environment.cookbook_versions({ apt: "= 1.2.3" }) @hash = @environment.to_hash end @@ -190,7 +190,7 @@ describe Chef::Environment do before(:each) do @environment.name("spec") @environment.description("Where we run the spec tests") - @environment.cookbook_versions({ :apt => "= 1.2.3" }) + @environment.cookbook_versions({ apt: "= 1.2.3" }) @json = @environment.to_json end @@ -311,17 +311,17 @@ describe Chef::Environment do end it "updates the name from parameters[:name]" do - @environment.update_from_params(:name => "kurrupt") + @environment.update_from_params(name: "kurrupt") expect(@environment.name).to eq("kurrupt") end it "validates the name given in the params" do - expect(@environment.update_from_params(:name => "@$%^&*()")).to be_falsey + expect(@environment.update_from_params(name: "@$%^&*()")).to be_falsey expect(@environment.invalid_fields[:name]).to eq(%q{Option name's value @$%^&*() does not match regular expression /^[\-[:alnum:]_]+$/}) end it "updates the description from parameters[:description]" do - @environment.update_from_params(:description => "wow, writing your own object mapper is kinda painful") + @environment.update_from_params(description: "wow, writing your own object mapper is kinda painful") expect(@environment.description).to eq("wow, writing your own object mapper is kinda painful") end @@ -329,13 +329,13 @@ describe Chef::Environment do # NOTE: I'm only choosing this (admittedly weird) structure for the hash b/c the better more obvious # one, i.e, {:cookbook_version_constraints => {COOKBOOK_NAME => CONSTRAINT}} is difficult to implement # the way merb does params - params = { :name => "superbowl", :cookbook_version => { "0" => "apache2 ~> 1.0.0", "1" => "nginx < 2.0.0" } } + params = { name: "superbowl", cookbook_version: { "0" => "apache2 ~> 1.0.0", "1" => "nginx < 2.0.0" } } @environment.update_from_params(params) expect(@environment.cookbook_versions).to eq({ "apache2" => "~> 1.0.0", "nginx" => "< 2.0.0" }) end it "validates the cookbook constraints" do - params = { :cookbook_version => { "0" => "apache2 >>> 1.0.0" } } + params = { cookbook_version: { "0" => "apache2 >>> 1.0.0" } } expect(@environment.update_from_params(params)).to be_falsey err_msg = @environment.invalid_fields[:cookbook_version]["0"] expect(err_msg).to eq("apache2 >>> 1.0.0 is not a valid cookbook constraint") @@ -352,12 +352,12 @@ describe Chef::Environment do end it "updates default attributes from a JSON string in params[:attributes]" do - @environment.update_from_params(:name => "fuuu", :default_attributes => %q|{"fuuu":"RAGE"}|) + @environment.update_from_params(name: "fuuu", default_attributes: %q|{"fuuu":"RAGE"}|) expect(@environment.default_attributes).to eq({ "fuuu" => "RAGE" }) end it "updates override attributes from a JSON string in params[:attributes]" do - @environment.update_from_params(:name => "fuuu", :override_attributes => %q|{"foo":"override"}|) + @environment.update_from_params(name: "fuuu", override_attributes: %q|{"foo":"override"}|) expect(@environment.override_attributes).to eq({ "foo" => "override" }) end @@ -374,7 +374,7 @@ describe Chef::Environment do describe "list" do describe "inflated" do it "should return a hash of environment names and objects" do - e1 = double("Chef::Environment", :name => "one") + e1 = double("Chef::Environment", name: "one") expect(@query).to receive(:search).with(:environment).and_yield(e1) r = Chef::Environment.list(true) expect(r["one"]).to eq(e1) diff --git a/spec/unit/file_access_control_spec.rb b/spec/unit/file_access_control_spec.rb index ee806b5c3a..de23fea1f3 100644 --- a/spec/unit/file_access_control_spec.rb +++ b/spec/unit/file_access_control_spec.rb @@ -36,7 +36,7 @@ describe Chef::FileAccessControl do @run_context = Chef::RunContext.new(@node, {}, @events) @current_resource = Chef::Resource::File.new("/tmp/different_file.txt") @provider_requirements = Chef::Provider::ResourceRequirements.new(@resource, @run_context) - @provider = double("File provider", :requirements => @provider_requirements, :manage_symlink_access? => false) + @provider = double("File provider", requirements: @provider_requirements, manage_symlink_access?: false) @fac = Chef::FileAccessControl.new(@current_resource, @resource, @provider) end @@ -61,7 +61,7 @@ describe Chef::FileAccessControl do end it "determines the uid of the owner specified by the resource" do - expect(Etc).to receive(:getpwnam).with("toor").and_return(OpenStruct.new(:uid => 2342)) + expect(Etc).to receive(:getpwnam).with("toor").and_return(OpenStruct.new(uid: 2342)) expect(@fac.target_uid).to eq(2342) end @@ -99,7 +99,7 @@ describe Chef::FileAccessControl do # uids. So we have to get ruby and negative uids to smoke the peace pipe # with each other. @resource.owner("nobody") - expect(Etc).to receive(:getpwnam).with("nobody").and_return(OpenStruct.new(:uid => (4294967294))) + expect(Etc).to receive(:getpwnam).with("nobody").and_return(OpenStruct.new(uid: (4294967294))) expect(@fac.target_uid).to eq(-2) end @@ -107,7 +107,7 @@ describe Chef::FileAccessControl do # More: when OSX userIDs are created by ActiveDirectory sync, it tends to use huge numbers # which had been incorrectly wrapped. It does not look like the OSX IDs go below -2 @resource.owner("bigdude") - expect(Etc).to receive(:getpwnam).with("bigdude").and_return(OpenStruct.new(:uid => (4294967286))) + expect(Etc).to receive(:getpwnam).with("bigdude").and_return(OpenStruct.new(uid: (4294967286))) expect(@fac.target_uid).to eq(4294967286) end @@ -153,7 +153,7 @@ describe Chef::FileAccessControl do end it "determines the gid of the group specified by the resource" do - expect(Etc).to receive(:getgrnam).with("wheel").and_return(OpenStruct.new(:gid => 2342)) + expect(Etc).to receive(:getgrnam).with("wheel").and_return(OpenStruct.new(gid: 2342)) expect(@fac.target_gid).to eq(2342) end @@ -294,7 +294,7 @@ describe Chef::FileAccessControl do end it "sets all access controls on a file" do - allow(@fac).to receive(:stat).and_return(OpenStruct.new(:owner => 99, :group => 99, :mode => 0100444)) + allow(@fac).to receive(:stat).and_return(OpenStruct.new(owner: 99, group: 99, mode: 0100444)) @resource.mode(0400) @resource.owner(0) @resource.group(0) diff --git a/spec/unit/file_content_management/deploy/mv_unix_spec.rb b/spec/unit/file_content_management/deploy/mv_unix_spec.rb index 569fd898a7..6c8736ae38 100644 --- a/spec/unit/file_content_management/deploy/mv_unix_spec.rb +++ b/spec/unit/file_content_management/deploy/mv_unix_spec.rb @@ -38,9 +38,9 @@ describe Chef::FileContentManagement::Deploy::MvUnix do let(:target_file_mode) { 0644 } let(:target_file_stat) do double "File::Stat struct for target file", - :mode => target_file_mode, - :uid => target_file_uid, - :gid => target_file_gid + mode: target_file_mode, + uid: target_file_uid, + gid: target_file_gid end before do diff --git a/spec/unit/file_content_management/deploy/mv_windows_spec.rb b/spec/unit/file_content_management/deploy/mv_windows_spec.rb index 30a62c4da9..456e7a2e3c 100644 --- a/spec/unit/file_content_management/deploy/mv_windows_spec.rb +++ b/spec/unit/file_content_management/deploy/mv_windows_spec.rb @@ -84,8 +84,8 @@ describe Chef::FileContentManagement::Deploy::MvWindows do let(:target_file_security_descriptor) do double "security descriptor for target file", - :group => original_target_file_group, - :owner => original_target_file_owner + group: original_target_file_group, + owner: original_target_file_owner end let(:updated_target_security_descriptor) do @@ -171,13 +171,13 @@ describe Chef::FileContentManagement::Deploy::MvWindows do end context "and the target has a dacl and sacl" do - let(:inherited_dacl_ace) { double("Windows dacl ace (inherited)", :inherited? => true) } - let(:not_inherited_dacl_ace) { double("Windows dacl ace (not inherited)", :inherited? => false) } + let(:inherited_dacl_ace) { double("Windows dacl ace (inherited)", inherited?: true) } + let(:not_inherited_dacl_ace) { double("Windows dacl ace (not inherited)", inherited?: false) } let(:original_target_file_dacl) { [inherited_dacl_ace, not_inherited_dacl_ace] } - let(:inherited_sacl_ace) { double("Windows sacl ace (inherited)", :inherited? => true) } - let(:not_inherited_sacl_ace) { double("Windows sacl ace (not inherited)", :inherited? => false) } + let(:inherited_sacl_ace) { double("Windows sacl ace (inherited)", inherited?: true) } + let(:not_inherited_sacl_ace) { double("Windows sacl ace (not inherited)", inherited?: false) } let(:original_target_file_sacl) { [inherited_sacl_ace, not_inherited_sacl_ace] } let(:custom_dacl) { double("Windows ACL for non-inherited dacl aces") } diff --git a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb index 3e988c584d..6c03750136 100644 --- a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +++ b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb @@ -57,7 +57,7 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do allow(@response).to receive(:body).and_return(@response_body) @exception = Net::HTTPServerException.new("(exception) forbidden", @response) @inspector = Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector.new(@node, @exception) - allow(@inspector).to receive(:config).and_return(:node_name => "unit-test.example.com") + allow(@inspector).to receive(:config).and_return(node_name: "unit-test.example.com") @inspector.add_explanation(@description) end @@ -76,9 +76,9 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do @exception = Net::HTTPServerException.new("(exception) unauthorized", @response) @inspector = Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector.new(@node, @exception) - allow(@inspector).to receive(:config).and_return(:node_name => "unit-test.example.com", - :client_key => "/etc/chef/client.pem", - :chef_server_url => "http://chef.example.com") + allow(@inspector).to receive(:config).and_return(node_name: "unit-test.example.com", + client_key: "/etc/chef/client.pem", + chef_server_url: "http://chef.example.com") @inspector.add_explanation(@description) end diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb index 746b343e9c..b2ca8704b0 100644 --- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb @@ -106,7 +106,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do end let(:shell_out) do - instance_double(Mixlib::ShellOut, :live_stream => true, :run_command => true, :error! => nil) + instance_double(Mixlib::ShellOut, live_stream: true, run_command: true, error!: nil) end before do @@ -118,7 +118,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do end it "merges to :code" do - expect(command_opts).to receive(:merge).with({ :code => "exit 0" }).and_call_original + expect(command_opts).to receive(:merge).with({ code: "exit 0" }).and_call_original expect(guard_interpreter.evaluate).to eq(true) end end @@ -131,7 +131,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do end it "merges to :code" do - expect(command_opts).to receive(:merge).with({ :command => "exit 0" }).and_call_original + expect(command_opts).to receive(:merge).with({ command: "exit 0" }).and_call_original expect(guard_interpreter.evaluate).to eq(true) end end @@ -145,7 +145,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do end it "merges to :command" do - expect(command_opts).to receive(:merge).with({ :command => "exit 0" }).and_call_original + expect(command_opts).to receive(:merge).with({ command: "exit 0" }).and_call_original expect(guard_interpreter.evaluate).to eq(true) end end diff --git a/spec/unit/handler/json_file_spec.rb b/spec/unit/handler/json_file_spec.rb index 4be448690a..f10c6a6701 100644 --- a/spec/unit/handler/json_file_spec.rb +++ b/spec/unit/handler/json_file_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Handler::JsonFile do before(:each) do - @handler = Chef::Handler::JsonFile.new(:the_sun => "will rise", :path => "/tmp/foobarbazqux") + @handler = Chef::Handler::JsonFile.new(the_sun: "will rise", path: "/tmp/foobarbazqux") end it "accepts arbitrary config options" do diff --git a/spec/unit/http/api_versions_spec.rb b/spec/unit/http/api_versions_spec.rb index 2ccb847acc..2b52e87cae 100644 --- a/spec/unit/http/api_versions_spec.rb +++ b/spec/unit/http/api_versions_spec.rb @@ -43,7 +43,7 @@ describe Chef::HTTP::APIVersions do end let(:response) do - m = double("HttpResponse", :body => response_body) + m = double("HttpResponse", body: response_body) allow(m).to receive(:key?).with("x-ops-server-api-version").and_return(true) allow(m).to receive(:code).and_return(return_value) allow(m).to receive(:[]) do |key| diff --git a/spec/unit/http/authenticator_spec.rb b/spec/unit/http/authenticator_spec.rb index 548fc0158c..c50a2c0481 100644 --- a/spec/unit/http/authenticator_spec.rb +++ b/spec/unit/http/authenticator_spec.rb @@ -59,7 +59,7 @@ describe Chef::HTTP::Authenticator do end context "when api_version is set to something other than the default" do - let(:class_instance) { Chef::HTTP::Authenticator.new({ :api_version => "-10" }) } + let(:class_instance) { Chef::HTTP::Authenticator.new({ api_version: "-10" }) } it "merges the requested version of X-Ops-Server-API-Version into the headers" do expect(class_instance.handle_request(method, url, headers, data)[2]). diff --git a/spec/unit/http/validate_content_length_spec.rb b/spec/unit/http/validate_content_length_spec.rb index 1f24acb94a..673e03f7f4 100644 --- a/spec/unit/http/validate_content_length_spec.rb +++ b/spec/unit/http/validate_content_length_spec.rb @@ -44,7 +44,7 @@ describe Chef::HTTP::ValidateContentLength do end let(:response) do - m = double("HttpResponse", :body => response_body) + m = double("HttpResponse", body: response_body) allow(m).to receive(:[]) do |key| response_headers[key] end @@ -67,7 +67,7 @@ describe Chef::HTTP::ValidateContentLength do data_length = streaming_length while data_length > 0 chunk_size = data_length > 10 ? 10 : data_length - stream_handler.handle_chunk(double("Chunk", :bytesize => chunk_size)) + stream_handler.handle_chunk(double("Chunk", bytesize: chunk_size)) data_length -= chunk_size end diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb index 97ba0fc48e..f259002b20 100644 --- a/spec/unit/knife/bootstrap/client_builder_spec.rb +++ b/spec/unit/knife/bootstrap/client_builder_spec.rb @@ -41,7 +41,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do end context "#sanity_check!" do - let(:response_404) { OpenStruct.new(:code => "404") } + let(:response_404) { OpenStruct.new(code: "404") } let(:exception_404) { Net::HTTPServerException.new("404 not found", response_404) } context "in cases where the prompting fails" do @@ -180,8 +180,8 @@ describe Chef::Knife::Bootstrap::ClientBuilder do end it "builds a node with first_boot_attributes if they're given" do - knife_config[:first_boot_attributes] = { :baz => :quux } - expect(node).to receive(:normal_attrs=).with({ :baz => :quux }) + knife_config[:first_boot_attributes] = { baz: :quux } + expect(node).to receive(:normal_attrs=).with({ baz: :quux }) expect(node).to receive(:run_list).with([]) client_builder.run end diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb index 994f4d33a4..feebab4986 100644 --- a/spec/unit/knife/client_bulk_delete_spec.rb +++ b/spec/unit/knife/client_bulk_delete_spec.rb @@ -128,7 +128,7 @@ describe Chef::Knife::ClientBulkDelete do end describe "with --delete-validators" do - let(:option_args) { { :delete_validators => true } } + let(:option_args) { { delete_validators: true } } it "should mention that validator clients will be deleted" do knife.run diff --git a/spec/unit/knife/client_delete_spec.rb b/spec/unit/knife/client_delete_spec.rb index b05a487d62..41a83b05e4 100644 --- a/spec/unit/knife/client_delete_spec.rb +++ b/spec/unit/knife/client_delete_spec.rb @@ -23,7 +23,7 @@ describe Chef::Knife::ClientDelete do @knife = Chef::Knife::ClientDelete.new # defaults @knife.config = { - :delete_validators => false, + delete_validators: false, } @knife.name_args = [ "adam" ] end diff --git a/spec/unit/knife/client_reregister_spec.rb b/spec/unit/knife/client_reregister_spec.rb index 6776cafa0a..6b6519d44f 100644 --- a/spec/unit/knife/client_reregister_spec.rb +++ b/spec/unit/knife/client_reregister_spec.rb @@ -22,7 +22,7 @@ describe Chef::Knife::ClientReregister do before(:each) do @knife = Chef::Knife::ClientReregister.new @knife.name_args = [ "adam" ] - @client_mock = double("client_mock", :private_key => "foo_key") + @client_mock = double("client_mock", private_key: "foo_key") @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) end diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb index 27bb0d9a3f..1cdad0cd0e 100644 --- a/spec/unit/knife/configure_spec.rb +++ b/spec/unit/knife/configure_spec.rb @@ -6,7 +6,7 @@ describe Chef::Knife::Configure do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::Configure.new - @rest_client = double("null rest client", :post => { :result => :true }) + @rest_client = double("null rest client", post: { result: :true }) allow(@knife).to receive(:rest).and_return(@rest_client) @out = StringIO.new diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb index 62b8c9fe51..c8c1873081 100644 --- a/spec/unit/knife/cookbook_bulk_delete_spec.rb +++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb @@ -24,7 +24,7 @@ describe Chef::Knife::CookbookBulkDelete do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::CookbookBulkDelete.new - @knife.config = { :print_after => nil } + @knife.config = { print_after: nil } @knife.name_args = ["."] @stdout = StringIO.new @stderr = StringIO.new diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb index 1fb995f71d..af0b839cd6 100644 --- a/spec/unit/knife/cookbook_download_spec.rb +++ b/spec/unit/knife/cookbook_download_spec.rb @@ -53,7 +53,7 @@ describe Chef::Knife::CookbookDownload do let(:manifest_data) do { - :all_files => [ + all_files: [ { "path" => "recipes/foo.rb", "name" => "recipes/foo.rb", diff --git a/spec/unit/knife/cookbook_show_spec.rb b/spec/unit/knife/cookbook_show_spec.rb index bd952c215f..6642e0690d 100644 --- a/spec/unit/knife/cookbook_show_spec.rb +++ b/spec/unit/knife/cookbook_show_spec.rb @@ -49,10 +49,10 @@ describe Chef::Knife::CookbookShow do { "all_files" => [ { - :name => "recipes/default.rb", - :path => "recipes/default.rb", - :checksum => "1234", - :url => "http://example.org/files/default.rb", + name: "recipes/default.rb", + path: "recipes/default.rb", + checksum: "1234", + url: "http://example.org/files/default.rb", }, ], } @@ -172,32 +172,32 @@ describe Chef::Knife::CookbookShow do cb.manifest = { "all_files" => [ { - :name => "files/afile.rb", - :path => "files/host-examplehost.example.org/afile.rb", - :checksum => "1111", - :specificity => "host-examplehost.example.org", - :url => "http://example.org/files/1111", + name: "files/afile.rb", + path: "files/host-examplehost.example.org/afile.rb", + checksum: "1111", + specificity: "host-examplehost.example.org", + url: "http://example.org/files/1111", }, { - :name => "files/afile.rb", - :path => "files/ubuntu-9.10/afile.rb", - :checksum => "2222", - :specificity => "ubuntu-9.10", - :url => "http://example.org/files/2222", + name: "files/afile.rb", + path: "files/ubuntu-9.10/afile.rb", + checksum: "2222", + specificity: "ubuntu-9.10", + url: "http://example.org/files/2222", }, { - :name => "files/afile.rb", - :path => "files/ubuntu/afile.rb", - :checksum => "3333", - :specificity => "ubuntu", - :url => "http://example.org/files/3333", + name: "files/afile.rb", + path: "files/ubuntu/afile.rb", + checksum: "3333", + specificity: "ubuntu", + url: "http://example.org/files/3333", }, { - :name => "files/afile.rb", - :path => "files/default/afile.rb", - :checksum => "4444", - :specificity => "default", - :url => "http://example.org/files/4444", + name: "files/afile.rb", + path: "files/default/afile.rb", + checksum: "4444", + specificity: "default", + url: "http://example.org/files/4444", }, ], } diff --git a/spec/unit/knife/cookbook_site_download_spec.rb b/spec/unit/knife/cookbook_site_download_spec.rb index 0ab6a8a9b4..0e2798f374 100644 --- a/spec/unit/knife/cookbook_site_download_spec.rb +++ b/spec/unit/knife/cookbook_site_download_spec.rb @@ -59,7 +59,7 @@ describe Chef::Knife::CookbookSiteDownload do before do @cookbook_data = { "version" => @version, "file" => "http://example.com/apache2_#{@version_us}.tgz" } - @temp_file = double( :path => "/tmp/apache2_#{@version_us}.tgz" ) + @temp_file = double( path: "/tmp/apache2_#{@version_us}.tgz" ) @file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz") end @@ -124,7 +124,7 @@ describe Chef::Knife::CookbookSiteDownload do @version_us = @version.tr ".", "_" @cookbook_data = { "version" => @version, "file" => "http://example.com/apache2_#{@version_us}.tgz" } - @temp_file = double(:path => "/tmp/apache2_#{@version_us}.tgz") + @temp_file = double(path: "/tmp/apache2_#{@version_us}.tgz") @file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz") @knife.name_args << @version end diff --git a/spec/unit/knife/cookbook_site_install_spec.rb b/spec/unit/knife/cookbook_site_install_spec.rb index d93af10761..d5df88c997 100644 --- a/spec/unit/knife/cookbook_site_install_spec.rb +++ b/spec/unit/knife/cookbook_site_install_spec.rb @@ -25,9 +25,9 @@ describe Chef::Knife::CookbookSiteInstall do let(:downloader) { Hash.new } let(:archive) { double(Mixlib::Archive, extract: true) } let(:repo) do - double(:sanity_check => true, :reset_to_default_state => true, - :prepare_to_import => true, :finalize_updates_to => true, - :merge_updates_from => true) end + double(sanity_check: true, reset_to_default_state: true, + prepare_to_import: true, finalize_updates_to: true, + merge_updates_from: true) end let(:install_path) do if Chef::Platform.windows? "C:/tmp/chef" diff --git a/spec/unit/knife/cookbook_site_share_spec.rb b/spec/unit/knife/cookbook_site_share_spec.rb index 823eff8b04..ac12536d6e 100644 --- a/spec/unit/knife/cookbook_site_share_spec.rb +++ b/spec/unit/knife/cookbook_site_share_spec.rb @@ -39,7 +39,7 @@ describe Chef::Knife::CookbookSiteShare do @noauth_rest = double(Chef::ServerAPI) allow(@knife).to receive(:noauth_rest).and_return(@noauth_rest) - @cookbook_uploader = Chef::CookbookUploader.new("herpderp", :rest => "norest") + @cookbook_uploader = Chef::CookbookUploader.new("herpderp", rest: "norest") allow(Chef::CookbookUploader).to receive(:new).and_return(@cookbook_uploader) allow(@cookbook_uploader).to receive(:validate_cookbooks).and_return(true) allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return(Dir.mktmpdir) @@ -139,14 +139,14 @@ describe Chef::Knife::CookbookSiteShare do context "when the --dry-run flag is specified" do before do allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return("/var/tmp/dummy") - @knife.config = { :dry_run => true } + @knife.config = { dry_run: true } allow(@knife).to receive_message_chain(:shell_out!, :stdout).and_return("file") end it "should list files in the tarball" do allow(@knife).to receive(:tar_cmd).and_return("footar") - expect(@knife).to receive(:shell_out!).with("footar -czf #{@cookbook.name}.tgz #{@cookbook.name}", { :cwd => "/var/tmp/dummy" }) - expect(@knife).to receive(:shell_out!).with("footar -tzf #{@cookbook.name}.tgz", { :cwd => "/var/tmp/dummy" }) + expect(@knife).to receive(:shell_out!).with("footar -czf #{@cookbook.name}.tgz #{@cookbook.name}", { cwd: "/var/tmp/dummy" }) + expect(@knife).to receive(:shell_out!).with("footar -tzf #{@cookbook.name}.tgz", { cwd: "/var/tmp/dummy" }) @knife.run end @@ -172,7 +172,7 @@ describe Chef::Knife::CookbookSiteShare do end it 'should post the cookbook to "https://supermarket.chef.io"' do - response_text = Chef::JSONCompat.to_json({ :uri => "https://supermarket.chef.io/cookbooks/cookbook_name" }) + response_text = Chef::JSONCompat.to_json({ uri: "https://supermarket.chef.io/cookbooks/cookbook_name" }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(201) expect(Chef::CookbookSiteStreamingUploader).to receive(:post).with(/supermarket\.chef\.io/, anything(), anything(), anything()) @@ -180,7 +180,7 @@ describe Chef::Knife::CookbookSiteShare do end it "should alert the user when a version already exists" do - response_text = Chef::JSONCompat.to_json({ :error_messages => ["Version already exists"] }) + response_text = Chef::JSONCompat.to_json({ error_messages: ["Version already exists"] }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(409) expect { @knife.run }.to raise_error(SystemExit) @@ -188,7 +188,7 @@ describe Chef::Knife::CookbookSiteShare do end it "should pass any errors on to the user" do - response_text = Chef::JSONCompat.to_json({ :error_messages => ["You're holding it wrong"] }) + response_text = Chef::JSONCompat.to_json({ error_messages: ["You're holding it wrong"] }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(403) expect { @knife.run }.to raise_error(SystemExit) @@ -196,7 +196,7 @@ describe Chef::Knife::CookbookSiteShare do end it "should print the body if no errors are exposed on failure" do - response_text = Chef::JSONCompat.to_json({ :system_error => "Your call was dropped", :reason => "There's a map for that" }) + response_text = Chef::JSONCompat.to_json({ system_error: "Your call was dropped", reason: "There's a map for that" }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(500) expect(@knife.ui).to receive(:error).with(/#{Regexp.escape(response_text)}/) #.ordered diff --git a/spec/unit/knife/cookbook_site_unshare_spec.rb b/spec/unit/knife/cookbook_site_unshare_spec.rb index 8e4358226d..7797fdb3f8 100644 --- a/spec/unit/knife/cookbook_site_unshare_spec.rb +++ b/spec/unit/knife/cookbook_site_unshare_spec.rb @@ -55,14 +55,14 @@ describe Chef::Knife::CookbookSiteUnshare do end it "should log an error and exit when forbidden" do - exception = double('403 "Forbidden"', :code => "403") + exception = double('403 "Forbidden"', code: "403") allow(@rest).to receive(:delete).and_raise(Net::HTTPServerException.new('403 "Forbidden"', exception)) expect(@knife.ui).to receive(:error) expect { @knife.run }.to raise_error(SystemExit) end it "should re-raise any non-forbidden errors on delete" do - exception = double('500 "Application Error"', :code => "500") + exception = double('500 "Application Error"', code: "500") allow(@rest).to receive(:delete).and_raise(Net::HTTPServerException.new('500 "Application Error"', exception)) expect { @knife.run }.to raise_error(Net::HTTPServerException) end diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb index 9e07497c57..95ebe95fe7 100644 --- a/spec/unit/knife/cookbook_upload_spec.rb +++ b/spec/unit/knife/cookbook_upload_spec.rb @@ -36,7 +36,7 @@ describe Chef::Knife::CookbookUpload do cookbook_loader end - let(:cookbook_uploader) { double(:upload_cookbooks => nil) } + let(:cookbook_uploader) { double(upload_cookbooks: nil) } let(:output) { StringIO.new } @@ -62,15 +62,15 @@ describe Chef::Knife::CookbookUpload do allow(cookbook_loader).to receive(:each).and_yield("test_cookbook", test_cookbook) allow(cookbook_loader).to receive(:cookbook_names).and_return(["test_cookbook"]) expect(Chef::CookbookUploader).to receive(:new). - with( kind_of(Array), { :force => nil, :concurrency => 3 }). - and_return(double("Chef::CookbookUploader", :upload_cookbooks => true)) + with( kind_of(Array), { force: nil, concurrency: 3 }). + and_return(double("Chef::CookbookUploader", upload_cookbooks: true)) knife.run end end describe "run" do before(:each) do - allow(Chef::CookbookUploader).to receive_messages(:new => cookbook_uploader) + allow(Chef::CookbookUploader).to receive_messages(new: cookbook_uploader) allow(Chef::CookbookVersion).to receive(:list_all_versions).and_return({}) end diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb index 3a32155063..7ee177a7d1 100644 --- a/spec/unit/knife/core/bootstrap_context_spec.rb +++ b/spec/unit/knife/core/bootstrap_context_spec.rb @@ -26,15 +26,15 @@ describe Chef::Knife::Core::BootstrapContext do Chef::Config[:fips] = false end - let(:config) { { :foo => :bar, :color => true } } + let(:config) { { foo: :bar, color: true } } let(:run_list) { Chef::RunList.new("recipe[tmux]", "role[base]") } let(:chef_config) do { - :config_log_level => "info", - :config_log_location => "/tmp/log", - :validation_key => File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem"), - :chef_server_url => "http://chef.example.com:4444", - :validation_client_name => "chef-validator-testing", + config_log_level: "info", + config_log_location: "/tmp/log", + validation_key: File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem"), + chef_server_url: "http://chef.example.com:4444", + validation_client_name: "chef-validator-testing", } end @@ -51,14 +51,14 @@ describe Chef::Knife::Core::BootstrapContext do end describe "when in verbosity mode" do - let(:config) { { :verbosity => 2, :color => true } } + let(:config) { { verbosity: 2, color: true } } it "adds '-l debug' when verbosity is >= 2" do expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json -l debug" end end describe "when no color value has been set in config" do - let(:config) { { :color => false } } + let(:config) { { color: false } } it "adds '--no-color' when color is false" do expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json --no-color" end @@ -80,14 +80,14 @@ EXPECTED end describe "alternate chef-client path" do - let(:chef_config) { { :chef_client_path => "/usr/local/bin/chef-client" } } + let(:chef_config) { { chef_client_path: "/usr/local/bin/chef-client" } } it "runs chef-client from another path when specified" do expect(bootstrap_context.start_chef).to eq "/usr/local/bin/chef-client -j /etc/chef/first-boot.json" end end describe "validation key path that contains a ~" do - let(:chef_config) { { :validation_key => "~/my.key" } } + let(:chef_config) { { validation_key: "~/my.key" } } it "reads the validation key when it contains a ~" do expect(File).to receive(:exist?).with(File.expand_path("my.key", ENV["HOME"])).and_return(true) expect(IO).to receive(:read).with(File.expand_path("my.key", ENV["HOME"])) @@ -96,36 +96,36 @@ EXPECTED end describe "when an explicit node name is given" do - let(:config) { { :chef_node_name => "foobar.example.com" } } + let(:config) { { chef_node_name: "foobar.example.com" } } it "sets the node name in the client.rb" do expect(bootstrap_context.config_content).to match(/node_name "foobar\.example\.com"/) end end describe "when bootstrapping into a specific environment" do - let(:config) { { :environment => "prodtastic", :color => true } } + let(:config) { { environment: "prodtastic", color: true } } it "starts chef in the configured environment" do expect(bootstrap_context.start_chef).to eq("chef-client -j /etc/chef/first-boot.json -E prodtastic") end end describe "when tags are given" do - let(:config) { { :tags => [ "unicorn" ] } } + let(:config) { { tags: [ "unicorn" ] } } it "adds the attributes to first_boot" do - expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :run_list => run_list, :tags => ["unicorn"] })) + expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ run_list: run_list, tags: ["unicorn"] })) end end describe "when JSON attributes are given" do - let(:config) { { :first_boot_attributes => { :baz => :quux } } } + let(:config) { { first_boot_attributes: { baz: :quux } } } it "adds the attributes to first_boot" do - expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :baz => :quux, :run_list => run_list })) + expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ baz: :quux, run_list: run_list })) end end describe "when JSON attributes are NOT given" do it "sets first_boot equal to run_list" do - expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :run_list => run_list })) + expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ run_list: run_list })) end end @@ -159,7 +159,7 @@ EXPECTED describe "when a bootstrap_version is specified" do let(:chef_config) do { - :knife => { :bootstrap_version => "11.12.4" }, + knife: { bootstrap_version: "11.12.4" }, } end @@ -171,7 +171,7 @@ EXPECTED describe "when a pre-release bootstrap_version is specified" do let(:chef_config) do { - :knife => { :bootstrap_version => "11.12.4.rc.0" }, + knife: { bootstrap_version: "11.12.4.rc.0" }, } end @@ -195,7 +195,7 @@ EXPECTED describe "when configured in config" do let(:chef_config) do { - :knife => { :ssl_verify_mode => :verify_peer }, + knife: { ssl_verify_mode: :verify_peer }, } end @@ -204,7 +204,7 @@ EXPECTED end describe "when configured via CLI" do - let(:config) { { :node_ssl_verify_mode => "none" } } + let(:config) { { node_ssl_verify_mode: "none" } } it "uses CLI value" do expect(bootstrap_context.config_content).to include("ssl_verify_mode :verify_none") @@ -238,7 +238,7 @@ EXPECTED describe "when configured in config" do let(:chef_config) do { - :knife => { :verify_api_cert => :false }, + knife: { verify_api_cert: :false }, } end @@ -247,7 +247,7 @@ EXPECTED end describe "when configured via CLI" do - let(:config) { { :node_verify_api_cert => true } } + let(:config) { { node_verify_api_cert: true } } it "uses CLI value" do expect(bootstrap_context.config_content).to include("verify_api_cert true") @@ -262,7 +262,7 @@ EXPECTED end describe "when configured via cli" do - let(:config) { { :prerelease => true } } + let(:config) { { prerelease: true } } it "uses CLI value" do expect(bootstrap_context.latest_current_chef_version_string).to eq("-p") @@ -272,49 +272,49 @@ EXPECTED describe "#config_log_location" do context "when config_log_location is nil" do - let(:chef_config) { { :config_log_location => nil } } + let(:chef_config) { { config_log_location: nil } } it "sets the default config_log_location in the client.rb" do expect(bootstrap_context.get_log_location).to eq "STDOUT" end end context "when config_log_location is empty" do - let(:chef_config) { { :config_log_location => "" } } + let(:chef_config) { { config_log_location: "" } } it "sets the default config_log_location in the client.rb" do expect(bootstrap_context.get_log_location).to eq "STDOUT" end end context "when config_log_location is :win_evt" do - let(:chef_config) { { :config_log_location => :win_evt } } + let(:chef_config) { { config_log_location: :win_evt } } it "raise error when config_log_location is :win_evt " do expect { bootstrap_context.get_log_location }.to raise_error("The value :win_evt is not supported for config_log_location on Linux Platforms \n") end end context "when config_log_location is :syslog" do - let(:chef_config) { { :config_log_location => :syslog } } + let(:chef_config) { { config_log_location: :syslog } } it "sets the config_log_location value as :syslog in the client.rb" do expect(bootstrap_context.get_log_location).to eq ":syslog" end end context "When config_log_location is STDOUT" do - let(:chef_config) { { :config_log_location => STDOUT } } + let(:chef_config) { { config_log_location: STDOUT } } it "Sets the config_log_location value as STDOUT in the client.rb" do expect(bootstrap_context.get_log_location).to eq "STDOUT" end end context "when config_log_location is STDERR" do - let(:chef_config) { { :config_log_location => STDERR } } + let(:chef_config) { { config_log_location: STDERR } } it "sets the config_log_location value as STDERR in the client.rb" do expect(bootstrap_context.get_log_location).to eq "STDERR" end end context "when config_log_location is a path" do - let(:chef_config) { { :config_log_location => "/tmp/ChefLogFile" } } + let(:chef_config) { { config_log_location: "/tmp/ChefLogFile" } } it "sets the config_log_location path in the client.rb" do expect(bootstrap_context.get_log_location).to eq "\"/tmp/ChefLogFile\"" end diff --git a/spec/unit/knife/core/cookbook_scm_repo_spec.rb b/spec/unit/knife/core/cookbook_scm_repo_spec.rb index 3c16f93533..a530dbcdaa 100644 --- a/spec/unit/knife/core/cookbook_scm_repo_spec.rb +++ b/spec/unit/knife/core/cookbook_scm_repo_spec.rb @@ -24,7 +24,7 @@ describe Chef::Knife::CookbookSCMRepo do @repo_path = File.join(CHEF_SPEC_DATA, "cookbooks") @stdout, @stderr, @stdin = StringIO.new, StringIO.new, StringIO.new @ui = Chef::Knife::UI.new(@stdout, @stderr, @stdin, {}) - @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => "master") + @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, default_branch: "master") @branch_list = Mixlib::ShellOut.new @branch_list.stdout.replace(<<-BRANCHES) @@ -69,7 +69,7 @@ BRANCHES it "exits when the default branch doesn't exist" do @nobranches = Mixlib::ShellOut.new.tap { |s| s.stdout.replace "\n" } - expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@nobranches) + expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@nobranches) expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit) end @@ -77,7 +77,7 @@ BRANCHES before do @master_branch = Mixlib::ShellOut.new @master_branch.stdout.replace "* master\n" - expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@master_branch) + expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@master_branch) end it "exits when the git repo is dirty" do @@ -85,14 +85,14 @@ BRANCHES @dirty_status.stdout.replace(<<-DIRTY) M chef/lib/chef/knife/cookbook_site_install.rb DIRTY - expect(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@dirty_status) + expect(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", cwd: @repo_path).and_return(@dirty_status) expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit) end describe "and the repo is clean" do before do @clean_status = Mixlib::ShellOut.new.tap { |s| s.stdout.replace("\n") } - allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@clean_status) + allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", cwd: @repo_path).and_return(@clean_status) end it "passes the sanity check" do @@ -106,35 +106,35 @@ DIRTY end it "resets to default state by checking out the default branch" do - expect(@cookbook_repo).to receive(:shell_out!).with("git checkout master", :cwd => @repo_path) + expect(@cookbook_repo).to receive(:shell_out!).with("git checkout master", cwd: @repo_path) @cookbook_repo.reset_to_default_state end it "determines if a the pristine copy branch exists" do - expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list) + expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@branch_list) expect(@cookbook_repo.branch_exists?("chef-vendor-apache2")).to be_truthy - expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list) + expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@branch_list) expect(@cookbook_repo.branch_exists?("chef-vendor-nginx")).to be_falsey end it "determines if a the branch not exists correctly without substring search" do - expect(@cookbook_repo).to receive(:shell_out!).twice.with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list) + expect(@cookbook_repo).to receive(:shell_out!).twice.with("git branch --no-color", cwd: @repo_path).and_return(@branch_list) expect(@cookbook_repo).not_to be_branch_exists("chef-vendor-absent") expect(@cookbook_repo).to be_branch_exists("chef-vendor-absent-new") end describe "when the pristine copy branch does not exist" do it "prepares for import by creating the pristine copy branch" do - expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list) - expect(@cookbook_repo).to receive(:shell_out!).with("git checkout -b chef-vendor-nginx", :cwd => @repo_path) + expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@branch_list) + expect(@cookbook_repo).to receive(:shell_out!).with("git checkout -b chef-vendor-nginx", cwd: @repo_path) @cookbook_repo.prepare_to_import("nginx") end end describe "when the pristine copy branch does exist" do it "prepares for import by checking out the pristine copy branch" do - expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list) - expect(@cookbook_repo).to receive(:shell_out!).with("git checkout chef-vendor-apache2", :cwd => @repo_path) + expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@branch_list) + expect(@cookbook_repo).to receive(:shell_out!).with("git checkout chef-vendor-apache2", cwd: @repo_path) @cookbook_repo.prepare_to_import("apache2") end end @@ -143,7 +143,7 @@ DIRTY before do @updates = Mixlib::ShellOut.new @updates.stdout.replace("\n") - allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", :cwd => @repo_path).and_return(@updates) + allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", cwd: @repo_path).and_return(@updates) end it "shows no changes in the pristine copy" do @@ -159,7 +159,7 @@ DIRTY before do @updates = Mixlib::ShellOut.new @updates.stdout.replace(" M cookbooks/apache2/recipes/default.rb\n") - allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", :cwd => @repo_path).and_return(@updates) + allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", cwd: @repo_path).and_return(@updates) end it "shows changes in the pristine copy" do @@ -167,20 +167,20 @@ DIRTY end it "commits the changes to the repo and tags the commit" do - expect(@cookbook_repo).to receive(:shell_out!).with("git add apache2", :cwd => @repo_path) - expect(@cookbook_repo).to receive(:shell_out!).with("git commit -m \"Import apache2 version 1.2.3\" -- apache2", :cwd => @repo_path) - expect(@cookbook_repo).to receive(:shell_out!).with("git tag -f cookbook-site-imported-apache2-1.2.3", :cwd => @repo_path) + expect(@cookbook_repo).to receive(:shell_out!).with("git add apache2", cwd: @repo_path) + expect(@cookbook_repo).to receive(:shell_out!).with("git commit -m \"Import apache2 version 1.2.3\" -- apache2", cwd: @repo_path) + expect(@cookbook_repo).to receive(:shell_out!).with("git tag -f cookbook-site-imported-apache2-1.2.3", cwd: @repo_path) expect(@cookbook_repo.finalize_updates_to("apache2", "1.2.3")).to be_truthy end end describe "when a custom default branch is specified" do before do - @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => "develop") + @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, default_branch: "develop") end it "resets to default state by checking out the default branch" do - expect(@cookbook_repo).to receive(:shell_out!).with("git checkout develop", :cwd => @repo_path) + expect(@cookbook_repo).to receive(:shell_out!).with("git checkout develop", cwd: @repo_path) @cookbook_repo.reset_to_default_state end end diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb index 0b986258b7..c2b87cca38 100644 --- a/spec/unit/knife/core/ui_spec.rb +++ b/spec/unit/knife/core/ui_spec.rb @@ -25,10 +25,10 @@ describe Chef::Knife::UI do before do @out, @err, @in = StringIO.new, StringIO.new, StringIO.new @config = { - :verbosity => 0, - :yes => nil, - :format => "summary", - :field_separator => ".", + verbosity: 0, + yes: nil, + format: "summary", + field_separator: ".", } @ui = Chef::Knife::UI.new(@out, @err, @in, @config) end @@ -171,12 +171,12 @@ describe Chef::Knife::UI do describe "format_list_for_display" do it "should print the full hash if --with-uri is true" do @ui.config[:with_uri] = true - expect(@ui.format_list_for_display({ :marcy => :playground })).to eq({ :marcy => :playground }) + expect(@ui.format_list_for_display({ marcy: :playground })).to eq({ marcy: :playground }) end it "should print only the keys if --with-uri is false" do @ui.config[:with_uri] = false - expect(@ui.format_list_for_display({ :marcy => :playground })).to eq([ :marcy ]) + expect(@ui.format_list_for_display({ marcy: :playground })).to eq([ :marcy ]) end end @@ -358,7 +358,7 @@ EOM describe "format_for_display" do it "should return the raw data" do - input = { :gi => :go } + input = { gi: :go } expect(@ui.format_for_display(input)).to eq(input) end @@ -480,7 +480,7 @@ EOM context "when running on Windows" do before(:each) do - stdout = double("StringIO", :tty? => true) + stdout = double("StringIO", tty?: true) allow(@ui).to receive(:stdout).and_return(stdout) allow(ChefConfig).to receive(:windows?) { true } Chef::Config.reset @@ -631,7 +631,7 @@ EOM out = StringIO.new allow(@ui).to receive(:stdout).and_return(out) allow(@ui).to receive(:stdin).and_return(StringIO.new(" \n")) - expect(@ui.ask_question("your chef server URL? ", :default => "http://localhost:4000")).to eq("http://localhost:4000") + expect(@ui.ask_question("your chef server URL? ", default: "http://localhost:4000")).to eq("http://localhost:4000") expect(out.string).to eq("your chef server URL? [http://localhost:4000] ") end end diff --git a/spec/unit/knife/data_bag_create_spec.rb b/spec/unit/knife/data_bag_create_spec.rb index 169c6e1845..6624fb70ab 100644 --- a/spec/unit/knife/data_bag_create_spec.rb +++ b/spec/unit/knife/data_bag_create_spec.rb @@ -60,7 +60,7 @@ describe Chef::Knife::DataBagCreate do context "when data_bag doesn't exist" do before do # Data bag doesn't exist by default so we mock the GET request to return 404 - exception = double("404 error", :code => "404") + exception = double("404 error", code: "404") allow(rest).to receive(:get) .with("data/#{bag_name}") .and_raise(Net::HTTPServerException.new("404", exception)) @@ -82,7 +82,7 @@ describe Chef::Knife::DataBagCreate do context "when part of the name is a reserved name" do before do - exception = double("404 error", :code => "404") + exception = double("404 error", code: "404") %w{node role client environment}.each do |name| allow(rest).to receive(:get) .with("data/sudoing_#{name}_admins") diff --git a/spec/unit/knife/data_bag_edit_spec.rb b/spec/unit/knife/data_bag_edit_spec.rb index 635dc63489..ff131a7d91 100644 --- a/spec/unit/knife/data_bag_edit_spec.rb +++ b/spec/unit/knife/data_bag_edit_spec.rb @@ -74,7 +74,7 @@ describe Chef::Knife::DataBagEdit do end context "when config[:print_after] is set" do - let(:config) { { :print_after => true } } + let(:config) { { print_after: true } } before do expect(knife.ui).to receive(:output).with(raw_edited_hash) end diff --git a/spec/unit/knife/data_bag_secret_options_spec.rb b/spec/unit/knife/data_bag_secret_options_spec.rb index 2f4d8c8a88..5aa34029e9 100644 --- a/spec/unit/knife/data_bag_secret_options_spec.rb +++ b/spec/unit/knife/data_bag_secret_options_spec.rb @@ -73,13 +73,13 @@ describe Chef::Knife::DataBagSecretOptions do it "returns the secret first" do Chef::Config[:knife][:cl_secret] = secret - expect(example_db).to receive(:config).and_return({ :secret => secret }) + expect(example_db).to receive(:config).and_return({ secret: secret }) expect(example_db.read_secret).to eq(secret) end it "returns the secret_file only if secret does not exist" do Chef::Config[:knife][:cl_secret_file] = secret_file.path - expect(example_db).to receive(:config).and_return({ :secret_file => secret_file.path }) + expect(example_db).to receive(:config).and_return({ secret_file: secret_file.path }) expect(Chef::EncryptedDataBagItem).to receive(:load_secret).with(secret_file.path).and_return("secret file contents") expect(example_db.read_secret).to eq("secret file contents") end @@ -111,19 +111,19 @@ describe Chef::Knife::DataBagSecretOptions do end it "returns true if --encrypt is passed on the CL and :secret is in config" do - expect(example_db).to receive(:config).and_return({ :encrypt => true }) + expect(example_db).to receive(:config).and_return({ encrypt: true }) Chef::Config[:knife][:secret] = secret expect(example_db.encryption_secret_provided?).to eq(true) end it "returns true if --encrypt is passed on the CL and :secret_file is in config" do - expect(example_db).to receive(:config).and_return({ :encrypt => true }) + expect(example_db).to receive(:config).and_return({ encrypt: true }) Chef::Config[:knife][:secret_file] = secret_file.path expect(example_db.encryption_secret_provided?).to eq(true) end it "throws an error if --encrypt is passed and there is not :secret or :secret_file in the config" do - expect(example_db).to receive(:config).and_return({ :encrypt => true }) + expect(example_db).to receive(:config).and_return({ encrypt: true }) expect(example_db).to receive(:exit).with(1) expect(example_db.ui).to receive(:fatal).with("No secret or secret_file specified in config, unable to encrypt item.") example_db.encryption_secret_provided? diff --git a/spec/unit/knife/environment_from_file_spec.rb b/spec/unit/knife/environment_from_file_spec.rb index 4505da3637..11e05cb922 100644 --- a/spec/unit/knife/environment_from_file_spec.rb +++ b/spec/unit/knife/environment_from_file_spec.rb @@ -61,7 +61,7 @@ describe Chef::Knife::EnvironmentFromFile do allow(File).to receive(:expand_path).with("./environments/").and_return("/tmp/environments") allow(Dir).to receive(:glob).with("/tmp/environments/*.{json,rb}").and_return(["spec.rb", "apple.rb"]) @knife.name_args = [] - allow(@knife).to receive(:config).and_return({ :all => true }) + allow(@knife).to receive(:config).and_return({ all: true }) expect(@environment).to receive(:save).twice @knife.run end diff --git a/spec/unit/knife/node_delete_spec.rb b/spec/unit/knife/node_delete_spec.rb index 1a6b277dbb..cc2e0b23af 100644 --- a/spec/unit/knife/node_delete_spec.rb +++ b/spec/unit/knife/node_delete_spec.rb @@ -23,7 +23,7 @@ describe Chef::Knife::NodeDelete do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeDelete.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = %w{ adam ben } allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/node_edit_spec.rb b/spec/unit/knife/node_edit_spec.rb index e5fa9317b1..dfc0986ebe 100644 --- a/spec/unit/knife/node_edit_spec.rb +++ b/spec/unit/knife/node_edit_spec.rb @@ -30,9 +30,9 @@ describe Chef::Knife::NodeEdit do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeEdit.new @knife.config = { - :editor => "cat", - :attribute => nil, - :print_after => nil, + editor: "cat", + attribute: nil, + print_after: nil, } @knife.name_args = [ "adam" ] @node = Chef::Node.new() @@ -48,10 +48,10 @@ describe Chef::Knife::NodeEdit do @knife.config[:all_attributes] = false allow(@knife).to receive(:node).and_return(@node) - @node.automatic_attrs = { :go => :away } - @node.default_attrs = { :hide => :me } - @node.override_attrs = { :dont => :show } - @node.normal_attrs = { :do_show => :these } + @node.automatic_attrs = { go: :away } + @node.default_attrs = { hide: :me } + @node.override_attrs = { dont: :show } + @node.normal_attrs = { do_show: :these } @node.chef_environment("prod") @node.run_list("recipe[foo]") end diff --git a/spec/unit/knife/node_from_file_spec.rb b/spec/unit/knife/node_from_file_spec.rb index 61c63c150e..cf128a80a0 100644 --- a/spec/unit/knife/node_from_file_spec.rb +++ b/spec/unit/knife/node_from_file_spec.rb @@ -25,7 +25,7 @@ describe Chef::Knife::NodeFromFile do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeFromFile.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = [ "adam.rb" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/node_run_list_add_spec.rb b/spec/unit/knife/node_run_list_add_spec.rb index e11bf78029..03c89ff9eb 100644 --- a/spec/unit/knife/node_run_list_add_spec.rb +++ b/spec/unit/knife/node_run_list_add_spec.rb @@ -23,7 +23,7 @@ describe Chef::Knife::NodeRunListAdd do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeRunListAdd.new @knife.config = { - :after => nil, + after: nil, } @knife.name_args = [ "adam", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/osc_user_edit_spec.rb b/spec/unit/knife/osc_user_edit_spec.rb index 59fb152b5b..1792e38027 100644 --- a/spec/unit/knife/osc_user_edit_spec.rb +++ b/spec/unit/knife/osc_user_edit_spec.rb @@ -37,7 +37,7 @@ describe Chef::Knife::OscUserEdit do end it "loads and edits the user" do - data = { :name => "my_user" } + data = { name: "my_user" } allow(Chef::User).to receive(:load).with("my_user").and_return(data) expect(@knife).to receive(:edit_hash).with(data).and_return(data) @knife.run diff --git a/spec/unit/knife/osc_user_reregister_spec.rb b/spec/unit/knife/osc_user_reregister_spec.rb index de706dfa42..b0ac92568e 100644 --- a/spec/unit/knife/osc_user_reregister_spec.rb +++ b/spec/unit/knife/osc_user_reregister_spec.rb @@ -28,7 +28,7 @@ describe Chef::Knife::OscUserReregister do Chef::Knife::OscUserReregister.load_deps @knife = Chef::Knife::OscUserReregister.new @knife.name_args = [ "a_user" ] - @user_mock = double("user_mock", :private_key => "private_key") + @user_mock = double("user_mock", private_key: "private_key") allow(Chef::User).to receive(:load).and_return(@user_mock) @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) diff --git a/spec/unit/knife/role_bulk_delete_spec.rb b/spec/unit/knife/role_bulk_delete_spec.rb index e9054c1d00..d49adb9354 100644 --- a/spec/unit/knife/role_bulk_delete_spec.rb +++ b/spec/unit/knife/role_bulk_delete_spec.rb @@ -23,7 +23,7 @@ describe Chef::Knife::RoleBulkDelete do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::RoleBulkDelete.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = ["."] @stdout = StringIO.new diff --git a/spec/unit/knife/role_create_spec.rb b/spec/unit/knife/role_create_spec.rb index 9466d9642c..5e2b2caeb5 100644 --- a/spec/unit/knife/role_create_spec.rb +++ b/spec/unit/knife/role_create_spec.rb @@ -23,7 +23,7 @@ describe Chef::Knife::RoleCreate do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::RoleCreate.new @knife.config = { - :description => nil, + description: nil, } @knife.name_args = [ "adam" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/role_delete_spec.rb b/spec/unit/knife/role_delete_spec.rb index f095e5ba2d..98c0cde9b2 100644 --- a/spec/unit/knife/role_delete_spec.rb +++ b/spec/unit/knife/role_delete_spec.rb @@ -23,7 +23,7 @@ describe Chef::Knife::RoleDelete do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::RoleDelete.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = [ "adam" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/role_env_run_list_add_spec.rb b/spec/unit/knife/role_env_run_list_add_spec.rb index 4738101f90..e679b88295 100644 --- a/spec/unit/knife/role_env_run_list_add_spec.rb +++ b/spec/unit/knife/role_env_run_list_add_spec.rb @@ -25,7 +25,7 @@ describe Chef::Knife::RoleEnvRunListAdd do # Chef::Config[:env_name] = "QA" @knife = Chef::Knife::RoleEnvRunListAdd.new @knife.config = { - :after => nil, + after: nil, } @knife.name_args = [ "will", "QA", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) 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 c9c24858c0..7a580ecd4a 100644 --- a/spec/unit/knife/role_env_run_list_clear_spec.rb +++ b/spec/unit/knife/role_env_run_list_clear_spec.rb @@ -28,7 +28,7 @@ describe Chef::Knife::RoleEnvRunListClear do @knife = Chef::Knife::RoleEnvRunListClear.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = %w{will QA} allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/role_env_run_list_remove_spec.rb b/spec/unit/knife/role_env_run_list_remove_spec.rb index 8a077f1de3..afbabec528 100644 --- a/spec/unit/knife/role_env_run_list_remove_spec.rb +++ b/spec/unit/knife/role_env_run_list_remove_spec.rb @@ -28,7 +28,7 @@ describe Chef::Knife::RoleEnvRunListRemove do @knife = Chef::Knife::RoleEnvRunListRemove.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = [ "will", "QA", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/role_env_run_list_replace_spec.rb b/spec/unit/knife/role_env_run_list_replace_spec.rb index 08dcdd90e2..c4d231d638 100644 --- a/spec/unit/knife/role_env_run_list_replace_spec.rb +++ b/spec/unit/knife/role_env_run_list_replace_spec.rb @@ -28,7 +28,7 @@ describe Chef::Knife::RoleEnvRunListReplace do @knife = Chef::Knife::RoleEnvRunListReplace.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = [ "will", "QA", "role[dude]", "role[person]" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/role_env_run_list_set_spec.rb b/spec/unit/knife/role_env_run_list_set_spec.rb index aed1c9fe1e..79bd3b152e 100644 --- a/spec/unit/knife/role_env_run_list_set_spec.rb +++ b/spec/unit/knife/role_env_run_list_set_spec.rb @@ -28,7 +28,7 @@ describe Chef::Knife::RoleEnvRunListSet do @knife = Chef::Knife::RoleEnvRunListSet.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = [ "will", "QA", "role[owen]", "role[mauntel]" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/role_from_file_spec.rb b/spec/unit/knife/role_from_file_spec.rb index 104894df17..827b8ae04d 100644 --- a/spec/unit/knife/role_from_file_spec.rb +++ b/spec/unit/knife/role_from_file_spec.rb @@ -25,7 +25,7 @@ describe Chef::Knife::RoleFromFile do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::RoleFromFile.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = [ "adam.rb" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/role_run_list_add_spec.rb b/spec/unit/knife/role_run_list_add_spec.rb index fe7318c040..3358da130c 100644 --- a/spec/unit/knife/role_run_list_add_spec.rb +++ b/spec/unit/knife/role_run_list_add_spec.rb @@ -25,7 +25,7 @@ describe Chef::Knife::RoleRunListAdd do # Chef::Config[:env_name] = "QA" @knife = Chef::Knife::RoleRunListAdd.new @knife.config = { - :after => nil, + after: nil, } @knife.name_args = [ "will", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/role_run_list_clear_spec.rb b/spec/unit/knife/role_run_list_clear_spec.rb index 4ed1f312b0..8bbc816d6f 100644 --- a/spec/unit/knife/role_run_list_clear_spec.rb +++ b/spec/unit/knife/role_run_list_clear_spec.rb @@ -27,7 +27,7 @@ describe Chef::Knife::RoleRunListClear do @knife = Chef::Knife::RoleRunListClear.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = [ "will" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/role_run_list_remove_spec.rb b/spec/unit/knife/role_run_list_remove_spec.rb index 087bc2c6ee..c18416feca 100644 --- a/spec/unit/knife/role_run_list_remove_spec.rb +++ b/spec/unit/knife/role_run_list_remove_spec.rb @@ -27,7 +27,7 @@ describe Chef::Knife::RoleRunListRemove do @knife = Chef::Knife::RoleRunListRemove.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = [ "will", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/role_run_list_replace_spec.rb b/spec/unit/knife/role_run_list_replace_spec.rb index 2bc060ae2d..9b212de0ae 100644 --- a/spec/unit/knife/role_run_list_replace_spec.rb +++ b/spec/unit/knife/role_run_list_replace_spec.rb @@ -27,7 +27,7 @@ describe Chef::Knife::RoleRunListReplace do @knife = Chef::Knife::RoleRunListReplace.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = [ "will", "role[dude]", "role[person]" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/role_run_list_set_spec.rb b/spec/unit/knife/role_run_list_set_spec.rb index 27b4d9fea1..f8e440f524 100644 --- a/spec/unit/knife/role_run_list_set_spec.rb +++ b/spec/unit/knife/role_run_list_set_spec.rb @@ -27,7 +27,7 @@ describe Chef::Knife::RoleRunListSet do @knife = Chef::Knife::RoleRunListSet.new @knife.config = { - :print_after => nil, + print_after: nil, } @knife.name_args = [ "will", "role[owen]", "role[mauntel]" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb index 9d7fcb6f9e..ec345d5aff 100644 --- a/spec/unit/knife/ssh_spec.rb +++ b/spec/unit/knife/ssh_spec.rb @@ -224,7 +224,7 @@ describe Chef::Knife::Ssh do describe "#session_from_list" do before :each do @knife.instance_variable_set(:@longest, 0) - ssh_config = { :timeout => 50, :user => "locutus", :port => 23, :keepalive => true, :keepalive_interval => 60 } + ssh_config = { timeout: 50, user: "locutus", port: 23, keepalive: true, keepalive_interval: 60 } allow(Net::SSH).to receive(:configuration_for).with("the.b.org", true).and_return(ssh_config) end @@ -279,20 +279,20 @@ describe Chef::Knife::Ssh do end describe "#ssh_command" do - let(:execution_channel) { double(:execution_channel, :on_data => nil) } - let(:session_channel) { double(:session_channel, :request_pty => nil) } + let(:execution_channel) { double(:execution_channel, on_data: nil) } + let(:session_channel) { double(:session_channel, request_pty: nil) } - let(:execution_channel2) { double(:execution_channel, :on_data => nil) } - let(:session_channel2) { double(:session_channel, :request_pty => nil) } + let(:execution_channel2) { double(:execution_channel, on_data: nil) } + let(:session_channel2) { double(:session_channel, request_pty: nil) } - let(:session) { double(:session, :loop => nil) } + let(:session) { double(:session, loop: nil) } let(:command) { "false" } before do expect(execution_channel). to receive(:on_request). - and_yield(nil, double(:data_stream, :read_long => exit_status)) + and_yield(nil, double(:data_stream, read_long: exit_status)) expect(session_channel). to receive(:exec). @@ -301,7 +301,7 @@ describe Chef::Knife::Ssh do expect(execution_channel2). to receive(:on_request). - and_yield(nil, double(:data_stream, :read_long => exit_status2)) + and_yield(nil, double(:data_stream, read_long: exit_status2)) expect(session_channel2). to receive(:exec). @@ -344,7 +344,7 @@ describe Chef::Knife::Ssh do describe "#tmux" do before do - ssh_config = { :timeout => 50, :user => "locutus", :port => 23, :keepalive => true, :keepalive_interval => 60 } + ssh_config = { timeout: 50, user: "locutus", port: 23, keepalive: true, keepalive_interval: 60 } allow(Net::SSH).to receive(:configuration_for).with("foo.example.org", true).and_return(ssh_config) @query = Chef::Search::Query.new expect(@query).to receive(:search).and_yield(@node_foo) diff --git a/spec/unit/knife/user_reregister_spec.rb b/spec/unit/knife/user_reregister_spec.rb index d650ff9fb8..8501347087 100644 --- a/spec/unit/knife/user_reregister_spec.rb +++ b/spec/unit/knife/user_reregister_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::UserReregister do let(:knife) { Chef::Knife::UserReregister.new } - let(:user_mock) { double("user_mock", :private_key => "private_key") } + let(:user_mock) { double("user_mock", private_key: "private_key") } let(:stdout) { StringIO.new } before do diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb index adaab11d55..86fe59ca58 100644 --- a/spec/unit/knife_spec.rb +++ b/spec/unit/knife_spec.rb @@ -37,7 +37,7 @@ describe Chef::Knife do instance_double("WorkstationConfigLoader", load: nil, no_config_found?: false, config_location: config_location, - :chef_config_dir => "/etc/chef") + chef_config_dir: "/etc/chef") end before(:each) do @@ -225,10 +225,10 @@ describe Chef::Knife do it "merges the global knife CLI options" do extra_opts = {} - extra_opts[:editor] = { :long => "--editor EDITOR", - :description => "Set the editor to use for interactive commands", - :short => "-e EDITOR", - :default => "/usr/bin/vim" } + extra_opts[:editor] = { long: "--editor EDITOR", + description: "Set the editor to use for interactive commands", + short: "-e EDITOR", + default: "/usr/bin/vim" } # there is special hackery to return the subcommand instance going on here. command = Chef::Knife.run(%w{test yourself}, extra_opts) @@ -283,8 +283,8 @@ describe Chef::Knife do describe "merging configuration options" do before do KnifeSpecs::TestYourself.option(:opt_with_default, - :short => "-D VALUE", - :default => "default-value") + short: "-D VALUE", + default: "default-value") end it "sets the default log_location to STDERR for Chef::Log warnings" do @@ -330,7 +330,7 @@ describe Chef::Knife do before do knife.config[:verbosity] = 1 knife.config[:config_file] = fake_config - config_loader = double("Chef::WorkstationConfigLoader", :load => true, :no_config_found? => false, :chef_config_dir => "/etc/chef", :config_location => fake_config) + config_loader = double("Chef::WorkstationConfigLoader", load: true, no_config_found?: false, chef_config_dir: "/etc/chef", config_location: fake_config) allow(config_loader).to receive(:explicit_config_file=).with(fake_config).and_return(fake_config) allow(config_loader).to receive(:profile=) allow(Chef::WorkstationConfigLoader).to receive(:new).and_return(config_loader) @@ -423,7 +423,7 @@ describe Chef::Knife do it "formats 401s nicely" do response = Net::HTTPUnauthorized.new("1.1", "401", "Unauthorized") response.instance_variable_set(:@read, true) # I hate you, net/http. - allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "y u no syncronize your clock?")) + allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no syncronize your clock?")) allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("401 Unauthorized", response)) knife.run_with_pretty_exceptions expect(stderr.string).to match(/ERROR: Failed to authenticate to/) @@ -433,7 +433,7 @@ describe Chef::Knife do it "formats 403s nicely" do response = Net::HTTPForbidden.new("1.1", "403", "Forbidden") response.instance_variable_set(:@read, true) # I hate you, net/http. - allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "y u no administrator")) + allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no administrator")) allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("403 Forbidden", response)) allow(knife).to receive(:username).and_return("sadpanda") knife.run_with_pretty_exceptions @@ -453,7 +453,7 @@ describe Chef::Knife do it "formats proxy errors nicely" do response = Net::HTTPForbidden.new("1.1", "403", "Forbidden") response.instance_variable_set(:@read, true) - allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "y u no administrator")) + allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no administrator")) allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("403 Forbidden", response)) allow(knife).to receive(:username).and_return("sadpanda") knife.run_with_pretty_exceptions @@ -466,7 +466,7 @@ describe Chef::Knife do it "formats 400s nicely" do response = Net::HTTPBadRequest.new("1.1", "400", "Bad Request") response.instance_variable_set(:@read, true) # I hate you, net/http. - allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "y u search wrong")) + allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u search wrong")) allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("400 Bad Request", response)) knife.run_with_pretty_exceptions expect(stderr.string).to match(%r{ERROR: The data in your request was invalid}) @@ -476,7 +476,7 @@ describe Chef::Knife do it "formats 404s nicely" do response = Net::HTTPNotFound.new("1.1", "404", "Not Found") response.instance_variable_set(:@read, true) # I hate you, net/http. - allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "nothing to see here")) + allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nothing to see here")) allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("404 Not Found", response)) knife.run_with_pretty_exceptions expect(stderr.string).to match(%r{ERROR: The object you are looking for could not be found}) @@ -488,9 +488,9 @@ describe Chef::Knife do response.instance_variable_set(:@read, true) # I hate you, net/http. # set the header - response["x-ops-server-api-version"] = Chef::JSONCompat.to_json(:min_version => "0", :max_version => "1", :request_version => "10000000") + response["x-ops-server-api-version"] = Chef::JSONCompat.to_json(min_version: "0", max_version: "1", request_version: "10000000") - allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "sad trombone")) + allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "sad trombone")) allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("406 Not Acceptable", response)) knife.run_with_pretty_exceptions @@ -502,7 +502,7 @@ describe Chef::Knife do it "formats 500s nicely" do response = Net::HTTPInternalServerError.new("1.1", "500", "Internal Server Error") response.instance_variable_set(:@read, true) # I hate you, net/http. - allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "sad trombone")) + allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "sad trombone")) allow(knife).to receive(:run).and_raise(Net::HTTPFatalError.new("500 Internal Server Error", response)) knife.run_with_pretty_exceptions expect(stderr.string).to match(%r{ERROR: internal server error}) @@ -512,7 +512,7 @@ describe Chef::Knife do it "formats 502s nicely" do response = Net::HTTPBadGateway.new("1.1", "502", "Bad Gateway") response.instance_variable_set(:@read, true) # I hate you, net/http. - allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "sadder trombone")) + allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "sadder trombone")) allow(knife).to receive(:run).and_raise(Net::HTTPFatalError.new("502 Bad Gateway", response)) knife.run_with_pretty_exceptions expect(stderr.string).to match(%r{ERROR: bad gateway}) @@ -522,7 +522,7 @@ describe Chef::Knife do it "formats 503s nicely" do response = Net::HTTPServiceUnavailable.new("1.1", "503", "Service Unavailable") response.instance_variable_set(:@read, true) # I hate you, net/http. - allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "saddest trombone")) + allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "saddest trombone")) allow(knife).to receive(:run).and_raise(Net::HTTPFatalError.new("503 Service Unavailable", response)) knife.run_with_pretty_exceptions expect(stderr.string).to match(%r{ERROR: Service temporarily unavailable}) @@ -532,7 +532,7 @@ describe Chef::Knife do it "formats other HTTP errors nicely" do response = Net::HTTPPaymentRequired.new("1.1", "402", "Payment Required") response.instance_variable_set(:@read, true) # I hate you, net/http. - allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "nobugfixtillyoubuy")) + allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nobugfixtillyoubuy")) allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("402 Payment Required", response)) knife.run_with_pretty_exceptions expect(stderr.string).to match(%r{ERROR: Payment Required}) diff --git a/spec/unit/log/syslog_spec.rb b/spec/unit/log/syslog_spec.rb index 6d56b96575..4586503e88 100644 --- a/spec/unit/log/syslog_spec.rb +++ b/spec/unit/log/syslog_spec.rb @@ -18,7 +18,7 @@ require "spec_helper" -describe "Chef::Log::Syslog", :unix_only => true do +describe "Chef::Log::Syslog", unix_only: true do let(:syslog) { Chef::Log::Syslog.new } before do diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index b42ac3af1e..3776372965 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -243,8 +243,8 @@ describe "LWRP" do let(:klass) do Class.new(Chef::Resource::LWRPBase) do self.resource_name = :sample_resource - attribute :food, :default => lazy { "BACON!" * 3 } - attribute :drink, :default => lazy { |r| "Drink after #{r.food}!" } + attribute :food, default: lazy { "BACON!" * 3 } + attribute :drink, default: lazy { |r| "Drink after #{r.food}!" } end end diff --git a/spec/unit/mash_spec.rb b/spec/unit/mash_spec.rb index e58f6b85a1..0797e80f2c 100644 --- a/spec/unit/mash_spec.rb +++ b/spec/unit/mash_spec.rb @@ -21,7 +21,7 @@ require "chef/mash" describe Mash do it "should duplicate a simple key/value mash to a new mash" do - data = { :x => "one", :y => "two", :z => "three" } + data = { x: "one", y: "two", z: "three" } @orig = Mash.new(data) @copy = @orig.dup expect(@copy.to_hash).to eq(Mash.new(data).to_hash) @@ -30,7 +30,7 @@ describe Mash do end it "should duplicate a mash with an array to a new mash" do - data = { :x => "one", :y => "two", :z => [1, 2, 3] } + data = { x: "one", y: "two", z: [1, 2, 3] } @orig = Mash.new(data) @copy = @orig.dup expect(@copy.to_hash).to eq(Mash.new(data).to_hash) @@ -39,7 +39,7 @@ describe Mash do end it "should duplicate a nested mash to a new mash" do - data = { :x => "one", :y => "two", :z => Mash.new({ :a => [1, 2, 3] }) } + data = { x: "one", y: "two", z: Mash.new({ a: [1, 2, 3] }) } @orig = Mash.new(data) @copy = @orig.dup expect(@copy.to_hash).to eq(Mash.new(data).to_hash) diff --git a/spec/unit/mixin/api_version_request_handling_spec.rb b/spec/unit/mixin/api_version_request_handling_spec.rb index 191dee643b..5cbad7efa0 100644 --- a/spec/unit/mixin/api_version_request_handling_spec.rb +++ b/spec/unit/mixin/api_version_request_handling_spec.rb @@ -26,7 +26,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do let(:default_supported_client_versions) { [0, 1, 2] } context "when the response code is not 406" do - let(:response) { OpenStruct.new(:code => "405") } + let(:response) { OpenStruct.new(code: "405") } let(:exception) { Net::HTTPServerException.new("405 Something Else", response) } it "returns nil" do @@ -37,7 +37,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do end # when the response code is not 406 context "when the response code is 406" do - let(:response) { OpenStruct.new(:code => "406") } + let(:response) { OpenStruct.new(code: "406") } let(:exception) { Net::HTTPServerException.new("406 Not Acceptable", response) } context "when x-ops-server-api-version header does not exist" do diff --git a/spec/unit/mixin/checksum_spec.rb b/spec/unit/mixin/checksum_spec.rb index 801c8820d2..873d2a2fc0 100644 --- a/spec/unit/mixin/checksum_spec.rb +++ b/spec/unit/mixin/checksum_spec.rb @@ -29,7 +29,7 @@ describe Chef::Mixin::Checksum do @checksum_user = Chef::CMCCheck.new @cache = Chef::Digester.instance @file = CHEF_SPEC_DATA + "/checksum/random.txt" - @stat = double("File::Stat", { :mtime => Time.at(0) }) + @stat = double("File::Stat", { mtime: Time.at(0) }) allow(File).to receive(:stat).and_return(@stat) end diff --git a/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb b/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb index 248de0ba95..701de06167 100644 --- a/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +++ b/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb @@ -51,11 +51,11 @@ describe Chef::Mixin::EnforceOwnershipAndPermissions do allow_any_instance_of(Chef::FileAccessControl).to receive(:define_resource_requirements) allow_any_instance_of(Chef::FileAccessControl).to receive(:describe_changes) - passwd_struct = OpenStruct.new(:name => "root", :passwd => "x", - :uid => 0, :gid => 0, :dir => "/root", - :shell => "/bin/bash") + passwd_struct = OpenStruct.new(name: "root", passwd: "x", + uid: 0, gid: 0, dir: "/root", + shell: "/bin/bash") - group_struct = OpenStruct.new(:name => "root", :passwd => "x", :gid => 0) + group_struct = OpenStruct.new(name: "root", passwd: "x", gid: 0) allow(Etc).to receive(:getpwuid).and_return(passwd_struct) allow(Etc).to receive(:getgrgid).and_return(group_struct) end @@ -75,11 +75,11 @@ describe Chef::Mixin::EnforceOwnershipAndPermissions do allow_any_instance_of(Chef::FileAccessControl).to receive(:uid_from_resource).and_return(0) allow_any_instance_of(Chef::FileAccessControl).to receive(:describe_changes) - passwd_struct = OpenStruct.new(:name => "root", :passwd => "x", - :uid => 0, :gid => 0, :dir => "/root", - :shell => "/bin/bash") + passwd_struct = OpenStruct.new(name: "root", passwd: "x", + uid: 0, gid: 0, dir: "/root", + shell: "/bin/bash") - group_struct = OpenStruct.new(:name => "root", :passwd => "x", :gid => 0) + group_struct = OpenStruct.new(name: "root", passwd: "x", gid: 0) allow(Etc).to receive(:getpwuid).and_return(passwd_struct) allow(Etc).to receive(:getgrgid).and_return(group_struct) end diff --git a/spec/unit/mixin/homebrew_user_spec.rb b/spec/unit/mixin/homebrew_user_spec.rb index 67d79719aa..df89962cce 100644 --- a/spec/unit/mixin/homebrew_user_spec.rb +++ b/spec/unit/mixin/homebrew_user_spec.rb @@ -56,7 +56,7 @@ describe Chef::Mixin::HomebrewUser do context "debug statement prints owner name" do before do - expect(Etc).to receive(:getpwuid).with(brew_owner).and_return(OpenStruct.new(:name => "name")) + expect(Etc).to receive(:getpwuid).with(brew_owner).and_return(OpenStruct.new(name: "name")) end it "returns the owner of the brew executable when it is at a default location" do diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb index 7bc8a27398..62d6b3e117 100644 --- a/spec/unit/mixin/params_validate_spec.rb +++ b/spec/unit/mixin/params_validate_spec.rb @@ -34,7 +34,7 @@ describe Chef::Mixin::ParamsValidate do end it "should allow a hash and a hash as arguments to validate" do - expect { @vo.validate({ :one => "two" }, {}) }.not_to raise_error + expect { @vo.validate({ one: "two" }, {}) }.not_to raise_error end it "should raise an argument error if validate is called incorrectly" do @@ -42,26 +42,26 @@ describe Chef::Mixin::ParamsValidate do end it "should require validation map keys to be symbols or strings" do - expect { @vo.validate({ :one => "two" }, { :one => true }) }.not_to raise_error - expect { @vo.validate({ :one => "two" }, { "one" => true }) }.not_to raise_error - expect { @vo.validate({ :one => "two" }, { Hash.new => true }) }.to raise_error(ArgumentError) + expect { @vo.validate({ one: "two" }, { one: true }) }.not_to raise_error + expect { @vo.validate({ one: "two" }, { "one" => true }) }.not_to raise_error + expect { @vo.validate({ one: "two" }, { Hash.new => true }) }.to raise_error(ArgumentError) end it "should allow options to be required with true" do - expect { @vo.validate({ :one => "two" }, { :one => true }) }.not_to raise_error + expect { @vo.validate({ one: "two" }, { one: true }) }.not_to raise_error end it "should allow options to be optional with false" do - expect { @vo.validate({}, { :one => false }) }.not_to raise_error + expect { @vo.validate({}, { one: false }) }.not_to raise_error end it "should allow you to check what kind_of? thing an argument is with kind_of" do expect do @vo.validate( - { :one => "string" }, + { one: "string" }, { - :one => { - :kind_of => String, + one: { + kind_of: String, }, } ) @@ -69,10 +69,10 @@ describe Chef::Mixin::ParamsValidate do expect do @vo.validate( - { :one => "string" }, + { one: "string" }, { - :one => { - :kind_of => Array, + one: { + kind_of: Array, }, } ) @@ -82,10 +82,10 @@ describe Chef::Mixin::ParamsValidate do it "should allow you to specify an argument is required with required" do expect do @vo.validate( - { :one => "string" }, + { one: "string" }, { - :one => { - :required => true, + one: { + required: true, }, } ) @@ -93,10 +93,10 @@ describe Chef::Mixin::ParamsValidate do expect do @vo.validate( - { :two => "string" }, + { two: "string" }, { - :one => { - :required => true, + one: { + required: true, }, } ) @@ -104,10 +104,10 @@ describe Chef::Mixin::ParamsValidate do expect do @vo.validate( - { :two => "string" }, + { two: "string" }, { - :one => { - :required => false, + one: { + required: false, }, } ) @@ -117,10 +117,10 @@ describe Chef::Mixin::ParamsValidate do it "should allow you to specify whether an object has a method with respond_to" do expect do @vo.validate( - { :one => @vo }, + { one: @vo }, { - :one => { - :respond_to => "validate", + one: { + respond_to: "validate", }, } ) @@ -128,10 +128,10 @@ describe Chef::Mixin::ParamsValidate do expect do @vo.validate( - { :one => @vo }, + { one: @vo }, { - :one => { - :respond_to => "monkey", + one: { + respond_to: "monkey", }, } ) @@ -141,10 +141,10 @@ describe Chef::Mixin::ParamsValidate do it "should allow you to specify whether an object has all the given methods with respond_to and an array" do expect do @vo.validate( - { :one => @vo }, + { one: @vo }, { - :one => { - :respond_to => %w{validate music}, + one: { + respond_to: %w{validate music}, }, } ) @@ -152,10 +152,10 @@ describe Chef::Mixin::ParamsValidate do expect do @vo.validate( - { :one => @vo }, + { one: @vo }, { - :one => { - :respond_to => %w{monkey validate}, + one: { + respond_to: %w{monkey validate}, }, } ) @@ -165,8 +165,8 @@ describe Chef::Mixin::ParamsValidate do it "should let you set a default value with default => value" do arguments = Hash.new @vo.validate(arguments, { - :one => { - :default => "is the loneliest number", + one: { + default: "is the loneliest number", }, }) expect(arguments[:one]).to eq("is the loneliest number") @@ -175,10 +175,10 @@ describe Chef::Mixin::ParamsValidate do it "should let you check regular expressions" do expect do @vo.validate( - { :one => "is good" }, + { one: "is good" }, { - :one => { - :regex => /^is good$/, + one: { + regex: /^is good$/, }, } ) @@ -186,10 +186,10 @@ describe Chef::Mixin::ParamsValidate do expect do @vo.validate( - { :one => "is good" }, + { one: "is good" }, { - :one => { - :regex => /^is bad$/, + one: { + regex: /^is bad$/, }, } ) @@ -199,10 +199,10 @@ describe Chef::Mixin::ParamsValidate do it "should let you specify your own callbacks" do expect do @vo.validate( - { :one => "is good" }, + { one: "is good" }, { - :one => { - :callbacks => { + one: { + callbacks: { "should be equal to is good" => lambda do |a| a == "is good" end, @@ -214,10 +214,10 @@ describe Chef::Mixin::ParamsValidate do expect do @vo.validate( - { :one => "is bad" }, + { one: "is bad" }, { - :one => { - :callbacks => { + one: { + callbacks: { "should be equal to 'is good'" => lambda do |a| a == "is good" end, @@ -229,27 +229,27 @@ describe Chef::Mixin::ParamsValidate do end it "should let you combine checks" do - args = { :one => "is good", :two => "is bad" } + args = { one: "is good", two: "is bad" } expect do @vo.validate( args, { - :one => { - :kind_of => String, - :respond_to => [ :to_s, :upcase ], - :regex => /^is good/, - :callbacks => { + one: { + kind_of: String, + respond_to: [ :to_s, :upcase ], + regex: /^is good/, + callbacks: { "should be your friend" => lambda do |a| a == "is good" end, }, - :required => true, + required: true, }, - :two => { - :kind_of => String, - :required => false, + two: { + kind_of: String, + required: false, }, - :three => { :default => "neato mosquito" }, + three: { default: "neato mosquito" }, } ) end.not_to raise_error @@ -258,22 +258,22 @@ describe Chef::Mixin::ParamsValidate do @vo.validate( args, { - :one => { - :kind_of => String, - :respond_to => [ :to_s, :upcase ], - :regex => /^is good/, - :callbacks => { + one: { + kind_of: String, + respond_to: [ :to_s, :upcase ], + regex: /^is good/, + callbacks: { "should be your friend" => lambda do |a| a == "is good" end, }, - :required => true, + required: true, }, - :two => { - :kind_of => Hash, - :required => false, + two: { + kind_of: Hash, + required: false, }, - :three => { :default => "neato mosquito" }, + three: { default: "neato mosquito" }, } ) end.to raise_error(ArgumentError) @@ -282,10 +282,10 @@ describe Chef::Mixin::ParamsValidate do it "should raise an ArgumentError if the validation map has an unknown check" do expect do @vo.validate( - { :one => "two" }, + { one: "two" }, { - :one => { - :busted => "check", + one: { + busted: "check", }, } ) @@ -294,37 +294,37 @@ describe Chef::Mixin::ParamsValidate do it "should accept keys that are strings in the options" do expect do - @vo.validate({ "one" => "two" }, { :one => { :regex => /^two$/ } }) + @vo.validate({ "one" => "two" }, { one: { regex: /^two$/ } }) end.not_to raise_error end it "should allow an array to kind_of" do expect do @vo.validate( - { :one => "string" }, + { one: "string" }, { - :one => { - :kind_of => [ String, Array ], + one: { + kind_of: [ String, Array ], }, } ) end.not_to raise_error expect do @vo.validate( - { :one => ["string"] }, + { one: ["string"] }, { - :one => { - :kind_of => [ String, Array ], + one: { + kind_of: [ String, Array ], }, } ) end.not_to raise_error expect do @vo.validate( - { :one => Hash.new }, + { one: Hash.new }, { - :one => { - :kind_of => [ String, Array ], + one: { + kind_of: [ String, Array ], }, } ) @@ -333,23 +333,23 @@ describe Chef::Mixin::ParamsValidate do it "asserts that a value returns false from a predicate method" do expect do - @vo.validate({ :not_blank => "should pass" }, - { :not_blank => { :cannot_be => [ :nil, :empty ] } }) + @vo.validate({ not_blank: "should pass" }, + { not_blank: { cannot_be: [ :nil, :empty ] } }) end.not_to raise_error expect do - @vo.validate({ :not_blank => "" }, - { :not_blank => { :cannot_be => [ :nil, :empty ] } }) + @vo.validate({ not_blank: "" }, + { not_blank: { cannot_be: [ :nil, :empty ] } }) end.to raise_error(Chef::Exceptions::ValidationFailed) end it "allows a custom validation message" do expect do - @vo.validate({ :not_blank => "should pass" }, - { :not_blank => { :cannot_be => [ :nil, :empty ], validation_message: "my validation message" } }) + @vo.validate({ not_blank: "should pass" }, + { not_blank: { cannot_be: [ :nil, :empty ], validation_message: "my validation message" } }) end.not_to raise_error expect do - @vo.validate({ :not_blank => "" }, - { :not_blank => { :cannot_be => [ :nil, :empty ], validation_message: "my validation message" } }) + @vo.validate({ not_blank: "" }, + { not_blank: { cannot_be: [ :nil, :empty ], validation_message: "my validation message" } }) end.to raise_error(Chef::Exceptions::ValidationFailed, "my validation message") end @@ -361,38 +361,38 @@ describe Chef::Mixin::ParamsValidate do it "should set and return a default value when the argument is nil, then return the same value" do value = "meow" - expect(@vo.set_or_return(:test, nil, { :default => value }).object_id).to eq(value.object_id) + expect(@vo.set_or_return(:test, nil, { default: value }).object_id).to eq(value.object_id) expect(@vo.set_or_return(:test, nil, {}).object_id).to eq(value.object_id) end it "should raise an ArgumentError when argument is nil and required is true" do expect do - @vo.set_or_return(:test, nil, { :required => true }) + @vo.set_or_return(:test, nil, { required: true }) end.to raise_error(ArgumentError) end it "should not raise an error when argument is nil and required is false" do expect do - @vo.set_or_return(:test, nil, { :required => false }) + @vo.set_or_return(:test, nil, { required: false }) end.not_to raise_error end it "should set and return @name, then return @name for foo when argument is nil" do value = "meow" expect(@vo.set_or_return(:name, value, {}).object_id).to eq(value.object_id) - expect(@vo.set_or_return(:foo, nil, { :name_attribute => true }).object_id).to eq(value.object_id) + expect(@vo.set_or_return(:foo, nil, { name_attribute: true }).object_id).to eq(value.object_id) end it "should allow DelayedEvaluator instance to be set for value regardless of restriction" do value = Chef::DelayedEvaluator.new { "test" } - @vo.set_or_return(:test, value, { :kind_of => Numeric }) + @vo.set_or_return(:test, value, { kind_of: Numeric }) end it "should raise an error when delayed evaluated attribute is not valid" do value = Chef::DelayedEvaluator.new { "test" } - @vo.set_or_return(:test, value, { :kind_of => Numeric }) + @vo.set_or_return(:test, value, { kind_of: Numeric }) expect do - @vo.set_or_return(:test, nil, { :kind_of => Numeric }) + @vo.set_or_return(:test, nil, { kind_of: Numeric }) end.to raise_error(Chef::Exceptions::ValidationFailed) end diff --git a/spec/unit/mixin/securable_spec.rb b/spec/unit/mixin/securable_spec.rb index 6f50ce853f..7ec39ac63f 100644 --- a/spec/unit/mixin/securable_spec.rb +++ b/spec/unit/mixin/securable_spec.rb @@ -258,23 +258,23 @@ describe Chef::Mixin::Securable do end it "should allow you to specify whether the permissions applies_to_children with true/false/:containers_only/:objects_only" do - expect { @securable.rights :read, "The Dude", :applies_to_children => false }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => true }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => :containers_only }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => :objects_only }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => "poop" }.to raise_error(ArgumentError) + expect { @securable.rights :read, "The Dude", applies_to_children: false }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: true }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: :containers_only }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: :objects_only }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: "poop" }.to raise_error(ArgumentError) end it "should allow you to specify whether the permissions applies_to_self with true/false" do - expect { @securable.rights :read, "The Dude", :applies_to_children => true, :applies_to_self => false }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_self => true }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_self => "poop" }.to raise_error(ArgumentError) + expect { @securable.rights :read, "The Dude", applies_to_children: true, applies_to_self: false }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_self: true }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_self: "poop" }.to raise_error(ArgumentError) end it "should allow you to specify whether the permissions applies one_level_deep with true/false" do - expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => false }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => true }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => "poop" }.to raise_error(ArgumentError) + expect { @securable.rights :read, "The Dude", applies_to_children: true, one_level_deep: false }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: true, one_level_deep: true }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: true, one_level_deep: "poop" }.to raise_error(ArgumentError) end it "should allow multiple rights and deny_rights declarations" do @@ -288,21 +288,21 @@ describe Chef::Mixin::Securable do end it "should allow you to specify whether the permission applies_to_self only if you specified applies_to_children" do - expect { @securable.rights :read, "The Dude", :applies_to_children => true, :applies_to_self => true }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => true, :applies_to_self => false }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => false, :applies_to_self => true }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => false, :applies_to_self => false }.to raise_error(ArgumentError) - expect { @securable.rights :read, "The Dude", :applies_to_self => true }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_self => false }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: true, applies_to_self: true }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: true, applies_to_self: false }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: false, applies_to_self: true }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: false, applies_to_self: false }.to raise_error(ArgumentError) + expect { @securable.rights :read, "The Dude", applies_to_self: true }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_self: false }.not_to raise_error end it "should allow you to specify whether the permission applies one_level_deep only if you specified applies_to_children" do - expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => true }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => false }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => false, :one_level_deep => true }.to raise_error(ArgumentError) - expect { @securable.rights :read, "The Dude", :applies_to_children => false, :one_level_deep => false }.not_to raise_error - expect { @securable.rights :read, "The Dude", :one_level_deep => true }.not_to raise_error - expect { @securable.rights :read, "The Dude", :one_level_deep => false }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: true, one_level_deep: true }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: true, one_level_deep: false }.not_to raise_error + expect { @securable.rights :read, "The Dude", applies_to_children: false, one_level_deep: true }.to raise_error(ArgumentError) + expect { @securable.rights :read, "The Dude", applies_to_children: false, one_level_deep: false }.not_to raise_error + expect { @securable.rights :read, "The Dude", one_level_deep: true }.not_to raise_error + expect { @securable.rights :read, "The Dude", one_level_deep: false }.not_to raise_error end it "should allow you to specify whether the permissions inherit with true/false" do diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb index 2fef051b29..6b0cd659ef 100644 --- a/spec/unit/mixin/shell_out_spec.rb +++ b/spec/unit/mixin/shell_out_spec.rb @@ -60,21 +60,21 @@ describe Chef::Mixin::ShellOut do describe "when the last argument is a Hash" do describe "and environment is an option" do it "should not change environment language settings when they are set to nil" do - options = { :environment => { "LC_ALL" => nil, "LANGUAGE" => nil, "LANG" => nil, env_path => nil } } + options = { environment: { "LC_ALL" => nil, "LANGUAGE" => nil, "LANG" => nil, env_path => nil } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj) shell_out_obj.send(method, cmd, options) end it "should not change environment language settings when they are set to non-nil" do - options = { :environment => { "LC_ALL" => "en_US.UTF-8", "LANGUAGE" => "en_US.UTF-8", "LANG" => "en_US.UTF-8", env_path => "foo:bar:baz" } } + options = { environment: { "LC_ALL" => "en_US.UTF-8", "LANGUAGE" => "en_US.UTF-8", "LANG" => "en_US.UTF-8", env_path => "foo:bar:baz" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj) shell_out_obj.send(method, cmd, options) end it "should set environment language settings to the configured internal locale when they are not present" do - options = { :environment => { "HOME" => "/Users/morty" } } + options = { environment: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { - :environment => { + environment: { "HOME" => "/Users/morty", "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], @@ -86,9 +86,9 @@ describe Chef::Mixin::ShellOut do end it "should not mutate the options hash when it adds language settings" do - options = { :environment => { "HOME" => "/Users/morty" } } + options = { environment: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { - :environment => { + environment: { "HOME" => "/Users/morty", "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], @@ -103,21 +103,21 @@ describe Chef::Mixin::ShellOut do describe "and env is an option" do it "should not change env when langauge options are set to nil" do - options = { :env => { "LC_ALL" => nil, "LANG" => nil, "LANGUAGE" => nil, env_path => nil } } + options = { env: { "LC_ALL" => nil, "LANG" => nil, "LANGUAGE" => nil, env_path => nil } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj) shell_out_obj.send(method, cmd, options) end it "should not change env when language options are set to non-nil" do - options = { :env => { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8", env_path => "foo:bar:baz" } } + options = { env: { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8", env_path => "foo:bar:baz" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj) shell_out_obj.send(method, cmd, options) end it "should set environment language settings to the configured internal locale when they are not present" do - options = { :env => { "HOME" => "/Users/morty" } } + options = { env: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { - :env => { + env: { "HOME" => "/Users/morty", "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], @@ -129,9 +129,9 @@ describe Chef::Mixin::ShellOut do end it "should not mutate the options hash when it adds language settings" do - options = { :env => { "HOME" => "/Users/morty" } } + options = { env: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { - :env => { + env: { "HOME" => "/Users/morty", "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], @@ -146,10 +146,10 @@ describe Chef::Mixin::ShellOut do describe "and no env/environment option is present" do it "should set environment language settings to the configured internal locale" do - options = { :user => "morty" } + options = { user: "morty" } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { - :user => "morty", - :environment => { + user: "morty", + environment: { "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], @@ -164,7 +164,7 @@ describe Chef::Mixin::ShellOut do describe "when the last argument is not a Hash" do it "should set environment language settings to the configured internal locale" do expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { - :environment => { + environment: { "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], @@ -185,19 +185,19 @@ describe Chef::Mixin::ShellOut do describe "when the last argument is a Hash" do describe "and environment is an option" do it "should not change environment['LC_ALL'] when set to nil" do - options = { :environment => { "LC_ALL" => nil } } + options = { environment: { "LC_ALL" => nil } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end it "should not change environment['LC_ALL'] when set to non-nil" do - options = { :environment => { "LC_ALL" => "en_US.UTF-8" } } + options = { environment: { "LC_ALL" => "en_US.UTF-8" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end it "should no longer set environment['LC_ALL'] to nil when 'LC_ALL' not present" do - options = { :environment => { "HOME" => "/Users/morty" } } + options = { environment: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end @@ -205,19 +205,19 @@ describe Chef::Mixin::ShellOut do describe "and env is an option" do it "should not change env when set to nil" do - options = { :env => { "LC_ALL" => nil } } + options = { env: { "LC_ALL" => nil } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end it "should not change env when set to non-nil" do - options = { :env => { "LC_ALL" => "en_US.UTF-8" } } + options = { env: { "LC_ALL" => "en_US.UTF-8" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end it "should no longer set env['LC_ALL'] to nil when 'LC_ALL' not present" do - options = { :env => { "HOME" => "/Users/morty" } } + options = { env: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end @@ -225,7 +225,7 @@ describe Chef::Mixin::ShellOut do describe "and no env/environment option is present" do it "should no longer add environment option and set environment['LC_ALL'] to nil" do - options = { :user => "morty" } + options = { user: "morty" } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end @@ -245,19 +245,19 @@ describe Chef::Mixin::ShellOut do describe "when the last argument is a Hash" do describe "and environment is an option" do it "should not change environment['LC_ALL'] when set to nil" do - options = { :environment => { "LC_ALL" => nil } } + options = { environment: { "LC_ALL" => nil } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out(cmd, **options, default_env: false) end it "should not change environment['LC_ALL'] when set to non-nil" do - options = { :environment => { "LC_ALL" => "en_US.UTF-8" } } + options = { environment: { "LC_ALL" => "en_US.UTF-8" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out(cmd, **options, default_env: false) end it "should no longer set environment['LC_ALL'] to nil when 'LC_ALL' not present" do - options = { :environment => { "HOME" => "/Users/morty" } } + options = { environment: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out(cmd, **options, default_env: false) end @@ -265,19 +265,19 @@ describe Chef::Mixin::ShellOut do describe "and env is an option" do it "should not change env when set to nil" do - options = { :env => { "LC_ALL" => nil } } + options = { env: { "LC_ALL" => nil } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out(cmd, **options, default_env: false) end it "should not change env when set to non-nil" do - options = { :env => { "LC_ALL" => "en_US.UTF-8" } } + options = { env: { "LC_ALL" => "en_US.UTF-8" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out(cmd, **options, default_env: false) end it "should no longer set env['LC_ALL'] to nil when 'LC_ALL' not present" do - options = { :env => { "HOME" => "/Users/morty" } } + options = { env: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out(cmd, **options, default_env: false) end @@ -285,7 +285,7 @@ describe Chef::Mixin::ShellOut do describe "and no env/environment option is present" do it "should no longer add environment option and set environment['LC_ALL'] to nil" do - options = { :user => "morty" } + options = { user: "morty" } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out(cmd, **options, default_env: false) end diff --git a/spec/unit/mixin/user_context_spec.rb b/spec/unit/mixin/user_context_spec.rb index 3dadf6a2c3..896241f173 100644 --- a/spec/unit/mixin/user_context_spec.rb +++ b/spec/unit/mixin/user_context_spec.rb @@ -43,7 +43,7 @@ describe "a class that mixes in user_context" do allow(::Chef::Util::Windows::LogonSession).to receive(:new).and_return(logon_session) end - let(:logon_session) { instance_double("::Chef::Util::Windows::LogonSession", :set_user_context => nil, :open => nil, :close => nil) } + let(:logon_session) { instance_double("::Chef::Util::Windows::LogonSession", set_user_context: nil, open: nil, close: nil) } it "does not raise an exception when the user and all parameters are nil" do expect { instance_with_user_context.with_context(nil, nil, nil) {} }.not_to raise_error diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index 557c469216..618a9bbe0e 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -22,8 +22,8 @@ require "chef/node/attribute" describe Chef::Node::Attribute do let(:events) { instance_double(Chef::EventDispatch::Dispatcher) } - let(:run_context) { instance_double(Chef::RunContext, :events => events) } - let(:node) { instance_double(Chef::Node, :run_context => run_context) } + let(:run_context) { instance_double(Chef::RunContext, events: events) } + let(:node) { instance_double(Chef::Node, run_context: run_context) } before(:each) do allow(events).to receive(:attribute_changed) @attribute_hash = @@ -184,7 +184,7 @@ describe Chef::Node::Attribute do [ :normal, :default, :override, :automatic ].each do |accessor| it "should set #{accessor}" do - na = Chef::Node::Attribute.new({ :normal => true }, { :default => true }, { :override => true }, { :automatic => true }) + na = Chef::Node::Attribute.new({ normal: true }, { default: true }, { override: true }, { automatic: true }) expect(na.send(accessor)).to eq({ accessor.to_s => true }) end end diff --git a/spec/unit/node/vivid_mash_spec.rb b/spec/unit/node/vivid_mash_spec.rb index 4898c22380..e1021ba0c0 100644 --- a/spec/unit/node/vivid_mash_spec.rb +++ b/spec/unit/node/vivid_mash_spec.rb @@ -61,7 +61,7 @@ describe Chef::Node::VividMash do it "deep converts values through arrays" do expect(root).to receive(:reset_cache).with("foo") - vivid["foo"] = [ { :bar => true } ] + vivid["foo"] = [ { bar: true } ] expect(vivid["foo"].class).to eql(Chef::Node::AttrArray) expect(vivid["foo"][0].class).to eql(Chef::Node::VividMash) expect(vivid["foo"][0]["bar"]).to be true @@ -69,7 +69,7 @@ describe Chef::Node::VividMash do it "deep converts values through nested arrays" do expect(root).to receive(:reset_cache).with("foo") - vivid["foo"] = [ [ { :bar => true } ] ] + vivid["foo"] = [ [ { bar: true } ] ] expect(vivid["foo"].class).to eql(Chef::Node::AttrArray) expect(vivid["foo"][0].class).to eql(Chef::Node::AttrArray) expect(vivid["foo"][0][0].class).to eql(Chef::Node::VividMash) @@ -78,7 +78,7 @@ describe Chef::Node::VividMash do it "deep converts values through hashes" do expect(root).to receive(:reset_cache).with("foo") - vivid["foo"] = { baz: { :bar => true } } + vivid["foo"] = { baz: { bar: true } } expect(vivid["foo"]).to be_an_instance_of(Chef::Node::VividMash) expect(vivid["foo"]["baz"]).to be_an_instance_of(Chef::Node::VividMash) expect(vivid["foo"]["baz"]["bar"]).to be true diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb index 253486438b..df70ad380a 100644 --- a/spec/unit/node_map_spec.rb +++ b/spec/unit/node_map_spec.rb @@ -145,14 +145,14 @@ describe Chef::NodeMap do describe "deleting classes" do it "deletes a class and removes the mapping completely" do node_map.set(:thing, Bar) - expect( node_map.delete_class(Bar) ).to include({ :thing => [{ :klass => Bar, :cookbook_override => false, :core_override => false }] }) + expect( node_map.delete_class(Bar) ).to include({ thing: [{ klass: Bar, cookbook_override: false, core_override: false }] }) expect( node_map.get(node, :thing) ).to eql(nil) end it "deletes a class and leaves the mapping that still has an entry" do node_map.set(:thing, Bar) node_map.set(:thing, Foo) - expect( node_map.delete_class(Bar) ).to eql({ :thing => [{ :klass => Bar, :cookbook_override => false, :core_override => false }] }) + expect( node_map.delete_class(Bar) ).to eql({ thing: [{ klass: Bar, cookbook_override: false, core_override: false }] }) expect( node_map.get(node, :thing) ).to eql(Foo) end @@ -160,7 +160,7 @@ describe Chef::NodeMap do node_map.set(:thing1, Bar) node_map.set(:thing2, Bar) node_map.set(:thing2, Foo) - expect( node_map.delete_class(Bar) ).to eql({ :thing1 => [{ :klass => Bar, :cookbook_override => false, :core_override => false }], :thing2 => [{ :klass => Bar, :cookbook_override => false, :core_override => false }] }) + expect( node_map.delete_class(Bar) ).to eql({ thing1: [{ klass: Bar, cookbook_override: false, core_override: false }], thing2: [{ klass: Bar, cookbook_override: false, core_override: false }] }) expect( node_map.get(node, :thing1) ).to eql(nil) expect( node_map.get(node, :thing2) ).to eql(Foo) end diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index 3a43a155d5..ee0f969f6d 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -52,7 +52,7 @@ describe Chef::Node do describe "when the node does not exist on the server" do before do - response = OpenStruct.new(:code => "404") + response = OpenStruct.new(code: "404") exception = Net::HTTPServerException.new("404 not found", response) allow(Chef::Node).to receive(:load).and_raise(exception) node.name("created-node") @@ -852,7 +852,7 @@ describe Chef::Node do describe "consuming json" do before do - @ohai_data = { :platform => "foo", :platform_version => "bar" } + @ohai_data = { platform: "foo", platform_version: "bar" } end it "consumes the run list portion of a collection of attributes and returns the remainder" do @@ -944,7 +944,7 @@ describe Chef::Node do describe "preparing for a chef client run" do before do - @ohai_data = { :platform => "foobuntu", :platform_version => "23.42" } + @ohai_data = { platform: "foobuntu", platform_version: "23.42" } end it "sets its platform according to platform detection" do @@ -1096,12 +1096,12 @@ describe Chef::Node do before do node.chef_environment = "rspec" @expansion = Chef::RunList::RunListExpansion.new("rspec", []) - @expansion.default_attrs.replace({ :default => "from role", :d_role => "role only" }) - @expansion.override_attrs.replace({ :override => "from role", :o_role => "role only" }) + @expansion.default_attrs.replace({ default: "from role", d_role: "role only" }) + @expansion.override_attrs.replace({ override: "from role", o_role: "role only" }) @environment = Chef::Environment.new - @environment.default_attributes = { :default => "from env", :d_env => "env only" } - @environment.override_attributes = { :override => "from env", :o_env => "env only" } + @environment.default_attributes = { default: "from env", d_env: "env only" } + @environment.override_attributes = { override: "from env", o_env: "env only" } allow(Chef::Environment).to receive(:load).and_return(@environment) node.apply_expansion_attributes(@expansion) end @@ -1269,7 +1269,7 @@ describe Chef::Node do end describe "converting to or from json" do - it "should serialize itself as json", :json => true do + it "should serialize itself as json", json: true do node.from_file(File.expand_path("nodes/test.example.com.rb", CHEF_SPEC_DATA)) json = Chef::JSONCompat.to_json(node) expect(json).to match(/json_class/) @@ -1281,7 +1281,7 @@ describe Chef::Node do expect(json).to match(/run_list/) end - it "should serialize valid json with a run list", :json => true do + it "should serialize valid json with a run list", json: true do #This test came about because activesupport mucks with Chef json serialization #Test should pass with and without Activesupport node.run_list << { "type" => "role", "name" => "Cthulu" } @@ -1290,7 +1290,7 @@ describe Chef::Node do expect(json).to match(/\"run_list\":\[\"role\[Cthulu\]\",\"role\[Hastur\]\"\]/) end - it "should serialize the correct run list", :json => true do + it "should serialize the correct run list", json: true do node.run_list << "role[marxist]" node.run_list << "role[leninist]" node.override_runlist << "role[stalinist]" @@ -1315,7 +1315,7 @@ describe Chef::Node do expect(node_for_json["default"]["env default"]).to eq("env default") end - it "should deserialize itself from json", :json => true do + it "should deserialize itself from json", json: true do node.from_file(File.expand_path("nodes/test.example.com.rb", CHEF_SPEC_DATA)) json = Chef::JSONCompat.to_json(node) serialized_node = Chef::Node.from_hash(Chef::JSONCompat.parse(json)) @@ -1392,7 +1392,7 @@ describe Chef::Node do describe "list" do describe "inflated" do it "should return a hash of node names and objects" do - n1 = double("Chef::Node", :name => "one") + n1 = double("Chef::Node", name: "one") allow(n1).to receive(:kind_of?).with(Chef::Node) { true } expect(@query).to receive(:search).with(:node).and_yield(n1) r = Chef::Node.list(true) @@ -1446,7 +1446,7 @@ describe Chef::Node do it "should create if it cannot update" do node.name("monkey") allow(node).to receive(:data_for_save).and_return({}) - exception = double("404 error", :code => "404") + exception = double("404 error", code: "404") expect(@rest).to receive(:put).and_raise(Net::HTTPServerException.new("foo", exception)) expect(@rest).to receive(:post).with("nodes", {}) node.save diff --git a/spec/unit/org_spec.rb b/spec/unit/org_spec.rb index 49557417a5..79a29b1fff 100644 --- a/spec/unit/org_spec.rb +++ b/spec/unit/org_spec.rb @@ -164,7 +164,7 @@ describe Chef::Org do describe "create" do it "creates a new org via the API" do - expect(rest).to receive(:post).with("organizations", { :name => "foobar", :full_name => "foo bar bat" }).and_return({}) + expect(rest).to receive(:post).with("organizations", { name: "foobar", full_name: "foo bar bat" }).and_return({}) org.create end end @@ -181,7 +181,7 @@ describe Chef::Org do describe "update" do it "updates an existing org on via the API" do - expect(rest).to receive(:put).with("organizations/foobar", { :name => "foobar", :full_name => "foo bar bat" }).and_return({}) + expect(rest).to receive(:put).with("organizations/foobar", { name: "foobar", full_name: "foo bar bat" }).and_return({}) org.update end end diff --git a/spec/unit/policy_builder/expand_node_object_spec.rb b/spec/unit/policy_builder/expand_node_object_spec.rb index a7f4f1fa43..438e0805e7 100644 --- a/spec/unit/policy_builder/expand_node_object_spec.rb +++ b/spec/unit/policy_builder/expand_node_object_spec.rb @@ -176,7 +176,7 @@ describe Chef::PolicyBuilder::ExpandNodeObject do let(:expansion) do recipe_list = Chef::RunList::VersionedRecipeList.new recipe_list.add_recipe("recipe[from_role::default", "1.0.2") - double("RunListExpansion", :recipes => recipe_list) + double("RunListExpansion", recipes: recipe_list) end let(:node) do @@ -268,13 +268,13 @@ describe Chef::PolicyBuilder::ExpandNodeObject do let(:chef_http) { double("Chef::ServerAPI") } let(:cookbook_resolve_url) { "environments/#{node.chef_environment}/cookbook_versions" } - let(:cookbook_resolve_post_data) { { :run_list => ["first::default", "second::default"] } } + let(:cookbook_resolve_post_data) { { run_list: ["first::default", "second::default"] } } # cookbook_hash is just a hash, but since we're passing it between mock # objects, we get a little better test strictness by using a double (which # will have object equality rather than semantic equality #== semantics). let(:cookbook_hash) { double("cookbook hash") } - let(:expanded_cookbook_hash) { double("expanded cookbook hash", :each => nil) } + let(:expanded_cookbook_hash) { double("expanded cookbook hash", each: nil) } let(:cookbook_synchronizer) { double("CookbookSynchronizer") } diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb index 5663cb8b19..260b99c89c 100644 --- a/spec/unit/policy_builder/policyfile_spec.rb +++ b/spec/unit/policy_builder/policyfile_spec.rb @@ -393,10 +393,10 @@ describe Chef::PolicyBuilder::Policyfile do let(:run_list_for_data_collector) do { - :id => "_policy_node", - :run_list => [ - { :type => "recipe", :name => "test::default", :skipped => false, :version => nil }, - { :type => "recipe", :name => "test::other", :skipped => false, :version => nil }, + id: "_policy_node", + run_list: [ + { type: "recipe", name: "test::default", skipped: false, version: nil }, + { type: "recipe", name: "test::other", skipped: false, version: nil }, ], } end diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index 79c4baa89f..463f9469c6 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -1070,13 +1070,13 @@ describe "Chef::Resource.property" do end it "raises an error if both name_property and name_attribute are specified" do - expect { resource_class.property :x, :name_property => false, :name_attribute => 1 }.to raise_error ArgumentError, + expect { resource_class.property :x, name_property: false, name_attribute: 1 }.to raise_error ArgumentError, /name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./ - expect { resource_class.property :x, :name_property => false, :name_attribute => nil }.to raise_error ArgumentError, + expect { resource_class.property :x, name_property: false, name_attribute: nil }.to raise_error ArgumentError, /name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./ - expect { resource_class.property :x, :name_property => false, :name_attribute => false }.to raise_error ArgumentError, + expect { resource_class.property :x, name_property: false, name_attribute: false }.to raise_error ArgumentError, /name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./ - expect { resource_class.property :x, :name_property => true, :name_attribute => true }.to raise_error ArgumentError, + expect { resource_class.property :x, name_property: true, name_attribute: true }.to raise_error ArgumentError, /name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./ end diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb index d881d01124..54f1f2df66 100644 --- a/spec/unit/provider/apt_repository_spec.rb +++ b/spec/unit/provider/apt_repository_spec.rb @@ -67,14 +67,14 @@ describe Chef::Provider::AptRepository do end let(:gpg_shell_out_success) do - double("shell_out", :stdout => "pub 2048R/7BD9BF62 2011-08-19 nginx signing key <signing-key@nginx.com>", - :exitstatus => 0, :error? => false) + double("shell_out", stdout: "pub 2048R/7BD9BF62 2011-08-19 nginx signing key <signing-key@nginx.com>", + exitstatus: 0, error?: false) end let(:gpg_shell_out_failure) do - double("shell_out", :stderr => "gpg: no valid OpenPGP data found.\n + double("shell_out", stderr: "gpg: no valid OpenPGP data found.\n gpg: processing message failed: eof", - :exitstatus => 1, :error? => true) + exitstatus: 1, error?: true) end let(:apt_fingerprints) do diff --git a/spec/unit/provider/cookbook_file/content_spec.rb b/spec/unit/provider/cookbook_file/content_spec.rb index 096ac85b64..4e07915a95 100644 --- a/spec/unit/provider/cookbook_file/content_spec.rb +++ b/spec/unit/provider/cookbook_file/content_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Provider::CookbookFile::Content do - let(:new_resource) { double("Chef::Resource::CookbookFile (new)", :cookbook_name => "apache2", :cookbook => "apache2") } + let(:new_resource) { double("Chef::Resource::CookbookFile (new)", cookbook_name: "apache2", cookbook: "apache2") } let(:content) do @run_context = double("Chef::RunContext") @current_resource = double("Chef::Resource::CookbookFile (current)") diff --git a/spec/unit/provider/cookbook_file_spec.rb b/spec/unit/provider/cookbook_file_spec.rb index f27392de5d..e1ef3c63d8 100644 --- a/spec/unit/provider/cookbook_file_spec.rb +++ b/spec/unit/provider/cookbook_file_spec.rb @@ -26,7 +26,7 @@ describe Chef::Provider::CookbookFile do let(:node) { double("Chef::Node") } let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:logger) { double("Mixlib::Log::Child").as_null_object } - let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) } + let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) } let(:enclosing_directory) do canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) end diff --git a/spec/unit/provider/cron/unix_spec.rb b/spec/unit/provider/cron/unix_spec.rb index 62b941c4aa..843f3f3d8c 100644 --- a/spec/unit/provider/cron/unix_spec.rb +++ b/spec/unit/provider/cron/unix_spec.rb @@ -37,9 +37,9 @@ describe Chef::Provider::Cron::Unix do end end - let(:status) { double("Process::Status", :exitstatus => exitstatus) } + let(:status) { double("Process::Status", exitstatus: exitstatus) } let(:exitstatus) { 0 } - let(:shell_out) { double("Mixlib::ShellOut", :status => status, :stdout => stdout, :stderr => stderr) } + let(:shell_out) { double("Mixlib::ShellOut", status: status, stdout: stdout, stderr: stderr) } let(:logger) { double("Mixlib::Log::Child").as_null_object } @@ -66,12 +66,12 @@ describe Chef::Provider::Cron::Unix do before do allow(logger).to receive(:trace) allow(shell_out).to receive(:format_for_exception).and_return("formatted command output") - allow(provider).to receive(:shell_out).with("/usr/bin/crontab -l", :user => username).and_return(shell_out) + allow(provider).to receive(:shell_out).with("/usr/bin/crontab -l", user: username).and_return(shell_out) end it "should call crontab -l with the user" do provider.send(:read_crontab) - expect(provider).to have_received(:shell_out).with("/usr/bin/crontab -l", :user => username) + expect(provider).to have_received(:shell_out).with("/usr/bin/crontab -l", user: username) end it "should return the contents of the crontab" do @@ -111,7 +111,7 @@ describe Chef::Provider::Cron::Unix do describe "write_crontab" do let(:stdout) { "" } let(:stderr) { "" } - let(:tempfile) { double("foo", :path => "/tmp/foo", :close => true) } + let(:tempfile) { double("foo", path: "/tmp/foo", close: true) } before do expect(Tempfile).to receive(:new).and_return(tempfile) @@ -119,12 +119,12 @@ describe Chef::Provider::Cron::Unix do expect(tempfile).to receive(:chmod).with(420) expect(tempfile).to receive(:close!) allow(tempfile).to receive(:<<) - allow(provider).to receive(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username).and_return(shell_out) + allow(provider).to receive(:shell_out).with("/usr/bin/crontab #{tempfile.path}", user: username).and_return(shell_out) end it "should call crontab for the user" do provider.send(:write_crontab, "Foo") - expect(provider).to have_received(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username) + expect(provider).to have_received(:shell_out).with("/usr/bin/crontab #{tempfile.path}", user: username) end it "should call crontab with a file containing the crontab" do diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb index 747e37f308..ab675c4ddd 100644 --- a/spec/unit/provider/dsc_resource_spec.rb +++ b/spec/unit/provider/dsc_resource_spec.rb @@ -104,7 +104,7 @@ describe Chef::Provider::DscResource do it "flags the resource as reboot required when required" do expect(provider).to receive(:test_resource).and_return(false) expect(provider).to receive(:invoke_resource). - and_return(double(:stdout => "", :return_value => nil)) + and_return(double(stdout: "", return_value: nil)) expect(provider).to receive(:add_dsc_verbose_log) expect(provider).to receive(:return_dsc_resource_result).and_return(true) expect(provider).to receive(:create_reboot_resource) @@ -114,7 +114,7 @@ describe Chef::Provider::DscResource do it "does not flag the resource as reboot required when not required" do expect(provider).to receive(:test_resource).and_return(false) expect(provider).to receive(:invoke_resource). - and_return(double(:stdout => "", :return_value => nil)) + and_return(double(stdout: "", return_value: nil)) expect(provider).to receive(:add_dsc_verbose_log) expect(provider).to receive(:return_dsc_resource_result).and_return(false) expect(provider).to_not receive(:create_reboot_resource) @@ -293,12 +293,12 @@ describe Chef::Provider::DscResource do set_node_object end - let(:cmdlet) { double(:run! => nil) } + let(:cmdlet) { double(run!: nil) } before(:each) do allow(provider).to receive(:translate_type).and_return("my_properties") provider.instance_variable_set(:@new_resource, double( - :properties => "my_properties", :resource => "my_resource", :timeout => 123 + properties: "my_properties", resource: "my_resource", timeout: 123 )) end diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb index 78534bfb57..48cee78462 100644 --- a/spec/unit/provider/execute_spec.rb +++ b/spec/unit/provider/execute_spec.rb @@ -26,7 +26,7 @@ describe Chef::Provider::Execute do let(:provider) { Chef::Provider::Execute.new(new_resource, run_context) } let(:current_resource) { Chef::Resource::Ifconfig.new("foo_resource", run_context) } # You will be the same object, I promise. - @live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, :name => :execute) + @live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, name: :execute) let(:opts) do { diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb index f840d92dbb..e65d094327 100644 --- a/spec/unit/provider/file/content_spec.rb +++ b/spec/unit/provider/file/content_spec.rb @@ -36,7 +36,7 @@ describe Chef::Provider::File::Content do end let(:new_resource) do - double("Chef::Provider::File::Resource (new)", :name => "seattle.txt", :path => resource_path) + double("Chef::Provider::File::Resource (new)", name: "seattle.txt", path: resource_path) end let(:run_context) do diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb index fed9cd5ece..311ef4c55a 100644 --- a/spec/unit/provider/file_spec.rb +++ b/spec/unit/provider/file_spec.rb @@ -35,7 +35,7 @@ describe Chef::Provider::File do let(:node) { double("Chef::Node") } let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:logger) { double("Mixlib::Log::Child").as_null_object } - let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) } + let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) } let(:enclosing_directory) do canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) end diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb index a20c7a838c..fafb83f548 100644 --- a/spec/unit/provider/git_spec.rb +++ b/spec/unit/provider/git_spec.rb @@ -58,7 +58,7 @@ describe Chef::Provider::Git do it "determines the current revision when there is one" do expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true) @stdout = "9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\n" - expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", { :cwd => "/my/deploy/dir", :returns => [0, 128], :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", { cwd: "/my/deploy/dir", returns: [0, 128], log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.find_current_revision).to eql("9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13") end @@ -66,7 +66,7 @@ describe Chef::Provider::Git do expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true) @stderr = "fatal: Not a git repository (or any of the parent directories): .git" @stdout = "" - expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", :cwd => "/my/deploy/dir", :returns => [0, 128], :log_tag => "git[web2.0 app]" ).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr)) + expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", cwd: "/my/deploy/dir", returns: [0, 128], log_tag: "git[web2.0 app]" ).and_return(double("ShellOut result", stdout: "", stderr: @stderr)) expect(@provider.find_current_revision).to be_nil end end @@ -152,7 +152,7 @@ describe Chef::Provider::Git do @resource.revision "v1.0" @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -161,7 +161,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0^{}\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53") end @@ -170,7 +170,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/releases/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -179,7 +179,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53") end @@ -188,7 +188,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.1\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -198,7 +198,7 @@ describe Chef::Provider::Git do "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + "805c22a5e41f5ae3193460cca044ed1435029f53\trefs/pulls/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("805c22a5e41f5ae3193460cca044ed1435029f53") end @@ -207,7 +207,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -222,21 +222,21 @@ describe Chef::Provider::Git do it "raises an unresolvable git reference error if the revision can't be resolved to any revision and assertions are run" do @resource.revision "FAIL, that's the revision I want" @provider.action = :checkout - expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", :stdout => "\n")) + expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", stdout: "\n")) @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::UnresolvableGitReference) end it "does not raise an error if the revision can't be resolved when assertions are not run" do @resource.revision "FAIL, that's the revision I want" - expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", :stdout => "\n")) + expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", stdout: "\n")) expect(@provider.target_revision).to eq(nil) end it "does not raise an error when the revision is valid and assertions are run." do @resource.revision "0.8-alpha" @stdout = "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) @provider.action = :checkout allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) @provider.define_resource_requirements @@ -261,7 +261,7 @@ b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{} ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package SHAS @resource.revision "" - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("28af684d8460ba4793eda3e7ac238c864a5d029a") end end @@ -276,15 +276,15 @@ SHAS let(:expected_cmd) { 'git clone "git://github.com/opscode/chef.git" "/my/deploy/dir"' } let(:default_options) do { - :user => deploy_user, - :environment => { "GIT_SSH" => wrapper, "HOME" => "/home/deployNinja" }, - :log_tag => "git[web2.0 app]", + user: deploy_user, + environment: { "GIT_SSH" => wrapper, "HOME" => "/home/deployNinja" }, + log_tag: "git[web2.0 app]", } end before do @resource.user deploy_user @resource.ssh_wrapper wrapper - allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja")) + allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja")) end context "without a timeout set" do it "clones a repo with default git options" do @@ -296,7 +296,7 @@ SHAS let (:seconds) { 10 } before { @resource.timeout(seconds) } it "clones a repo with amended git options" do - expect(@provider).to receive(:shell_out!).with(expected_cmd, default_options.merge(:timeout => seconds)) + expect(@provider).to receive(:shell_out!).with(expected_cmd, default_options.merge(timeout: seconds)) @provider.clone end end @@ -306,9 +306,9 @@ SHAS end let(:overrided_options) do { - :user => deploy_user, - :environment => { "GIT_SSH" => wrapper, "HOME" => "/home/masterNinja" }, - :log_tag => "git[web2.0 app]", + user: deploy_user, + environment: { "GIT_SSH" => wrapper, "HOME" => "/home/masterNinja" }, + log_tag: "git[web2.0 app]", } end before do @@ -327,14 +327,14 @@ SHAS let(:expected_cmd) { 'git clone "git://github.com/opscode/chef.git" "/my/deploy/dir"' } let(:default_options) do { - :user => 123, - :environment => { "HOME" => "/home/deployNinja" }, - :log_tag => "git[web2.0 app]", + user: 123, + environment: { "HOME" => "/home/deployNinja" }, + log_tag: "git[web2.0 app]", } end before do @resource.user deploy_user - allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja")) + allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja")) end context "with a specific home" do let (:override_home) do @@ -342,9 +342,9 @@ SHAS end let(:overrided_options) do { - :user => 123, - :environment => { "HOME" => "/home/masterNinja" }, - :log_tag => "git[web2.0 app]", + user: 123, + environment: { "HOME" => "/home/masterNinja" }, + log_tag: "git[web2.0 app]", } end before do @@ -360,13 +360,13 @@ SHAS it "runs a clone command with escaped destination" do @resource.user "deployNinja" - allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja")) + allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja")) @resource.destination "/Application Support/with/space" @resource.ssh_wrapper "do_it_this_way.sh" expected_cmd = "git clone \"git://github.com/opscode/chef.git\" \"/Application Support/with/space\"" - expect(@provider).to receive(:shell_out!).with(expected_cmd, :user => "deployNinja", - :log_tag => "git[web2.0 app]", - :environment => { "HOME" => "/home/deployNinja", + expect(@provider).to receive(:shell_out!).with(expected_cmd, user: "deployNinja", + log_tag: "git[web2.0 app]", + environment: { "HOME" => "/home/deployNinja", "GIT_SSH" => "do_it_this_way.sh" }) @provider.clone end @@ -377,8 +377,8 @@ SHAS version_response = double("shell_out") allow(version_response).to receive(:stdout) { "git version 1.7.9" } expect(@provider).to receive(:shell_out!).with("git --version", - :log_tag => "git[web2.0 app]").and_return(version_response) - expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]") + log_tag: "git[web2.0 app]").and_return(version_response) + expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]") @provider.clone end @@ -388,33 +388,33 @@ SHAS version_response = double("shell_out") allow(version_response).to receive(:stdout) { "git version 1.7.10" } expect(@provider).to receive(:shell_out!).with("git --version", - :log_tag => "git[web2.0 app]").and_return(version_response) - expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]") + log_tag: "git[web2.0 app]").and_return(version_response) + expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]") @provider.clone end it "compiles a clone command with a remote other than ``origin''" do @resource.remote "opscode" expected_cmd = "git clone -o opscode \"git://github.com/opscode/chef.git\" \"/my/deploy/dir\"" - expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]") @provider.clone end it "runs a checkout command with default options" do - expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]").ordered - expect(@provider).to receive(:shell_out!).with("git checkout deploy", :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]").ordered + expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]").ordered + expect(@provider).to receive(:shell_out!).with("git checkout deploy", cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]").ordered @provider.checkout end it "runs an enable_submodule command" do @resource.enable_submodules true expected_cmd = "git submodule sync" - expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd, cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") expected_cmd = "git submodule update --init --recursive" - expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") @provider.enable_submodules end @@ -426,35 +426,35 @@ SHAS it "runs a sync command with default options" do expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) expected_cmd1 = "git fetch --prune origin" - expect(@provider).to receive(:shell_out!).with(expected_cmd1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") expected_cmd2 = "git fetch origin --tags" - expect(@provider).to receive(:shell_out!).with(expected_cmd2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") expected_cmd3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - expect(@provider).to receive(:shell_out!).with(expected_cmd3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") @provider.fetch_updates end it "runs a sync command with the user and group specified in the resource" do @resource.user("whois") - allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois")) + allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/whois")) @resource.group("thisis") expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) expected_cmd1 = "git fetch --prune origin" - expect(@provider).to receive(:shell_out!).with(expected_cmd1, :cwd => "/my/deploy/dir", - :user => "whois", :group => "thisis", - :log_tag => "git[web2.0 app]", - :environment => { "HOME" => "/home/whois" }) + expect(@provider).to receive(:shell_out!).with(expected_cmd1, cwd: "/my/deploy/dir", + user: "whois", group: "thisis", + log_tag: "git[web2.0 app]", + environment: { "HOME" => "/home/whois" }) expected_cmd2 = "git fetch origin --tags" - expect(@provider).to receive(:shell_out!).with(expected_cmd2, :cwd => "/my/deploy/dir", - :user => "whois", :group => "thisis", - :log_tag => "git[web2.0 app]", - :environment => { "HOME" => "/home/whois" }) + expect(@provider).to receive(:shell_out!).with(expected_cmd2, cwd: "/my/deploy/dir", + user: "whois", group: "thisis", + log_tag: "git[web2.0 app]", + environment: { "HOME" => "/home/whois" }) expected_cmd3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - expect(@provider).to receive(:shell_out!).with(expected_cmd3, :cwd => "/my/deploy/dir", - :user => "whois", :group => "thisis", - :log_tag => "git[web2.0 app]", - :environment => { "HOME" => "/home/whois" }) + expect(@provider).to receive(:shell_out!).with(expected_cmd3, cwd: "/my/deploy/dir", + user: "whois", group: "thisis", + log_tag: "git[web2.0 app]", + environment: { "HOME" => "/home/whois" }) @provider.fetch_updates end @@ -462,11 +462,11 @@ SHAS @resource.remote "origin" expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) fetch_command1 = "git fetch --prune origin" - expect(@provider).to receive(:shell_out!).with(fetch_command1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") fetch_command2 = "git fetch origin --tags" - expect(@provider).to receive(:shell_out!).with(fetch_command2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") fetch_command3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - expect(@provider).to receive(:shell_out!).with(fetch_command3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") @provider.fetch_updates end @@ -474,11 +474,11 @@ SHAS @resource.remote "opscode" expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) fetch_command1 = "git fetch --prune opscode" - expect(@provider).to receive(:shell_out!).with(fetch_command1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") fetch_command2 = "git fetch opscode --tags" - expect(@provider).to receive(:shell_out!).with(fetch_command2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") fetch_command3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - expect(@provider).to receive(:shell_out!).with(fetch_command3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") @provider.fetch_updates end @@ -489,37 +489,37 @@ SHAS allow(command_response).to receive(:exitstatus) { 1 } expected_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(expected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(add_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end it "runs the config with the user and group specified in the resource" do @resource.user("whois") @resource.group("thisis") - allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois")) + allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/whois")) command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 1 } expected_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(expected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :user => "whois", - :group => "thisis", - :environment => { "HOME" => "/home/whois" }, - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + user: "whois", + group: "thisis", + environment: { "HOME" => "/home/whois" }, + returns: [0, 1, 2]).and_return(command_response) add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(add_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :user => "whois", - :group => "thisis", - :environment => { "HOME" => "/home/whois" }) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + user: "whois", + group: "thisis", + environment: { "HOME" => "/home/whois" }) @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -529,13 +529,13 @@ SHAS allow(command_response).to receive(:exitstatus) { 1 } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) expected_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(expected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end end @@ -547,13 +547,13 @@ SHAS allow(command_response).to receive(:stdout) { "some_other_url" } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) expected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\"" expect(@provider).to receive(:shell_out!).with(expected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -563,13 +563,13 @@ SHAS allow(command_response).to receive(:stdout) { @resource.repository } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) unexpected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\"" expect(@provider).not_to receive(:shell_out!).with(unexpected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -578,13 +578,13 @@ SHAS allow(command_response).to receive(:exitstatus) { 2 } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) expected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\"" expect(@provider).to receive(:shell_out!).with(expected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end end @@ -705,7 +705,7 @@ SHAS allow(::File).to receive(:directory?).with("/my/deploy/dir").and_return(true) allow(@provider).to receive(:sync_command).and_return("huzzah!") expect(@provider).to receive(:action_checkout) - expect(@provider).not_to receive(:shell_out!).with("huzzah!", :cwd => "/my/deploy/dir") + expect(@provider).not_to receive(:shell_out!).with("huzzah!", cwd: "/my/deploy/dir") @provider.run_action(:sync) #@resource.should be_updated end @@ -719,8 +719,8 @@ SHAS describe "calling add_remotes" do it "adds a new remote for each entry in additional remotes hash" do - @resource.additional_remotes({ :opscode => "opscode_repo_url", - :another_repo => "some_other_repo_url" }) + @resource.additional_remotes({ opscode: "opscode_repo_url", + another_repo: "some_other_repo_url" }) allow(STDOUT).to receive(:tty?).and_return(false) command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 0 } diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb index c3e0d4b345..437b8c45ea 100644 --- a/spec/unit/provider/group_spec.rb +++ b/spec/unit/provider/group_spec.rb @@ -37,9 +37,9 @@ describe Chef::Provider::User do @provider.current_resource = @current_resource @pw_group = double("Struct::Group", - :name => "wheel", - :gid => 20, - :mem => %w{root aj} + name: "wheel", + gid: 20, + mem: %w{root aj} ) allow(Etc).to receive(:getgrnam).with("wheel").and_return(@pw_group) end diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb index 10dbdc1766..8f1ec8c3ba 100644 --- a/spec/unit/provider/link_spec.rb +++ b/spec/unit/provider/link_spec.rb @@ -46,7 +46,7 @@ describe Chef::Resource::Link do describe "when the target is a symlink" do before(:each) do - lstat = double("stats", :ino => 5) + lstat = double("stats", ino: 5) allow(lstat).to receive(:uid).and_return(501) allow(lstat).to receive(:gid).and_return(501) allow(lstat).to receive(:mode).and_return(0777) @@ -146,7 +146,7 @@ describe Chef::Resource::Link do describe "when the target is a regular old file" do before do - stat = double("stats", :ino => 5) + stat = double("stats", ino: 5) allow(stat).to receive(:uid).and_return(501) allow(stat).to receive(:gid).and_return(501) allow(stat).to receive(:mode).and_return(0755) @@ -178,7 +178,7 @@ describe Chef::Resource::Link do describe "and the source exists" do before do - stat = double("stats", :ino => 6) + stat = double("stats", ino: 6) allow(stat).to receive(:uid).and_return(502) allow(stat).to receive(:gid).and_return(502) allow(stat).to receive(:mode).and_return(0644) @@ -205,7 +205,7 @@ describe Chef::Resource::Link do describe "and is hardlinked to the source" do before do - stat = double("stats", :ino => 5) + stat = double("stats", ino: 5) allow(stat).to receive(:uid).and_return(502) allow(stat).to receive(:gid).and_return(502) allow(stat).to receive(:mode).and_return(0644) @@ -254,7 +254,7 @@ describe Chef::Resource::Link do describe "action_delete" do before(:each) do - stat = double("stats", :ino => 5) + stat = double("stats", ino: 5) allow(stat).to receive(:uid).and_return(501) allow(stat).to receive(:gid).and_return(501) allow(stat).to receive(:mode).and_return(0755) @@ -321,7 +321,7 @@ describe Chef::Resource::Link do end before(:each) do - stat = double("stats", :ino => 5) + stat = double("stats", ino: 5) allow(stat).to receive(:uid).and_return(502) allow(stat).to receive(:gid).and_return(502) allow(stat).to receive(:mode).and_return(0644) diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb index 8ef884e131..17824c4fb8 100644 --- a/spec/unit/provider/mdadm_spec.rb +++ b/spec/unit/provider/mdadm_spec.rb @@ -32,20 +32,20 @@ describe Chef::Provider::Mdadm do describe "when determining the current metadevice status" do it "should set the current resources mount point to the new resources mount point" do - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:status => 0)) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(status: 0)) @provider.load_current_resource expect(@provider.current_resource.name).to eq("/dev/md1") expect(@provider.current_resource.raid_device).to eq("/dev/md1") end it "determines that the metadevice exists when mdadm exit code is zero" do - allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 0)) + allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", returns: [0, 4]).and_return(OpenStruct.new(status: 0)) @provider.load_current_resource expect(@provider.current_resource.exists).to be_truthy end it "determines that the metadevice does not exist when mdadm exit code is 4" do - allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 4)) + allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", returns: [0, 4]).and_return(OpenStruct.new(status: 4)) @provider.load_current_resource expect(@provider.current_resource.exists).to be_falsey end diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb index 615f3c3304..d807409d05 100644 --- a/spec/unit/provider/mount/aix_spec.rb +++ b/spec/unit/provider/mount/aix_spec.rb @@ -61,7 +61,7 @@ WRONG @new_resource.device_type :device @new_resource.fstype "jfs2" - @new_resource.supports :remount => false + @new_resource.supports remount: false @provider = Chef::Provider::Mount::Aix.new(@new_resource, @run_context) @@ -70,12 +70,12 @@ WRONG end def stub_mounted(provider, mounted_output) - response = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => mounted_output, :stderr => "") + response = double("Mixlib::ShellOut command", exitstatus: 0, stdout: mounted_output, stderr: "") expect(provider).to receive(:shell_out!).with("mount").and_return(response) end def stub_enabled(provider, enabled_output) - response = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => enabled_output, :stderr => "") + response = double("Mixlib::ShellOut command", exitstatus: 0, stdout: enabled_output, stderr: "") expect(provider).to receive(:shell_out).with("lsfs -c #{@new_resource.mount_point}").and_return(response) end @@ -179,7 +179,7 @@ WRONG describe "remount_fs" do it "should remount resource if it is already mounted and it supports remounting" do - @new_resource.supports({ :remount => true }) + @new_resource.supports({ remount: true }) stub_mounted_enabled(@provider, @mounted_output, "") expect(@provider).to receive(:shell_out!).with("mount -o remount #{@new_resource.device} #{@new_resource.mount_point}") @@ -188,7 +188,7 @@ WRONG end it "should remount with new mount options if it is already mounted and it supports remounting" do - @new_resource.supports({ :remount => true }) + @new_resource.supports({ remount: true }) @new_resource.options("nodev,rw") stub_mounted_enabled(@provider, @mounted_output, "") diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index af7916e5bd..18523e3bc6 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -30,7 +30,7 @@ describe Chef::Provider::Mount::Mount do @new_resource.device_type :device @new_resource.fstype "ext3" - @new_resource.supports :remount => false + @new_resource.supports remount: false @provider = Chef::Provider::Mount::Mount.new(@new_resource, @run_context) @@ -42,7 +42,7 @@ describe Chef::Provider::Mount::Mount do describe "when discovering the current fs state" do before do - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "")) allow(::File).to receive(:foreach).with("/etc/fstab") end @@ -54,10 +54,10 @@ describe Chef::Provider::Mount::Mount do end it "should accept device_type :uuid", :not_supported_on_solaris do - @status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1) + @status = double(stdout: "/dev/sdz1\n", exitstatus: 1) @new_resource.device_type :uuid @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" - @stdout_findfs = double("STDOUT", :first => "/dev/sdz1") + @stdout_findfs = double("STDOUT", first: "/dev/sdz1") expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(@status) @provider.load_current_resource @provider.mountable? @@ -73,7 +73,7 @@ describe Chef::Provider::Mount::Mount do it "should ignore trailing slash and set mounted to true for network mount (#{type})" do @new_resource.device fs_spec - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n")) @provider.load_current_resource expect(@provider.current_resource.mounted).to be_truthy end @@ -94,7 +94,7 @@ describe Chef::Provider::Mount::Mount do end it "should raise an error if the mount device (uuid) does not exist", :not_supported_on_solaris do - status = double(:stdout => "", :exitstatus => 1) + status = double(stdout: "", exitstatus: 1) @new_resource.device_type :uuid @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status) @@ -121,13 +121,13 @@ describe Chef::Provider::Mount::Mount do end it "should set mounted true if the mount point is found in the mounts list" do - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdz1 on /tmp/foo type ext3 (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdz1 on /tmp/foo type ext3 (rw)\n")) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_truthy end it "should set mounted false if another mount point beginning with the same path is found in the mounts list" do - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdz1 on /tmp/foobar type ext3 (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdz1 on /tmp/foobar type ext3 (rw)\n")) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_falsey end @@ -139,7 +139,7 @@ describe Chef::Provider::Mount::Mount do allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true) allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target) - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{target} on /tmp/foo type ext3 (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{target} on /tmp/foo type ext3 (rw)\n")) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_truthy end @@ -153,7 +153,7 @@ describe Chef::Provider::Mount::Mount do allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true) allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target) - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{absolute_target} on /tmp/foo type ext3 (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{absolute_target} on /tmp/foo type ext3 (rw)\n")) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_truthy end @@ -162,7 +162,7 @@ describe Chef::Provider::Mount::Mount do mount = "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n" mount << "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n" - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => mount)) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: mount)) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_truthy end @@ -171,13 +171,13 @@ describe Chef::Provider::Mount::Mount do mount = "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n" mount << "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n" - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => mount)) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: mount)) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_falsey end it "mounted should be false if the mount point is not found in the mounts list" do - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdy1 on /tmp/foo type ext3 (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdy1 on /tmp/foo type ext3 (rw)\n")) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_falsey end @@ -307,7 +307,7 @@ describe Chef::Provider::Mount::Mount do end it "should mount the filesystem specified by uuid", :not_supported_on_solaris do - status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1) + status = double(stdout: "/dev/sdz1\n", exitstatus: 1) @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" @new_resource.device_type :uuid allow(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status) @@ -341,14 +341,14 @@ describe Chef::Provider::Mount::Mount do describe "remount_fs" do it "should use mount -o remount if remount is supported" do - @new_resource.supports({ :remount => true }) + @new_resource.supports({ remount: true }) @current_resource.mounted(true) expect(@provider).to receive(:shell_out!).with("mount -o remount,defaults #{@new_resource.mount_point}") @provider.remount_fs end it "should use mount -o remount with new mount options if remount is supported" do - @new_resource.supports({ :remount => true }) + @new_resource.supports({ remount: true }) options = "rw,noexec,noauto" @new_resource.options(%w{rw noexec noauto}) @current_resource.mounted(true) @@ -357,7 +357,7 @@ describe Chef::Provider::Mount::Mount do end it "should umount and mount if remount is not supported" do - @new_resource.supports({ :remount => false }) + @new_resource.supports({ remount: false }) @current_resource.mounted(true) expect(@provider).to receive(:umount_fs) expect(@provider).to receive(:sleep).with(1) @@ -499,7 +499,7 @@ describe Chef::Provider::Mount::Mount do context "when the device is described differently", :not_supported_on_solaris do it "should update the existing line" do @current_resource.enabled(true) - status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1) + status = double(stdout: "/dev/sdz1\n", exitstatus: 1) expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status) filesystems = [%q{/dev/sdy1 /tmp/foo ext3 defaults 1 2}, diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb index 2ec9feaf3b..e489b9001a 100644 --- a/spec/unit/provider/mount/solaris_spec.rb +++ b/spec/unit/provider/mount/solaris_spec.rb @@ -48,7 +48,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do new_resource.fsck_device fsck_device new_resource.fstype fstype new_resource.options options - new_resource.supports :remount => false + new_resource.supports remount: false new_resource end @@ -92,7 +92,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do before do stub_const("Chef::Provider::Mount::Solaris::VFSTAB", vfstab_file.path ) - allow(provider).to receive(:shell_out!).with("mount -v").and_return(OpenStruct.new(:stdout => mount_output)) + allow(provider).to receive(:shell_out!).with("mount -v").and_return(OpenStruct.new(stdout: mount_output)) allow(File).to receive(:symlink?).with(device).and_return(false) allow(File).to receive(:exist?).and_call_original # Tempfile.open on ruby 1.8.7 calls File.exist? allow(File).to receive(:exist?).with(device).and_return(true) diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb index fdb44836b5..6d55fb958c 100644 --- a/spec/unit/provider/mount/windows_spec.rb +++ b/spec/unit/provider/mount/windows_spec.rb @@ -99,10 +99,10 @@ describe Chef::Provider::Mount::Windows do end it "should mount the filesystem if it is not mounted" do - expect(@vol).to receive(:add).with(:remote => @new_resource.device, - :username => @new_resource.username, - :domainname => @new_resource.domain, - :password => @new_resource.password) + expect(@vol).to receive(:add).with(remote: @new_resource.device, + username: @new_resource.username, + domainname: @new_resource.domain, + password: @new_resource.password) @provider.mount_fs end diff --git a/spec/unit/provider/ohai_spec.rb b/spec/unit/provider/ohai_spec.rb index fad08ba589..518523dca2 100644 --- a/spec/unit/provider/ohai_spec.rb +++ b/spec/unit/provider/ohai_spec.rb @@ -29,16 +29,16 @@ describe Chef::Provider::Ohai do @platform_version = "example-platform" Chef::Config[:node_name] = @fqdn mock_ohai = { - :fqdn => @fqdn, - :hostname => @hostname, - :platform => @platform, - :platform_version => @platform_version, - :data => { - :origdata => "somevalue", + fqdn: @fqdn, + hostname: @hostname, + platform: @platform, + platform_version: @platform_version, + data: { + origdata: "somevalue", }, - :data2 => { - :origdata => "somevalue", - :newdata => "somevalue", + data2: { + origdata: "somevalue", + newdata: "somevalue", }, } allow(mock_ohai).to receive(:all_plugins).and_return(true) diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb index a1dcf3ecd6..dce52fd598 100644 --- a/spec/unit/provider/osx_profile_spec.rb +++ b/spec/unit/provider/osx_profile_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Provider::OsxProfile do let(:shell_out_success) do - double("shell_out", :exitstatus => 0, :error? => false) + double("shell_out", exitstatus: 0, error?: false) end describe "action_create" do let(:node) { Chef::Node.new } diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb index f15929880d..1047534f98 100644 --- a/spec/unit/provider/package/apt_spec.rb +++ b/spec/unit/provider/package/apt_spec.rb @@ -31,7 +31,7 @@ describe Chef::Provider::Package::Apt do allow(@run_context).to receive(:logger).and_return(logger) @new_resource = Chef::Resource::AptPackage.new("irssi", @run_context) - @status = double("Status", :exitstatus => 0) + @status = double("Status", exitstatus: 0) @provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context) @stdin = StringIO.new @stdout = <<-PKG_STATUS @@ -43,7 +43,7 @@ irssi: 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages PKG_STATUS @stderr = "" - @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0) + @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0) @timeout = 900 end @@ -52,8 +52,8 @@ irssi: it "should create a current resource with the name of the new_resource" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "policy", @new_resource.package_name, - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(@shell_out) @provider.load_current_resource @@ -89,20 +89,20 @@ sudo: policy_out = <<-POLICY_STDOUT N: Unable to locate package conic-smarms POLICY_STDOUT - policy = double(:stdout => policy_out, :exitstatus => 0) + policy = double(stdout: policy_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "policy", "conic-smarms", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(policy) showpkg_out = <<-SHOWPKG_STDOUT N: Unable to locate package conic-smarms SHOWPKG_STDOUT - showpkg = double(:stdout => showpkg_out, :exitstatus => 0) + showpkg = double(stdout: showpkg_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "showpkg", "conic-smarms", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(showpkg) @provider.load_current_resource end @@ -117,11 +117,11 @@ libmysqlclient15-dev: Candidate: (none) Version table: VPKG_STDOUT - virtual_package = double(:stdout => virtual_package_out, :exitstatus => 0) + virtual_package = double(stdout: virtual_package_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "policy", "libmysqlclient15-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(virtual_package) showpkg_out = <<-SHOWPKG_STDOUT Package: libmysqlclient15-dev @@ -141,11 +141,11 @@ libmysqlclient-dev 5.1.41-3ubuntu12.7 libmysqlclient-dev 5.1.41-3ubuntu12.10 libmysqlclient-dev 5.1.41-3ubuntu12 SHOWPKG_STDOUT - showpkg = double(:stdout => showpkg_out, :exitstatus => 0) + showpkg = double(stdout: showpkg_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "showpkg", "libmysqlclient15-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(showpkg) real_package_out = <<-RPKG_STDOUT libmysqlclient-dev: @@ -160,11 +160,11 @@ libmysqlclient-dev: 5.1.41-3ubuntu12 0 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages RPKG_STDOUT - real_package = double(:stdout => real_package_out, :exitstatus => 0) + real_package = double(stdout: real_package_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "policy", "libmysqlclient-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(real_package) @provider.load_current_resource end @@ -177,11 +177,11 @@ mp3-decoder: Candidate: (none) Version table: VPKG_STDOUT - virtual_package = double(:stdout => virtual_package_out, :exitstatus => 0) + virtual_package = double(stdout: virtual_package_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "policy", "mp3-decoder", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(virtual_package) showpkg_out = <<-SHOWPKG_STDOUT Package: mp3-decoder @@ -204,11 +204,11 @@ opencubicplayer 1:0.1.17-2 mpg321 0.2.10.6 mpg123 1.12.1-0ubuntu1 SHOWPKG_STDOUT - showpkg = double(:stdout => showpkg_out, :exitstatus => 0) + showpkg = double(stdout: showpkg_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "showpkg", "mp3-decoder", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(showpkg) expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package) end @@ -221,8 +221,8 @@ mpg123 1.12.1-0ubuntu1 @new_resource.provider(nil) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "-o", "APT::Default-Release=lenny-backports", "policy", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(@shell_out) @provider.load_current_resource end @@ -231,8 +231,8 @@ mpg123 1.12.1-0ubuntu1 @new_resource.source "pluto" expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "policy", @new_resource.package_name, - :env => { "DEBIAN_FRONTEND" => "noninteractive" } , - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" } , + timeout: @timeout ).and_return(@shell_out) expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) end @@ -260,8 +260,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get install with the package name and version" do expect(@provider).to receive(:shell_out_compacted!). with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.install_package(["irssi"], ["0.8.12-7"]) end @@ -269,8 +269,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get install with the package name and version and options if specified" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "--force-yes", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @new_resource.options("--force-yes") @provider.install_package(["irssi"], ["0.8.12-7"]) @@ -285,8 +285,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "-o", "APT::Default-Release=lenny-backports", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.install_package(["irssi"], ["0.8.12-7"]) @@ -295,8 +295,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get install with the package name and quotes options if specified" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "--force-yes", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confnew", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @new_resource.options('--force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew"') @provider.install_package(["irssi"], ["0.8.12-7"]) @@ -316,8 +316,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get remove with the package name" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "remove", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.remove_package(["irssi"], ["0.8.12-7"]) end @@ -325,8 +325,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get remove with the package name and options if specified" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "--force-yes", "remove", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @new_resource.options("--force-yes") @@ -339,8 +339,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get purge with the package name" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "purge", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.purge_package(["irssi"], ["0.8.12-7"]) end @@ -348,8 +348,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get purge with the package name and options if specified" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "--force-yes", "purge", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @new_resource.options("--force-yes") @@ -367,8 +367,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:shell_out_compacted!).with( "debconf-set-selections", "/tmp/irssi-0.8.12-7.seed", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.preseed_package(file) @@ -377,8 +377,8 @@ mpg123 1.12.1-0ubuntu1 it "should run debconf-set-selections on the preseed file if it has changed" do expect(@provider).to receive(:shell_out_compacted!).with( "debconf-set-selections", "/tmp/irssi-0.8.12-7.seed", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) file = @provider.get_preseed_file("irssi", "0.8.12-7") @provider.preseed_package(file) @@ -398,8 +398,8 @@ mpg123 1.12.1-0ubuntu1 it "should run dpkg-reconfigure package" do expect(@provider).to receive(:shell_out_compacted!).with( "dpkg-reconfigure", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.reconfig_package("irssi", "0.8.12-7") end @@ -409,8 +409,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-mark hold package" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-mark", "hold", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.lock_package("irssi", "0.8.12-7") end @@ -430,8 +430,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-mark unhold package" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-mark", "unhold", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.unlock_package("irssi", "0.8.12-7") end @@ -452,8 +452,8 @@ mpg123 1.12.1-0ubuntu1 @provider.package_data["libmysqlclient15-dev"][:virtual] = true expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "libmysqlclient15-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.install_package(["libmysqlclient15-dev"], ["not_a_real_version"]) end @@ -464,8 +464,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:resolve_virtual_package_name).with("libmysqlclient15-dev").and_return("libmysqlclient-dev") expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "remove", "libmysqlclient-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.remove_package(["libmysqlclient15-dev"], ["not_a_real_version"]) end @@ -476,8 +476,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:resolve_virtual_package_name).with("libmysqlclient15-dev").and_return("libmysqlclient-dev") expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "purge", "libmysqlclient-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.purge_package(["libmysqlclient15-dev"], ["not_a_real_version"]) end @@ -488,8 +488,8 @@ mpg123 1.12.1-0ubuntu1 # https://github.com/chef/chef/issues/2914 expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "libmysqlclient15-dev", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.install_package(["libmysqlclient15-dev", "irssi"], ["not_a_real_version", "0.8.12-7"]) end @@ -511,8 +511,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:version_compare).and_return(-1) expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.run_action(:upgrade) end @@ -523,8 +523,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).not_to receive(:version_compare) expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.run_action(:upgrade) end diff --git a/spec/unit/provider/package/bff_spec.rb b/spec/unit/provider/package/bff_spec.rb index df407914d3..7606092762 100644 --- a/spec/unit/provider/package/bff_spec.rb +++ b/spec/unit/provider/package/bff_spec.rb @@ -38,11 +38,11 @@ describe Chef::Provider::Package::Bff do @bffinfo = "/usr/lib/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX: /etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:" - @empty_status = double("Status", :stdout => "", :exitstatus => 0) + @empty_status = double("Status", stdout: "", exitstatus: 0) end it "should create a current resource with the name of new_resource" do - status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + status = double("Status", stdout: @bffinfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status) @provider.load_current_resource @@ -50,7 +50,7 @@ describe Chef::Provider::Package::Bff do end it "should set the current resource bff package name to the new resource bff package name" do - status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + status = double("Status", stdout: @bffinfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status) @provider.load_current_resource @@ -66,7 +66,7 @@ describe Chef::Provider::Package::Bff do end it "should get the source package version from lslpp if provided" do - status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + status = double("Status", stdout: @bffinfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status) @provider.load_current_resource @@ -78,7 +78,7 @@ describe Chef::Provider::Package::Bff do it "should warn if the package is not a fileset" do info = "samba.base:samba.base.samples:3.3.12.0::COMMITTED:I:Samba for AIX: /etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:" - status = double("Status", :stdout => info, :exitstatus => 0) + status = double("Status", stdout: info, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status) expect(logger).to receive(:warn).once.with(%r{bff package by product name}) @@ -89,7 +89,7 @@ describe Chef::Provider::Package::Bff do end it "should return the current version installed if found by lslpp" do - status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + status = double("Status", stdout: @bffinfo, exitstatus: 0) @stdout = StringIO.new(@bffinfo) @stdin, @stderr = StringIO.new, StringIO.new expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) @@ -99,7 +99,7 @@ describe Chef::Provider::Package::Bff do end it "should raise an exception if the source is not set but we are installing" do - status = double("Status", :stdout => "", :exitstatus => 1, :format_for_exception => "") + status = double("Status", stdout: "", exitstatus: 1, format_for_exception: "") @new_resource = Chef::Resource::Package.new("samba.base") @provider = Chef::Provider::Package::Bff.new(@new_resource, @run_context) allow(@provider).to receive(:shell_out_compacted).and_return(status) @@ -107,13 +107,13 @@ describe Chef::Provider::Package::Bff do end it "should raise an exception if installp/lslpp fails to run" do - status = double(:stdout => "", :exitstatus => -1, :format_for_exception => "") + status = double(stdout: "", exitstatus: -1, format_for_exception: "") allow(@provider).to receive(:shell_out_compacted).and_return(status) expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package) end it "should return a current resource with a nil version if the package is not found" do - status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + status = double("Status", stdout: @bffinfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status) @provider.load_current_resource @@ -123,7 +123,7 @@ describe Chef::Provider::Package::Bff do it "should raise an exception if the source doesn't provide the requested package" do wrongbffinfo = "/usr/lib/objrepos:openssl.base:0.9.8.2400::COMMITTED:I:Open Secure Socket Layer: /etc/objrepos:openssl.base:0.9.8.2400::COMMITTED:I:Open Secure Socket Layer:" - status = double("Status", :stdout => wrongbffinfo, :exitstatus => 0) + status = double("Status", stdout: wrongbffinfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package) end @@ -137,13 +137,13 @@ describe Chef::Provider::Package::Bff do end it "should lookup the candidate_version if the variable is not already set" do - status = double(:stdout => "", :exitstatus => 0) + status = double(stdout: "", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) @provider.candidate_version end it "should throw and exception if the exitstatus is not 0" do - @status = double(:stdout => "", :exitstatus => 1, :format_for_exception => "") + @status = double(stdout: "", exitstatus: 1, format_for_exception: "") allow(@provider).to receive(:shell_out_compacted).and_return(@status) expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package) end diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb index a0a73c445a..40fca821d9 100644 --- a/spec/unit/provider/package/chocolatey_spec.rb +++ b/spec/unit/provider/package/chocolatey_spec.rb @@ -45,8 +45,8 @@ ConEmu|15.10.25.0 before do allow(provider).to receive(:choco_install_path).and_return(choco_install_path) allow(provider).to receive(:choco_exe).and_return(choco_exe) - local_list_obj = double(:stdout => local_list_stdout) - allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -l -r", { :returns => [0], :timeout => timeout }).and_return(local_list_obj) + local_list_obj = double(stdout: local_list_stdout) + allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -l -r", { returns: [0], timeout: timeout }).and_return(local_list_obj) end def allow_remote_list(package_names, args = nil) @@ -60,7 +60,7 @@ munin-node|1.6.1.20130823 EOF remote_list_obj = double(stdout: remote_list_stdout) package_names.each do |pkg| - allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -r #{pkg}#{args}", { :returns => [0], timeout: timeout }).and_return(remote_list_obj) + allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -r #{pkg}#{args}", { returns: [0], timeout: timeout }).and_return(remote_list_obj) end end @@ -182,7 +182,7 @@ munin-node|1.6.1.20130823 it "should install a single package" do allow_remote_list(["git"]) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -193,7 +193,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git"]) new_resource.timeout(timeout) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -222,7 +222,7 @@ munin-node|1.6.1.20130823 new_resource.package_name("ConEmu") new_resource.version("15.10.25.1") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -235,7 +235,7 @@ munin-node|1.6.1.20130823 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_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -245,7 +245,7 @@ munin-node|1.6.1.20130823 new_resource.package_name("conemu") new_resource.version("15.10.25.1") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -255,8 +255,8 @@ munin-node|1.6.1.20130823 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_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double) - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -265,7 +265,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git", "munin-node"]) new_resource.package_name(["git", "munin-node"]) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git munin-node", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git munin-node", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -275,7 +275,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git"], " -source localpackages") new_resource.source("localpackages") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -source localpackages git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -source localpackages git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -285,7 +285,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git"]) new_resource.options("-force") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -force git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -force git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -319,7 +319,7 @@ munin-node|1.6.1.20130823 it "should install a package that is not installed" do allow_remote_list(["git"]) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -328,7 +328,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["ConEmu"]) new_resource.package_name("ConEmu") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -337,7 +337,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["conemu"]) new_resource.package_name("conemu") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -346,7 +346,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["chocolatey"]) new_resource.package_name("chocolatey") provider.load_current_resource - expect(provider).not_to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y chocolatey", { :returns => [0], :timeout => timeout }) + expect(provider).not_to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y chocolatey", { returns: [0], timeout: timeout }) provider.run_action(:upgrade) expect(new_resource).not_to be_updated_by_last_action end @@ -355,7 +355,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git"]) new_resource.version("2.6.2") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y --version 2.6.2 git", { :returns => [0], :timeout => timeout }) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y --version 2.6.2 git", { returns: [0], timeout: timeout }) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -363,7 +363,7 @@ munin-node|1.6.1.20130823 it "upgrading multiple packages uses a single command" do allow_remote_list(%w{conemu git}) new_resource.package_name(%w{conemu git}) - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -415,7 +415,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["ConEmu"]) new_resource.package_name("ConEmu") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y ConEmu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y ConEmu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -424,7 +424,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["conemu"]) new_resource.package_name("conemu") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -434,7 +434,7 @@ munin-node|1.6.1.20130823 allow_remote_list(%w{git conemu}) new_resource.package_name(%w{git conemu}) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -457,7 +457,7 @@ describe "behavior when Chocolatey is not installed" do provider.instance_variable_set("@choco_install_path", nil) # we don't care what this returns, but we have to let it be called. - allow(provider).to receive(:shell_out_compacted!).and_return(double(:stdout => "")) + allow(provider).to receive(:shell_out_compacted!).and_return(double(stdout: "")) end let(:error_regex) do diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb index c99e91dd46..cf8f5097f0 100644 --- a/spec/unit/provider/package/dpkg_spec.rb +++ b/spec/unit/provider/package/dpkg_spec.rb @@ -31,7 +31,7 @@ describe Chef::Provider::Package::Dpkg do let(:provider) { Chef::Provider::Package::Dpkg.new(new_resource, run_context) } let(:dpkg_deb_version) { "1.11.4" } - let(:dpkg_deb_status) { status = double(:stdout => "#{package}\t#{dpkg_deb_version}", :exitstatus => 0) } + let(:dpkg_deb_status) { status = double(stdout: "#{package}\t#{dpkg_deb_version}", exitstatus: 0) } let(:dpkg_s_version) { "1.11.4-1ubuntu1" } let(:dpkg_s_status) do stdout = <<-DPKG_S @@ -47,7 +47,7 @@ Config-Version: #{dpkg_s_version} Depends: libc6 (>= 2.8~20080505), libssl0.9.8 (>= 0.9.8f-5) Conflicts: wget-ssl DPKG_S - status = double(:stdout => stdout, :exitstatus => 1) + status = double(stdout: stdout, exitstatus: 1) end before(:each) do @@ -112,7 +112,7 @@ Conflicts: wget-ssl describe "gets the source package version from dpkg-deb" do def check_version(version) - status = double(:stdout => "wget\t#{version}", :exitstatus => 0) + status = double(stdout: "wget\t#{version}", exitstatus: 0) expect(provider).to receive(:shell_out_compacted!).with("dpkg-deb", "-W", source, timeout: 900).and_return(status) provider.load_current_resource expect(provider.current_resource.package_name).to eq(["wget"]) @@ -206,7 +206,7 @@ Section: ruby end it "should raise an exception if dpkg-deb -W fails to run" do - status = double(:stdout => "", :exitstatus => -1) + status = double(stdout: "", exitstatus: -1) expect(provider).to receive(:shell_out_compacted!).with("dpkg-deb", "-W", "/tmp/wget_1.11.4-1ubuntu1_amd64.deb", timeout: 900).and_raise(Mixlib::ShellOut::ShellCommandFailed) expect { provider.load_current_resource }.to raise_error(Mixlib::ShellOut::ShellCommandFailed) end diff --git a/spec/unit/provider/package/freebsd/pkg_spec.rb b/spec/unit/provider/package/freebsd/pkg_spec.rb index 259bd7a4c4..6ad6813503 100644 --- a/spec/unit/provider/package/freebsd/pkg_spec.rb +++ b/spec/unit/provider/package/freebsd/pkg_spec.rb @@ -78,21 +78,21 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do end it "should return the version number when it is installed" do - pkg_info = OpenStruct.new(:stdout => "zsh-4.3.6_7") + pkg_info = OpenStruct.new(stdout: "zsh-4.3.6_7") expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info) allow(@provider).to receive(:package_name).and_return("zsh") expect(@provider.current_installed_version).to eq("4.3.6_7") end it "does not set the current version number when the package is not installed" do - pkg_info = OpenStruct.new(:stdout => "") + pkg_info = OpenStruct.new(stdout: "") expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info) allow(@provider).to receive(:package_name).and_return("zsh") expect(@provider.current_installed_version).to be_nil end it "should return the port path for a valid port name" do - whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh") + whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh") expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis) allow(@provider).to receive(:port_name).and_return("zsh") expect(@provider.port_path).to eq("/usr/ports/shells/zsh") @@ -101,7 +101,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do # Not happy with the form of these tests as they are far too closely tied to the implementation and so very fragile. it "should return the ports candidate version when given a valid port path" do allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh") - make_v = OpenStruct.new(:stdout => "4.3.6\n", :exitstatus => 0) + make_v = OpenStruct.new(stdout: "4.3.6\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PORTVERSION", { cwd: "/usr/ports/shells/zsh", returns: [0, 1], env: nil, timeout: 900 }).and_return(make_v) expect(@provider.ports_candidate_version).to eq("4.3.6") end @@ -109,7 +109,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do it "should figure out the package name when we have ports" do allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true) allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh") - make_v = OpenStruct.new(:stdout => "zsh-4.3.6_7\n", :exitstatus => 0) + make_v = OpenStruct.new(stdout: "zsh-4.3.6_7\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PKGNAME", { cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900 }).and_return(make_v) #@provider.should_receive(:ports_makefile_variable_value).with("PKGNAME").and_return("zsh-4.3.6_7") expect(@provider.package_name).to eq("zsh") @@ -118,7 +118,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do describe Chef::Provider::Package::Freebsd::Pkg, "install_package" do before(:each) do - @cmd_result = OpenStruct.new(:status => true) + @cmd_result = OpenStruct.new(status: true) @provider.current_resource = @current_resource allow(@provider).to receive(:package_name).and_return("zsh") @@ -141,7 +141,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do end it "should figure out the port path from the package_name using whereis" do - whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh") + whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh") expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis) expect(@provider.port_path).to eq("/usr/ports/shells/zsh") end @@ -174,7 +174,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do allow(@provider).to receive(:package_name).and_return("ruby18-iconv") allow(@provider).to receive(:latest_link_name).and_return("ruby18-iconv") - @install_result = OpenStruct.new(:status => true) + @install_result = OpenStruct.new(status: true) end it "should run pkg_add -r with the package name" do @@ -185,7 +185,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do describe Chef::Provider::Package::Freebsd::Pkg, "remove_package" do before(:each) do - @pkg_delete = OpenStruct.new(:status => true) + @pkg_delete = OpenStruct.new(status: true) @new_resource.version "4.3.6_7" @current_resource.version "4.3.6_7" @provider.current_resource = @current_resource @@ -212,14 +212,14 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do end it "should return the port path for a valid port name" do - whereis = OpenStruct.new(:stdout => "bonnie++: /usr/ports/benchmarks/bonnie++") + whereis = OpenStruct.new(stdout: "bonnie++: /usr/ports/benchmarks/bonnie++") expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "bonnie++", env: nil, timeout: 900).and_return(whereis) allow(@provider).to receive(:port_name).and_return("bonnie++") expect(@provider.port_path).to eq("/usr/ports/benchmarks/bonnie++") end it "should return the version number when it is installed" do - pkg_info = OpenStruct.new(:stdout => "bonnie++-1.96") + pkg_info = OpenStruct.new(stdout: "bonnie++-1.96") expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "bonnie++*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info) allow(@provider).to receive(:package_name).and_return("bonnie++") expect(@provider.current_installed_version).to eq("1.96") @@ -252,7 +252,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do allow(@provider).to receive(:package_name).and_return("perl") allow(@provider).to receive(:latest_link_name).and_return("perl") - cmd = OpenStruct.new(:status => true) + cmd = OpenStruct.new(status: true) expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "perl", env: nil, timeout: 900).and_return(cmd) @provider.install_package("perl5.8", "5.8.8_1") end @@ -266,7 +266,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do allow(@provider).to receive(:package_name).and_return("mysql-server") allow(@provider).to receive(:latest_link_name).and_return("mysql50-server") - cmd = OpenStruct.new(:status => true) + cmd = OpenStruct.new(status: true) expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "mysql50-server", env: nil, timeout: 900).and_return(cmd) @provider.install_package("mysql50-server", "5.0.45_1") end diff --git a/spec/unit/provider/package/freebsd/pkgng_spec.rb b/spec/unit/provider/package/freebsd/pkgng_spec.rb index 2fdcb87758..a4da5bb235 100644 --- a/spec/unit/provider/package/freebsd/pkgng_spec.rb +++ b/spec/unit/provider/package/freebsd/pkgng_spec.rb @@ -63,7 +63,7 @@ describe Chef::Provider::Package::Freebsd::Port do describe "determining current installed version" do before(:each) do allow(@provider).to receive(:supports_pkgng?) - @pkg_info = OpenStruct.new(:stdout => "zsh-3.1.7\nVersion : 3.1.7\n") + @pkg_info = OpenStruct.new(stdout: "zsh-3.1.7\nVersion : 3.1.7\n") end it "should query pkg database" do @@ -74,14 +74,14 @@ describe Chef::Provider::Package::Freebsd::Port do describe "determining candidate version" do it "should query repository" do - pkg_query = OpenStruct.new(:stdout => "5.0.5\n", :exitstatus => 0) + pkg_query = OpenStruct.new(stdout: "5.0.5\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with("pkg", "rquery", "%v", "zsh", env: nil, timeout: 900).and_return(pkg_query) expect(@provider.candidate_version).to eq("5.0.5") end it "should query specified repository when given option" do @provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration. - pkg_query = OpenStruct.new(:stdout => "5.0.3\n", :exitstatus => 0) + pkg_query = OpenStruct.new(stdout: "5.0.3\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with("pkg", "rquery", "-r", "LocalMirror", "%v", "zsh", env: nil, timeout: 900).and_return(pkg_query) expect(@provider.candidate_version).to eq("5.0.3") end @@ -94,7 +94,7 @@ describe Chef::Provider::Package::Freebsd::Port do describe "installing a binary package" do before(:each) do - @install_result = OpenStruct.new(:status => true) + @install_result = OpenStruct.new(status: true) end it "should handle package source from file" do @@ -129,7 +129,7 @@ describe Chef::Provider::Package::Freebsd::Port do describe "removing a binary package" do before(:each) do - @install_result = OpenStruct.new(:status => true) + @install_result = OpenStruct.new(status: true) end it "should call pkg delete" do diff --git a/spec/unit/provider/package/freebsd/port_spec.rb b/spec/unit/provider/package/freebsd/port_spec.rb index 26a960dedc..1406235725 100644 --- a/spec/unit/provider/package/freebsd/port_spec.rb +++ b/spec/unit/provider/package/freebsd/port_spec.rb @@ -62,7 +62,7 @@ describe Chef::Provider::Package::Freebsd::Port do describe "determining current installed version" do before(:each) do - @pkg_info = OpenStruct.new(:stdout => "zsh-3.1.7\n") + @pkg_info = OpenStruct.new(stdout: "zsh-3.1.7\n") end it "should check 'pkg_info' if system uses pkg_* tools" do @@ -73,7 +73,7 @@ describe Chef::Provider::Package::Freebsd::Port do end it "should check 'pkg info' if make supports WITH_PKGNG if freebsd version is < 1000017" do - pkg_enabled = OpenStruct.new(:stdout => "yes\n") + pkg_enabled = OpenStruct.new(stdout: "yes\n") [1000016, 1000000, 901503, 902506, 802511].each do |freebsd_version| @node.automatic_attrs[:os_version] = freebsd_version expect(@new_resource).to receive(:shell_out_compacted!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled) @@ -92,7 +92,7 @@ describe Chef::Provider::Package::Freebsd::Port do describe "determining candidate version" do before(:each) do - @port_version = OpenStruct.new(:stdout => "5.0.5\n", :exitstatus => 0) + @port_version = OpenStruct.new(stdout: "5.0.5\n", exitstatus: 0) end it "should return candidate version if port exists" do @@ -121,13 +121,13 @@ describe Chef::Provider::Package::Freebsd::Port do end it "should query system for path given just a name" do - whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh\n") + whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh\n") expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis) expect(@provider.port_dir).to eq("/usr/ports/shells/zsh") end it "should raise exception if not found" do - whereis = OpenStruct.new(:stdout => "zsh:\n") + whereis = OpenStruct.new(stdout: "zsh:\n") expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis) expect { @provider.port_dir }.to raise_error(Chef::Exceptions::Package, "Could not find port with the name zsh") end @@ -135,13 +135,13 @@ describe Chef::Provider::Package::Freebsd::Port do describe "building a binary package" do before(:each) do - @install_result = OpenStruct.new(:status => true) + @install_result = OpenStruct.new(status: true) end it "should run make install in port directory" do allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh") expect(@provider).to receive(:shell_out_compacted!). - with("make", "-DBATCH", "install", "clean", :timeout => 1800, :cwd => "/usr/ports/shells/zsh", :env => nil). + with("make", "-DBATCH", "install", "clean", timeout: 1800, cwd: "/usr/ports/shells/zsh", env: nil). and_return(@install_result) @provider.install_package("zsh", "5.0.5") end @@ -149,13 +149,13 @@ describe Chef::Provider::Package::Freebsd::Port do describe "removing a binary package" do before(:each) do - @install_result = OpenStruct.new(:status => true) + @install_result = OpenStruct.new(status: true) end it "should run make deinstall in port directory" do allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh") expect(@provider).to receive(:shell_out_compacted!). - with("make", "deinstall", :timeout => 300, :cwd => "/usr/ports/shells/zsh", :env => nil). + with("make", "deinstall", timeout: 300, cwd: "/usr/ports/shells/zsh", env: nil). and_return(@install_result) @provider.remove_package("zsh", "5.0.5") end diff --git a/spec/unit/provider/package/homebrew_spec.rb b/spec/unit/provider/package/homebrew_spec.rb index 833fa7bd3e..903aebc93e 100644 --- a/spec/unit/provider/package/homebrew_spec.rb +++ b/spec/unit/provider/package/homebrew_spec.rb @@ -173,16 +173,16 @@ describe Chef::Provider::Package::Homebrew do describe "brew" do before do expect(provider).to receive(:find_homebrew_uid).and_return(homebrew_uid) - expect(Etc).to receive(:getpwuid).with(homebrew_uid).and_return(OpenStruct.new(:name => "name", :dir => "/")) + expect(Etc).to receive(:getpwuid).with(homebrew_uid).and_return(OpenStruct.new(name: "name", dir: "/")) end it "passes a single to the brew command and return stdout" do - allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo")) + allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "zombo")) expect(provider.brew).to eql("zombo") end it "takes multiple arguments as an array" do - allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "homestarrunner")) + allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "homestarrunner")) expect(provider.brew("info", "opts", "bananas")).to eql("homestarrunner") end @@ -190,7 +190,7 @@ describe Chef::Provider::Package::Homebrew do let(:new_resource) { Chef::Resource::Package.new("emacs") } it "does not try to read homebrew_user from Package, which does not have it" do - allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo")) + allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "zombo")) expect(provider.brew).to eql("zombo") end end diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb index eac0fd90f3..46f0c72399 100644 --- a/spec/unit/provider/package/ips_spec.rb +++ b/spec/unit/provider/package/ips_spec.rb @@ -41,7 +41,7 @@ installed on the system. Try specifying -r to query remotely: crypto/gnupg PKG_STATUS - OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 1) + OpenStruct.new(stdout: stdout, stdin: stdin, stderr: stderr, status: @status, exitstatus: 1) end def remote_output @@ -59,7 +59,7 @@ Packaging Date: April 1, 2012 05:55:52 PM PKG_STATUS stdin = StringIO.new stderr = "" - OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 0) + OpenStruct.new(stdout: stdout, stdin: stdin, stderr: stderr, status: @status, exitstatus: 0) end context "when loading current resource" do diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb index 04e0a9177e..54c5340d72 100644 --- a/spec/unit/provider/package/macports_spec.rb +++ b/spec/unit/provider/package/macports_spec.rb @@ -75,13 +75,13 @@ The following ports are currently installed: openssl @0.9.8k_0 (active) EOF - status = double(:stdout => stdout, :exitstatus => 0) + status = double(stdout: stdout, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.current_installed_version).to eq("0.9.8k_0") end it "should return nil if a package is not currently installed" do - status = double(:stdout => " \n", :exitstatus => 0) + status = double(stdout: " \n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.current_installed_version).to be_nil end @@ -89,13 +89,13 @@ EOF describe "macports_candidate_version" do it "should return the latest available version of a given package" do - status = double(:stdout => "version: 4.2.7\n", :exitstatus => 0) + status = double(stdout: "version: 4.2.7\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.macports_candidate_version).to eq("4.2.7") end it "should return nil if there is no version for a given package" do - status = double(:stdout => "Error: port fadsfadsfads not found\n", :exitstatus => 0) + status = double(stdout: "Error: port fadsfadsfads not found\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.macports_candidate_version).to be_nil end diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb index 07950acf6e..01d6571f65 100644 --- a/spec/unit/provider/package/openbsd_spec.rb +++ b/spec/unit/provider/package/openbsd_spec.rb @@ -45,7 +45,7 @@ describe Chef::Provider::Package::Openbsd do context "when not already installed" do before do - allow(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{name}->0", anything()).and_return(instance_double("shellout", :stdout => "")) + allow(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{name}->0", anything()).and_return(instance_double("shellout", stdout: "")) end context "when there is a single candidate" do @@ -53,11 +53,11 @@ describe Chef::Provider::Package::Openbsd do context "when source is not provided" do it "should run the installation command" do expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return( - instance_double("shellout", :stdout => "#{name}-#{version}\n")) + instance_double("shellout", stdout: "#{name}-#{version}\n")) expect(provider).to receive(:shell_out_compacted!).with( "pkg_add", "-r", "#{name}-#{version}", - { :env => { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 } - ) { OpenStruct.new :status => true } + { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 } + ) { OpenStruct.new status: true } provider.run_action(:install) end end @@ -70,7 +70,7 @@ describe Chef::Provider::Package::Openbsd do context "if no version is specified" do it "should raise an exception" do expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return( - instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n")) + instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n")) expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /multiple matching candidates/) end end @@ -83,13 +83,13 @@ describe Chef::Provider::Package::Openbsd do context "if no version is specified" do it "should run the installation command" do - expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{package_name}->0", anything()).and_return(instance_double("shellout", :stdout => "")) + expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{package_name}->0", anything()).and_return(instance_double("shellout", stdout: "")) expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return( - instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor}\n")) + instance_double("shellout", stdout: "#{name}-#{version}-#{flavor}\n")) expect(provider).to receive(:shell_out_compacted!).with( "pkg_add", "-r", "#{name}-#{version}-#{flavor}", { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 } - ) { OpenStruct.new :status => true } + ) { OpenStruct.new status: true } provider.run_action(:install) end end @@ -99,13 +99,13 @@ describe Chef::Provider::Package::Openbsd do context "if a version is specified" do it "should use the flavor from the version" do expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", "#{name}-#{version}-#{flavor_b}", anything()).and_return( - instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n")) + instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n")) new_resource.version("#{version}-#{flavor_b}") expect(provider).to receive(:shell_out_compacted!).with( "pkg_add", "-r", "#{name}-#{version}-#{flavor_b}", { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 } - ) { OpenStruct.new :status => true } + ) { OpenStruct.new status: true } provider.run_action(:install) end end @@ -124,7 +124,7 @@ describe Chef::Provider::Package::Openbsd do it "should run the command to delete the installed package" do expect(@provider).to receive(:shell_out_compacted!).with( "pkg_delete", @name, env: nil, timeout: 900 - ) { OpenStruct.new :status => true } + ) { OpenStruct.new status: true } @provider.remove_package(@name, nil) end end diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb index d41df8c24b..9fbba202f5 100644 --- a/spec/unit/provider/package/pacman_spec.rb +++ b/spec/unit/provider/package/pacman_spec.rb @@ -26,7 +26,7 @@ describe Chef::Provider::Package::Pacman do @new_resource = Chef::Resource::Package.new("nano") @current_resource = Chef::Resource::Package.new("nano") - @status = double(:stdout => "", :exitstatus => 0) + @status = double(stdout: "", exitstatus: 0) @provider = Chef::Provider::Package::Pacman.new(@new_resource, @run_context) allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource) @@ -88,14 +88,14 @@ Install Script : Yes Description : Pico editor clone with enhancements PACMAN - status = double(:stdout => stdout, :exitstatus => 0) + status = double(stdout: stdout, exitstatus: 0) allow(@provider).to receive(:shell_out_compacted).and_return(status) @provider.load_current_resource expect(@current_resource.version).to eq("2.2.2-1") end it "should set the candidate version if pacman has one" do - status = double(:stdout => "core nano 2.2.3-1", :exitstatus => 0) + status = double(stdout: "core nano 2.2.3-1", exitstatus: 0) allow(@provider).to receive(:shell_out_compacted).and_return(status) @provider.load_current_resource expect(@provider.candidate_version).to eql("2.2.3-1") @@ -120,7 +120,7 @@ Include = /etc/pacman.d/mirrorlist Include = /etc/pacman.d/mirrorlist PACMAN_CONF - status = double(:stdout => "customrepo nano 1.2.3-4", :exitstatus => 0) + status = double(stdout: "customrepo nano 1.2.3-4", exitstatus: 0) allow(::File).to receive(:exist?).with("/etc/pacman.conf").and_return(true) allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(@pacman_conf) allow(@provider).to receive(:shell_out_compacted).and_return(status) diff --git a/spec/unit/provider/package/paludis_spec.rb b/spec/unit/provider/package/paludis_spec.rb index 5481a33c0d..a9ae5bf9d3 100644 --- a/spec/unit/provider/package/paludis_spec.rb +++ b/spec/unit/provider/package/paludis_spec.rb @@ -42,7 +42,7 @@ user/ntp 0 installed-accounts net/ntp 4.2.6_p5-r1 installed PKG_STATUS @pid = 12345 - @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0) + @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0) end context "when loading current resource" do @@ -86,12 +86,12 @@ INSTALLED context "when installing a package" do it "should run pkg install with the package name and version" do - expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 }) + expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 }) @provider.install_package("net/ntp", "4.2.6_p5-r2") end it "should run pkg install with the package name and version and options if specified" do - expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "--preserve-world", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 }) + expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "--preserve-world", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 }) @new_resource.options "--preserve-world" @provider.install_package("net/ntp", "4.2.6_p5-r2") end @@ -101,7 +101,7 @@ INSTALLED sys-process/lsof 4.87 arbor sys-process/lsof 4.87 x86_64 PKG_STATUS - expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=sys-process/lsof-4.87", { :timeout => @new_resource.timeout || 900 }) + expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=sys-process/lsof-4.87", { timeout: @new_resource.timeout || 900 }) @provider.install_package("sys-process/lsof", "4.87") end @@ -119,7 +119,7 @@ PKG_STATUS context "when upgrading a package" do it "should run pkg install with the package name and version" do - expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 }) + expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 }) @provider.upgrade_package("net/ntp", "4.2.6_p5-r2") end end diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb index 7bf8e7f2e8..889053e826 100644 --- a/spec/unit/provider/package/portage_spec.rb +++ b/spec/unit/provider/package/portage_spec.rb @@ -113,19 +113,19 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do end it "should throw an exception if the exitstatus is not 0" do - status = double(:stdout => "", :stderr => "", :exitstatus => 1) + status = double(stdout: "", stderr: "", exitstatus: 1) allow(@provider).to receive(:shell_out_compacted).and_return(status) expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package) end it "should find the candidate_version if a category is specifed and there are no duplicates" do - status = double(:stdout => "dev-vcs/git-2.16.2", :exitstatus => 0) + status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.candidate_version).to eq("2.16.2") end it "should find the candidate_version if a category is not specifed and there are no duplicates" do - status = double(:stdout => "dev-vcs/git-2.16.2", :exitstatus => 0) + status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0) @provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.candidate_version).to eq("2.16.2") @@ -139,7 +139,7 @@ You specified an unqualified atom that matched multiple packages: Please use a more specific atom. EOF - status = double(:stdout => "", :stderr => stderr_output, :exitstatus => 1) + status = double(stdout: "", stderr: stderr_output, exitstatus: 1) @provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package) diff --git a/spec/unit/provider/package/powershell_spec.rb b/spec/unit/provider/package/powershell_spec.rb index 63f611ac23..c7a16acaa2 100644 --- a/spec/unit/provider/package/powershell_spec.rb +++ b/spec/unit/provider/package/powershell_spec.rb @@ -34,63 +34,63 @@ describe Chef::Provider::Package::Powershell do end let(:package_xcertificate_installed) do - double("powershell_out", :stdout => "2.1.0.0\r\n") + double("powershell_out", stdout: "2.1.0.0\r\n") end let(:package_xcertificate_installed_2_0_0_0) do - double("powershell_out", :stdout => "2.0.0.0\r\n") + double("powershell_out", stdout: "2.0.0.0\r\n") end let(:package_xcertificate_available) do - double("powershell_out", :stdout => "2.1.0.0\r\n") + double("powershell_out", stdout: "2.1.0.0\r\n") end let(:package_xcertificate_available_2_0_0_0) do - double("powershell_out", :stdout => "2.0.0.0\r\n") + double("powershell_out", stdout: "2.0.0.0\r\n") end let(:package_xcertificate_not_installed) do - double("powershell_out", :stdout => "") + double("powershell_out", stdout: "") end let(:package_xcertificate_not_available) do - double("powershell_out", :stdout => "") + double("powershell_out", stdout: "") end let(:package_xnetworking_installed) do - double("powershell_out", :stdout => "2.12.0.0\r\n") + double("powershell_out", stdout: "2.12.0.0\r\n") end let(:package_xnetworking_installed_2_11_0_0) do - double("powershell_out", :stdout => "2.11.0.0\r\n") + double("powershell_out", stdout: "2.11.0.0\r\n") end let(:package_xnetworking_available) do - double("powershell_out", :stdout => "2.12.0.0\r\n") + double("powershell_out", stdout: "2.12.0.0\r\n") end let(:package_xnetworking_available_2_11_0_0) do - double("powershell_out", :stdout => "2.11.0.0\r\n") + double("powershell_out", stdout: "2.11.0.0\r\n") end let(:package_xnetworking_not_installed) do - double("powershell_out", :stdout => "") + double("powershell_out", stdout: "") end let(:package_xnetworking_not_available) do - double("powershell_out", :stdout => "") + double("powershell_out", stdout: "") end let(:package_7zip_available) do - double("powershell_out", :stdout => "16.02\r\n") + double("powershell_out", stdout: "16.02\r\n") end let(:package_7zip_not_installed) do - double("powershell_out", :stdout => "") + double("powershell_out", stdout: "") end let(:powershell_installed_version) do - double("powershell_out", :stdout => "5") + double("powershell_out", stdout: "5") end let(:generated_command) { "( Get-Package posh-git -Force -ForceBootstrap ).Version" } @@ -116,14 +116,14 @@ describe Chef::Provider::Package::Powershell do describe "#candidate_version" do it "should set the candidate_version to the latest version when not pinning" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) new_resource.package_name(["xNetworking"]) new_resource.version(nil) expect(provider.candidate_version).to eql(["2.12.0.0"]) end it "should use the candidate_version from the correct source" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) new_resource.package_name(["xNetworking"]) new_resource.version(nil) new_resource.source("MyGallery") @@ -131,60 +131,60 @@ describe Chef::Provider::Package::Powershell do end it "should set the candidate_version to the latest version when not pinning and package name is space seperated" do - allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_available) + allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available) new_resource.package_name(["7-Zip 16.02 (x64)"]) new_resource.version(nil) expect(provider.candidate_version).to eql(["16.02"]) end it "should set the candidate_version to pinned version if available" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.0.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.0.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0) new_resource.package_name(["xCertificate"]) new_resource.version(["2.0.0.0"]) expect(provider.candidate_version).to eql(["2.0.0.0"]) end it "should set the candidate_version to nil if there is no candidate" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) new_resource.package_name(["xCertificate"]) expect(provider.candidate_version).to eql([nil]) end it "should set the candidate_version correctly when there are two packages to install" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) expect(provider.candidate_version).to eql(["2.1.0.0", "2.12.0.0"]) end it "should set the candidate_version correctly when only the first is installable" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) expect(provider.candidate_version).to eql(["2.1.0.0", nil]) end it "should set the candidate_version correctly when only the last is installable" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) expect(provider.candidate_version).to eql([nil, "2.12.0.0"]) end it "should set the candidate_version correctly when neither are is installable and version is passed as nil array" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) new_resource.package_name(%w{xNetworking xCertificate}) new_resource.version([nil, nil]) expect(provider.candidate_version).to eql([nil, nil]) end it "should set the candidate_version correctly when neither are is installable and version is not passed" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) new_resource.package_name(%w{xNetworking xCertificate}) new_resource.version(nil) expect(provider.candidate_version).to eql([nil, nil]) @@ -283,10 +283,10 @@ describe Chef::Provider::Package::Powershell do provider.load_current_resource new_resource.package_name(["xCertificate"]) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -296,10 +296,10 @@ describe Chef::Provider::Package::Powershell do new_resource.package_name(["xCertificate"]) new_resource.version(nil) new_resource.source("MyGallery") - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout }) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -309,10 +309,10 @@ describe Chef::Provider::Package::Powershell do new_resource.package_name(["xCertificate"]) new_resource.version(nil) new_resource.skip_publisher_check(true) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -321,10 +321,10 @@ describe Chef::Provider::Package::Powershell do provider.load_current_resource new_resource.package_name(["7-Zip 16.02 (x64)"]) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_available) - allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_not_installed) + allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available) + allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_not_installed) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -RequiredVersion 16.02 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -RequiredVersion 16.02 ).Version", { timeout: new_resource.timeout }) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -336,10 +336,10 @@ describe Chef::Provider::Package::Powershell do provider.load_current_resource new_resource.package_name(["xCertificate"]) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -348,8 +348,8 @@ describe Chef::Provider::Package::Powershell do it "should not install packages that are up-to-date" do new_resource.package_name(["xCertificate"]) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource expect(provider).not_to receive(:install_package) @@ -360,8 +360,8 @@ describe Chef::Provider::Package::Powershell do it "should not install packages that are up-to-date" do new_resource.package_name(["xNetworking"]) new_resource.version(["2.11.0.0"]) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource expect(provider).not_to receive(:install_package) @@ -374,13 +374,13 @@ describe Chef::Provider::Package::Powershell do # new_version.resource[0] new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version([nil, "2.11.0.0"]) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }) provider.load_current_resource provider.run_action(:install) expect(new_resource).to be_updated_by_last_action @@ -389,13 +389,13 @@ describe Chef::Provider::Package::Powershell do it "should split up commands when given two packages, one with a version pin" do new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(["2.1.0.0", nil]) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout }) provider.load_current_resource provider.run_action(:install) @@ -405,13 +405,13 @@ describe Chef::Provider::Package::Powershell do it "should do multipackage installs when given two packages without constraints" do new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout }) provider.load_current_resource provider.run_action(:install) expect(new_resource).to be_updated_by_last_action @@ -421,13 +421,13 @@ describe Chef::Provider::Package::Powershell do new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) new_resource.source("MyGallery") - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout }) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout }) provider.load_current_resource provider.run_action(:install) expect(new_resource).to be_updated_by_last_action @@ -439,8 +439,8 @@ describe Chef::Provider::Package::Powershell do provider.load_current_resource new_resource.package_name(["xCertificate"]) new_resource.version(["2.1.0.0"]) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) expect(provider).not_to receive(:remove_package) provider.run_action(:remove) @@ -451,11 +451,11 @@ describe Chef::Provider::Package::Powershell do new_resource.package_name(["xCertificate"]) new_resource.version(["2.1.0.0"]) new_resource.source("MyGallery") - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource - expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -463,10 +463,10 @@ describe Chef::Provider::Package::Powershell do it "does nothing when all the packages are already removed" do new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource expect(provider).not_to receive(:remove_package) @@ -477,11 +477,11 @@ describe Chef::Provider::Package::Powershell do it "removes a package when version is specified" do new_resource.package_name(["xCertificate"]) new_resource.version(["2.1.0.0"]) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource - expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -489,11 +489,11 @@ describe Chef::Provider::Package::Powershell do it "removes a package when version is not specified" do new_resource.package_name(["xCertificate"]) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource - expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb index cb5e987a85..172bfbac84 100644 --- a/spec/unit/provider/package/smartos_spec.rb +++ b/spec/unit/provider/package/smartos_spec.rb @@ -28,14 +28,14 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do @new_resource = Chef::Resource::Package.new("varnish") @current_resource = Chef::Resource::Package.new("varnish") - @status = double("Status", :exitstatus => 0) + @status = double("Status", exitstatus: 0) @provider = Chef::Provider::Package::SmartOS.new(@new_resource, @run_context) allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource) @stdin = StringIO.new @stdout = "varnish-2.1.5nb2\n" @stderr = StringIO.new @pid = 10 - @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0) + @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0) end describe "when loading current resource" do @@ -59,7 +59,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do end it "should set the installed version to nil if it's not installed" do - out = OpenStruct.new(:stdout => nil) + out = OpenStruct.new(stdout: nil) expect(@provider).to receive(:shell_out_compacted!).and_return(out) @provider.load_current_resource expect(@current_resource.version).to eq(nil) @@ -79,8 +79,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do expect(search).to receive(:each_line). and_yield("something-varnish-1.1.1 something varnish like\n"). and_yield("varnish-2.3.4 actual varnish\n") - @shell_out = double("shell_out!", :stdout => search) - expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out) + @shell_out = double("shell_out!", stdout: search) + expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", env: nil, returns: [0, 1], timeout: 900).and_return(@shell_out) expect(@provider.candidate_version).to eq("2.3.4") end @@ -89,8 +89,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do expect(search).to receive(:each_line). and_yield("something-varnish-1.1.1;;something varnish like\n"). and_yield("varnish-2.3.4;;actual varnish\n") - @shell_out = double("shell_out!", :stdout => search) - expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out) + @shell_out = double("shell_out!", stdout: search) + expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", env: nil, returns: [0, 1], timeout: 900).and_return(@shell_out) expect(@provider.candidate_version).to eq("2.3.4") end end @@ -98,9 +98,9 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do describe "when manipulating a resource" do it "run pkgin and install the package" do - out = OpenStruct.new(:stdout => nil) - expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/sbin/pkg_info", "-E", "varnish*", { :env => nil, :returns => [0, 1], :timeout => 900 }).and_return(@shell_out) - expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", { :env => nil, :timeout => 900 }).and_return(out) + out = OpenStruct.new(stdout: nil) + expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/sbin/pkg_info", "-E", "varnish*", { env: nil, returns: [0, 1], timeout: 900 }).and_return(@shell_out) + expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", { env: nil, timeout: 900 }).and_return(out) @provider.load_current_resource @provider.install_package("varnish", "2.1.5nb2") end diff --git a/spec/unit/provider/package/solaris_spec.rb b/spec/unit/provider/package/solaris_spec.rb index 57a0288f58..2ebf8fe4be 100644 --- a/spec/unit/provider/package/solaris_spec.rb +++ b/spec/unit/provider/package/solaris_spec.rb @@ -46,7 +46,7 @@ INSTDATE: Nov 04 2009 01:02 HOTLINE: Please contact your local service provider PKGINFO - @status = double("Status", :stdout => "", :exitstatus => 0) + @status = double("Status", stdout: "", exitstatus: 0) end it "should create a current resource with the name of new_resource" do @@ -70,7 +70,7 @@ PKGINFO end it "should get the source package version from pkginfo if provided" do - status = double(:stdout => @pkginfo, :exitstatus => 0) + status = double(stdout: @pkginfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "-d", "/tmp/bash.pkg", "SUNWbash", { timeout: 900 }).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "SUNWbash", { timeout: 900 }).and_return(@status) @provider.load_current_resource @@ -80,7 +80,7 @@ PKGINFO end it "should return the current version installed if found by pkginfo" do - status = double(:stdout => @pkginfo, :exitstatus => 0) + status = double(stdout: @pkginfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "-d", "/tmp/bash.pkg", "SUNWbash", { timeout: 900 }).and_return(@status) expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "SUNWbash", { timeout: 900 }).and_return(status) @provider.load_current_resource @@ -95,7 +95,7 @@ PKGINFO end it "should raise an exception if pkginfo fails to run" do - status = double(:stdout => "", :exitstatus => -1) + status = double(stdout: "", exitstatus: -1) allow(@provider).to receive(:shell_out_compacted).and_return(status) expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package) end @@ -116,14 +116,14 @@ PKGINFO end it "should lookup the candidate_version if the variable is not already set" do - status = double(:stdout => "", :exitstatus => 0) + status = double(stdout: "", exitstatus: 0) allow(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider).to receive(:shell_out_compacted) @provider.candidate_version end it "should throw and exception if the exitstatus is not 0" do - status = double(:stdout => "", :exitstatus => 1) + status = double(stdout: "", exitstatus: 1) allow(@provider).to receive(:shell_out_compacted).and_return(status) expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package) end diff --git a/spec/unit/provider/package/windows/exe_spec.rb b/spec/unit/provider/package/windows/exe_spec.rb index f18cbf3dca..f8c4e83fc5 100644 --- a/spec/unit/provider/package/windows/exe_spec.rb +++ b/spec/unit/provider/package/windows/exe_spec.rb @@ -126,7 +126,7 @@ describe Chef::Provider::Package::Windows::Exe do it "removes installed package and quotes uninstall string" do new_resource.timeout = 300 allow(::File).to receive(:exist?).with("uninst_dir/uninst_file").and_return(true) - expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir\/uninst_file\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, :timeout => 300, :returns => [0]) + expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir\/uninst_file\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, timeout: 300, returns: [0]) provider.remove_package end end diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb index aa528ab90e..0e939610db 100644 --- a/spec/unit/provider/package/windows/msi_spec.rb +++ b/spec/unit/provider/package/windows/msi_spec.rb @@ -22,7 +22,7 @@ require "chef/provider/package/windows/msi" describe Chef::Provider::Package::Windows::MSI do let(:node) { double("Chef::Node") } let(:events) { double("Chef::Events").as_null_object } # mock all the methods - let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } + let(:run_context) { double("Chef::RunContext", node: node, events: events) } let(:package_name) { "calculator" } let(:resource_source) { "calculator.msi" } let(:resource_version) { nil } diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb index aed0ca88be..3030b7f04a 100644 --- a/spec/unit/provider/package/windows_spec.rb +++ b/spec/unit/provider/package/windows_spec.rb @@ -50,7 +50,7 @@ describe Chef::Provider::Package::Windows, :windows_only do before(:each) do allow(Chef::Util::PathHelper).to receive(:validate_path) allow(provider).to receive(:package_provider).and_return(double("package_provider", - :installed_version => "1.0", :package_version => "2.0")) + installed_version: "1.0", package_version: "2.0")) end it "creates a current resource with the name of the new resource" do diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index 4ba8ac36ac..6795f9e051 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -30,7 +30,7 @@ describe Chef::Provider::Package::Zypper do Chef::Provider::Package::Zypper.new(new_resource, run_context) end - let(:status) { double(:stdout => "\n", :exitstatus => 0) } + let(:status) { double(stdout: "\n", exitstatus: 0) } before(:each) do allow(Chef::Resource::Package).to receive(:new).and_return(current_resource) @@ -73,7 +73,7 @@ describe Chef::Provider::Package::Zypper do end it "should set the installed version if zypper info has one (zypper version < 1.13.0)" do - status = double(:stdout => "Version: 1.0\nInstalled: Yes\n", :exitstatus => 0) + status = double(stdout: "Version: 1.0\nInstalled: Yes\n", exitstatus: 0) allow(provider).to receive(:shell_out_compacted!).and_return(status) expect(current_resource).to receive(:version).with(["1.0"]).and_return(true) @@ -81,7 +81,7 @@ describe Chef::Provider::Package::Zypper do end it "should set the installed version if zypper info has one (zypper version >= 1.13.0)" do - status = double(:stdout => "Version : 1.0 \nInstalled : Yes \n", :exitstatus => 0) + status = double(stdout: "Version : 1.0 \nInstalled : Yes \n", exitstatus: 0) allow(provider).to receive(:shell_out_compacted!).and_return(status) expect(current_resource).to receive(:version).with(["1.0"]).and_return(true) @@ -89,7 +89,7 @@ describe Chef::Provider::Package::Zypper do end it "should set the installed version if zypper info has one (zypper version >= 1.13.17)" do - status = double(:stdout => "Version : 1.0\nInstalled : Yes (automatically)\n", :exitstatus => 0) + status = double(stdout: "Version : 1.0\nInstalled : Yes (automatically)\n", exitstatus: 0) allow(provider).to receive(:shell_out_compacted!).and_return(status) expect(current_resource).to receive(:version).with(["1.0"]).and_return(true) @@ -97,7 +97,7 @@ describe Chef::Provider::Package::Zypper do end it "should set the candidate version if zypper info has one (zypper version < 1.13.0)" do - status = double(:stdout => "Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)", :exitstatus => 0) + status = double(stdout: "Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)", exitstatus: 0) allow(provider).to receive(:shell_out_compacted!).and_return(status) provider.load_current_resource @@ -105,7 +105,7 @@ describe Chef::Provider::Package::Zypper do end it "should set the candidate version if zypper info has one (zypper version >= 1.13.0)" do - status = double(:stdout => "Version : 1.0 \nInstalled : No \nStatus : out-of-date (version 0.9 installed)", :exitstatus => 0) + status = double(stdout: "Version : 1.0 \nInstalled : No \nStatus : out-of-date (version 0.9 installed)", exitstatus: 0) allow(provider).to receive(:shell_out_compacted!).and_return(status) provider.load_current_resource diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb index f4663861c6..79d84e61dc 100644 --- a/spec/unit/provider/powershell_script_spec.rb +++ b/spec/unit/provider/powershell_script_spec.rb @@ -25,7 +25,7 @@ describe Chef::Provider::PowershellScript, "action_run" do node.default["kernel"] = Hash.new node.default["kernel"][:machine] = :x86_64.to_s if ! powershell_version.nil? - node.default[:languages] = { :powershell => { :version => powershell_version } } + node.default[:languages] = { powershell: { version: powershell_version } } end node end diff --git a/spec/unit/provider/registry_key_spec.rb b/spec/unit/provider/registry_key_spec.rb index 096fe9b9ed..3563af4dc4 100644 --- a/spec/unit/provider/registry_key_spec.rb +++ b/spec/unit/provider/registry_key_spec.rb @@ -275,20 +275,20 @@ describe Chef::Provider::RegistryKey do context "when the key data is safe" do let(:keyname) { 'HKLM\Software\Opscode\Testing\Safe' } - let(:testval1) { { :name => "one", :type => :string, :data => "1" } } - let(:testval1_wrong_type) { { :name => "one", :type => :multi_string, :data => "1" } } - let(:testval1_wrong_data) { { :name => "one", :type => :string, :data => "2" } } - let(:testval2) { { :name => "two", :type => :string, :data => "2" } } + let(:testval1) { { name: "one", type: :string, data: "1" } } + let(:testval1_wrong_type) { { name: "one", type: :multi_string, data: "1" } } + let(:testval1_wrong_data) { { name: "one", type: :string, data: "2" } } + let(:testval2) { { name: "two", type: :string, data: "2" } } it_should_behave_like "a registry key" end context "when the key data is unsafe" do let(:keyname) { 'HKLM\Software\Opscode\Testing\Unsafe' } - let(:testval1) { { :name => "one", :type => :binary, :data => 255.chr * 1 } } - let(:testval1_wrong_type) { { :name => "one", :type => :string, :data => 255.chr * 1 } } - let(:testval1_wrong_data) { { :name => "one", :type => :binary, :data => 254.chr * 1 } } - let(:testval2) { { :name => "two", :type => :binary, :data => 0.chr * 1 } } + let(:testval1) { { name: "one", type: :binary, data: 255.chr * 1 } } + let(:testval1_wrong_type) { { name: "one", type: :string, data: 255.chr * 1 } } + let(:testval1_wrong_data) { { name: "one", type: :binary, data: 254.chr * 1 } } + let(:testval2) { { name: "two", type: :binary, data: 0.chr * 1 } } it_should_behave_like "a registry key" end @@ -296,8 +296,8 @@ describe Chef::Provider::RegistryKey do describe "action_create" do context "when key exists and type matches" do let(:keyname) { 'hklm\\software\\opscode\\testing\\dword' } - let(:dword_passed_as_integer) { { :name => "one", :type => :dword, :data => 12345 } } - let(:testval1) { { :name => "one", :type => :dword, :data => "12345" } } + let(:dword_passed_as_integer) { { name: "one", type: :dword, data: 12345 } } + let(:testval1) { { name: "one", type: :dword, data: "12345" } } before do expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true) end @@ -321,33 +321,33 @@ describe Chef::Provider::RegistryKey, "key_missing?" do let(:provider) { Chef::Provider::RegistryKey.new(new_resource, run_context) } let(:all_keys_present_in_all_hash) do - [ { :name => "input1_value1", :type => :string, :data => "my_value1" }, - { :name => "input1_value2", :type => :string, :data => "my_value2" }, + [ { name: "input1_value1", type: :string, data: "my_value1" }, + { name: "input1_value2", type: :string, data: "my_value2" }, ] end let(:type_key_not_present_in_any_hash) do - [ { :name => "input2_value1", :data => "my_value1" }, - { :name => "input2_value2", :data => "my_value2" }, + [ { name: "input2_value1", data: "my_value1" }, + { name: "input2_value2", data: "my_value2" }, ] end let(:type_key_not_present_in_some_hash) do - [ { :name => "input3_value1", :data => "my_value1" }, - { :name => "input3_value2", :type => :string, :data => "my_value2" }, + [ { name: "input3_value1", data: "my_value1" }, + { name: "input3_value2", type: :string, data: "my_value2" }, ] end let(:data_key_not_present_in_any_hash) do - [ { :name => "input4_value1", :type => :string }, - { :name => "input4_value2", :type => :string }, + [ { name: "input4_value1", type: :string }, + { name: "input4_value2", type: :string }, ] end let(:data_key_not_present_in_some_hash) do - [ { :name => "input5_value1", :type => :string, :data => "my_value1" }, - { :name => "input5_value2", :type => :string }, + [ { name: "input5_value1", type: :string, data: "my_value1" }, + { name: "input5_value2", type: :string }, ] end let(:only_name_key_present_in_all_hash) do - [ { :name => "input6_value1" }, - { :name => "input6_value2" }, + [ { name: "input6_value1" }, + { name: "input6_value2" }, ] end diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb index 307eb98187..1afc95fa48 100644 --- a/spec/unit/provider/remote_file/content_spec.rb +++ b/spec/unit/provider/remote_file/content_spec.rb @@ -84,7 +84,7 @@ describe Chef::Provider::RemoteFile::Content do describe "when the fetcher returns nil for the tempfile" do before do - http_fetcher = double("Chef::Provider::RemoteFile::HTTP", :fetch => nil) + http_fetcher = double("Chef::Provider::RemoteFile::HTTP", fetch: nil) expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher) end @@ -97,7 +97,7 @@ describe Chef::Provider::RemoteFile::Content do let(:mtime) { Time.now } let(:tempfile) { double("Tempfile") } - let(:http_fetcher) { double("Chef::Provider::RemoteFile::HTTP", :fetch => tempfile) } + let(:http_fetcher) { double("Chef::Provider::RemoteFile::HTTP", fetch: tempfile) } before do expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher) @@ -199,7 +199,7 @@ describe Chef::Provider::RemoteFile::Content do before do @tempfile = double("Tempfile") mtime = Time.now - http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile) + http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", fetch: @tempfile) expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(http_fetcher_works) end @@ -236,7 +236,7 @@ describe Chef::Provider::RemoteFile::Content do expect(URI).not_to receive(:parse).with(new_resource.source[1]) @tempfile = double("Tempfile") mtime = Time.now - http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile) + http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", fetch: @tempfile) expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri0, new_resource, current_resource).and_return(http_fetcher_works) end diff --git a/spec/unit/provider/remote_file/fetcher_spec.rb b/spec/unit/provider/remote_file/fetcher_spec.rb index f5b32800f2..b110e2c03a 100644 --- a/spec/unit/provider/remote_file/fetcher_spec.rb +++ b/spec/unit/provider/remote_file/fetcher_spec.rb @@ -46,7 +46,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed an http url" do - let(:uri) { double("uri", :scheme => "http" ) } + let(:uri) { double("uri", scheme: "http" ) } before do expect(Chef::Provider::RemoteFile::HTTP).to receive(:new).and_return(fetcher_instance) end @@ -56,7 +56,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed an https url" do - let(:uri) { double("uri", :scheme => "https" ) } + let(:uri) { double("uri", scheme: "https" ) } before do expect(Chef::Provider::RemoteFile::HTTP).to receive(:new).and_return(fetcher_instance) end @@ -66,7 +66,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed an ftp url" do - let(:uri) { double("uri", :scheme => "ftp" ) } + let(:uri) { double("uri", scheme: "ftp" ) } before do expect(Chef::Provider::RemoteFile::FTP).to receive(:new).and_return(fetcher_instance) end @@ -76,7 +76,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed a file url" do - let(:uri) { double("uri", :scheme => "file" ) } + let(:uri) { double("uri", scheme: "file" ) } before do expect(Chef::Provider::RemoteFile::LocalFile).to receive(:new).and_return(fetcher_instance) end @@ -86,7 +86,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed a url we do not recognize" do - let(:uri) { double("uri", :scheme => "xyzzy" ) } + let(:uri) { double("uri", scheme: "xyzzy" ) } it "throws an ArgumentError exception" do expect { described_class.for_resource(uri, new_resource, current_resource) }.to raise_error(ArgumentError) end diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb index e1f74bd35a..8ece1a854b 100644 --- a/spec/unit/provider/remote_file/http_spec.rb +++ b/spec/unit/provider/remote_file/http_spec.rb @@ -292,7 +292,7 @@ describe Chef::Provider::RemoteFile::HTTP do context "and the target file is a tarball [CHEF-3140]" do let(:uri) { URI.parse("http://opscode.com/tarball.tgz") } - let(:expected_http_opts) { { :disable_gzip => true } } + let(:expected_http_opts) { { disable_gzip: true } } # CHEF-3140 # Some servers return tarballs as content type tar and encoding gzip, which diff --git a/spec/unit/provider/remote_file/local_file_spec.rb b/spec/unit/provider/remote_file/local_file_spec.rb index 6f345cadd1..6dad6a57f2 100644 --- a/spec/unit/provider/remote_file/local_file_spec.rb +++ b/spec/unit/provider/remote_file/local_file_spec.rb @@ -84,8 +84,8 @@ describe Chef::Provider::RemoteFile::LocalFile do describe "when fetching the object" do - let(:tempfile) { double("Tempfile", :path => "/tmp/foo/bar/nyan.png", :close => nil) } - let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", :tempfile => tempfile) } + let(:tempfile) { double("Tempfile", path: "/tmp/foo/bar/nyan.png", close: nil) } + let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", tempfile: tempfile) } before do current_resource.source("file:///nyan_cat.png") diff --git a/spec/unit/provider/remote_file/network_file_spec.rb b/spec/unit/provider/remote_file/network_file_spec.rb index ecb326fc64..1c2bcc5911 100644 --- a/spec/unit/provider/remote_file/network_file_spec.rb +++ b/spec/unit/provider/remote_file/network_file_spec.rb @@ -28,9 +28,9 @@ describe Chef::Provider::RemoteFile::NetworkFile do describe "when fetching the object" do - let(:tempfile) { double("Tempfile", :path => "/tmp/foo/bar/Foo.tar.gz", :close => nil) } - let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", :tempfile => tempfile) } - let(:source_file) { double("::File", :read => nil) } + let(:tempfile) { double("Tempfile", path: "/tmp/foo/bar/Foo.tar.gz", close: nil) } + let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", tempfile: tempfile) } + let(:source_file) { double("::File", read: nil) } before do allow(Chef::Platform).to receive(:windows?).and_return(true) diff --git a/spec/unit/provider/remote_file/sftp_spec.rb b/spec/unit/provider/remote_file/sftp_spec.rb index ddab1605f0..d8fff87dec 100644 --- a/spec/unit/provider/remote_file/sftp_spec.rb +++ b/spec/unit/provider/remote_file/sftp_spec.rb @@ -120,7 +120,7 @@ describe Chef::Provider::RemoteFile::SFTP do let(:uri) { URI.parse("sftp://conan:cthu1hu@opscode.com:8021/seattle.txt") } it "should connect on an alternate port when one is provided" do - expect(Net::SFTP).to receive(:start).with("opscode.com:8021", "conan", :password => "cthu1hu") + expect(Net::SFTP).to receive(:start).with("opscode.com:8021", "conan", password: "cthu1hu") fetcher.fetch end diff --git a/spec/unit/provider/remote_file_spec.rb b/spec/unit/provider/remote_file_spec.rb index 3f91377c60..07b854da6b 100644 --- a/spec/unit/provider/remote_file_spec.rb +++ b/spec/unit/provider/remote_file_spec.rb @@ -37,7 +37,7 @@ describe Chef::Provider::RemoteFile do let(:node) { double("Chef::Node") } let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:logger) { double("Mixlib::Log::Child").as_null_object } - let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) } + let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) } let(:enclosing_directory) do canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) end diff --git a/spec/unit/provider/script_spec.rb b/spec/unit/provider/script_spec.rb index 651e5130e0..08b19730a7 100644 --- a/spec/unit/provider/script_spec.rb +++ b/spec/unit/provider/script_spec.rb @@ -93,7 +93,7 @@ describe Chef::Provider::Script, "action_run" do end context "when an alternate user is specified" do - let(:security_descriptor) { instance_double("Chef::ReservedNames::Win32::Security::SecurityDescriptor", :dacl => []) } + let(:security_descriptor) { instance_double("Chef::ReservedNames::Win32::Security::SecurityDescriptor", dacl: []) } let(:securable_object) { instance_double("Chef::ReservedNames::Win32::Security::SecurableObject", :security_descriptor => security_descriptor, :dacl= => nil) } it "sets the script file's security descriptor" do new_resource.user("toor") diff --git a/spec/unit/provider/service/aix_service_spec.rb b/spec/unit/provider/service/aix_service_spec.rb index 802ccee2c7..cf6309e82a 100644 --- a/spec/unit/provider/service/aix_service_spec.rb +++ b/spec/unit/provider/service/aix_service_spec.rb @@ -33,7 +33,7 @@ describe Chef::Provider::Service::Aix do describe "load current resource" do it "should create a current resource with the name of the new resource and determine the status" do - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) expect(Chef::Resource::Service).to receive(:new).and_return(@current_resource) @@ -47,7 +47,7 @@ describe Chef::Provider::Service::Aix do describe "determine current status" do context "when the service is active" do before do - @status = double("Status", :exitstatus => 0, :stdout => "chef chef 12345 active\n") + @status = double("Status", exitstatus: 0, stdout: "chef chef 12345 active\n") end it "current resource is running" do @@ -61,7 +61,7 @@ describe Chef::Provider::Service::Aix do context "when the service is inoperative" do before do - @status = double("Status", :exitstatus => 0, :stdout => "chef chef inoperative\n") + @status = double("Status", exitstatus: 0, stdout: "chef chef inoperative\n") end it "current resource is not running" do @@ -75,7 +75,7 @@ describe Chef::Provider::Service::Aix do context "when there is no such service" do before do - @status = double("Status", :exitstatus => 1, :stdout => "0513-085 The chef Subsystem is not on file.\n") + @status = double("Status", exitstatus: 1, stdout: "0513-085 The chef Subsystem is not on file.\n") end it "current resource is not running" do expect(@provider).to receive(:shell_out!).with("lssrc -s chef").and_return(@status) @@ -90,7 +90,7 @@ describe Chef::Provider::Service::Aix do describe "is resource group" do context "when there are multiple subsystems associated with group" do before do - @status = double("Status", :exitstatus => 0, :stdout => "chef1 chef 12345 active\nchef2 chef 12334 active\nchef3 chef inoperative") + @status = double("Status", exitstatus: 0, stdout: "chef1 chef 12345 active\nchef2 chef 12334 active\nchef3 chef inoperative") end it "service is a group" do @@ -102,7 +102,7 @@ describe Chef::Provider::Service::Aix do context "when there is a single subsystem in the group" do before do - @status = double("Status", :exitstatus => 0, :stdout => "chef1 chef inoperative\n") + @status = double("Status", exitstatus: 0, stdout: "chef1 chef inoperative\n") end it "service is a group" do @@ -114,8 +114,8 @@ describe Chef::Provider::Service::Aix do context "when the service is a subsystem" do before do - @group_status = double("Status", :exitstatus => 1, :stdout => "0513-086 The chef Group is not on file.\n") - @service_status = double("Status", :exitstatus => 0, :stdout => "chef chef inoperative\n") + @group_status = double("Status", exitstatus: 1, stdout: "0513-086 The chef Group is not on file.\n") + @service_status = double("Status", exitstatus: 0, stdout: "chef chef inoperative\n") end it "service is a subsystem" do diff --git a/spec/unit/provider/service/aixinit_service_spec.rb b/spec/unit/provider/service/aixinit_service_spec.rb index 09c177903b..725d6e210c 100644 --- a/spec/unit/provider/service/aixinit_service_spec.rb +++ b/spec/unit/provider/service/aixinit_service_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Provider::Service::AixInit do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = { :ps => "fuuuu" } + @node.automatic_attrs[:command] = { ps: "fuuuu" } @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb index 2139e31818..818c2ccb27 100644 --- a/spec/unit/provider/service/arch_service_spec.rb +++ b/spec/unit/provider/service/arch_service_spec.rb @@ -26,14 +26,14 @@ require "ostruct" describe Chef::Provider::Service::Arch, "load_current_resource" do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = { :ps => "ps -ef" } + @node.automatic_attrs[:command] = { ps: "ps -ef" } @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::Service.new("chef") @new_resource.pattern("chef") - @new_resource.supports({ :status => false }) + @new_resource.supports({ status: false }) @provider = Chef::Provider::Service::Arch.new(@new_resource, @run_context) @@ -43,7 +43,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do describe "when first created" do it "should set the current resources service name to the new resources service name" do - allow(@provider).to receive(:shell_out).and_return(OpenStruct.new(:exitstatus => 0, :stdout => "")) + allow(@provider).to receive(:shell_out).and_return(OpenStruct.new(exitstatus: 0, stdout: "")) @provider.load_current_resource expect(@provider.current_resource.service_name).to eq("chef") end @@ -51,22 +51,22 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do describe "when the service supports status" do before do - @new_resource.supports({ :status => true }) + @new_resource.supports({ status: true }) end it "should run '/etc/rc.d/service_name status'" do - expect(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0)) + expect(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 0)) @provider.load_current_resource end it "should set running to true if the status command returns 0" do - allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0)) + allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 0)) @provider.load_current_resource expect(@provider.current_resource.running).to be_truthy end it "should set running to false if the status command returns anything except 0" do - allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 1)) + allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 1)) @provider.load_current_resource expect(@provider.current_resource.running).to be_falsey end @@ -85,21 +85,21 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do end it "should run the services status command if one has been specified" do - expect(@provider).to receive(:shell_out).with("/etc/rc.d/chefhasmonkeypants status").and_return(OpenStruct.new(:exitstatus => 0)) + expect(@provider).to receive(:shell_out).with("/etc/rc.d/chefhasmonkeypants status").and_return(OpenStruct.new(exitstatus: 0)) @provider.load_current_resource end end it "should raise error if the node has a nil ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => nil } + @node.automatic_attrs[:command] = { ps: nil } @provider.define_resource_requirements @provider.action = :start expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end it "should raise error if the node has an empty ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => "" } + @node.automatic_attrs[:command] = { ps: "" } @provider.define_resource_requirements @provider.action = :start expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) @@ -122,10 +122,10 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb DEFAULT_PS - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) - @node.automatic_attrs[:command] = { :ps => "ps -ef" } + @node.automatic_attrs[:command] = { ps: "ps -ef" } end it "determines the service is running when it appears in ps" do @@ -274,7 +274,7 @@ RUNNING_PS # end it "should call 'restart' on the service_name if the resource supports it" do - @new_resource.supports({ :restart => true }) + @new_resource.supports({ restart: true }) expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restart", default_env: false) @provider.restart_service() end @@ -309,7 +309,7 @@ RUNNING_PS # end it "should call 'reload' on the service if it supports it" do - @new_resource.supports({ :reload => true }) + @new_resource.supports({ reload: true }) expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} reload", default_env: false) @provider.reload_service() end diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb index 25e7c9acc2..173f5e9b61 100644 --- a/spec/unit/provider/service/debian_service_spec.rb +++ b/spec/unit/provider/service/debian_service_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Provider::Service::Debian do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = { :ps => "fuuuu" } + @node.automatic_attrs[:command] = { ps: "fuuuu" } @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb index 511962f432..11a02c3421 100644 --- a/spec/unit/provider/service/freebsd_service_spec.rb +++ b/spec/unit/provider/service/freebsd_service_spec.rb @@ -27,14 +27,14 @@ end describe Chef::Provider::Service::Freebsd do let(:node) do node = Chef::Node.new - node.automatic_attrs[:command] = { :ps => "ps -ax" } + node.automatic_attrs[:command] = { ps: "ps -ax" } node end let(:new_resource) do new_resource = Chef::Resource::Service.new("apache22") new_resource.pattern("httpd") - new_resource.supports({ :status => false }) + new_resource.supports({ status: false }) new_resource end @@ -99,7 +99,7 @@ describe Chef::Provider::Service::Freebsd do end context "when a status command has been specified" do - let(:status) { double(:stdout => "", :exitstatus => 0) } + let(:status) { double(stdout: "", exitstatus: 0) } before do new_resource.status_command("/bin/chefhasmonkeypants status") @@ -112,10 +112,10 @@ describe Chef::Provider::Service::Freebsd do end context "when the service supports status" do - let(:status) { double(:stdout => "", :exitstatus => 0) } + let(:status) { double(stdout: "", exitstatus: 0) } before do - new_resource.supports({ :status => true }) + new_resource.supports({ status: true }) end it "should run '/etc/init.d/service_name status'" do @@ -144,10 +144,10 @@ describe Chef::Provider::Service::Freebsd do 545 ?? Ss 0:17.53 sendmail: accepting connections (sendmail) PS_SAMPLE end - let(:status) { double(:stdout => stdout, :exitstatus => 0) } + let(:status) { double(stdout: stdout, exitstatus: 0) } before do - node.automatic_attrs[:command] = { :ps => "ps -ax" } + node.automatic_attrs[:command] = { ps: "ps -ax" } end it "should shell_out! the node's ps command" do @@ -191,7 +191,7 @@ PS_SAMPLE context "when ps is empty string" do before do - node.automatic_attrs[:command] = { :ps => "" } + node.automatic_attrs[:command] = { ps: "" } end it "should set running to nil" do @@ -369,7 +369,7 @@ EOF end before do - status = double(:stdout => rcvar_stdout, :exitstatus => 0) + status = double(stdout: rcvar_stdout, exitstatus: 0) allow(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} rcvar").and_return(status) end @@ -469,7 +469,7 @@ EOF describe Chef::Provider::Service::Freebsd, "restart_service" do it "should call 'restart' on the service_name if the resource supports it" do - new_resource.supports({ :restart => true }) + new_resource.supports({ restart: true }) expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart", default_env: false) provider.restart_service() end diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb index a00ca7aadd..6a928d849b 100644 --- a/spec/unit/provider/service/gentoo_service_spec.rb +++ b/spec/unit/provider/service/gentoo_service_spec.rb @@ -30,7 +30,7 @@ describe Chef::Provider::Service::Gentoo do @provider = Chef::Provider::Service::Gentoo.new(@new_resource, @run_context) allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource) - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out).and_return(@status) allow(File).to receive(:exists?).with("/etc/init.d/chef").and_return(true) allow(File).to receive(:exists?).with("/sbin/rc-update").and_return(true) diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb index ff7fae767a..5d403c6898 100644 --- a/spec/unit/provider/service/init_service_spec.rb +++ b/spec/unit/provider/service/init_service_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Provider::Service::Init, "load_current_resource" do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = { :ps => "ps -ef" } + @node.automatic_attrs[:command] = { ps: "ps -ef" } @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -37,7 +37,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb PS - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) end @@ -53,7 +53,7 @@ PS describe "when the service supports status" do before do - @new_resource.supports({ :status => true }) + @new_resource.supports({ status: true }) end it "should run '/etc/init.d/service_name status'" do @@ -109,7 +109,7 @@ PS describe "when the node has not specified a ps command" do it "should raise an error if the node has a nil ps attribute" do - @node.automatic_attrs[:command] = { :ps => nil } + @node.automatic_attrs[:command] = { ps: nil } @provider.load_current_resource @provider.action = :start @provider.define_resource_requirements @@ -117,7 +117,7 @@ PS end it "should raise an error if the node has an empty ps attribute" do - @node.automatic_attrs[:command] = { :ps => "" } + @node.automatic_attrs[:command] = { ps: "" } @provider.load_current_resource @provider.action = :start @provider.define_resource_requirements @@ -189,7 +189,7 @@ RUNNING_PS describe "when restarting a service" do it "should call 'restart' on the service_name if the resource supports it" do - @new_resource.supports({ :restart => true }) + @new_resource.supports({ restart: true }) expect(@provider).to receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} restart", default_env: false) @provider.restart_service() end @@ -210,7 +210,7 @@ RUNNING_PS describe "when reloading a service" do it "should call 'reload' on the service if it supports it" do - @new_resource.supports({ :reload => true }) + @new_resource.supports({ reload: true }) expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef reload", default_env: false) @provider.reload_service() end diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb index 3b2b19c432..f2fe19db59 100644 --- a/spec/unit/provider/service/insserv_service_spec.rb +++ b/spec/unit/provider/service/insserv_service_spec.rb @@ -23,13 +23,13 @@ describe Chef::Provider::Service::Insserv do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @node.automatic_attrs[:command] = { :ps => "ps -ax" } + @node.automatic_attrs[:command] = { ps: "ps -ax" } @new_resource = Chef::Resource::Service.new("initgrediant") @current_resource = Chef::Resource::Service.new("initgrediant") @provider = Chef::Provider::Service::Insserv.new(@new_resource, @run_context) - @status = double("Process::Status mock", :exitstatus => 0, :stdout => "") + @status = double("Process::Status mock", exitstatus: 0, stdout: "") allow(@provider).to receive(:shell_out!).and_return(@status) end diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb index e70ba7e094..a63e3e1afb 100644 --- a/spec/unit/provider/service/invokercd_service_spec.rb +++ b/spec/unit/provider/service/invokercd_service_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Provider::Service::Invokercd, "load_current_resource" do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = { :ps => "ps -ef" } + @node.automatic_attrs[:command] = { ps: "ps -ef" } @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -37,7 +37,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb PS - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) end @@ -53,7 +53,7 @@ PS describe "when the service supports status" do before do - @new_resource.supports({ :status => true }) + @new_resource.supports({ status: true }) end it "should run '/usr/sbin/invoke-rc.d service_name status'" do @@ -95,14 +95,14 @@ PS describe "when the node has not specified a ps command" do it "should raise error if the node has a nil ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => nil } + @node.automatic_attrs[:command] = { ps: nil } @provider.action = :start @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end it "should raise error if the node has an empty ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => "" } + @node.automatic_attrs[:command] = { ps: "" } @provider.action = :start @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) @@ -112,7 +112,7 @@ PS describe "when we have a 'ps' attribute" do it "should shell_out! the node's ps command" do - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) expect(@provider).to receive(:shell_out!).with(@node[:command][:ps]).and_return(@status) @provider.load_current_resource end @@ -122,14 +122,14 @@ PS aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos RUNNING_PS - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) expect(@provider).to receive(:shell_out!).and_return(@status) @provider.load_current_resource expect(@current_resource.running).to be_truthy end it "should set running to false if the regex doesn't match" do - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) expect(@provider).to receive(:shell_out!).and_return(@status) @provider.load_current_resource expect(@current_resource.running).to be_falsey @@ -176,7 +176,7 @@ RUNNING_PS describe "when restarting a service" do it "should call 'restart' on the service_name if the resource supports it" do - @new_resource.supports({ :restart => true }) + @new_resource.supports({ restart: true }) expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restart", default_env: false) @provider.restart_service() end @@ -197,7 +197,7 @@ RUNNING_PS describe "when reloading a service" do it "should call 'reload' on the service if it supports it" do - @new_resource.supports({ :reload => true }) + @new_resource.supports({ reload: true }) expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef reload", default_env: false) @provider.reload_service() end diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb index 283512108a..5ca06d9ec8 100644 --- a/spec/unit/provider/service/macosx_spec.rb +++ b/spec/unit/provider/service/macosx_spec.rb @@ -76,20 +76,20 @@ XML before do allow(run_context).to receive(:logger).and_return(logger) allow(Dir).to receive(:glob).and_return([plist], []) - @stat = double("File::Stat", { :uid => 501 }) + @stat = double("File::Stat", { uid: 501 }) allow(File).to receive(:stat).and_return(@stat) - @getpwuid = double("Etc::Passwd", { :name => "mikedodge04" }) + @getpwuid = double("Etc::Passwd", { name: "mikedodge04" }) allow(Etc).to receive(:getpwuid).and_return(@getpwuid) allow(node).to receive(:[]).with("platform_version").and_return(platform_version) cmd = "launchctl list #{service_label}" allow(provider).to receive(:shell_out). with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false). and_return(double("Status", - :stdout => launchctl_stdout, :exitstatus => 0)) + stdout: launchctl_stdout, exitstatus: 0)) allow(File).to receive(:exists?).and_return([true], []) allow(provider).to receive(:shell_out!). with(/plutil -convert xml1 -o/, default_env: false). - and_return(double("Status", :stdout => plutil_stdout)) + and_return(double("Status", stdout: plutil_stdout)) end context "#{service_name} that is a #{service_type} running Osx #{platform_version}" do diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb index b990532aaf..38283f609d 100644 --- a/spec/unit/provider/service/openbsd_service_spec.rb +++ b/spec/unit/provider/service/openbsd_service_spec.rb @@ -31,11 +31,11 @@ end describe Chef::Provider::Service::Openbsd do let(:node) do node = Chef::Node.new - node.automatic_attrs[:command] = { :ps => "ps -ax" } + node.automatic_attrs[:command] = { ps: "ps -ax" } node end - let(:supports) { { :status => false } } + let(:supports) { { status: false } } let(:new_resource) do new_resource = Chef::Resource::Service.new("sndiod") @@ -93,7 +93,7 @@ describe Chef::Provider::Service::Openbsd do end context "when a status command has been specified" do - let(:status) { double(:stdout => "", :exitstatus => 0) } + let(:status) { double(stdout: "", exitstatus: 0) } before do new_resource.status_command("/bin/chefhasmonkeypants status") @@ -106,9 +106,9 @@ describe Chef::Provider::Service::Openbsd do end context "when the service supports status" do - let(:status) { double(:stdout => "", :exitstatus => 0) } + let(:status) { double(stdout: "", exitstatus: 0) } - let(:supports) { { :status => true } } + let(:supports) { { status: true } } it "should run '/etc/rc.d/service_name status'" do expect(provider).to receive(:shell_out).with("/etc/rc.d/#{new_resource.service_name} check").and_return(status) diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index 40f9bc3a91..b965183d14 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -23,17 +23,17 @@ shared_examples_for "define_resource_requirements_common" do it "should raise an error if /sbin/chkconfig does not exist" do allow(File).to receive(:exists?).with("/sbin/chkconfig").and_return(false) allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_raise(Errno::ENOENT) - allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_raise(Errno::ENOENT) + allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_raise(Errno::ENOENT) @provider.load_current_resource @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end it "should not raise an error if the service exists but is not added to any runlevels" do - status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "") + status = double("Status", exitstatus: 0, stdout: "" , stderr: "") expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status) - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "", :stderr => "service chef supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add chef')") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "", stderr: "service chef supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add chef')") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) @provider.load_current_resource @provider.define_resource_requirements expect { @provider.process_resource_requirements }.not_to raise_error @@ -44,7 +44,7 @@ describe "Chef::Provider::Service::Redhat" do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = { :ps => "foo" } + @node.automatic_attrs[:command] = { ps: "foo" } @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -65,13 +65,13 @@ describe "Chef::Provider::Service::Redhat" do describe "load current resource" do before do - status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "") + status = double("Status", exitstatus: 0, stdout: "" , stderr: "") allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status) end it "sets supports[:status] to true by default" do - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false @provider.load_current_resource expect(@provider.supports[:status]).to be true @@ -80,9 +80,9 @@ describe "Chef::Provider::Service::Redhat" do it "lets the user override supports[:status] in the new_resource" do @new_resource.supports( { status: false } ) @new_resource.pattern "myservice" - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) - foo_out = double("ps_command", :exitstatus => 0, :stdout => "a line that matches myservice", :stderr => "") + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) + foo_out = double("ps_command", exitstatus: 0, stdout: "a line that matches myservice", stderr: "") expect(@provider).to receive(:shell_out!).with("foo").and_return(foo_out) expect(@provider.service_missing).to be false expect(@provider).not_to receive(:shell_out).with("/sbin/service chef status") @@ -91,16 +91,16 @@ describe "Chef::Provider::Service::Redhat" do end it "sets the current enabled status to true if the service is enabled for any run level" do - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false @provider.load_current_resource expect(@current_resource.enabled).to be true end it "sets the current enabled status to false if the regex does not match" do - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false expect(@provider.load_current_resource).to eql(@current_resource) expect(@current_resource.enabled).to be false @@ -108,8 +108,8 @@ describe "Chef::Provider::Service::Redhat" do it "sets the current enabled status to true if the service is enabled at specified run levels" do @new_resource.run_levels([1, 2]) - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false @provider.load_current_resource expect(@current_resource.enabled).to be true @@ -118,8 +118,8 @@ describe "Chef::Provider::Service::Redhat" do it "sets the current enabled status to false if the service is enabled at a run level it should not" do @new_resource.run_levels([1, 2]) - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:on 4:off 5:off 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:on 3:on 4:off 5:off 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false @provider.load_current_resource expect(@current_resource.enabled).to be false @@ -128,8 +128,8 @@ describe "Chef::Provider::Service::Redhat" do it "sets the current enabled status to false if the service is not enabled at specified run levels" do @new_resource.run_levels([ 2 ]) - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false @provider.load_current_resource expect(@current_resource.enabled).to be false @@ -142,10 +142,10 @@ describe "Chef::Provider::Service::Redhat" do context "when the service does not exist" do before do - status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service") + status = double("Status", exitstatus: 1, stdout: "", stderr: "chef: unrecognized service") expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status) - chkconfig = double("Chkconfig", :existatus => 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", existatus: 1, stdout: "", stderr: "error reading information on service chef: No such file or directory") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) @provider.load_current_resource @provider.define_resource_requirements end @@ -194,10 +194,10 @@ describe "Chef::Provider::Service::Redhat" do it_should_behave_like "define_resource_requirements_common" it "should not raise an error if the service does not exist" do - status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service") + status = double("Status", exitstatus: 1, stdout: "", stderr: "chef: unrecognized service") expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status) - chkconfig = double("Chkconfig", :existatus => 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", existatus: 1, stdout: "", stderr: "error reading information on service chef: No such file or directory") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) @provider.load_current_resource @provider.define_resource_requirements expect { @provider.process_resource_requirements }.not_to raise_error diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb index 8a03c0552d..e9fe1b0482 100644 --- a/spec/unit/provider/service/simple_service_spec.rb +++ b/spec/unit/provider/service/simple_service_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Provider::Service::Simple, "load_current_resource" do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = { :ps => "ps -ef" } + @node.automatic_attrs[:command] = { ps: "ps -ef" } @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -36,7 +36,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi simple_service_spec.rb NOMOCKINGSTRINGSPLZ - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) end @@ -51,13 +51,13 @@ NOMOCKINGSTRINGSPLZ end it "should raise error if the node has a nil ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => nil } + @node.automatic_attrs[:command] = { ps: nil } @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end it "should raise error if the node has an empty ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => "" } + @node.automatic_attrs[:command] = { ps: "" } @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end @@ -79,7 +79,7 @@ NOMOCKINGSTRINGSPLZ aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos NOMOCKINGSTRINGSPLZ - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) @provider.load_current_resource expect(@current_resource.running).to be_truthy diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb index a5148c236a..7b8bd950d2 100644 --- a/spec/unit/provider/service/solaris_smf_service_spec.rb +++ b/spec/unit/provider/service/solaris_smf_service_spec.rb @@ -74,19 +74,19 @@ describe Chef::Provider::Service::Solaris do ].join("\n") # shell_out! return value for a service that is running - @enabled_svc_status = double("Status", :exitstatus => 0, :stdout => enabled_svc_stdout, :stdin => "", :stderr => "") + @enabled_svc_status = double("Status", exitstatus: 0, stdout: enabled_svc_stdout, stdin: "", stderr: "") # shell_out! return value for a service that is disabled - @disabled_svc_status = double("Status", :exitstatus => 0, :stdout => disabled_svc_stdout, :stdin => "", :stderr => "") + @disabled_svc_status = double("Status", exitstatus: 0, stdout: disabled_svc_stdout, stdin: "", stderr: "") # shell_out! return value for a service that is in maintenance mode - @maintenance_svc_status = double("Status", :exitstatus => 0, :stdout => maintenance_svc_stdout, :stdin => "", :stderr => "") + @maintenance_svc_status = double("Status", exitstatus: 0, stdout: maintenance_svc_stdout, stdin: "", stderr: "") # shell_out! return value for a service that does not exist - @no_svc_status = double("Status", :exitstatus => 1, :stdout => "", :stdin => "", :stderr => "svcs: Pattern 'chef' doesn't match any instances\n") + @no_svc_status = double("Status", exitstatus: 1, stdout: "", stdin: "", stderr: "svcs: Pattern 'chef' doesn't match any instances\n") # shell_out! return value for a successful execution - @success = double("clear", :exitstatus => 0, :stdout => "", :stdin => "", :stderr => "") + @success = double("clear", exitstatus: 0, stdout: "", stdin: "", stderr: "") end it "should raise an error if /bin/svcs and /usr/sbin/svcadm are not executable" do @@ -116,19 +116,19 @@ describe Chef::Provider::Service::Solaris do describe "when discovering the current service state" do it "should create a current resource with the name of the new resource" do - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(Chef::Resource::Service).to receive(:new).and_return(@current_resource) expect(@provider.maintenance).to be_falsey @provider.load_current_resource end it "should return the current resource" do - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(@provider.load_current_resource).to eql(@current_resource) end it "should call '/bin/svcs -l service_name'" do - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) @provider.load_current_resource end @@ -163,7 +163,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm enable -s chef" do - expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success) @provider.load_current_resource @@ -173,7 +173,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm enable -s chef for start_service" do - expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success) @provider.load_current_resource @@ -183,7 +183,7 @@ describe Chef::Provider::Service::Solaris do it "should call svcadm clear chef for start_service when state maintenance" do # we are in maint mode - expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@maintenance_svc_status) + expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@maintenance_svc_status) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name).and_return(@success) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success) @@ -192,7 +192,7 @@ describe Chef::Provider::Service::Solaris do expect(@provider.enable_service).to be_truthy # now we are enabled - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) @provider.load_current_resource expect(@current_resource.enabled).to be_truthy @@ -206,7 +206,7 @@ describe Chef::Provider::Service::Solaris do it "should call svcadm enable -s -r chef" do @new_resource.options("-r") - expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", @current_resource.service_name).and_return(@success) @provider.load_current_resource @@ -216,7 +216,7 @@ describe Chef::Provider::Service::Solaris do it "should call svcadm enable -s -r -t chef when passed an array of options" do @new_resource.options(["-r", "-t"]) - expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", "-t", @current_resource.service_name).and_return(@success) @provider.load_current_resource @@ -232,7 +232,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm disable -s chef" do - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success) @provider.load_current_resource expect(@provider.disable_service).to be_truthy @@ -240,7 +240,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm disable -s chef for stop_service" do - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success) @provider.load_current_resource expect(@provider.disable_service).to be_truthy @@ -249,7 +249,7 @@ describe Chef::Provider::Service::Solaris do it "should call svcadm disable chef with options" do @new_resource.options("-t") - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "-t", "chef").and_return(@success) @provider.load_current_resource expect(@provider.disable_service).to be_truthy @@ -261,7 +261,7 @@ describe Chef::Provider::Service::Solaris do describe "when reloading the service" do before(:each) do @provider.current_resource = @current_resource - allow(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + allow(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) end it "should call svcadm refresh chef" do @@ -274,7 +274,7 @@ describe Chef::Provider::Service::Solaris do describe "when the service doesn't exist" do before(:each) do @provider.current_resource = @current_resource - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@no_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@no_svc_status) end it "should be marked not running" do diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb index 1082bdfdc4..ccd814a3a9 100644 --- a/spec/unit/provider/service/systemd_service_spec.rb +++ b/spec/unit/provider/service/systemd_service_spec.rb @@ -36,11 +36,11 @@ describe Chef::Provider::Service::Systemd do let(:provider) { Chef::Provider::Service::Systemd.new(new_resource, run_context) } let(:shell_out_success) do - double("shell_out", :exitstatus => 0, :error? => false) + double("shell_out", exitstatus: 0, error?: false) end let(:shell_out_failure) do - double("shell_out", :exitstatus => 1, :error? => true) + double("shell_out", exitstatus: 1, error?: true) end let(:current_resource) { Chef::Resource::Service.new(service_name) } @@ -190,14 +190,14 @@ describe Chef::Provider::Service::Systemd do context "when a user is specified" do it "should call '#{systemctl_path} --user start service_name' if no start command is specified" do current_resource.user("joe") - expect(provider).to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe", default_env: false }).and_return(shell_out_success) + expect(provider).to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, user: "joe", default_env: false }).and_return(shell_out_success) provider.start_service end it "should not call '#{systemctl_path} --user start service_name' if it is already running" do current_resource.running(true) current_resource.user("joe") - expect(provider).not_to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe" }) + expect(provider).not_to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, user: "joe" }) provider.start_service end end @@ -340,22 +340,22 @@ describe Chef::Provider::Service::Systemd do end it "should return true if '#{systemctl_path} --system is-enabled service_name' returns 'masked' and returns anything except 0" do - expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "masked", :exitstatus => shell_out_failure)) + expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "masked", exitstatus: shell_out_failure)) expect(provider.is_masked?).to be true end it "should return true if '#{systemctl_path} --system is-enabled service_name' outputs 'masked-runtime' and returns anything except 0" do - expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "masked-runtime", :exitstatus => shell_out_failure)) + expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "masked-runtime", exitstatus: shell_out_failure)) expect(provider.is_masked?).to be true end it "should return false if '#{systemctl_path} --system is-enabled service_name' returns 0" do - expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "enabled", :exitstatus => shell_out_success)) + expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "enabled", exitstatus: shell_out_success)) expect(provider.is_masked?).to be false end it "should return false if '#{systemctl_path} --system is-enabled service_name' returns anything except 0 and outputs an error'" do - expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "Failed to get unit file state for #{service_name}: No such file or directory", :exitstatus => shell_out_failure)) + expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "Failed to get unit file state for #{service_name}: No such file or directory", exitstatus: shell_out_failure)) expect(provider.is_masked?).to be false end end diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index a95f9c494e..ae94e49835 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Provider::Service::Upstart do let(:shell_out_success) do - double("shell_out", :exitstatus => 0, :error? => false) + double("shell_out", exitstatus: 0, error?: false) end before(:each) do @@ -66,7 +66,7 @@ describe Chef::Provider::Service::Upstart do describe "load_current_resource" do before(:each) do - @node.automatic_attrs[:command] = { :ps => "ps -ax" } + @node.automatic_attrs[:command] = { ps: "ps -ax" } @current_resource = Chef::Resource::Service.new("rsyslog") allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource) @@ -167,14 +167,14 @@ describe Chef::Provider::Service::Upstart do end it "should set enabled to true when it finds 'starts on'" do - @lines = double("start on filesystem", :gets => "start on filesystem") + @lines = double("start on filesystem", gets: "start on filesystem") allow(::File).to receive(:open).and_yield(@lines) expect(@current_resource).to receive(:running).with(false) @provider.load_current_resource end it "should set enabled to false when it finds '#starts on'" do - @lines = double("start on filesystem", :gets => "#start on filesystem") + @lines = double("start on filesystem", gets: "#start on filesystem") allow(::File).to receive(:open).and_yield(@lines) expect(@current_resource).to receive(:running).with(false) @provider.load_current_resource diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb index 18ea004795..978d180026 100644 --- a/spec/unit/provider/service/windows_spec.rb +++ b/spec/unit/provider/service/windows_spec.rb @@ -98,7 +98,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl Win32::Service::DISABLED = 0x00000004 allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "running")) allow(Win32::Service).to receive(:config_info).with(new_resource.service_name) .and_return(chef_service_config_info) @@ -502,8 +502,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "start_service" do before(:each) do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "stopped"), - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "stopped"), + double("StatusStruct", current_state: "running")) end it "calls the start command if one is specified" do @@ -528,7 +528,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "does nothing if the service is running" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "running")) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) provider.start_service @@ -537,7 +537,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "raises an error if the service is paused" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "paused")) + double("StatusStruct", current_state: "paused")) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) expect { provider.start_service }.to raise_error( Chef::Exceptions::Service ) @@ -546,9 +546,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "waits and continues if the service is in start_pending" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "start pending"), - double("StatusStruct", :current_state => "start pending"), - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "start pending"), + double("StatusStruct", current_state: "start pending"), + double("StatusStruct", current_state: "running")) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) provider.start_service @@ -557,7 +557,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "fails if the service is in stop_pending" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "stop pending")) + double("StatusStruct", current_state: "stop pending")) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) expect { provider.start_service }.to raise_error( Chef::Exceptions::Service ) @@ -597,8 +597,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl before(:each) do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "running"), - double("StatusStruct", :current_state => "stopped")) + double("StatusStruct", current_state: "running"), + double("StatusStruct", current_state: "stopped")) end it "calls the stop command if one is specified" do @@ -623,7 +623,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "does nothing if the service is stopped" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "stopped")) + double("StatusStruct", current_state: "stopped")) provider.load_current_resource expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name) provider.stop_service @@ -632,7 +632,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "raises an error if the service is paused" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "paused")) + double("StatusStruct", current_state: "paused")) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service ) @@ -641,9 +641,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "waits and continue if the service is in stop_pending" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "stop pending"), - double("StatusStruct", :current_state => "stop pending"), - double("StatusStruct", :current_state => "stopped")) + double("StatusStruct", current_state: "stop pending"), + double("StatusStruct", current_state: "stop pending"), + double("StatusStruct", current_state: "stopped")) provider.load_current_resource expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name) provider.stop_service @@ -652,7 +652,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "fails if the service is in start_pending" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "start pending")) + double("StatusStruct", current_state: "start pending")) provider.load_current_resource expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name) expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service ) @@ -661,7 +661,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "passes custom timeout to the stop command if provided" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "running")) new_resource.timeout 1 expect(Win32::Service).to receive(:stop).with(new_resource.service_name) Timeout.timeout(2) do @@ -683,10 +683,10 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "stops then starts the service if it is running" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "running"), - double("StatusStruct", :current_state => "stopped"), - double("StatusStruct", :current_state => "stopped"), - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "running"), + double("StatusStruct", current_state: "stopped"), + double("StatusStruct", current_state: "stopped"), + double("StatusStruct", current_state: "running")) expect(Win32::Service).to receive(:stop).with(new_resource.service_name) expect(Win32::Service).to receive(:start).with(new_resource.service_name) provider.restart_service @@ -695,9 +695,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "just starts the service if it is stopped" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "stopped"), - double("StatusStruct", :current_state => "stopped"), - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "stopped"), + double("StatusStruct", current_state: "stopped"), + double("StatusStruct", current_state: "running")) expect(Win32::Service).to receive(:start).with(new_resource.service_name) provider.restart_service expect(new_resource.updated_by_last_action?).to be_truthy @@ -716,11 +716,11 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "enable_service" do before(:each) do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "disabled")) + double("ConfigStruct", start_type: "disabled")) end it "enables service" do - expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START) + expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::AUTO_START) provider.enable_service expect(new_resource.updated_by_last_action?).to be_truthy end @@ -736,14 +736,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "action_enable" do it "does nothing if the service is enabled" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "auto start")) + double("ConfigStruct", start_type: "auto start")) expect(provider).not_to receive(:enable_service) provider.action_enable end it "enables the service if it is not set to automatic start" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "disabled")) + double("ConfigStruct", start_type: "disabled")) expect(provider).to receive(:enable_service) provider.action_enable end @@ -752,14 +752,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "action_disable" do it "does nothing if the service is disabled" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "disabled")) + double("ConfigStruct", start_type: "disabled")) expect(provider).not_to receive(:disable_service) provider.action_disable end it "disables the service if it is not set to disabled" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "auto start")) + double("ConfigStruct", start_type: "auto start")) expect(provider).to receive(:disable_service) provider.action_disable end @@ -768,7 +768,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "disable_service" do before(:each) do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "auto start")) + double("ConfigStruct", start_type: "auto start")) end it "disables service" do @@ -810,17 +810,17 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "set_start_type" do it "when called with :automatic it calls Win32::Service#configure with Win32::Service::AUTO_START" do - expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START) + expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::AUTO_START) provider.send(:set_startup_type, :automatic) end it "when called with :manual it calls Win32::Service#configure with Win32::Service::DEMAND_START" do - expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DEMAND_START) + expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::DEMAND_START) provider.send(:set_startup_type, :manual) end it "when called with :disabled it calls Win32::Service#configure with Win32::Service::DISABLED" do - expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DISABLED) + expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::DISABLED) provider.send(:set_startup_type, :disabled) end diff --git a/spec/unit/provider/service_spec.rb b/spec/unit/provider/service_spec.rb index c788cb223e..f3e725abb6 100644 --- a/spec/unit/provider/service_spec.rb +++ b/spec/unit/provider/service_spec.rb @@ -99,7 +99,7 @@ describe Chef::Provider::Service do describe "action_restart" do before do - @current_resource.supports(:restart => true) + @current_resource.supports(restart: true) end it "should restart the service if it's supported and set the resource as updated" do @@ -118,11 +118,11 @@ describe Chef::Provider::Service do describe "action_reload" do before do - @new_resource.supports(:reload => true) + @new_resource.supports(reload: true) end it "should raise an exception if reload isn't supported" do - @new_resource.supports(:reload => false) + @new_resource.supports(reload: false) @new_resource.reload_command(false) expect { @provider.run_action(:reload) }.to raise_error(Chef::Exceptions::UnsupportedAction) end diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb index 55d6dc5d24..8f364aa8c8 100644 --- a/spec/unit/provider/subversion_spec.rb +++ b/spec/unit/provider/subversion_spec.rb @@ -46,7 +46,7 @@ describe Chef::Provider::Subversion do it "converts resource attributes to options for shell_out" do expect(@provider.run_options).to eq({}) @resource.user "deployninja" - expect(@provider.run_options).to eq({ :user => "deployninja" }) + expect(@provider.run_options).to eq({ user: "deployninja" }) end context "determining the revision of the currently deployed code" do @@ -73,18 +73,18 @@ describe Chef::Provider::Subversion do "Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision "Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n" expect(::File).to receive(:exist?).at_least(1).times.with("/my/deploy/dir/.svn").and_return(true) - expected_command = ["svn info", { :cwd => "/my/deploy/dir", :returns => [0, 1] }] + expected_command = ["svn info", { cwd: "/my/deploy/dir", returns: [0, 1] }] expect(@provider).to receive(:shell_out!).with(*expected_command). - and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) + and_return(double("ShellOut result", stdout: example_svn_info, stderr: "")) expect(@provider.find_current_revision).to eql("11410") end it "gives nil as the current revision if the deploy dir isn't a SVN working copy" do example_svn_info = "svn: '/tmp/deploydir' is not a working copy\n" expect(::File).to receive(:exist?).with("/my/deploy/dir/.svn").and_return(true) - expected_command = ["svn info", { :cwd => "/my/deploy/dir", :returns => [0, 1] }] + expected_command = ["svn info", { cwd: "/my/deploy/dir", returns: [0, 1] }] expect(@provider).to receive(:shell_out!).with(*expected_command). - and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) + and_return(double("ShellOut result", stdout: example_svn_info, stderr: "")) expect(@provider.find_current_revision).to be_nil end @@ -128,18 +128,18 @@ describe Chef::Provider::Subversion do "Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision "Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n" @resource.revision "HEAD" - expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { :cwd => "/my/deploy/dir", :returns => [0, 1] }] + expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { cwd: "/my/deploy/dir", returns: [0, 1] }] expect(@provider).to receive(:shell_out!).with(*expected_command). - and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) + and_return(double("ShellOut result", stdout: example_svn_info, stderr: "")) expect(@provider.revision_int).to eql("11410") end it "returns a helpful message if data from `svn info` can't be parsed" do example_svn_info = "some random text from an error message\n" @resource.revision "HEAD" - expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { :cwd => "/my/deploy/dir", :returns => [0, 1] }] + expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { cwd: "/my/deploy/dir", returns: [0, 1] }] expect(@provider).to receive(:shell_out!).with(*expected_command). - and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) + and_return(double("ShellOut result", stdout: example_svn_info, stderr: "")) expect { @provider.revision_int }.to raise_error(RuntimeError, "Could not parse `svn info` data: some random text from an error message\n") end diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb index 5e57cbb840..8c42c41420 100644 --- a/spec/unit/provider/systemd_unit_spec.rb +++ b/spec/unit/provider/systemd_unit_spec.rb @@ -50,27 +50,27 @@ describe Chef::Provider::SystemdUnit do let(:user_cmd_opts) do { - :user => "joe", - :environment => { + user: "joe", + environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/1000/bus", }, } end let(:shell_out_success) do - double("shell_out", :exitstatus => 0, :error? => false) + double("shell_out", exitstatus: 0, error?: false) end let(:shell_out_failure) do - double("shell_out", :exitstatus => 1, :error? => true) + double("shell_out", exitstatus: 1, error?: true) end let(:shell_out_masked) do - double("shell_out", :exit_status => 0, :error? => false, :stdout => "masked") + double("shell_out", exit_status: 0, error?: false, stdout: "masked") end let(:shell_out_static) do - double("shell_out", :exit_status => 0, :error? => false, :stdout => "static") + double("shell_out", exit_status: 0, error?: false, stdout: "static") end before(:each) do diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb index 8f30d8f868..fb5d127d57 100644 --- a/spec/unit/provider/template/content_spec.rb +++ b/spec/unit/provider/template/content_spec.rb @@ -30,20 +30,20 @@ describe Chef::Provider::Template::Content do let(:new_resource) do double("Chef::Resource::Template (new)", - :cookbook_name => "openldap", - :recipe_name => "default", - :source_line => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'", - :source_line_file => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb", - :source_line_number => "2", - :source => "openldap_stuff.conf.erb", - :name => "openldap_stuff.conf", - :path => resource_path, - :local => false, - :cookbook => nil, - :variables => {}, - :inline_helper_blocks => {}, - :inline_helper_modules => [], - :helper_modules => []) + cookbook_name: "openldap", + recipe_name: "default", + source_line: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'", + source_line_file: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb", + source_line_number: "2", + source: "openldap_stuff.conf.erb", + name: "openldap_stuff.conf", + path: resource_path, + local: false, + cookbook: nil, + variables: {}, + inline_helper_blocks: {}, + inline_helper_modules: [], + helper_modules: []) end let(:rendered_file_locations) do @@ -58,7 +58,7 @@ describe Chef::Provider::Template::Content do cl.load_cookbooks cookbook_collection = Chef::CookbookCollection.new(cl) node = Chef::Node.new - double("Chef::Resource::RunContext", :node => node, :cookbook_collection => cookbook_collection) + double("Chef::Resource::RunContext", node: node, cookbook_collection: cookbook_collection) end let(:content) do @@ -130,20 +130,20 @@ describe Chef::Provider::Template::Content do describe "when using location helpers" do let(:new_resource) do double("Chef::Resource::Template (new)", - :cookbook_name => "openldap", - :recipe_name => "default", - :source_line => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'", - :source_line_file => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb", - :source_line_number => "2", - :source => "helpers.erb", - :name => "helpers.erb", - :path => CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb", - :local => false, - :cookbook => nil, - :variables => {}, - :inline_helper_blocks => {}, - :inline_helper_modules => [], - :helper_modules => []) + cookbook_name: "openldap", + recipe_name: "default", + source_line: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'", + source_line_file: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb", + source_line_number: "2", + source: "helpers.erb", + name: "helpers.erb", + path: CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb", + local: false, + cookbook: nil, + variables: {}, + inline_helper_blocks: {}, + inline_helper_modules: [], + helper_modules: []) end it "creates the template with the rendered content" do diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb index 9f69772bc8..a65846ecb2 100644 --- a/spec/unit/provider/template_spec.rb +++ b/spec/unit/provider/template_spec.rb @@ -27,7 +27,7 @@ describe Chef::Provider::Template do let(:node) { double("Chef::Node") } let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:logger) { double("Mixlib::Log::Child").as_null_object } - let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) } + let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) } let(:enclosing_directory) do canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) end @@ -50,7 +50,7 @@ describe Chef::Provider::Template do end let(:content) do - content = double("Chef::Provider::File::Content::Template", :template_location => "/foo/bar/baz") + content = double("Chef::Provider::File::Content::Template", template_location: "/foo/bar/baz") allow(File).to receive(:exists?).with("/foo/bar/baz").and_return(true) content end diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb index 8cc69f88af..7c6948bf84 100644 --- a/spec/unit/provider/user/pw_spec.rb +++ b/spec/unit/provider/user/pw_spec.rb @@ -202,7 +202,7 @@ describe Chef::Provider::User::Pw do end it "should run pw usermod with the username and the option -H 0" do - expect(@provider).to receive(:shell_out_compacted!).with( "pw usermod adam -H 0", { :input => "abracadabra" }).and_return(@status) + expect(@provider).to receive(:shell_out_compacted!).with( "pw usermod adam -H 0", { input: "abracadabra" }).and_return(@status) @provider.modify_password end diff --git a/spec/unit/provider/windows_task_spec.rb b/spec/unit/provider/windows_task_spec.rb index 66bd6854b6..39f39b37fe 100644 --- a/spec/unit/provider/windows_task_spec.rb +++ b/spec/unit/provider/windows_task_spec.rb @@ -70,20 +70,20 @@ describe Chef::Provider::WindowsTask, :windows_only do new_resource.frequency_modifier 15 new_resource.random_delay 60 result = { - :start_year => 2017, - :start_month => 12, - :start_day => 2, - :start_hour => 17, - :start_minute => 30, - :end_month => 0, - :end_day => 0, - :end_year => 0, - :trigger_type => 1, - :type => { :once => nil }, - :random_minutes_interval => 60, - :minutes_interval => 15, - :run_on_last_day_of_month => false, - :run_on_last_week_of_month => false + start_year: 2017, + start_month: 12, + start_day: 2, + start_hour: 17, + start_minute: 30, + end_month: 0, + end_day: 0, + end_year: 0, + trigger_type: 1, + type: { once: nil }, + random_minutes_interval: 60, + minutes_interval: 15, + run_on_last_day_of_month: false, + run_on_last_week_of_month: false } expect(provider.send(:trigger)).to eq(result) @@ -145,7 +145,7 @@ describe Chef::Provider::WindowsTask, :windows_only do new_resource.frequency_modifier 2 result = provider.send(:type) expect(result).to include(:once) - expect(result).to eq({ :once => nil }) + expect(result).to eq({ once: nil }) end it "returns type hash when frequency :daily" do diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb index 93d03756a7..3b16edaa4a 100644 --- a/spec/unit/recipe_spec.rb +++ b/spec/unit/recipe_spec.rb @@ -110,7 +110,7 @@ describe Chef::Recipe do it "locate resource for particular platform" do ShaunTheSheep = Class.new(Chef::Resource) ShaunTheSheep.resource_name :shaun_the_sheep - ShaunTheSheep.provides :laughter, :platform => ["television"] + ShaunTheSheep.provides :laughter, platform: ["television"] node.automatic[:platform] = "television" node.automatic[:platform_version] = "123" res = recipe.laughter "timmy" @@ -183,7 +183,7 @@ describe Chef::Recipe do it "does not add the resource to the resource collection" do zm_resource # force let binding evaluation - expect { run_context.resource_collection.resources(:zen_master => "klopp") }.to raise_error(Chef::Exceptions::ResourceNotFound) + expect { run_context.resource_collection.resources(zen_master: "klopp") }.to raise_error(Chef::Exceptions::ResourceNotFound) end end @@ -238,7 +238,7 @@ describe Chef::Recipe do it "adds the resource to the resource collection" do zm_resource # force let binding evaluation - expect(run_context.resource_collection.resources(:zen_master => "klopp")).to eq(zm_resource) + expect(run_context.resource_collection.resources(zen_master: "klopp")).to eq(zm_resource) end it "will insert another resource if create_if_missing is not set (cloned resource as of Chef-12)" do @@ -339,7 +339,7 @@ describe Chef::Recipe do describe "resource definitions" do it "should execute defined resources" do crow_define = Chef::ResourceDefinition.new - crow_define.define :crow, :peace => false, :something => true do + crow_define.define :crow, peace: false, something: true do zen_master "lao tzu" do peace params[:peace] something params[:something] @@ -349,13 +349,13 @@ describe Chef::Recipe do recipe.crow "mine" do peace true end - expect(run_context.resource_collection.resources(:zen_master => "lao tzu").name).to eql("lao tzu") - expect(run_context.resource_collection.resources(:zen_master => "lao tzu").something).to eql(true) + expect(run_context.resource_collection.resources(zen_master: "lao tzu").name).to eql("lao tzu") + expect(run_context.resource_collection.resources(zen_master: "lao tzu").something).to eql(true) end it "should set the node on defined resources" do crow_define = Chef::ResourceDefinition.new - crow_define.define :crow, :peace => false, :something => true do + crow_define.define :crow, peace: false, something: true do zen_master "lao tzu" do peace params[:peace] something params[:something] @@ -366,12 +366,12 @@ describe Chef::Recipe do recipe.crow "mine" do something node[:foo] end - expect(recipe.resources(:zen_master => "lao tzu").something).to eql(false) + expect(recipe.resources(zen_master: "lao tzu").something).to eql(false) end it "should return the last statement in the definition as the retval" do crow_define = Chef::ResourceDefinition.new - crow_define.define :crow, :peace => false, :something => true do + crow_define.define :crow, peace: false, something: true do "the return val" end run_context.definitions[:crow] = crow_define @@ -392,7 +392,7 @@ describe Chef::Recipe do end CODE expect { recipe.instance_eval(code) }.not_to raise_error - expect(recipe.resources(:zen_master => "gnome").name).to eql("gnome") + expect(recipe.resources(zen_master: "gnome").name).to eql("gnome") end end @@ -408,7 +408,7 @@ describe Chef::Recipe do describe "from_file" do it "should load a resource from a ruby file" do recipe.from_file(File.join(CHEF_SPEC_DATA, "recipes", "test.rb")) - res = recipe.resources(:file => "/etc/nsswitch.conf") + res = recipe.resources(file: "/etc/nsswitch.conf") expect(res.name).to eql("/etc/nsswitch.conf") expect(res.action).to eql([:create]) expect(res.owner).to eql("root") @@ -426,7 +426,7 @@ describe Chef::Recipe do expect(node).to receive(:loaded_recipe).with(:openldap, "gigantor") allow(run_context).to receive(:unreachable_cookbook?).with(:openldap).and_return(false) run_context.include_recipe "openldap::gigantor" - res = run_context.resource_collection.resources(:cat => "blanket") + res = run_context.resource_collection.resources(cat: "blanket") expect(res.name).to eql("blanket") expect(res.pretty_kitty).to eql(false) end @@ -435,7 +435,7 @@ describe Chef::Recipe do expect(node).to receive(:loaded_recipe).with(:openldap, "default") allow(run_context).to receive(:unreachable_cookbook?).with(:openldap).and_return(false) run_context.include_recipe "openldap" - res = run_context.resource_collection.resources(:cat => "blanket") + res = run_context.resource_collection.resources(cat: "blanket") expect(res.name).to eql("blanket") expect(res.pretty_kitty).to eql(true) end diff --git a/spec/unit/resource/conditional_spec.rb b/spec/unit/resource/conditional_spec.rb index c38ebbdd46..2a2e166e6c 100644 --- a/spec/unit/resource/conditional_spec.rb +++ b/spec/unit/resource/conditional_spec.rb @@ -22,7 +22,7 @@ require "ostruct" describe Chef::Resource::Conditional do before do allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(nil) - @status = OpenStruct.new(:success? => true) + @status = OpenStruct.new(success?: true) allow_any_instance_of(Mixlib::ShellOut).to receive(:status).and_return(@status) @parent_resource = Chef::Resource.new("", Chef::Node.new) end diff --git a/spec/unit/resource/cookbook_file_spec.rb b/spec/unit/resource/cookbook_file_spec.rb index 734fc152c1..c670d2f543 100644 --- a/spec/unit/resource/cookbook_file_spec.rb +++ b/spec/unit/resource/cookbook_file_spec.rb @@ -72,8 +72,8 @@ describe Chef::Resource::CookbookFile do state = resource.state_for_resource_reporter if Chef::Platform.windows? puts state - expect(state[:rights]).to eq([{ :permissions => :read, :principals => "Everyone" }]) - expect(state[:deny_rights]).to eq([{ :permissions => :full_control, :principals => "Clumsy_Sam" }]) + expect(state[:rights]).to eq([{ permissions: :read, principals: "Everyone" }]) + expect(state[:deny_rights]).to eq([{ permissions: :full_control, principals: "Clumsy_Sam" }]) else expect(state[:group]).to eq("wheel") expect(state[:mode]).to eq("0664") diff --git a/spec/unit/resource/dnf_package_spec.rb b/spec/unit/resource/dnf_package_spec.rb index 1b90fd3a0d..f4262a0396 100644 --- a/spec/unit/resource/dnf_package_spec.rb +++ b/spec/unit/resource/dnf_package_spec.rb @@ -59,19 +59,19 @@ describe Chef::Resource::DnfPackage, "flush_cache" do let(:resource) { Chef::Resource::DnfPackage.new("foo") } it "defaults the flush timing to false" do - flush_hash = { :before => false, :after => false } + flush_hash = { before: false, after: false } expect(resource.flush_cache).to eq(flush_hash) end it "allows you to set the flush timing with an array" do flush_array = [ :before, :after ] - flush_hash = { :before => true, :after => true } + flush_hash = { before: true, after: true } resource.flush_cache(flush_array) expect(resource.flush_cache).to eq(flush_hash) end it "allows you to set the flush timing with a hash" do - flush_hash = { :before => true, :after => true } + flush_hash = { before: true, after: true } resource.flush_cache(flush_hash) expect(resource.flush_cache).to eq(flush_hash) end diff --git a/spec/unit/resource/execute_spec.rb b/spec/unit/resource/execute_spec.rb index 947f6c608e..9bd434b74a 100644 --- a/spec/unit/resource/execute_spec.rb +++ b/spec/unit/resource/execute_spec.rb @@ -109,7 +109,7 @@ describe Chef::Resource::Execute do shared_examples_for "a consumer of the Execute resource" do context "when running on Windows" do before do - allow(resource).to receive(:node).and_return({ :platform_family => "windows" }) + allow(resource).to receive(:node).and_return({ platform_family: "windows" }) end context "when no user, domain, or password is specified" do @@ -211,7 +211,7 @@ describe Chef::Resource::Execute do context "when not running on Windows" do before do - allow(resource).to receive(:node).and_return({ :platform_family => "ubuntu" }) + allow(resource).to receive(:node).and_return({ platform_family: "ubuntu" }) end context "when no user, domain, or password is specified" do diff --git a/spec/unit/resource/file/verification/systemd_unit_spec.rb b/spec/unit/resource/file/verification/systemd_unit_spec.rb index 8a3d849582..b1f9239442 100644 --- a/spec/unit/resource/file/verification/systemd_unit_spec.rb +++ b/spec/unit/resource/file/verification/systemd_unit_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Resource::File::Verification::SystemdUnit do let(:command) { "#{systemd_analyze_path} verify %{path}" } - let(:opts) { { :future => true } } + let(:opts) { { future: true } } let(:parent_resource) { Chef::Resource.new("llama") } let(:systemd_analyze_path) { "/usr/bin/systemd-analyze" } let(:systemd_dir) { "/etc/systemd/system" } diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb index e46040268a..f0ec999019 100644 --- a/spec/unit/resource/file/verification_spec.rb +++ b/spec/unit/resource/file/verification_spec.rb @@ -48,7 +48,7 @@ describe Chef::Resource::File::Verification do it "accepts an options hash" do v = Chef::Resource::File::Verification.new(parent_resource, nil, {}) {} - expect { v.verify("/foo/bar", { :future => true }) }.to_not raise_error + expect { v.verify("/foo/bar", { future: true }) }.to_not raise_error end context "with a verification block" do diff --git a/spec/unit/resource/file_spec.rb b/spec/unit/resource/file_spec.rb index 7e9b96616a..5e649da1a9 100644 --- a/spec/unit/resource/file_spec.rb +++ b/spec/unit/resource/file_spec.rb @@ -113,15 +113,15 @@ describe Chef::Resource::File do end - describe "when access controls are set on windows", :windows_only => true do + describe "when access controls are set on windows", windows_only: true do before do resource.rights :read, "Everyone" resource.rights :full_control, "DOMAIN\User" end it "describes its state including windows ACL attributes" do state = resource.state_for_resource_reporter - expect(state[:rights]).to eq([ { :permissions => :read, :principals => "Everyone" }, - { :permissions => :full_control, :principals => "DOMAIN\User" } ]) + expect(state[:rights]).to eq([ { permissions: :read, principals: "Everyone" }, + { permissions: :full_control, principals: "DOMAIN\User" } ]) end end end diff --git a/spec/unit/resource/freebsd_package_spec.rb b/spec/unit/resource/freebsd_package_spec.rb index 9747c41a88..154bd09616 100644 --- a/spec/unit/resource/freebsd_package_spec.rb +++ b/spec/unit/resource/freebsd_package_spec.rb @@ -79,8 +79,8 @@ describe Chef::Resource::FreebsdPackage do describe "if pkgng enabled" do it "is Freebsd::Pkgng" do - pkg_enabled = OpenStruct.new(:stdout => "yes\n") - allow(resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", :env => nil).and_return(pkg_enabled) + pkg_enabled = OpenStruct.new(stdout: "yes\n") + allow(resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled) resource.after_created expect(resource.provider).to eq(Chef::Provider::Package::Freebsd::Pkgng) end @@ -88,8 +88,8 @@ describe Chef::Resource::FreebsdPackage do describe "if freebsd_version is less than 1000017 and pkgng not enabled" do it "is Freebsd::Pkg" do - pkg_enabled = OpenStruct.new(:stdout => "\n") - allow(resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", :env => nil).and_return(pkg_enabled) + pkg_enabled = OpenStruct.new(stdout: "\n") + allow(resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled) [1000016, 1000000, 901503, 902506, 802511].each do |freebsd_version| node.automatic_attrs[:os_version] = freebsd_version diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb index 638d8718c7..10bef38410 100644 --- a/spec/unit/resource/group_spec.rb +++ b/spec/unit/resource/group_spec.rb @@ -72,7 +72,7 @@ describe Chef::Resource::Group, "group_name" do end it "does not allow a hash" do - expect { resource.send(:group_name, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError) + expect { resource.send(:group_name, { aj: "is freakin awesome" }) }.to raise_error(ArgumentError) end end @@ -85,7 +85,7 @@ describe Chef::Resource::Group, "gid" do end it "does not allow a hash" do - expect { resource.send(:gid, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError) + expect { resource.send(:gid, { aj: "is freakin awesome" }) }.to raise_error(ArgumentError) end end @@ -109,7 +109,7 @@ describe Chef::Resource::Group, "members" do end it "(#{method}) does not allow a hash" do - expect { resource.send(method, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError) + expect { resource.send(method, { aj: "is freakin awesome" }) }.to raise_error(ArgumentError) end end end @@ -127,7 +127,7 @@ describe Chef::Resource::Group, "append" do end it "does not allow a hash" do - expect { resource.send(:gid, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError) + expect { resource.send(:gid, { aj: "is freakin awesome" }) }.to raise_error(ArgumentError) end describe "when it has members" do diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb index 721f30cf09..ec6fb1232a 100644 --- a/spec/unit/resource/mount_spec.rb +++ b/spec/unit/resource/mount_spec.rb @@ -144,19 +144,19 @@ describe Chef::Resource::Mount do end it "defaults all feature support to false" do - support_hash = { :remount => false } + support_hash = { remount: false } expect(resource.supports).to eq(support_hash) end it "allows you to set feature support as an array" do support_array = [ :remount ] - support_hash = { :remount => true } + support_hash = { remount: true } resource.supports(support_array) expect(resource.supports).to eq(support_hash) end it "allows you to set feature support as a hash" do - support_hash = { :remount => true } + support_hash = { remount: true } resource.supports(support_hash) expect(resource.supports).to eq(support_hash) end diff --git a/spec/unit/resource/package_spec.rb b/spec/unit/resource/package_spec.rb index 79a714edfc..b0e1304775 100644 --- a/spec/unit/resource/package_spec.rb +++ b/spec/unit/resource/package_spec.rb @@ -56,8 +56,8 @@ describe Chef::Resource::Package do end it "accepts a hash for response file template variables" do - resource.response_file_variables({ :variables => true }) - expect(resource.response_file_variables).to eql({ :variables => true }) + resource.response_file_variables({ variables: true }) + expect(resource.response_file_variables).to eql({ variables: true }) end it "accepts a string for the source" do diff --git a/spec/unit/resource/powershell_package_source_spec.rb b/spec/unit/resource/powershell_package_source_spec.rb index d8cb8a09a0..4033f4515f 100644 --- a/spec/unit/resource/powershell_package_source_spec.rb +++ b/spec/unit/resource/powershell_package_source_spec.rb @@ -205,13 +205,13 @@ describe Chef::Resource::PowershellPackageSource do describe "#package_source_exists?" do it "returns true if it exists" do - allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", :stdout => "MyGallery\r\n")) + allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", stdout: "MyGallery\r\n")) resource.source_name("MyGallery") expect(provider.package_source_exists?).to eql(true) end it "returns false if it doesn't exist" do - allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", :stdout => "")) + allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", stdout: "")) resource.source_name("MyGallery") expect(provider.package_source_exists?).to eql(false) end diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb index 9cdb6fdbee..9afd202f91 100644 --- a/spec/unit/resource/powershell_script_spec.rb +++ b/spec/unit/resource/powershell_script_spec.rb @@ -87,7 +87,7 @@ describe Chef::Resource::PowershellScript do it "enables convert_boolean_return by default for guards in the context of powershell_script when no guard params are specified" do allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - { :convert_boolean_return => true, :code => "$true" }).and_return(Proc.new {}) + { convert_boolean_return: true, code: "$true" }).and_return(Proc.new {}) resource.only_if("$true") end @@ -98,27 +98,27 @@ describe Chef::Resource::PowershellScript do file_resource.guard_interpreter :powershell_script allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - { :convert_boolean_return => true, :code => "$true" }).and_return(Proc.new {}) + { convert_boolean_return: true, code: "$true" }).and_return(Proc.new {}) resource.only_if("$true") end it "enables convert_boolean_return by default for guards in the context of powershell_script when guard params are specified" do - guard_parameters = { :cwd => "/etc/chef", :architecture => :x86_64 } + guard_parameters = { cwd: "/etc/chef", architecture: :x86_64 } allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - { :convert_boolean_return => true, :code => "$true" }.merge(guard_parameters)).and_return(Proc.new {}) + { convert_boolean_return: true, code: "$true" }.merge(guard_parameters)).and_return(Proc.new {}) resource.only_if("$true", guard_parameters) end it "passes convert_boolean_return as true if it was specified as true in a guard parameter" do - guard_parameters = { :cwd => "/etc/chef", :convert_boolean_return => true, :architecture => :x86_64 } + guard_parameters = { cwd: "/etc/chef", convert_boolean_return: true, architecture: :x86_64 } allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - { :convert_boolean_return => true, :code => "$true" }.merge(guard_parameters)).and_return(Proc.new {}) + { convert_boolean_return: true, code: "$true" }.merge(guard_parameters)).and_return(Proc.new {}) resource.only_if("$true", guard_parameters) end it "passes convert_boolean_return as false if it was specified as true in a guard parameter" do - other_guard_parameters = { :cwd => "/etc/chef", :architecture => :x86_64 } - parameters_with_boolean_disabled = other_guard_parameters.merge({ :convert_boolean_return => false, :code => "$true" }) + other_guard_parameters = { cwd: "/etc/chef", architecture: :x86_64 } + parameters_with_boolean_disabled = other_guard_parameters.merge({ convert_boolean_return: false, code: "$true" }) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( parameters_with_boolean_disabled).and_return(Proc.new {}) resource.only_if("$true", parameters_with_boolean_disabled) diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb index c7e95c37be..147bc8492c 100644 --- a/spec/unit/resource/registry_key_spec.rb +++ b/spec/unit/resource/registry_key_spec.rb @@ -72,7 +72,7 @@ describe Chef::Resource::RegistryKey, "key" do end it "does not allow a hash" do - expect { resource.send(:key, { :sonic => "screwdriver" }) }.to raise_error(ArgumentError) + expect { resource.send(:key, { sonic: "screwdriver" }) }.to raise_error(ArgumentError) end end @@ -80,26 +80,26 @@ describe Chef::Resource::RegistryKey, "values" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } it "allows a single proper hash of registry values" do - resource.values( { :name => "poosh", :type => :string, :data => "carmen" } ) - expect(resource.values).to eql([ { :name => "poosh", :type => :string, :data => "carmen" } ]) + resource.values( { name: "poosh", type: :string, data: "carmen" } ) + expect(resource.values).to eql([ { name: "poosh", type: :string, data: "carmen" } ]) end it "allows an array of proper hashes of registry values" do - resource.values [ { :name => "poosh", :type => :string, :data => "carmen" } ] - expect(resource.values).to eql([ { :name => "poosh", :type => :string, :data => "carmen" } ]) + resource.values [ { name: "poosh", type: :string, data: "carmen" } ] + expect(resource.values).to eql([ { name: "poosh", type: :string, data: "carmen" } ]) end it "returns checksummed data if the type is unsafe" do - resource.values( { :name => "poosh", :type => :binary, :data => 255.chr * 1 }) - expect(resource.values).to eql([ { :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" } ]) + resource.values( { name: "poosh", type: :binary, data: 255.chr * 1 }) + expect(resource.values).to eql([ { name: "poosh", type: :binary, data: "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" } ]) end it "raises an exception if the name field is missing" do - expect { resource.values [ { :type => :string, :data => "carmen" } ] }.to raise_error(ArgumentError) + expect { resource.values [ { type: :string, data: "carmen" } ] }.to raise_error(ArgumentError) end it "raises an exception if extra fields are present" do - expect { resource.values [ { :name => "poosh", :type => :string, :data => "carmen", :screwdriver => "sonic" } ] }.to raise_error(ArgumentError) + expect { resource.values [ { name: "poosh", type: :string, data: "carmen", screwdriver: "sonic" } ] }.to raise_error(ArgumentError) end it "does not allow a string" do @@ -111,26 +111,26 @@ describe Chef::Resource::RegistryKey, "values" do end it "raises an exception if type of name is not string" do - expect { resource.values([ { :name => 123, :type => :string, :data => "carmen" } ]) }.to raise_error(ArgumentError) + expect { resource.values([ { name: 123, type: :string, data: "carmen" } ]) }.to raise_error(ArgumentError) end it "does not raise an exception if type of name is string" do - expect { resource.values([ { :name => "123", :type => :string, :data => "carmen" } ]) }.to_not raise_error + expect { resource.values([ { name: "123", type: :string, data: "carmen" } ]) }.to_not raise_error end context "type key not given" do it "does not raise an exception" do - expect { resource.values([ { :name => "123", :data => "carmen" } ]) }.to_not raise_error + expect { resource.values([ { name: "123", data: "carmen" } ]) }.to_not raise_error end end context "type key given" do it "raises an exception if type of type is not symbol" do - expect { resource.values([ { :name => "123", :type => "string", :data => "carmen" } ]) }.to raise_error(ArgumentError) + expect { resource.values([ { name: "123", type: "string", data: "carmen" } ]) }.to raise_error(ArgumentError) end it "does not raise an exception if type of type is symbol" do - expect { resource.values([ { :name => "123", :type => :string, :data => "carmen" } ]) }.to_not raise_error + expect { resource.values([ { name: "123", type: :string, data: "carmen" } ]) }.to_not raise_error end end end @@ -144,7 +144,7 @@ describe Chef::Resource::RegistryKey, "recursive" do end it "does not allow a hash" do - expect { resource.recursive({ :sonic => :screwdriver }) }.to raise_error(ArgumentError) + expect { resource.recursive({ sonic: :screwdriver }) }.to raise_error(ArgumentError) end it "does not allow an array" do @@ -175,7 +175,7 @@ describe Chef::Resource::RegistryKey, "architecture" do end it "does not allow a hash" do - expect { resource.architecture({ :sonic => :screwdriver }) }.to raise_error(ArgumentError) + expect { resource.architecture({ sonic: :screwdriver }) }.to raise_error(ArgumentError) end it "does not allow an array" do @@ -195,7 +195,7 @@ describe Chef::Resource::RegistryKey, ":unscrubbed_values" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } it "returns unsafe data as-is" do - key_values = [ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ] + key_values = [ { name: "poosh", type: :binary, data: 255.chr * 1 } ] resource.values(key_values) expect(resource.unscrubbed_values).to eql(key_values) end @@ -205,7 +205,7 @@ describe Chef::Resource::RegistryKey, "state" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } it "returns scrubbed values" do - resource.values([ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ]) - expect(resource.state_for_resource_reporter[:values]).to eql( [{ :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" }] ) + resource.values([ { name: "poosh", type: :binary, data: 255.chr * 1 } ]) + expect(resource.state_for_resource_reporter[:values]).to eql( [{ name: "poosh", type: :binary, data: "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" }] ) end end diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb index 581b2dbf6e..39d34d9a96 100644 --- a/spec/unit/resource/remote_file_spec.rb +++ b/spec/unit/resource/remote_file_spec.rb @@ -199,8 +199,8 @@ describe Chef::Resource::RemoteFile do state = resource.state_for_resource_reporter if Chef::Platform.windows? puts state - expect(state[:rights]).to eq([{ :permissions => :read, :principals => "Everyone" }]) - expect(state[:deny_rights]).to eq([{ :permissions => :full_control, :principals => "Clumsy_Sam" }]) + expect(state[:rights]).to eq([{ permissions: :read, principals: "Everyone" }]) + expect(state[:deny_rights]).to eq([{ permissions: :full_control, principals: "Clumsy_Sam" }]) else expect(state[:group]).to eq("pokemon") expect(state[:mode]).to eq("0664") diff --git a/spec/unit/resource/resource_notification_spec.rb b/spec/unit/resource/resource_notification_spec.rb index e141e01fcf..07fd63bb2b 100644 --- a/spec/unit/resource/resource_notification_spec.rb +++ b/spec/unit/resource/resource_notification_spec.rb @@ -65,7 +65,7 @@ describe Chef::Resource::Notification do end it "resolves a lazy reference to a resource" do - notification.resource = { :cat => "keyboard_cat" } + notification.resource = { cat: "keyboard_cat" } @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") @resource_collection = Chef::ResourceCollection.new @resource_collection << @keyboard_cat @@ -78,7 +78,7 @@ describe Chef::Resource::Notification do it "resolves a lazy reference to its notifying resource" do @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") notification.resource = @keyboard_cat - notification.notifying_resource = { :cat => "long_cat" } + notification.notifying_resource = { cat: "long_cat" } @long_cat = Chef::Resource::Cat.new("long_cat") @resource_collection = Chef::ResourceCollection.new @resource_collection << @long_cat @@ -87,11 +87,11 @@ describe Chef::Resource::Notification do end it "resolves lazy references to both its resource and its notifying resource" do - notification.resource = { :cat => "keyboard_cat" } + notification.resource = { cat: "keyboard_cat" } @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") @resource_collection = Chef::ResourceCollection.new @resource_collection << @keyboard_cat - notification.notifying_resource = { :cat => "long_cat" } + notification.notifying_resource = { cat: "long_cat" } @long_cat = Chef::Resource::Cat.new("long_cat") @resource_collection << @long_cat notification.resolve_resource_reference(@resource_collection) @@ -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 => %w{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 => %w{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 @@ -124,7 +124,7 @@ describe Chef::Resource::Notification do end it "raises a RuntimeError if it can't find a resource in the resource collection when resolving a lazy reference" do - notification.resource = { :cat => "keyboard_cat" } + notification.resource = { cat: "keyboard_cat" } @cheez_cat = Chef::Resource::Cat.new("cheez_cat") @resource_collection = Chef::ResourceCollection.new @resource_collection << @cheez_cat @@ -134,7 +134,7 @@ describe Chef::Resource::Notification do end it "raises a RuntimeError if it can't find a notifying resource in the resource collection when resolving a lazy reference" do - notification.notifying_resource = { :cat => "long_cat" } + notification.notifying_resource = { cat: "long_cat" } @cheez_cat = Chef::Resource::Cat.new("cheez_cat") @resource_collection = Chef::ResourceCollection.new @resource_collection << @cheez_cat diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb index fc82c19b79..963c2b2d89 100644 --- a/spec/unit/resource/service_spec.rb +++ b/spec/unit/resource/service_spec.rb @@ -168,19 +168,19 @@ describe Chef::Resource::Service do end it "defaults all the feature support to nil" do - support_hash = { :status => nil, :restart => nil, :reload => nil } + support_hash = { status: nil, restart: nil, reload: nil } expect(resource.supports).to eq(support_hash) end it "allows you to set what features this resource supports as a array" do support_array = [ :status, :restart ] - support_hash = { :status => true, :restart => true } + support_hash = { status: true, restart: true } resource.supports(support_array) expect(resource.supports).to eq(support_hash) end it "allows you to set what features this resource supports as a hash" do - support_hash = { :status => true, :restart => true } + support_hash = { status: true, restart: true } resource.supports(support_hash) expect(resource.supports).to eq(support_hash) end diff --git a/spec/unit/resource/template_spec.rb b/spec/unit/resource/template_spec.rb index 06469f2f9c..56af50517c 100644 --- a/spec/unit/resource/template_spec.rb +++ b/spec/unit/resource/template_spec.rb @@ -64,8 +64,8 @@ describe Chef::Resource::Template do describe "variables" do it "accepts a hash for the variable list" do - resource.variables({ :reluctance => :awkward }) - expect(resource.variables).to eq({ :reluctance => :awkward }) + resource.variables({ reluctance: :awkward }) + expect(resource.variables).to eq({ reluctance: :awkward }) end end diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb index 1c583afc44..2a96c5328d 100644 --- a/spec/unit/resource/user_spec.rb +++ b/spec/unit/resource/user_spec.rb @@ -75,7 +75,7 @@ end end it "does not allow a hash" do - expect { resource.send(attrib, { :woot => "i found it" }) }.to raise_error(ArgumentError) + expect { resource.send(attrib, { woot: "i found it" }) }.to raise_error(ArgumentError) end end end @@ -95,7 +95,7 @@ end end it "does not allow a hash" do - expect { resource.send(attrib, { :woot => "i found it" }) }.to raise_error(ArgumentError) + expect { resource.send(attrib, { woot: "i found it" }) }.to raise_error(ArgumentError) end end diff --git a/spec/unit/resource/yum_package_spec.rb b/spec/unit/resource/yum_package_spec.rb index ce289ce45a..d1dc1a3cce 100644 --- a/spec/unit/resource/yum_package_spec.rb +++ b/spec/unit/resource/yum_package_spec.rb @@ -90,19 +90,19 @@ describe Chef::Resource::YumPackage, "flush_cache" do end it "should default the flush timing to false" do - flush_hash = { :before => false, :after => false } + flush_hash = { before: false, after: false } expect(@resource.flush_cache).to eq(flush_hash) end it "should allow you to set the flush timing with an array" do flush_array = [ :before, :after ] - flush_hash = { :before => true, :after => true } + flush_hash = { before: true, after: true } @resource.flush_cache(flush_array) expect(@resource.flush_cache).to eq(flush_hash) end it "should allow you to set the flush timing with a hash" do - flush_hash = { :before => true, :after => true } + flush_hash = { before: true, after: true } @resource.flush_cache(flush_hash) expect(@resource.flush_cache).to eq(flush_hash) end diff --git a/spec/unit/resource_collection/resource_set_spec.rb b/spec/unit/resource_collection/resource_set_spec.rb index 9955bc2bea..403be4c566 100644 --- a/spec/unit/resource_collection/resource_set_spec.rb +++ b/spec/unit/resource_collection/resource_set_spec.rb @@ -73,25 +73,25 @@ describe Chef::ResourceCollection::ResourceSet do it "should find a resource by type symbol and name" do collection.insert_as(zen_master) - expect(collection.find(:zen_master => zen_master_name)).to equal(zen_master) + expect(collection.find(zen_master: zen_master_name)).to equal(zen_master) end it "should find a resource by type symbol and array of names" do collection.insert_as(zen_master) collection.insert_as(zen_master2) - check_by_names(collection.find(:zen_master => [zen_master_name, zen_master2_name]), zen_master_name, zen_master2_name) + check_by_names(collection.find(zen_master: [zen_master_name, zen_master2_name]), zen_master_name, zen_master2_name) end 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 => %w{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 collection.insert_as(zen_master) collection.insert_as(zen_follower) - check_by_names(collection.find(:zen_master => [zen_master_name], :zen_follower => [zen_follower_name]), + check_by_names(collection.find(zen_master: [zen_master_name], zen_follower: [zen_follower_name]), zen_master_name, zen_follower_name) end @@ -99,7 +99,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 => %w{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 @@ -215,7 +215,7 @@ describe Chef::ResourceCollection::ResourceSet do end it "accepts a single-element :resource_type => 'resource_name' Hash" do - expect(collection.validate_lookup_spec!(:service => "apache2")).to be_truthy + expect(collection.validate_lookup_spec!(service: "apache2")).to be_truthy end it "accepts a chef resource object" do diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb index c696572b13..8dd367b0ec 100644 --- a/spec/unit/resource_collection_spec.rb +++ b/spec/unit/resource_collection_spec.rb @@ -65,7 +65,7 @@ describe Chef::ResourceCollection do end it "should accept named arguments in any order" do - rc.insert(resource, :instance_name => "foo", :resource_type => "bar") + rc.insert(resource, instance_name: "foo", resource_type: "bar") expect(rc[0]).to eq(resource) end @@ -196,19 +196,19 @@ describe Chef::ResourceCollection do it "should find a resource by symbol and name (:zen_master => monkey)" do load_up_resources - expect(rc.resources(:zen_master => "monkey").name).to eql("monkey") + expect(rc.resources(zen_master: "monkey").name).to eql("monkey") end it "should find a resource by symbol and array of names (:zen_master => [a,b])" do load_up_resources - results = rc.resources(:zen_master => %w{monkey dog}) + results = rc.resources(zen_master: %w{monkey dog}) expect(results.length).to eql(2) check_by_names(results, "monkey", "dog") end it "should find resources of multiple kinds (:zen_master => a, :file => b)" do load_up_resources - results = rc.resources(:zen_master => "monkey", :file => "something") + results = rc.resources(zen_master: "monkey", file: "something") expect(results.length).to eql(2) check_by_names(results, "monkey", "something") end @@ -253,7 +253,7 @@ describe Chef::ResourceCollection do end it "accepts a single-element :resource_type => 'resource_name' Hash" do - expect(rc.validate_lookup_spec!(:service => "apache2")).to be_truthy + expect(rc.validate_lookup_spec!(service: "apache2")).to be_truthy end it "accepts a chef resource object" do diff --git a/spec/unit/resource_definition_spec.rb b/spec/unit/resource_definition_spec.rb index cc19cc7a01..5be3e59009 100644 --- a/spec/unit/resource_definition_spec.rb +++ b/spec/unit/resource_definition_spec.rb @@ -66,13 +66,13 @@ describe Chef::ResourceDefinition do it "should accept a new definition with a hash" do expect do - defn.define :smoke, :cigar => "cuban", :cigarette => "marlboro" do + defn.define :smoke, cigar: "cuban", cigarette: "marlboro" do end end.not_to raise_error end it "should expose the prototype hash params in the params hash" do - defn.define(:smoke, :cigar => "cuban", :cigarette => "marlboro") {} + defn.define(:smoke, cigar: "cuban", cigarette: "marlboro") {} expect(defn.params[:cigar]).to eql("cuban") expect(defn.params[:cigarette]).to eql("marlboro") end diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb index 97a4fe4b30..042b09659c 100644 --- a/spec/unit/resource_reporter_spec.rb +++ b/spec/unit/resource_reporter_spec.rb @@ -42,7 +42,7 @@ describe Chef::ResourceReporter do @new_resource = Chef::Resource::File.new("/tmp/a-file.txt") @cookbook_name = "monkey" @new_resource.cookbook_name = @cookbook_name - @cookbook_version = double("Cookbook::Version", :version => "1.2.3") + @cookbook_version = double("Cookbook::Version", version: "1.2.3") allow(@new_resource).to receive(:cookbook_version).and_return(@cookbook_version) @current_resource = Chef::Resource::File.new("/tmp/a-file.txt") @start_time = Time.new @@ -285,7 +285,7 @@ describe Chef::ResourceReporter do end it "resource_command in prepared_run_data should be blank" do - expect(@first_update_report["after"]).to eq({ :command => "sensitive-resource" }) + expect(@first_update_report["after"]).to eq({ command: "sensitive-resource" }) end end @@ -317,9 +317,9 @@ describe Chef::ResourceReporter do context "the new_resource name and id are hashes" do before do @bad_resource = Chef::Resource::File.new("/tmp/filename_as_hash.txt") - allow(@bad_resource).to receive(:name).and_return({ :foo => :bar }) - allow(@bad_resource).to receive(:identity).and_return({ :foo => :bar }) - allow(@bad_resource).to receive(:path).and_return({ :foo => :bar }) + allow(@bad_resource).to receive(:name).and_return({ foo: :bar }) + allow(@bad_resource).to receive(:identity).and_return({ foo: :bar }) + allow(@bad_resource).to receive(:path).and_return({ foo: :bar }) @resource_reporter.resource_action_start(@bad_resource, :create) @resource_reporter.resource_current_state_loaded(@bad_resource, :create, @current_resource) @resource_reporter.resource_updated(@bad_resource, :create) @@ -472,7 +472,7 @@ describe Chef::ResourceReporter do context "when the resource is a RegistryKey with binary data" do let(:new_resource) do resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs') - resource.values([ { :name => "rick", :type => :binary, :data => 255.chr * 1 } ]) + resource.values([ { name: "rick", type: :binary, data: 255.chr * 1 } ]) allow(resource).to receive(:cookbook_name).and_return(@cookbook_name) allow(resource).to receive(:cookbook_version).and_return(@cookbook_version) resource @@ -480,7 +480,7 @@ describe Chef::ResourceReporter do let(:current_resource) do resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs') - resource.values([ { :name => "rick", :type => :binary, :data => 255.chr * 1 } ]) + resource.values([ { name: "rick", type: :binary, data: 255.chr * 1 } ]) resource end @@ -617,8 +617,8 @@ describe Chef::ResourceReporter do @response = Net::HTTPNotFound.new("a response body", "404", "Not Found") @error = Net::HTTPServerException.new("404 message", @response) expect(@rest_client).to receive(:post). - with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id, - :start_time => @start_time.to_s }, + with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, + start_time: @start_time.to_s }, { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }). and_raise(@error) end @@ -647,7 +647,7 @@ describe Chef::ResourceReporter do @response = Net::HTTPInternalServerError.new("a response body", "500", "Internal Server Error") @error = Net::HTTPServerException.new("500 message", @response) expect(@rest_client).to receive(:post). - with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id, :start_time => @start_time.to_s }, + with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s }, { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }). and_raise(@error) end @@ -677,7 +677,7 @@ describe Chef::ResourceReporter do @response = Net::HTTPInternalServerError.new("a response body", "500", "Internal Server Error") @error = Net::HTTPServerException.new("500 message", @response) expect(@rest_client).to receive(:post). - with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id, :start_time => @start_time.to_s }, + with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s }, { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }). and_raise(@error) end @@ -698,7 +698,7 @@ describe Chef::ResourceReporter do before do response = { "uri" => "https://example.com/reports/nodes/spitfire/runs/@run_id" } expect(@rest_client).to receive(:post). - with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id, :start_time => @start_time.to_s }, + with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s }, { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }). and_return(response) @resource_reporter.run_started(@run_status) diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 26660c9415..28a1e01872 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -230,54 +230,54 @@ describe Chef::Resource do describe "notifies" do it "should make notified resources appear in the actions hash" do run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee") - resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee") + resource.notifies :reload, run_context.resource_collection.find(zen_master: "coffee") expect(resource.delayed_notifications.detect { |e| e.resource.name == "coffee" && e.action == :reload }).not_to be_nil end it "should make notified resources be capable of acting immediately" do run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee") - resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee"), :immediate + resource.notifies :reload, run_context.resource_collection.find(zen_master: "coffee"), :immediate expect(resource.immediate_notifications.detect { |e| e.resource.name == "coffee" && e.action == :reload }).not_to be_nil end it "should raise an exception if told to act in other than :delay or :immediate(ly)" do run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee") expect do - resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee"), :someday + resource.notifies :reload, run_context.resource_collection.find(zen_master: "coffee"), :someday end.to raise_error(ArgumentError) end it "should allow multiple notified resources appear in the actions hash" do run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee") - resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee") + resource.notifies :reload, run_context.resource_collection.find(zen_master: "coffee") expect(resource.delayed_notifications.detect { |e| e.resource.name == "coffee" && e.action == :reload }).not_to be_nil run_context.resource_collection << Chef::Resource::ZenMaster.new("beans") - resource.notifies :reload, run_context.resource_collection.find(:zen_master => "beans") + resource.notifies :reload, run_context.resource_collection.find(zen_master: "beans") expect(resource.delayed_notifications.detect { |e| e.resource.name == "beans" && e.action == :reload }).not_to be_nil end it "creates a notification for a resource that is not yet in the resource collection" do - resource.notifies(:restart, :service => "apache") - expected_notification = Chef::Resource::Notification.new({ :service => "apache" }, :restart, resource) + resource.notifies(:restart, service: "apache") + expected_notification = Chef::Resource::Notification.new({ service: "apache" }, :restart, resource) expect(resource.delayed_notifications).to include(expected_notification) end it "notifies another resource immediately" do - resource.notifies_immediately(:restart, :service => "apache") - expected_notification = Chef::Resource::Notification.new({ :service => "apache" }, :restart, resource) + resource.notifies_immediately(:restart, service: "apache") + expected_notification = Chef::Resource::Notification.new({ service: "apache" }, :restart, resource) expect(resource.immediate_notifications).to include(expected_notification) end it "notifies a resource to take action at the end of the chef run" do - resource.notifies_delayed(:restart, :service => "apache") - expected_notification = Chef::Resource::Notification.new({ :service => "apache" }, :restart, resource) + resource.notifies_delayed(:restart, service: "apache") + expected_notification = Chef::Resource::Notification.new({ service: "apache" }, :restart, resource) expect(resource.delayed_notifications).to include(expected_notification) 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(%w{coffee tea}) - resource.notifies :reload, run_context.resource_collection.find(:zen_master => "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 @@ -302,26 +302,26 @@ describe Chef::Resource do describe "subscribes" do it "should make resources appear in the actions hash of subscribed nodes" do run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee") - zr = run_context.resource_collection.find(:zen_master => "coffee") + zr = run_context.resource_collection.find(zen_master: "coffee") resource.subscribes :reload, zr expect(zr.delayed_notifications.detect { |e| e.resource.name == "funk" && e.action == :reload }).not_to be_nil end it "should make resources appear in the actions hash of subscribed nodes" do run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee") - zr = run_context.resource_collection.find(:zen_master => "coffee") + zr = run_context.resource_collection.find(zen_master: "coffee") resource.subscribes :reload, zr expect(zr.delayed_notifications.detect { |e| e.resource.name == resource.name && e.action == :reload }).not_to be_nil run_context.resource_collection << Chef::Resource::ZenMaster.new("bean") - zrb = run_context.resource_collection.find(:zen_master => "bean") + zrb = run_context.resource_collection.find(zen_master: "bean") zrb.subscribes :reload, zr expect(zr.delayed_notifications.detect { |e| e.resource.name == resource.name && e.action == :reload }).not_to be_nil end it "should make subscribed resources be capable of acting immediately" do run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee") - zr = run_context.resource_collection.find(:zen_master => "coffee") + zr = run_context.resource_collection.find(zen_master: "coffee") resource.subscribes :reload, zr, :immediately expect(zr.immediate_notifications.detect { |e| e.resource.name == resource.name && e.action == :reload }).not_to be_nil end @@ -691,8 +691,8 @@ end it "accepts command options for only_if conditionals" do expect_any_instance_of(Chef::Resource::Conditional).to receive(:evaluate_command).at_least(1).times - resource.only_if("true", :cwd => "/tmp") - expect(resource.only_if.first.command_opts).to eq({ :cwd => "/tmp" }) + resource.only_if("true", cwd: "/tmp") + expect(resource.only_if.first.command_opts).to eq({ cwd: "/tmp" }) resource.run_action(:purr) end @@ -715,8 +715,8 @@ end end it "accepts command options for not_if conditionals" do - resource.not_if("pwd" , :cwd => "/tmp") - expect(resource.not_if.first.command_opts).to eq({ :cwd => "/tmp" }) + resource.not_if("pwd" , cwd: "/tmp") + expect(resource.not_if.first.command_opts).to eq({ cwd: "/tmp" }) end it "accepts multiple not_if conditionals" do @@ -951,7 +951,7 @@ end node.name("bumblebee") node.automatic[:platform] = "autobots" node.automatic[:platform_version] = "6.1" - klz2.provides :dinobot, :platform => ["autobots"] + klz2.provides :dinobot, platform: ["autobots"] Object.const_set("Grimlock", klz2) klz2.provides :grimlock end diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb index 1bbbc4c7b0..9c8900d464 100644 --- a/spec/unit/role_spec.rb +++ b/spec/unit/role_spec.rb @@ -104,12 +104,12 @@ describe Chef::Role do describe "default_attributes" do it "should let you set the default attributes hash explicitly" do - expect(@role.default_attributes({ :one => "two" })).to eq({ :one => "two" }) + expect(@role.default_attributes({ one: "two" })).to eq({ one: "two" }) end it "should let you return the default attributes hash" do - @role.default_attributes({ :one => "two" }) - expect(@role.default_attributes).to eq({ :one => "two" }) + @role.default_attributes({ one: "two" }) + expect(@role.default_attributes).to eq({ one: "two" }) end it "should throw an ArgumentError if we aren't a kind of hash" do @@ -119,12 +119,12 @@ describe Chef::Role do describe "override_attributes" do it "should let you set the override attributes hash explicitly" do - expect(@role.override_attributes({ :one => "two" })).to eq({ :one => "two" }) + expect(@role.override_attributes({ one: "two" })).to eq({ one: "two" }) end it "should let you return the override attributes hash" do - @role.override_attributes({ :one => "two" }) - expect(@role.override_attributes).to eq({ :one => "two" }) + @role.override_attributes({ one: "two" }) + expect(@role.override_attributes).to eq({ one: "two" }) end it "should throw an ArgumentError if we aren't a kind of hash" do @@ -137,15 +137,15 @@ describe Chef::Role do @role.name("mars_volta") @role.description("Great band!") @role.run_list("one", "two", "role[a]") - @role.default_attributes({ :el_groupo => "nuevo" }) - @role.override_attributes({ :deloused => "in the comatorium" }) + @role.default_attributes({ el_groupo: "nuevo" }) + @role.override_attributes({ deloused: "in the comatorium" }) @example = Chef::Role.new @example.name("newname") @example.description("Really Great band!") @example.run_list("alpha", "bravo", "role[alpha]") - @example.default_attributes({ :el_groupo => "nuevo dos" }) - @example.override_attributes({ :deloused => "in the comatorium XOXO" }) + @example.default_attributes({ el_groupo: "nuevo dos" }) + @example.override_attributes({ deloused: "in the comatorium XOXO" }) end it "should update all fields except for name" do @@ -158,13 +158,13 @@ describe Chef::Role do end end - describe "when serialized as JSON", :json => true do + describe "when serialized as JSON", json: true do before(:each) do @role.name("mars_volta") @role.description("Great band!") @role.run_list("one", "two", "role[a]") - @role.default_attributes({ :el_groupo => "nuevo" }) - @role.override_attributes({ :deloused => "in the comatorium" }) + @role.default_attributes({ el_groupo: "nuevo" }) + @role.override_attributes({ deloused: "in the comatorium" }) @serialized_role = Chef::JSONCompat.to_json(@role) end @@ -197,7 +197,7 @@ describe Chef::Role do describe "and it has per-environment run lists" do before do @role.env_run_lists("_default" => ["one", "two", "role[a]"], "production" => ["role[monitoring]", "role[auditing]", "role[apache]"], "dev" => ["role[nginx]"]) - @serialized_role = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(@role), :create_additions => false) + @serialized_role = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(@role), create_additions: false) end it "includes the per-environment run lists" do @@ -218,7 +218,7 @@ describe Chef::Role do end end - describe "when created from JSON", :json => true do + describe "when created from JSON", json: true do before(:each) do @role.name("mars_volta") @role.description("Great band!") diff --git a/spec/unit/run_context_spec.rb b/spec/unit/run_context_spec.rb index f1c3072b8e..bfef3f8836 100644 --- a/spec/unit/run_context_spec.rb +++ b/spec/unit/run_context_spec.rb @@ -184,7 +184,7 @@ describe Chef::RunContext do describe "handling reboot requests" do let(:expected) do - { :reason => "spec tests require a reboot" } + { reason: "spec tests require a reboot" } end it "stores and deletes the reboot request" do diff --git a/spec/unit/run_list/run_list_item_spec.rb b/spec/unit/run_list/run_list_item_spec.rb index 3f8fd2ab3b..b57a7dcd53 100644 --- a/spec/unit/run_list/run_list_item_spec.rb +++ b/spec/unit/run_list/run_list_item_spec.rb @@ -22,15 +22,15 @@ describe Chef::RunList::RunListItem do describe "when creating from a Hash" do it "raises an exception when the hash doesn't have a :type key" do - expect { Chef::RunList::RunListItem.new(:name => "tatft") }.to raise_error(ArgumentError) + expect { Chef::RunList::RunListItem.new(name: "tatft") }.to raise_error(ArgumentError) end it "raises an exception when the hash doesn't have an :name key" do - expect { Chef::RunList::RunListItem.new(:type => "R") }.to raise_error(ArgumentError) + expect { Chef::RunList::RunListItem.new(type: "R") }.to raise_error(ArgumentError) end it "sets the name and type as given in the hash" do - item = Chef::RunList::RunListItem.new(:type => "fuuu", :name => "uuuu") + item = Chef::RunList::RunListItem.new(type: "fuuu", name: "uuuu") expect(item.to_s).to eq("fuuu[uuuu]") end diff --git a/spec/unit/run_list/versioned_recipe_list_spec.rb b/spec/unit/run_list/versioned_recipe_list_spec.rb index 859fee75ec..e116ffc130 100644 --- a/spec/unit/run_list/versioned_recipe_list_spec.rb +++ b/spec/unit/run_list/versioned_recipe_list_spec.rb @@ -54,25 +54,25 @@ describe Chef::RunList::VersionedRecipeList do it "should allow you to specify a version" do list.add_recipe "rails", "1.0.0" expect(list).to eq(%w{apt god apache2 rails}) - expect(list.with_versions).to include({ :name => "rails", :version => "1.0.0" }) + 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(%w{apt god apache2}) - expect(list.with_versions).to include({ :name => "apt", :version => "1.2.3" }) + expect(list.with_versions).to include({ name: "apt", version: "1.2.3" }) end it "should allow you to specify the same version of a recipe twice" do list.add_recipe "rails", "1.0.0" list.add_recipe "rails", "1.0.0" - expect(list.with_versions).to include({ :name => "rails", :version => "1.0.0" }) + expect(list.with_versions).to include({ name: "rails", version: "1.0.0" }) end it "should allow you to spcify no version, even when a version already exists" do list.add_recipe "rails", "1.0.0" list.add_recipe "rails" - expect(list.with_versions).to include({ :name => "rails", :version => "1.0.0" }) + expect(list.with_versions).to include({ name: "rails", version: "1.0.0" }) end it "should not allow multiple versions of the same recipe" do @@ -85,9 +85,9 @@ describe Chef::RunList::VersionedRecipeList do let(:versioned_recipes) do [ - { :name => "apt", :version => "1.0.0" }, - { :name => "god", :version => nil }, - { :name => "apache2", :version => "0.0.1" }, + { name: "apt", version: "1.0.0" }, + { name: "god", version: nil }, + { name: "apache2", version: "0.0.1" }, ] end it "should return an array of hashes with :name and :version" do @@ -106,9 +106,9 @@ describe Chef::RunList::VersionedRecipeList do let(:versioned_recipes) do [ - { :name => "apt", :version => "~> 1.2.0" }, - { :name => "god", :version => nil }, - { :name => "apache2", :version => "0.0.1" }, + { name: "apt", version: "~> 1.2.0" }, + { name: "god", version: nil }, + { name: "apache2", version: "0.0.1" }, ] end @@ -151,7 +151,7 @@ describe Chef::RunList::VersionedRecipeList do let(:versioned_recipes) do [ - { :name => "apt", :version => "~> 1.2.0" }, + { name: "apt", version: "~> 1.2.0" }, ] end @@ -170,7 +170,7 @@ describe Chef::RunList::VersionedRecipeList do let(:versioned_recipes) do [ - { :name => "apt::cacher", :version => "~> 1.2.0" }, + { name: "apt::cacher", version: "~> 1.2.0" }, ] end diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb index 0dcd349ced..6117a89ca7 100644 --- a/spec/unit/run_list_spec.rb +++ b/spec/unit/run_list_spec.rb @@ -170,12 +170,12 @@ describe Chef::RunList do @role = Chef::Role.new @role.name "stubby" @role.run_list "one", "two" - @role.default_attributes :one => :two - @role.override_attributes :three => :four + @role.default_attributes one: :two + @role.override_attributes three: :four @role.env_run_list["production"] = Chef::RunList.new( "one", "two", "five") allow(Chef::Role).to receive(:load).and_return(@role) - @rest = double("Chef::ServerAPI", { :get => @role.to_hash, :url => "/" }) + @rest = double("Chef::ServerAPI", { get: @role.to_hash, url: "/" }) allow(Chef::ServerAPI).to receive(:new).and_return(@rest) @run_list << "role[stubby]" @@ -263,7 +263,7 @@ describe Chef::RunList do it "should recurse into a child role" do dog = Chef::Role.new dog.name "dog" - dog.default_attributes :seven => :nine + dog.default_attributes seven: :nine dog.run_list "three" @role.run_list << "role[dog]" allow(Chef::Role).to receive(:from_disk).with("stubby").and_return(@role) @@ -277,7 +277,7 @@ describe Chef::RunList do it "should not recurse infinitely" do dog = Chef::Role.new dog.name "dog" - dog.default_attributes :seven => :nine + dog.default_attributes seven: :nine dog.run_list "role[dog]", "three" @role.run_list << "role[dog]" allow(Chef::Role).to receive(:from_disk).with("stubby").and_return(@role) diff --git a/spec/unit/scan_access_control_spec.rb b/spec/unit/scan_access_control_spec.rb index c747f6cc4a..ec3c088b48 100644 --- a/spec/unit/scan_access_control_spec.rb +++ b/spec/unit/scan_access_control_spec.rb @@ -49,7 +49,7 @@ describe Chef::ScanAccessControl do describe "when the fs entity exists" do before do - @stat = double("File::Stat for #{@new_resource.path}", :uid => 0, :gid => 0, :mode => 00100644) + @stat = double("File::Stat for #{@new_resource.path}", uid: 0, gid: 0, mode: 00100644) expect(File).to receive(:realpath).with(@new_resource.path).and_return(@real_file) expect(File).to receive(:stat).with(@real_file).and_return(@stat) expect(File).to receive(:exist?).with(@new_resource.path).and_return(true) @@ -128,7 +128,7 @@ describe Chef::ScanAccessControl do end it "sets the owner of current_resource to the username of the current owner" do - @root_passwd = double("Struct::Passwd for uid 0", :name => "root") + @root_passwd = double("Struct::Passwd for uid 0", name: "root") expect(Etc).to receive(:getpwuid).with(0).and_return(@root_passwd) @scanner.set_all! @@ -163,7 +163,7 @@ describe Chef::ScanAccessControl do end it "sets the group of the current resource to the group name" do - @group_entry = double("Struct::Group for wheel", :name => "wheel") + @group_entry = double("Struct::Group for wheel", name: "wheel") expect(Etc).to receive(:getgrgid).with(0).and_return(@group_entry) @scanner.set_all! diff --git a/spec/unit/shell/model_wrapper_spec.rb b/spec/unit/shell/model_wrapper_spec.rb index 00425f2a01..bcce7c1a08 100644 --- a/spec/unit/shell/model_wrapper_spec.rb +++ b/spec/unit/shell/model_wrapper_spec.rb @@ -21,13 +21,13 @@ require "ostruct" describe Shell::ModelWrapper do before do - @model = OpenStruct.new(:name => "Chef::Node") + @model = OpenStruct.new(name: "Chef::Node") @wrapper = Shell::ModelWrapper.new(@model) end describe "when created with an explicit model_symbol" do before do - @model = OpenStruct.new(:name => "Chef::ApiClient") + @model = OpenStruct.new(name: "Chef::ApiClient") @wrapper = Shell::ModelWrapper.new(@model, :client) end @@ -46,7 +46,7 @@ describe Shell::ModelWrapper do @node_1.name("sammich") @node_2 = Chef::Node.new @node_2.name("yummy") - @server_response = { :node_1 => @node_1, :node_2 => @node_2 } + @server_response = { node_1: @node_1, node_2: @node_2 } @wrapper = Shell::ModelWrapper.new(Chef::Node) allow(Chef::Node).to receive(:list).and_return(@server_response) end @@ -67,7 +67,7 @@ describe Shell::ModelWrapper do @node_1.name("sammich") @node_2 = Chef::Node.new @node_2.name("yummy") - @server_response = { :node_1 => @node_1, :node_2 => @node_2 } + @server_response = { node_1: @node_1, node_2: @node_2 } @wrapper = Shell::ModelWrapper.new(Chef::Node) # Creating a Chef::Search::Query object tries to read the private key... diff --git a/spec/unit/shell/shell_ext_spec.rb b/spec/unit/shell/shell_ext_spec.rb index 0afa1f6390..7ddacf8476 100644 --- a/spec/unit/shell/shell_ext_spec.rb +++ b/spec/unit/shell/shell_ext_spec.rb @@ -34,8 +34,8 @@ describe Shell::Extensions do it "finds a subsession in irb for an object" do target_context_obj = Chef::Node.new - irb_context = double("context", :main => target_context_obj) - irb_session = double("irb session", :context => irb_context) + irb_context = double("context", main: target_context_obj) + irb_session = double("irb session", context: irb_context) @job_manager.jobs = [[:thread, irb_session]] allow(@root_context).to receive(:jobs).and_return(@job_manager) @root_context.ensure_session_select_defined @@ -92,9 +92,9 @@ describe Shell::Extensions do end it "prints node attributes" do - node = double("node", :attribute => { :foo => :bar }) + node = double("node", attribute: { foo: :bar }) @shell_client.node = node - expect(@root_context).to receive(:pp).with({ :foo => :bar }) + expect(@root_context).to receive(:pp).with({ foo: :bar }) @root_context.ohai expect(@root_context).to receive(:pp).with(:bar) @root_context.ohai(:foo) diff --git a/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb index c96453eeae..c4cb7c6815 100644 --- a/spec/unit/shell/shell_session_spec.rb +++ b/spec/unit/shell/shell_session_spec.rb @@ -53,16 +53,16 @@ describe Shell::ClientSession do let(:session) { Shell::ClientSession.instance } let(:client) do double("Chef::Client.new", - :run_ohai => true, - :load_node => true, - :build_node => true, - :register => true, - :sync_cookbooks => {} + run_ohai: true, + load_node: true, + build_node: true, + register: true, + sync_cookbooks: {} ) end before do - Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] } + Chef::Config[:shell_config] = { override_runlist: [Chef::RunList::RunListItem.new("shell::override")] } session.node = node session.json_configuration = json_attribs end @@ -90,16 +90,16 @@ describe Shell::SoloSession do let(:session) { Shell::SoloSession.instance } let(:client) do double("Chef::Client.new", - :run_ohai => true, - :load_node => true, - :build_node => true, - :register => true, - :sync_cookbooks => {} + run_ohai: true, + load_node: true, + build_node: true, + register: true, + sync_cookbooks: {} ) end before do - Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] } + Chef::Config[:shell_config] = { override_runlist: [Chef::RunList::RunListItem.new("shell::override")] } session.node = node session.json_configuration = json_attribs end @@ -128,18 +128,18 @@ describe Shell::StandAloneSession do let(:session) { Shell::StandAloneSession.instance } let(:client) do double("Chef::Client.new", - :run_ohai => true, - :load_node => true, - :build_node => true, - :register => true, - :sync_cookbooks => {} + run_ohai: true, + load_node: true, + build_node: true, + register: true, + sync_cookbooks: {} ) end let(:recipe) { Chef::Recipe.new(nil, nil, run_context) } let(:run_context) { Chef::RunContext.new(node, {}, events) } before do - Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] } + Chef::Config[:shell_config] = { override_runlist: [Chef::RunList::RunListItem.new("shell::override")] } session.node = node session.json_configuration = json_attribs session.run_context = run_context @@ -166,7 +166,7 @@ describe Shell::StandAloneSession do it "runs chef with the standalone recipe" do allow(session).to receive(:node_built?).and_return(true) allow(Chef::Log).to receive(:level) - chef_runner = double("Chef::Runner.new", :converge => :converged) + chef_runner = double("Chef::Runner.new", converge: :converged) # pre-heat resource collection cache session.resource_collection @@ -185,7 +185,7 @@ describe Shell::SoloLegacySession do let(:json_attribs) { { "a" => "b" } } before do - Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] } + Chef::Config[:shell_config] = { override_runlist: [Chef::RunList::RunListItem.new("shell::override")] } Chef::Config[:shell_solo] = true @session = Shell::SoloLegacySession.instance @node = Chef::Node.new @@ -229,7 +229,7 @@ describe Shell::SoloLegacySession do it "runs chef with a resource collection from the compiled cookbooks" do allow(@session).to receive(:node_built?).and_return(true) - chef_runner = double("Chef::Runner.new", :converge => :converged) + chef_runner = double("Chef::Runner.new", converge: :converged) expect(Chef::Runner).to receive(:new).with(an_instance_of(Chef::RunContext)).and_return(chef_runner) expect(@recipe.run_chef).to eq(:converged) @@ -237,11 +237,11 @@ describe Shell::SoloLegacySession do it "passes the shell CLI args to the client" do @client = double("Chef::Client.new", - :run_ohai => true, - :load_node => true, - :build_node => true, - :register => true, - :sync_cookbooks => {}) + run_ohai: true, + load_node: true, + build_node: true, + register: true, + sync_cookbooks: {}) expect(Chef::Client).to receive(:new).with(json_attribs, Chef::Config[:shell_config]).and_return(@client) @session.json_configuration = json_attribs @session.send(:rebuild_node) diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb index 10a79f6c8a..48dbf010e9 100644 --- a/spec/unit/user_spec.rb +++ b/spec/unit/user_spec.rb @@ -243,7 +243,7 @@ describe Chef::User do describe "create" do it "creates a new user via the API" do @user.password "password" - expect(@http_client).to receive(:post).with("users", { :name => "foobar", :admin => false, :password => "password" }).and_return({}) + expect(@http_client).to receive(:post).with("users", { name: "foobar", admin: false, password: "password" }).and_return({}) @user.create end end @@ -260,7 +260,7 @@ describe Chef::User do describe "update" do it "updates an existing user on via the API" do - expect(@http_client).to receive(:put).with("users/foobar", { :name => "foobar", :admin => false }).and_return({}) + expect(@http_client).to receive(:put).with("users/foobar", { name: "foobar", admin: false }).and_return({}) @user.update end end diff --git a/spec/unit/user_v1_spec.rb b/spec/unit/user_v1_spec.rb index 16f0d0158b..074a68840e 100644 --- a/spec/unit/user_v1_spec.rb +++ b/spec/unit/user_v1_spec.rb @@ -311,7 +311,7 @@ describe Chef::UserV1 do end describe "Versioned API Interactions" do - let(:response_406) { OpenStruct.new(:code => "406") } + let(:response_406) { OpenStruct.new(code: "406") } let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) } before (:each) do @@ -334,13 +334,13 @@ describe Chef::UserV1 do let(:payload) do { - :username => "some_username", - :display_name => "some_display_name", - :first_name => "some_first_name", - :middle_name => "some_middle_name", - :last_name => "some_last_name", - :email => "some_email", - :password => "some_password", + username: "some_username", + display_name: "some_display_name", + first_name: "some_first_name", + middle_name: "some_middle_name", + last_name: "some_last_name", + email: "some_email", + password: "some_password", } end @@ -356,14 +356,14 @@ describe Chef::UserV1 do context "when server API V1 is not valid on the Chef Server receiving the request" do let(:payload) do { - :username => "some_username", - :display_name => "some_display_name", - :first_name => "some_first_name", - :middle_name => "some_middle_name", - :last_name => "some_last_name", - :email => "some_email", - :password => "some_password", - :public_key => "some_public_key", + username: "some_username", + display_name: "some_display_name", + first_name: "some_first_name", + middle_name: "some_middle_name", + last_name: "some_last_name", + email: "some_email", + password: "some_password", + public_key: "some_public_key", } end @@ -373,7 +373,7 @@ describe Chef::UserV1 do end context "when the server returns a 400" do - let(:response_400) { OpenStruct.new(:code => "400") } + let(:response_400) { OpenStruct.new(code: "400") } let(:exception_400) { Net::HTTPServerException.new("400 Bad Request", response_400) } context "when the 400 was due to public / private key fields no longer being supported" do @@ -444,12 +444,12 @@ describe Chef::UserV1 do describe "create" do let(:payload) do { - :username => "some_username", - :display_name => "some_display_name", - :first_name => "some_first_name", - :last_name => "some_last_name", - :email => "some_email", - :password => "some_password", + username: "some_username", + display_name: "some_display_name", + first_name: "some_first_name", + last_name: "some_last_name", + email: "some_email", + password: "some_password", } end before do @@ -473,7 +473,7 @@ describe Chef::UserV1 do context "when handling API V1" do it "creates a new user via the API with a middle_name when it exists" do @user.middle_name "some_middle_name" - expect(@user.chef_root_rest_v1).to receive(:post).with("users", payload.merge({ :middle_name => "some_middle_name" })).and_return({}) + expect(@user.chef_root_rest_v1).to receive(:post).with("users", payload.merge({ middle_name: "some_middle_name" })).and_return({}) @user.create end end # when server API V1 is valid on the Chef Server receiving the request @@ -496,7 +496,7 @@ describe Chef::UserV1 do it "creates a new user via the API with a middle_name when it exists" do @user.middle_name "some_middle_name" - expect(@user.chef_root_rest_v0).to receive(:post).with("users", payload.merge({ :middle_name => "some_middle_name" })).and_return({}) + expect(@user.chef_root_rest_v0).to receive(:post).with("users", payload.merge({ middle_name: "some_middle_name" })).and_return({}) @user.create end end # when server API V1 is not valid on the Chef Server receiving the request diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb index 4bb0abd087..70376bcdb1 100644 --- a/spec/unit/util/diff_spec.rb +++ b/spec/unit/util/diff_spec.rb @@ -546,7 +546,7 @@ shared_examples_for "a diff util" do end -describe Chef::Util::Diff, :uses_diff => true do +describe Chef::Util::Diff, uses_diff: true do let!(:old_file) { old_tempfile.path } let!(:new_file) { new_tempfile.path } diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb index cfa7a4e264..faf554326d 100644 --- a/spec/unit/util/dsc/configuration_generator_spec.rb +++ b/spec/unit/util/dsc/configuration_generator_spec.rb @@ -76,7 +76,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do context "when symbols are used as switches" do it "should merge the hash if there are no restricted switches" do - merged = conf_man.send(:get_merged_configuration_flags!, { :flag => "a" }, "hello") + merged = conf_man.send(:get_merged_configuration_flags!, { flag: "a" }, "hello") expect(merged).to include(:flag) expect(merged[:flag]).to eql("a") expect(merged).to include(:outputpath) @@ -84,18 +84,18 @@ describe Chef::Util::DSC::ConfigurationGenerator do it "should raise an ArgumentError if you try to override outputpath" do expect do - conf_man.send(:get_merged_configuration_flags!, { :outputpath => "a" }, "hello") + conf_man.send(:get_merged_configuration_flags!, { outputpath: "a" }, "hello") end.to raise_error(ArgumentError) end it "should be case insensitive for switches that are not allowed" do expect do - conf_man.send(:get_merged_configuration_flags!, { :OutputPath => "a" }, "hello") + conf_man.send(:get_merged_configuration_flags!, { OutputPath: "a" }, "hello") end.to raise_error(ArgumentError) end it "should be case insensitive to switches that are allowed" do - merged = conf_man.send(:get_merged_configuration_flags!, { :FLAG => "a" }, "hello") + merged = conf_man.send(:get_merged_configuration_flags!, { FLAG: "a" }, "hello") expect(merged).to include(:flag) end end diff --git a/spec/unit/util/dsc/local_configuration_manager_spec.rb b/spec/unit/util/dsc/local_configuration_manager_spec.rb index 4c33fc8616..33c618f2eb 100644 --- a/spec/unit/util/dsc/local_configuration_manager_spec.rb +++ b/spec/unit/util/dsc/local_configuration_manager_spec.rb @@ -50,7 +50,7 @@ EOH end let(:lcm_status) do - double("LCM cmdlet status", :stderr => lcm_standard_error, :return_value => lcm_standard_output, :succeeded? => lcm_cmdlet_success) + double("LCM cmdlet status", stderr: lcm_standard_error, return_value: lcm_standard_output, succeeded?: lcm_cmdlet_success) end describe "test_configuration method invocation" do @@ -192,7 +192,7 @@ EOH context "when invalid dsc script is given" do it "raises exception" do configuration_document = "invalid-config" - shellout_flags = { :cwd => nil, :environment => nil, :timeout => nil } + shellout_flags = { cwd: nil, environment: nil, timeout: nil } expect { lcm.send(:run_configuration_cmdlet, configuration_document, true, shellout_flags) }.to raise_error(Chef::Exceptions::PowershellCmdletException) end end diff --git a/spec/unit/util/powershell/cmdlet_spec.rb b/spec/unit/util/powershell/cmdlet_spec.rb index 800e4cc9c0..144e363979 100644 --- a/spec/unit/util/powershell/cmdlet_spec.rb +++ b/spec/unit/util/powershell/cmdlet_spec.rb @@ -75,7 +75,7 @@ describe Chef::Util::Powershell::Cmdlet do it "does not allow invalid switch names" do expect do - @cmdlet.send(:command_switches_string, { :foo! => "bar" }) + @cmdlet.send(:command_switches_string, { foo!: "bar" }) end.to raise_error(ArgumentError) end diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb index 8da6492fae..0d2d1aeb3f 100644 --- a/spec/unit/util/selinux_spec.rb +++ b/spec/unit/util/selinux_spec.rb @@ -60,8 +60,8 @@ describe Chef::Util::Selinux do describe "when selinux is enabled" do before do - cmd_result = double("Cmd Result", :exitstatus => 0) - expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result) + cmd_result = double("Cmd Result", exitstatus: 0) + expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { returns: [0, 1] }).and_return(cmd_result) end it "should report selinux is enabled" do @@ -73,8 +73,8 @@ describe Chef::Util::Selinux do describe "when selinux is disabled" do before do - cmd_result = double("Cmd Result", :exitstatus => 1) - expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result) + cmd_result = double("Cmd Result", exitstatus: 1) + expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { returns: [0, 1] }).and_return(cmd_result) end it "should report selinux is disabled" do @@ -86,8 +86,8 @@ describe Chef::Util::Selinux do describe "when selinux gives an unexpected status" do before do - cmd_result = double("Cmd Result", :exitstatus => 101) - expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result) + cmd_result = double("Cmd Result", exitstatus: 101) + expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { returns: [0, 1] }).and_return(cmd_result) end it "should throw an error" do diff --git a/spec/unit/win32/registry_spec.rb b/spec/unit/win32/registry_spec.rb index 1523ac1919..c880c8922a 100644 --- a/spec/unit/win32/registry_spec.rb +++ b/spec/unit/win32/registry_spec.rb @@ -21,8 +21,8 @@ require "spec_helper" describe Chef::Win32::Registry do include_context "Win32" - let(:value1) { { :name => "one", :type => :string, :data => "1" } } - let(:value1_upcase_name) { { :name => "ONE", :type => :string, :data => "1" } } + let(:value1) { { name: "one", type: :string, data: "1" } } + let(:value1_upcase_name) { { name: "ONE", type: :string, data: "1" } } let(:key_path) { 'HKCU\Software\OpscodeNumbers' } let(:key) { 'Software\OpscodeNumbers' } let(:key_parent) { "Software" } diff --git a/spec/unit/windows_service_spec.rb b/spec/unit/windows_service_spec.rb index 71e01a0b6b..45af0f9d9f 100644 --- a/spec/unit/windows_service_spec.rb +++ b/spec/unit/windows_service_spec.rb @@ -32,8 +32,8 @@ describe "Chef::Application::WindowsService", :windows_only do let(:timeout) { 7200 } let(:shellout_options) do { - :timeout => timeout, - :logger => Chef::Log, + timeout: timeout, + logger: Chef::Log, } end |