diff options
Diffstat (limited to 'spec/unit/provider')
86 files changed, 561 insertions, 634 deletions
diff --git a/spec/unit/provider/breakpoint_spec.rb b/spec/unit/provider/breakpoint_spec.rb index 5986083410..ffe8c8261f 100644 --- a/spec/unit/provider/breakpoint_spec.rb +++ b/spec/unit/provider/breakpoint_spec.rb @@ -16,7 +16,6 @@ # limitations under the License. # - require "spec_helper" describe Chef::Provider::Breakpoint do diff --git a/spec/unit/provider/cookbook_file/content_spec.rb b/spec/unit/provider/cookbook_file/content_spec.rb index b4116bda12..096ac85b64 100644 --- a/spec/unit/provider/cookbook_file/content_spec.rb +++ b/spec/unit/provider/cookbook_file/content_spec.rb @@ -37,4 +37,3 @@ describe Chef::Provider::CookbookFile::Content do end end - diff --git a/spec/unit/provider/cookbook_file_spec.rb b/spec/unit/provider/cookbook_file_spec.rb index 810adb52f9..b375784d00 100644 --- a/spec/unit/provider/cookbook_file_spec.rb +++ b/spec/unit/provider/cookbook_file_spec.rb @@ -24,7 +24,7 @@ require "support/shared/unit/provider/file" describe Chef::Provider::CookbookFile do let(:node) { double("Chef::Node") } - let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:enclosing_directory) { canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb index 107e4b9645..010b1b09f3 100644 --- a/spec/unit/provider/cron_spec.rb +++ b/spec/unit/provider/cron_spec.rb @@ -94,7 +94,7 @@ CRONTAB cron = @provider.load_current_resource expect(cron.mailto).to eq("warn@example.com") - expect(cron.environment).to eq({"TEST" => "lol", "FLAG" => "1"}) + expect(cron.environment).to eq({ "TEST" => "lol", "FLAG" => "1" }) end it "should not break with variables that match the cron resource internals" do @@ -109,7 +109,7 @@ CRONTAB cron = @provider.load_current_resource expect(cron.time).to eq(:reboot) - expect(cron.environment).to eq({"MINUTE" => "40", "REBOOT" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"}) + expect(cron.environment).to eq({ "MINUTE" => "40", "REBOOT" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production" }) end it "should report the match" do @@ -276,7 +276,7 @@ CRONTAB cron = @provider.load_current_resource expect(cron.mailto).to eq("warn@example.com") - expect(cron.environment).to eq({"TEST" => "lol", "FLAG" => "1"}) + expect(cron.environment).to eq({ "TEST" => "lol", "FLAG" => "1" }) end it "should not break with variabels that match the cron resource internals" do @@ -292,7 +292,7 @@ CRONTAB expect(cron.minute).to eq("*") expect(cron.hour).to eq("5") - expect(cron.environment).to eq({"MINUTE" => "40", "HOUR" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"}) + expect(cron.environment).to eq({ "MINUTE" => "40", "HOUR" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production" }) end it "should report the match" do diff --git a/spec/unit/provider/deploy/revision_spec.rb b/spec/unit/provider/deploy/revision_spec.rb index 5fe0f26a6b..8f8280e11d 100644 --- a/spec/unit/provider/deploy/revision_spec.rb +++ b/spec/unit/provider/deploy/revision_spec.rb @@ -41,7 +41,6 @@ describe Chef::Provider::Deploy::Revision do FileUtils.rm_rf @temp_dir if File.directory?( @temp_dir ) end - it "uses the resolved revision from the SCM as the release slug" do allow(@provider.scm_provider).to receive(:revision_slug).and_return("uglySlugly") expect(@provider.send(:release_slug)).to eq("uglySlugly") @@ -60,7 +59,7 @@ describe Chef::Provider::Deploy::Revision do @provider.cleanup! second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2" - expect(@provider.all_releases).to eq([@expected_release_dir,second_release]) + expect(@provider.all_releases).to eq([@expected_release_dir, second_release]) end it "removes a release from the file cache when it's used again in another release and append it to the end" do @@ -71,7 +70,7 @@ describe Chef::Provider::Deploy::Revision do @provider.load_current_resource @provider.cleanup! second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2" - expect(@provider.all_releases).to eq([@expected_release_dir,second_release]) + expect(@provider.all_releases).to eq([@expected_release_dir, second_release]) @provider.cleanup! allow(@provider).to receive(:release_slug).and_return("8a3195bf3efa246f743c5dfa83683201880f935c") @@ -82,7 +81,7 @@ describe Chef::Provider::Deploy::Revision do it "removes a release from the file cache when it's deleted by :cleanup!" do release_paths = %w{first second third fourth fifth}.map do |release_name| - "/my/deploy/dir/releases/#{release_name}" + "/my/deploy/dir/releases/#{release_name}" end release_paths.each do |release_path| @provider.send(:release_created, release_path) @@ -93,7 +92,7 @@ describe Chef::Provider::Deploy::Revision do @provider.cleanup! expected_release_paths = (%w{second third fourth fifth} << @resource.revision).map do |release_name| - "/my/deploy/dir/releases/#{release_name}" + "/my/deploy/dir/releases/#{release_name}" end expect(@provider.all_releases).to eq(expected_release_paths) diff --git a/spec/unit/provider/deploy_spec.rb b/spec/unit/provider/deploy_spec.rb index 7a3c208c9c..da5a69ac1b 100644 --- a/spec/unit/provider/deploy_spec.rb +++ b/spec/unit/provider/deploy_spec.rb @@ -164,7 +164,7 @@ describe Chef::Provider::Deploy do it "dont care by default if error happens on deploy" do allow(@provider).to receive(:all_releases).and_return(["previous_release"]) - allow(@provider).to receive(:deploy){ raise "Unexpected error" } + allow(@provider).to receive(:deploy) { raise "Unexpected error" } allow(@provider).to receive(:previous_release_path).and_return("previous_release") expect(@provider).not_to receive(:rollback) expect { @@ -175,7 +175,7 @@ describe Chef::Provider::Deploy do it "rollbacks to previous release if error happens on deploy" do @resource.rollback_on_error true allow(@provider).to receive(:all_releases).and_return(["previous_release"]) - allow(@provider).to receive(:deploy){ raise "Unexpected error" } + allow(@provider).to receive(:deploy) { raise "Unexpected error" } allow(@provider).to receive(:previous_release_path).and_return("previous_release") expect(@provider).to receive(:rollback) expect { @@ -266,7 +266,7 @@ describe Chef::Provider::Deploy do it "raises a runtime error when there's no release to rollback to" do all_releases = [] allow(Dir).to receive(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases) - expect {@provider.run_action(:rollback)}.to raise_error(RuntimeError) + expect { @provider.run_action(:rollback) }.to raise_error(RuntimeError) end it "runs the new resource collection in the runner during a callback" do @@ -286,12 +286,12 @@ describe Chef::Provider::Deploy do end it "raises a runtime error if a callback file is explicitly specified but does not exist" do - baz_callback = "/deploy/baz.rb" + baz_callback = "/deploy/baz.rb" expect(::File).to receive(:exist?).with("#{@expected_release_dir}/#{baz_callback}").and_return(false) - @resource.before_migrate baz_callback + @resource.before_migrate baz_callback @provider.define_resource_requirements @provider.action = :deploy - expect {@provider.process_resource_requirements}.to raise_error(RuntimeError) + expect { @provider.process_resource_requirements }.to raise_error(RuntimeError) end it "runs a default callback if the callback code is nil" do @@ -378,11 +378,11 @@ describe Chef::Provider::Deploy do allow(STDOUT).to receive(:tty?).and_return(true) allow(Chef::Log).to receive(:info?).and_return(true) - expect(@provider).to receive(:shell_out!).with("migration_foo",:cwd => @expected_release_dir, - :user => "deployNinja", :group => "deployNinjas", - :log_level => :info, :live_stream => STDOUT, - :log_tag => "deploy[/my/deploy/dir]", - :environment => {"RAILS_ENV"=>"production"}) + expect(@provider).to receive(:shell_out!).with("migration_foo", :cwd => @expected_release_dir, + :user => "deployNinja", :group => "deployNinjas", + :log_level => :info, :live_stream => STDOUT, + :log_tag => "deploy[/my/deploy/dir]", + :environment => { "RAILS_ENV" => "production" }) @provider.migrate end @@ -518,7 +518,7 @@ describe Chef::Provider::Deploy do it "runs an inline recipe with the provided block for :callback_name == {:recipe => &block} " do snitch = nil - recipe_code = Proc.new {snitch = 42} + recipe_code = Proc.new { snitch = 42 } #@provider.should_receive(:instance_eval).with(&recipe_code) @provider.callback(:whateverz, recipe_code) expect(snitch).to eq(42) @@ -533,7 +533,7 @@ describe Chef::Provider::Deploy do it "instance_evals a block/proc for restart command" do snitch = nil - restart_cmd = Proc.new {snitch = 42} + restart_cmd = Proc.new { snitch = 42 } @resource.restart(&restart_cmd) @provider.restart expect(snitch).to eq(42) @@ -569,7 +569,7 @@ describe Chef::Provider::Deploy do nil else expect(args.size).to eq(1) - expect(args.first).to eq({"APP_ENV" => "staging"}) + expect(args.first).to eq({ "APP_ENV" => "staging" }) end }.twice @provider.run("iGoToHell4this") @@ -586,7 +586,6 @@ describe Chef::Provider::Deploy do @provider.run("iGoToHell4this") end - it "converts sudo and run to exec resources in hooks" do runner = double("tehRunner") allow(Chef::Runner).to receive(:new).and_return(runner) @@ -613,7 +612,7 @@ describe Chef::Provider::Deploy do before do allow(::File).to receive(:exist?).with("#{@expected_release_dir}/gems.yml").and_return(true) - @gem_list = [{:name=>"eventmachine", :version=>"0.12.9"}] + @gem_list = [{ :name => "eventmachine", :version => "0.12.9" }] end it "reads a gems.yml file, creating gem providers for each with action :upgrade" do diff --git a/spec/unit/provider/directory_spec.rb b/spec/unit/provider/directory_spec.rb index c4cf070246..c8bec3e8ce 100644 --- a/spec/unit/provider/directory_spec.rb +++ b/spec/unit/provider/directory_spec.rb @@ -191,7 +191,7 @@ describe Chef::Provider::Directory do end it "raises the right exception when the parent directory is a file and recursive is true" do - pending "this seems to return the wrong error" # FIXME + pending "this seems to return the wrong error" # FIXME FileUtils.touch tmp_dir new_resource.recursive true expect { directory.run_action(:create) }.to raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist) @@ -219,7 +219,7 @@ describe Chef::Provider::Directory do allow(node).to receive(:[]).with("platform_version").and_return("10.11") allow(::File).to receive(:directory?).and_return(true) allow(Chef::FileAccessControl).to receive(:writable?).and_return(false) - expect {directory.run_action(:create) }.to raise_error(Chef::Exceptions::InsufficientPermissions) + expect { directory.run_action(:create) }.to raise_error(Chef::Exceptions::InsufficientPermissions) end it "os x 10.11 can write to sip exlcusions" do @@ -269,7 +269,7 @@ describe Chef::Provider::Directory do end it "cannot delete it and raises an exception" do - expect { directory.run_action(:delete) }.to raise_error(RuntimeError) + expect { directory.run_action(:delete) }.to raise_error(RuntimeError) end end @@ -280,7 +280,7 @@ describe Chef::Provider::Directory do end it "cannot delete it and raises an exception" do - expect { directory.run_action(:delete) }.to raise_error(RuntimeError) + expect { directory.run_action(:delete) }.to raise_error(RuntimeError) end end end diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb index 6a5063ac60..c0b412951d 100644 --- a/spec/unit/provider/dsc_resource_spec.rb +++ b/spec/unit/provider/dsc_resource_spec.rb @@ -35,7 +35,7 @@ describe Chef::Provider::DscResource do } it "raises a ProviderNotFound exception" do expect(provider).not_to receive(:meta_configuration) - expect{provider.run_action(:run)}.to raise_error( + expect { provider.run_action(:run) }.to raise_error( Chef::Exceptions::ProviderNotFound, /5\.0\.10018\.0/) end end @@ -70,7 +70,7 @@ describe Chef::Provider::DscResource do end end end - + context "when the LCM supports Invoke-DscResource" do let (:node) { node = Chef::Node.new @@ -92,27 +92,27 @@ describe Chef::Provider::DscResource do provider.run_action(:run) expect(resource).to be_updated end - + it "flags the resource as reboot required when required" do expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true) 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) provider.run_action(:run) end - + it "does not flag the resource as reboot required when not required" do expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true) 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) provider.run_action(:run) end end -end
\ No newline at end of file +end diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb index 0bea0e596d..3877a37e61 100644 --- a/spec/unit/provider/dsc_script_spec.rb +++ b/spec/unit/provider/dsc_script_spec.rb @@ -117,7 +117,7 @@ describe Chef::Provider::DscScript do it "should not converge if the script is already converged" do allow(provider).to receive(:run_configuration).with(:test).and_return([]) - + provider.run_action(:run) expect(resource).not_to be_updated end @@ -171,4 +171,3 @@ describe Chef::Provider::DscScript do end end end - diff --git a/spec/unit/provider/env/windows_spec.rb b/spec/unit/provider/env/windows_spec.rb index 0eeac3dba5..abe2344443 100644 --- a/spec/unit/provider/env/windows_spec.rb +++ b/spec/unit/provider/env/windows_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Provider::Env::Windows, :windows_only do let(:node) { Chef::Node.new } - let(:events) {Chef::EventDispatch::Dispatcher.new } + let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } context "when environment variable is not PATH" do @@ -29,8 +29,8 @@ describe Chef::Provider::Env::Windows, :windows_only do new_resource.value("foo") new_resource } - let(:provider) { - provider = Chef::Provider::Env::Windows.new(new_resource, run_context) + let(:provider) { + provider = Chef::Provider::Env::Windows.new(new_resource, run_context) allow(provider).to receive(:env_obj).and_return(double("null object").as_null_object) provider } @@ -74,21 +74,21 @@ describe Chef::Provider::Env::Windows, :windows_only do context "when environment is PATH" do describe "for PATH" do - let(:system_root) {"%SystemRoot%"} + let(:system_root) { "%SystemRoot%" } let(:system_root_value) { 'D:\Windows' } let(:new_resource) { new_resource = Chef::Resource::Env.new("PATH") new_resource.value(system_root) new_resource } - let(:provider) { - provider = Chef::Provider::Env::Windows.new(new_resource, run_context) + let(:provider) { + provider = Chef::Provider::Env::Windows.new(new_resource, run_context) allow(provider).to receive(:env_obj).and_return(double("null object").as_null_object) provider } before do - stub_const("ENV", {"PATH" => ""}) + stub_const("ENV", { "PATH" => "" }) end it "replaces Windows system variables" do diff --git a/spec/unit/provider/env_spec.rb b/spec/unit/provider/env_spec.rb index a5ea9f1259..e99aee5ad1 100644 --- a/spec/unit/provider/env_spec.rb +++ b/spec/unit/provider/env_spec.rb @@ -199,12 +199,12 @@ describe Chef::Provider::Env do expect(@new_resource).to be_updated end - context "when new_resource's value contains the delimiter" do + context "when new_resource's value contains the delimiter" do it "should return false if all the elements are deleted" do # This indicates that the entire key needs to be deleted @new_resource.value("C:/foo/bin;C:/bar/bin") expect(@provider.delete_element).to eql(false) - expect(@new_resource).not_to be_updated # This will be updated in action_delete + expect(@new_resource).not_to be_updated # This will be updated in action_delete end it "should return true if any, but not all, of the elements are deleted" do @@ -251,7 +251,7 @@ describe Chef::Provider::Env do expect(@provider.requires_modify_or_create?).to be_truthy end - context "when new_resource's value contains the delimiter" do + context "when new_resource's value contains the delimiter" do it "should return false if all the current values are contained in specified order" do @new_resource.value("C:/biz;C:/baz") @new_resource.delim(";") diff --git a/spec/unit/provider/erl_call_spec.rb b/spec/unit/provider/erl_call_spec.rb index 946d5384d1..f1c229028a 100644 --- a/spec/unit/provider/erl_call_spec.rb +++ b/spec/unit/provider/erl_call_spec.rb @@ -83,4 +83,3 @@ describe Chef::Provider::ErlCall do end end - diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb index 4cc27ef105..c0646f2999 100644 --- a/spec/unit/provider/execute_spec.rb +++ b/spec/unit/provider/execute_spec.rb @@ -130,7 +130,7 @@ describe Chef::Provider::Execute do expect(Chef::Log).to receive(:warn).with(/relative path/) expect(FileTest).to receive(:exist?).with(new_resource.creates).and_return(true) expect(provider).not_to receive(:shell_out!) - expect { provider.run_action(:run) }.to raise_error # @todo: add a real error for Chef-13 + expect { provider.run_action(:run) }.to raise_error # @todo: add a real error for Chef-13 end end diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb index 5179b5ce4d..ebef4faa09 100644 --- a/spec/unit/provider/file/content_spec.rb +++ b/spec/unit/provider/file/content_spec.rb @@ -89,7 +89,7 @@ describe Chef::Provider::File::Content do it "fails when :file_desployment_uses_destdir is set" do Chef::Config[:file_staging_uses_destdir] = true - expect{content.tempfile}.to raise_error + expect { content.tempfile }.to raise_error end it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb index 83cdf21050..11bef8a44d 100644 --- a/spec/unit/provider/file_spec.rb +++ b/spec/unit/provider/file_spec.rb @@ -33,7 +33,7 @@ describe Chef::Provider::File do end let(:node) { double("Chef::Node") } - let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:enclosing_directory) { canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) @@ -54,4 +54,3 @@ describe Chef::Provider::File do it_behaves_like "a file provider with content field" end - diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb index 8c55875ce7..97f04a5a77 100644 --- a/spec/unit/provider/git_spec.rb +++ b/spec/unit/provider/git_spec.rb @@ -16,7 +16,6 @@ # limitations under the License. # - require "spec_helper" describe Chef::Provider::Git do @@ -59,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]}).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] }).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.find_current_revision).to eql("9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13") end @@ -67,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]).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]).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr)) expect(@provider.find_current_revision).to be_nil end end @@ -98,7 +97,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 @@ -107,7 +106,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 @@ -116,7 +115,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 @@ -125,7 +124,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 @@ -134,7 +133,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 @@ -144,7 +143,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 @@ -153,7 +152,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 @@ -162,7 +161,7 @@ describe Chef::Provider::Git do @provider.action = :checkout @provider.define_resource_requirements allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - expect {@provider.process_resource_requirements}.to raise_error(Chef::Exceptions::InvalidRemoteGitReference) + expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::InvalidRemoteGitReference) end it "raises an unresolvable git reference error if the revision can't be resolved to any revision and assertions are run" do @@ -182,7 +181,7 @@ describe Chef::Provider::Git do 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 @@ -190,7 +189,7 @@ describe Chef::Provider::Git do end it "gives the latest HEAD revision SHA if nothing is specified" do - @stdout =<<-SHAS + @stdout = <<-SHAS 28af684d8460ba4793eda3e7ac238c864a5d029a\tHEAD 503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha 28af684d8460ba4793eda3e7ac238c864a5d029a\trefs/heads/master @@ -207,7 +206,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 @@ -248,7 +247,7 @@ SHAS end context "with a specific home" do let (:override_home) do - {"HOME" => "/home/masterNinja"} + { "HOME" => "/home/masterNinja" } end let(:overrided_options) do { @@ -275,9 +274,9 @@ SHAS @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", - :environment =>{"GIT_SSH"=>"do_it_this_way.sh", - "HOME" => "/home/deployNinja"}, - :log_tag => "git[web2.0 app]") + :environment => { "GIT_SSH" => "do_it_this_way.sh", + "HOME" => "/home/deployNinja" }, + :log_tag => "git[web2.0 app]") @provider.clone end @@ -312,9 +311,9 @@ SHAS 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 + :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 + :log_tag => "git[web2.0 app]").ordered @provider.checkout end @@ -322,7 +321,7 @@ SHAS @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]") + :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]") @provider.enable_submodules @@ -336,7 +335,7 @@ SHAS it "runs a sync command with default options" do expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) expected_cmd = "git fetch origin && git fetch origin --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - 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.fetch_updates end @@ -347,9 +346,9 @@ SHAS expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) expected_cmd = "git fetch origin && git fetch origin --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", - :user => "whois", :group => "thisis", - :log_tag => "git[web2.0 app]", - :environment=>{"HOME"=>"/home/whois"}) + :user => "whois", :group => "thisis", + :log_tag => "git[web2.0 app]", + :environment => { "HOME" => "/home/whois" }) @provider.fetch_updates end @@ -378,7 +377,7 @@ SHAS 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) + :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", @@ -398,15 +397,15 @@ SHAS :log_tag => "git[web2.0 app]", :user => "whois", :group => "thisis", - :environment=>{"HOME"=>"/home/whois"}, - :returns => [0,1,2]).and_return(command_response) + :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"}) + :environment => { "HOME" => "/home/whois" }) @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -418,7 +417,7 @@ SHAS 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) + :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", @@ -436,7 +435,7 @@ SHAS 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) + :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", @@ -452,7 +451,7 @@ SHAS 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) + :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", @@ -467,7 +466,7 @@ SHAS 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) + :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", @@ -479,7 +478,7 @@ SHAS it "raises an error if the git clone command would fail because the enclosing directory doesn't exist" do allow(@provider).to receive(:shell_out!) - expect {@provider.run_action(:sync)}.to raise_error(Chef::Exceptions::MissingParentDirectory) + expect { @provider.run_action(:sync) }.to raise_error(Chef::Exceptions::MissingParentDirectory) end it "does a checkout by cloning the repo and then enabling submodules" do @@ -488,7 +487,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".",".."]) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".", ".."]) expect(@provider).to receive(:clone) expect(@provider).to receive(:checkout) expect(@provider).to receive(:enable_submodules) @@ -504,7 +503,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".",".."]) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".", ".."]) @resource.enable_checkout false expect(@provider).to receive(:clone) @@ -519,7 +518,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(false) allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(false) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(["..","."]) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(["..", "."]) expect(@provider).to receive(:clone) expect(@provider).to receive(:checkout) expect(@provider).to receive(:enable_submodules) @@ -534,7 +533,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".","..","foo","bar"]) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".", "..", "foo", "bar"]) expect(@provider).not_to receive(:clone) expect(@provider).not_to receive(:checkout) expect(@provider).not_to receive(:enable_submodules) @@ -606,8 +605,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/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb index 44619f891b..52aff87dc5 100644 --- a/spec/unit/provider/group/dscl_spec.rb +++ b/spec/unit/provider/group/dscl_spec.rb @@ -40,7 +40,7 @@ describe Chef::Provider::Group::Dscl do it "should return an array of four elements - cmd, status, stdout, stderr" do dscl_retval = @provider.dscl("cmd /Path args") expect(dscl_retval).to be_a_kind_of(Array) - expect(dscl_retval).to eq(["dscl . -cmd /Path args",@status,"\n",""]) + expect(dscl_retval).to eq(["dscl . -cmd /Path args", @status, "\n", ""]) end describe "safe_dscl" do diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb index ad9e16ea94..b4295c9dff 100644 --- a/spec/unit/provider/group/groupadd_spec.rb +++ b/spec/unit/provider/group/groupadd_spec.rb @@ -43,9 +43,9 @@ describe Chef::Provider::Group::Groupadd, "set_options" do field_list.each do |attribute, option| it "should check for differences in #{attribute} between the current and new resources" do - expect(@new_resource).to receive(attribute) - expect(@current_resource).to receive(attribute) - @provider.set_options + expect(@new_resource).to receive(attribute) + expect(@current_resource).to receive(attribute) + @provider.set_options end it "should set the option for #{attribute} if the new resources #{attribute} is not null" do allow(@new_resource).to receive(attribute).and_return("wowaweea") @@ -55,7 +55,7 @@ describe Chef::Provider::Group::Groupadd, "set_options" do it "should combine all the possible options" do match_string = "" - field_list.sort{ |a,b| a[0] <=> b[0] }.each do |attribute, option| + field_list.sort { |a, b| a[0] <=> b[0] }.each do |attribute, option| allow(@new_resource).to receive(attribute).and_return("hola") match_string << " #{option} 'hola'" end diff --git a/spec/unit/provider/group/groupmod_spec.rb b/spec/unit/provider/group/groupmod_spec.rb index 1cb39ad0c3..21d026409e 100644 --- a/spec/unit/provider/group/groupmod_spec.rb +++ b/spec/unit/provider/group/groupmod_spec.rb @@ -19,16 +19,16 @@ require "spec_helper" describe Chef::Provider::Group::Groupmod do - before do - @node = Chef::Node.new - @events = Chef::EventDispatch::Dispatcher.new - @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::Group.new("wheel") - @new_resource.gid 123 - @new_resource.members %w{lobster rage fist} - @new_resource.append false - @provider = Chef::Provider::Group::Groupmod.new(@new_resource, @run_context) - end + before do + @node = Chef::Node.new + @events = Chef::EventDispatch::Dispatcher.new + @run_context = Chef::RunContext.new(@node, {}, @events) + @new_resource = Chef::Resource::Group.new("wheel") + @new_resource.gid 123 + @new_resource.members %w{lobster rage fist} + @new_resource.append false + @provider = Chef::Provider::Group::Groupmod.new(@new_resource, @run_context) + end describe "manage_group" do describe "when determining the current group state" do diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb index d5512b32cd..d41b0689ee 100644 --- a/spec/unit/provider/group_spec.rb +++ b/spec/unit/provider/group_spec.rb @@ -120,7 +120,7 @@ describe Chef::Provider::User do end it "should return true if the append is true and excluded_members include an existing user" do - @new_resource.members.each {|m| @new_resource.excluded_members << m } + @new_resource.members.each { |m| @new_resource.excluded_members << m } @new_resource.members.clear allow(@new_resource).to receive(:append).and_return(true) expect(@provider.compare_group).to be_truthy @@ -256,18 +256,18 @@ describe Chef::Provider::User do describe "when determining the reason for a change" do it "should report which group members are missing if members are missing and appending to the group" do - @new_resource.members << "user1" - @new_resource.members << "user2" - allow(@new_resource).to receive(:append).and_return true - expect(@provider.compare_group).to be_truthy - expect(@provider.change_desc).to eq([ "add missing member(s): user1, user2" ]) + @new_resource.members << "user1" + @new_resource.members << "user2" + allow(@new_resource).to receive(:append).and_return true + expect(@provider.compare_group).to be_truthy + expect(@provider.change_desc).to eq([ "add missing member(s): user1, user2" ]) end it "should report that the group members will be overwritten if not appending" do - @new_resource.members << "user1" - allow(@new_resource).to receive(:append).and_return false - expect(@provider.compare_group).to be_truthy - expect(@provider.change_desc).to eq([ "replace group members with new list of members" ]) + @new_resource.members << "user1" + allow(@new_resource).to receive(:append).and_return false + expect(@provider.compare_group).to be_truthy + expect(@provider.change_desc).to eq([ "replace group members with new list of members" ]) end it "should report the gid will be changed when it does not match" do diff --git a/spec/unit/provider/http_request_spec.rb b/spec/unit/provider/http_request_spec.rb index f4d415be4d..9a3519a95a 100644 --- a/spec/unit/provider/http_request_spec.rb +++ b/spec/unit/provider/http_request_spec.rb @@ -138,7 +138,7 @@ describe Chef::Provider::HttpRequest do it "should not update a HEAD request if a not modified response (CHEF-4762)" do if_modified_since = File.mtime(__FILE__).httpdate @new_resource.headers "If-Modified-Since" => if_modified_since - expect(@http).to receive(:head).with("http://www.opscode.com/", {"If-Modified-Since" => if_modified_since}).and_return(false) + expect(@http).to receive(:head).with("http://www.opscode.com/", { "If-Modified-Since" => if_modified_since }).and_return(false) @provider.run_action(:head) expect(@new_resource).not_to be_updated end diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb index 264ef1d205..7847fc9a5f 100644 --- a/spec/unit/provider/ifconfig/aix_spec.rb +++ b/spec/unit/provider/ifconfig/aix_spec.rb @@ -35,7 +35,6 @@ lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64 IFCONFIG end - before(:each) do @node = Chef::Node.new @cookbook_collection = Chef::CookbookCollection.new([]) @@ -87,7 +86,7 @@ IFCONFIG @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) end - expect{@provider.run_action(:add)}.to raise_error(Chef::Exceptions::Ifconfig, "interface metric attribute cannot be set for :add action") + expect { @provider.run_action(:add) }.to raise_error(Chef::Exceptions::Ifconfig, "interface metric attribute cannot be set for :add action") end end diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb index d0ae988344..1f61957721 100644 --- a/spec/unit/provider/ifconfig/debian_spec.rb +++ b/spec/unit/provider/ifconfig/debian_spec.rb @@ -37,7 +37,7 @@ describe Chef::Provider::Ifconfig::Debian do new_resource end - let(:current_resource) { Chef::Resource::Ifconfig.new("10.0.0.1", run_context) } + let(:current_resource) { Chef::Resource::Ifconfig.new("10.0.0.1", run_context) } let(:provider) do status = double("Status", :exitstatus => 0) @@ -120,7 +120,7 @@ iface eth0 inet static netmask 255.255.254.0 EOF ) - expect(File.exists?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist + expect(File.exists?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist end context "when the /etc/network/interfaces file has the source line" do @@ -253,7 +253,7 @@ iface eth0 inet static EOF ) expect(File).not_to receive(:new).with(config_filename_ifcfg, "w") - expect(File.exists?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist + expect(File.exists?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist end context "when the /etc/network/interfaces file has the source line" do diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb index cf49d651c2..421dd0c2dd 100644 --- a/spec/unit/provider/mdadm_spec.rb +++ b/spec/unit/provider/mdadm_spec.rb @@ -26,7 +26,7 @@ describe Chef::Provider::Mdadm do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::Mdadm.new("/dev/md1") - @new_resource.devices ["/dev/sdz1","/dev/sdz2","/dev/sdz3"] + @new_resource.devices ["/dev/sdz1", "/dev/sdz2", "/dev/sdz3"] @provider = Chef::Provider::Mdadm.new(@new_resource, @run_context) end @@ -39,13 +39,13 @@ describe Chef::Provider::Mdadm do 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 @@ -102,12 +102,12 @@ describe Chef::Provider::Mdadm do expect(@new_resource).to be_updated_by_last_action end - it "should not assemble the raid device if it doesnt exist" do + it "should not assemble the raid device if it doesnt exist" do @current_resource.exists(true) expect(@provider).not_to receive(:shell_out!) @provider.run_action(:assemble) expect(@new_resource).not_to be_updated_by_last_action - end + end end describe "when stopping the metadevice" do diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb index 3bd05073ea..9a34a6d21d 100644 --- a/spec/unit/provider/mount/aix_spec.rb +++ b/spec/unit/provider/mount/aix_spec.rb @@ -40,7 +40,7 @@ UNMOUNTED /dev/sdz3 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8 MOUNT - @enabled_output = <<-ENABLED + @enabled_output = <<-ENABLED #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct /tmp/foo:/dev/sdz1:jfs2::bootfs:10485760:rw:yes:no ENABLED @@ -156,7 +156,7 @@ ENABLED 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}") @@ -165,7 +165,7 @@ ENABLED 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 1fbe0c5c89..50ed356049 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -239,11 +239,11 @@ describe Chef::Provider::Mount::Mount do end it "should ignore commented lines in fstab " do - fstab = "\# #{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n" - allow(::File).to receive(:foreach).with("/etc/fstab").and_yield fstab + fstab = "\# #{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n" + allow(::File).to receive(:foreach).with("/etc/fstab").and_yield fstab - @provider.load_current_resource - expect(@provider.current_resource.enabled).to be_falsey + @provider.load_current_resource + expect(@provider.current_resource.enabled).to be_falsey end it "should set enabled to false if the mount point is not last in fstab" do @@ -347,14 +347,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) @@ -363,7 +363,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) diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb index 7304c4290f..a6d0620df6 100644 --- a/spec/unit/provider/mount/solaris_spec.rb +++ b/spec/unit/provider/mount/solaris_spec.rb @@ -103,7 +103,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do describe "#define_resource_requirements" do before do # we're not testing the actual actions so stub them all out - [:mount_fs, :umount_fs, :remount_fs, :enable_fs, :disable_fs].each {|m| allow(provider).to receive(m) } + [:mount_fs, :umount_fs, :remount_fs, :enable_fs, :disable_fs].each { |m| allow(provider).to receive(m) } end it "run_action(:mount) should raise an error if the device does not exist" do diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb index df7479fd46..ab7a161c08 100644 --- a/spec/unit/provider/mount/windows_spec.rb +++ b/spec/unit/provider/mount/windows_spec.rb @@ -100,9 +100,9 @@ describe Chef::Provider::Mount::Windows do 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) + :username => @new_resource.username, + :domainname => @new_resource.domain, + :password => @new_resource.password) @provider.mount_fs end @@ -114,9 +114,9 @@ describe Chef::Provider::Mount::Windows do it "should remount the filesystem if it is mounted and the options have changed" do expect(@vol).to receive(:add).with(:remote => @new_resource.device, - :username => @new_resource.username, - :domainname => @new_resource.domain, - :password => @new_resource.password) + :username => @new_resource.username, + :domainname => @new_resource.domain, + :password => @new_resource.password) @provider.mount_fs end diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb index 5aa247a30f..fa168e571e 100644 --- a/spec/unit/provider/mount_spec.rb +++ b/spec/unit/provider/mount_spec.rb @@ -135,7 +135,7 @@ describe Chef::Provider::Mount do provider.unmount_retries = 1 expect(provider).to receive(:umount_fs) expect(provider).to receive(:mounted?).and_return(true, true) - expect{ provider.run_action(:remount) }.to raise_error(Chef::Exceptions::Mount) + expect { provider.run_action(:remount) }.to raise_error(Chef::Exceptions::Mount) end end @@ -181,7 +181,6 @@ describe Chef::Provider::Mount do end end - it "should delegates the mount implementation to subclasses" do expect { provider.mount_fs }.to raise_error(Chef::Exceptions::UnsupportedAction) end diff --git a/spec/unit/provider/ohai_spec.rb b/spec/unit/provider/ohai_spec.rb index d04bef146e..100eee59a4 100644 --- a/spec/unit/provider/ohai_spec.rb +++ b/spec/unit/provider/ohai_spec.rb @@ -46,7 +46,7 @@ describe Chef::Provider::Ohai do mock_ohai[:data2]) allow(Ohai::System).to receive(:new).and_return(mock_ohai) allow(Chef::Platform).to receive(:find_platform_and_version).and_return({ "platform" => @platform, - "platform_version" => @platform_version}) + "platform_version" => @platform_version }) # Fake node with a dummy save @node = Chef::Node.new @node.name(@fqdn) @@ -56,7 +56,7 @@ describe Chef::Provider::Ohai do @new_resource = Chef::Resource::Ohai.new("ohai_reload") ohai = Ohai::System.new ohai.all_plugins - @node.consume_external_attrs(ohai.data,{}) + @node.consume_external_attrs(ohai.data, {}) @provider = Chef::Provider::Ohai.new(@new_resource, @run_context) end diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb index 13b65e8cc7..260204f98b 100644 --- a/spec/unit/provider/osx_profile_spec.rb +++ b/spec/unit/provider/osx_profile_spec.rb @@ -23,56 +23,47 @@ describe Chef::Provider::OsxProfile do double("shell_out", :exitstatus => 0, :error? => false) end describe "action_create" do - let(:node) { Chef::Node.new } - let(:events) { Chef::EventDispatch::Dispatcher.new } - let(:run_context) { Chef::RunContext.new(node, {}, events) } - let(:new_resource) { Chef::Resource::OsxProfile.new("Profile Test", run_context) } - let(:provider) { Chef::Provider::OsxProfile.new(new_resource, run_context) } - let(:all_profiles) do - {"_computerlevel"=> - [{"ProfileDisplayName"=>"Finder Settings", - "ProfileIdentifier"=>"com.apple.finder", - "ProfileInstallDate"=>"2015-11-08 23:15:21 +0000", - "ProfileItems"=> - [{"PayloadContent"=> - {"PayloadContentManagedPreferences"=> - {"com.apple.finder"=> - {"Forced"=>[{"mcx_preference_settings"=>{"ShowExternalHardDrivesOnDesktop"=>false}}]}}}, - "PayloadDisplayName"=>"Custom: (com.apple.finder)", - "PayloadIdentifier"=>"com.apple.finder", - "PayloadType"=>"com.apple.ManagedClient.preferences", - "PayloadUUID"=>"a017048f-684b-4e81-baa3-43afe316d739", - "PayloadVersion"=>1}], - "ProfileOrganization"=>"Chef", - "ProfileRemovalDisallowed"=>"false", - "ProfileType"=>"Configuration", - "ProfileUUID"=>"e2e09bef-e673-44a6-bcbe-ecb5f1c1b740", - "ProfileVerificationState"=>"unsigned", - "ProfileVersion"=>1}, - {"ProfileDisplayName"=>"ScreenSaver Settings", - "ProfileIdentifier"=>"com.testprofile.screensaver", - "ProfileInstallDate"=>"2015-10-05 23:15:21 +0000", - "ProfileItems"=> - [{"PayloadContent"=> - {"PayloadContentManagedPreferences"=> - {"com.apple.screensaver"=> - {"Forced"=>[{"mcx_preference_settings"=>{"idleTime"=>0}}]}}}, - "PayloadDisplayName"=>"Custom: (com.apple.screensaver)", - "PayloadIdentifier"=>"com.apple.screensaver", - "PayloadType"=>"com.apple.ManagedClient.preferences", - "PayloadUUID"=>"73fc30e0-1e57-0131-c32d-000c2944c110", - "PayloadVersion"=>1}], - "ProfileOrganization"=>"Chef", - "ProfileRemovalDisallowed"=>"false", - "ProfileType"=>"Configuration", - "ProfileUUID"=>"6e95927c-f200-54b4-85c7-52ab99b61c47", - "ProfileVerificationState"=>"unsigned", - "ProfileVersion"=>1}] - } - end + let(:node) { Chef::Node.new } + let(:events) { Chef::EventDispatch::Dispatcher.new } + let(:run_context) { Chef::RunContext.new(node, {}, events) } + let(:new_resource) { Chef::Resource::OsxProfile.new("Profile Test", run_context) } + let(:provider) { Chef::Provider::OsxProfile.new(new_resource, run_context) } + let(:all_profiles) do + { "_computerlevel" => [{ "ProfileDisplayName" => "Finder Settings", + "ProfileIdentifier" => "com.apple.finder", + "ProfileInstallDate" => "2015-11-08 23:15:21 +0000", + "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.finder" => { "Forced" => [{ "mcx_preference_settings" => { "ShowExternalHardDrivesOnDesktop" => false } }] } } }, + "PayloadDisplayName" => "Custom: (com.apple.finder)", + "PayloadIdentifier" => "com.apple.finder", + "PayloadType" => "com.apple.ManagedClient.preferences", + "PayloadUUID" => "a017048f-684b-4e81-baa3-43afe316d739", + "PayloadVersion" => 1 }], + "ProfileOrganization" => "Chef", + "ProfileRemovalDisallowed" => "false", + "ProfileType" => "Configuration", + "ProfileUUID" => "e2e09bef-e673-44a6-bcbe-ecb5f1c1b740", + "ProfileVerificationState" => "unsigned", + "ProfileVersion" => 1 }, + { "ProfileDisplayName" => "ScreenSaver Settings", + "ProfileIdentifier" => "com.testprofile.screensaver", + "ProfileInstallDate" => "2015-10-05 23:15:21 +0000", + "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } }, + "PayloadDisplayName" => "Custom: (com.apple.screensaver)", + "PayloadIdentifier" => "com.apple.screensaver", + "PayloadType" => "com.apple.ManagedClient.preferences", + "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c110", + "PayloadVersion" => 1 }], + "ProfileOrganization" => "Chef", + "ProfileRemovalDisallowed" => "false", + "ProfileType" => "Configuration", + "ProfileUUID" => "6e95927c-f200-54b4-85c7-52ab99b61c47", + "ProfileVerificationState" => "unsigned", + "ProfileVersion" => 1 }] + } + end # If anything is changed within this profile, be sure to update the # ProfileUUID in all_profiles to match the new config specific UUID - let(:test_profile) do + let(:test_profile) do { "PayloadIdentifier" => "com.testprofile.screensaver", "PayloadRemovalDisallowed" => false, @@ -82,7 +73,7 @@ describe Chef::Provider::OsxProfile do "PayloadOrganization" => "Chef", "PayloadVersion" => 1, "PayloadDisplayName" => "Screensaver Settings", - "PayloadContent"=> [ + "PayloadContent" => [ { "PayloadType" => "com.apple.ManagedClient.preferences", "PayloadVersion" => 1, @@ -104,10 +95,10 @@ describe Chef::Provider::OsxProfile do }, ], } - end - let(:no_profiles) do - { } - end + end + let(:no_profiles) do + {} + end before(:each) do allow(provider).to receive(:cookbook_file_available?).and_return(true) @@ -181,7 +172,7 @@ describe Chef::Provider::OsxProfile do test_profile.delete("PayloadIdentifier") new_resource.profile test_profile error_message = "The specified profile does not seem to be valid" - expect{provider.run_action(:install)}.to raise_error(RuntimeError, error_message) + expect { provider.run_action(:install) }.to raise_error(RuntimeError, error_message) end end @@ -194,45 +185,36 @@ describe Chef::Provider::OsxProfile do let(:provider) { Chef::Provider::OsxProfile.new(new_resource, run_context) } let(:current_resource) { Chef::Resource::OsxProfile.new("Profile Test") } let(:all_profiles) do - {"_computerlevel"=> - [{"ProfileDisplayName"=>"ScreenSaver Settings", - "ProfileIdentifier"=>"com.apple.screensaver", - "ProfileInstallDate"=>"2015-10-05 23:15:21 +0000", - "ProfileItems"=> - [{"PayloadContent"=> - {"PayloadContentManagedPreferences"=> - {"com.apple.screensaver"=> - {"Forced"=>[{"mcx_preference_settings"=>{"idleTime"=>0}}]}}}, - "PayloadDisplayName"=>"Custom: (com.apple.screensaver)", - "PayloadIdentifier"=>"com.apple.screensaver", - "PayloadType"=>"com.apple.ManagedClient.preferences", - "PayloadUUID"=>"73fc30e0-1e57-0131-c32d-000c2944c108", - "PayloadVersion"=>1}], - "ProfileOrganization"=>"Chef", - "ProfileRemovalDisallowed"=>"false", - "ProfileType"=>"Configuration", - "ProfileUUID"=>"1781fbec-3325-565f-9022-8aa28135c3cc", - "ProfileVerificationState"=>"unsigned", - "ProfileVersion"=>1}, - {"ProfileDisplayName"=>"ScreenSaver Settings", - "ProfileIdentifier"=>"com.testprofile.screensaver", - "ProfileInstallDate"=>"2015-10-05 23:15:21 +0000", - "ProfileItems"=> - [{"PayloadContent"=> - {"PayloadContentManagedPreferences"=> - {"com.apple.screensaver"=> - {"Forced"=>[{"mcx_preference_settings"=>{"idleTime"=>0}}]}}}, - "PayloadDisplayName"=>"Custom: (com.apple.screensaver)", - "PayloadIdentifier"=>"com.apple.screensaver", - "PayloadType"=>"com.apple.ManagedClient.preferences", - "PayloadUUID"=>"73fc30e0-1e57-0131-c32d-000c2944c110", - "PayloadVersion"=>1}], - "ProfileOrganization"=>"Chef", - "ProfileRemovalDisallowed"=>"false", - "ProfileType"=>"Configuration", - "ProfileUUID"=>"1781fbec-3325-565f-9022-8aa28135c3cc", - "ProfileVerificationState"=>"unsigned", - "ProfileVersion"=>1}] + { "_computerlevel" => [{ "ProfileDisplayName" => "ScreenSaver Settings", + "ProfileIdentifier" => "com.apple.screensaver", + "ProfileInstallDate" => "2015-10-05 23:15:21 +0000", + "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } }, + "PayloadDisplayName" => "Custom: (com.apple.screensaver)", + "PayloadIdentifier" => "com.apple.screensaver", + "PayloadType" => "com.apple.ManagedClient.preferences", + "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c108", + "PayloadVersion" => 1 }], + "ProfileOrganization" => "Chef", + "ProfileRemovalDisallowed" => "false", + "ProfileType" => "Configuration", + "ProfileUUID" => "1781fbec-3325-565f-9022-8aa28135c3cc", + "ProfileVerificationState" => "unsigned", + "ProfileVersion" => 1 }, + { "ProfileDisplayName" => "ScreenSaver Settings", + "ProfileIdentifier" => "com.testprofile.screensaver", + "ProfileInstallDate" => "2015-10-05 23:15:21 +0000", + "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } }, + "PayloadDisplayName" => "Custom: (com.apple.screensaver)", + "PayloadIdentifier" => "com.apple.screensaver", + "PayloadType" => "com.apple.ManagedClient.preferences", + "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c110", + "PayloadVersion" => 1 }], + "ProfileOrganization" => "Chef", + "ProfileRemovalDisallowed" => "false", + "ProfileType" => "Configuration", + "ProfileUUID" => "1781fbec-3325-565f-9022-8aa28135c3cc", + "ProfileVerificationState" => "unsigned", + "ProfileVersion" => 1 }] } end before(:each) do diff --git a/spec/unit/provider/package/aix_spec.rb b/spec/unit/provider/package/aix_spec.rb index b319d87929..6940874a43 100644 --- a/spec/unit/provider/package/aix_spec.rb +++ b/spec/unit/provider/package/aix_spec.rb @@ -33,10 +33,10 @@ describe Chef::Provider::Package::Aix do describe "assessing the current package status" do before 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:" + @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 diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb index abf128d086..f87c1e86bc 100644 --- a/spec/unit/provider/package/apt_spec.rb +++ b/spec/unit/provider/package/apt_spec.rb @@ -34,7 +34,7 @@ describe Chef::Provider::Package::Apt do @status = double("Status", :exitstatus => 0) @provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context) @stdin = StringIO.new - @stdout =<<-PKG_STATUS + @stdout = <<-PKG_STATUS irssi: Installed: (none) Candidate: 0.8.14-1ubuntu4 @@ -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 @@ -86,18 +86,18 @@ sudo: # list of virtual packages: http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt it "should not install the virtual package there is a single provider package and it is installed" do @new_resource.package_name("libmysqlclient15-dev") - virtual_package_out=<<-VPKG_STDOUT + virtual_package_out = <<-VPKG_STDOUT libmysqlclient15-dev: Installed: (none) 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!).with( "apt-cache policy libmysqlclient15-dev", :timeout => @timeout, ).and_return(virtual_package) - showpkg_out =<<-SHOWPKG_STDOUT + showpkg_out = <<-SHOWPKG_STDOUT Package: libmysqlclient15-dev Versions: @@ -115,12 +115,12 @@ 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!).with( "apt-cache showpkg libmysqlclient15-dev", :timeout => @timeout, ).and_return(showpkg) - real_package_out=<<-RPKG_STDOUT + real_package_out = <<-RPKG_STDOUT libmysqlclient-dev: Installed: 5.1.41-3ubuntu12.10 Candidate: 5.1.41-3ubuntu12.10 @@ -133,7 +133,7 @@ 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!).with( "apt-cache policy libmysqlclient-dev", :timeout => @timeout, @@ -143,18 +143,18 @@ libmysqlclient-dev: it "should raise an exception if you specify a virtual package with multiple provider packages" do @new_resource.package_name("mp3-decoder") - virtual_package_out=<<-VPKG_STDOUT + virtual_package_out = <<-VPKG_STDOUT mp3-decoder: Installed: (none) 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!).with( "apt-cache policy mp3-decoder", :timeout => @timeout, ).and_return(virtual_package) - showpkg_out=<<-SHOWPKG_STDOUT + showpkg_out = <<-SHOWPKG_STDOUT Package: mp3-decoder Versions: @@ -175,7 +175,7 @@ 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!).with( "apt-cache showpkg mp3-decoder", :timeout => @timeout, @@ -204,7 +204,7 @@ mpg123 1.12.1-0ubuntu1 ).and_return(@shell_out) @provider.load_current_resource @provider.define_resource_requirements - expect(@provider).to receive(:shell_out!).with("apt-cache policy irssi", {:timeout=>900}).and_return(@shell_out) + expect(@provider).to receive(:shell_out!).with("apt-cache policy irssi", { :timeout => 900 }).and_return(@shell_out) expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) end end @@ -219,7 +219,7 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get install with the package name and version" do expect(@provider).to receive(:shell_out!). with( "apt-get -q -y install irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil}, + :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, :timeout => @timeout, ) @provider.install_package("irssi", "0.8.12-7") @@ -228,7 +228,7 @@ 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!).with( "apt-get -q -y --force-yes install irssi=0.8.12-7", - :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, + :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, :timeout => @timeout, ) @new_resource.options("--force-yes") @@ -244,7 +244,7 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:shell_out!).with( "apt-get -q -y -o APT::Default-Release=lenny-backports install irssi=0.8.12-7", - :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, + :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, :timeout => @timeout, ) @@ -265,7 +265,7 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get remove with the package name" do expect(@provider).to receive(:shell_out!).with( "apt-get -q -y remove irssi", - :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil}, + :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, :timeout => @timeout, ) @provider.remove_package("irssi", "0.8.12-7") @@ -316,7 +316,7 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:shell_out!).with( "debconf-set-selections /tmp/irssi-0.8.12-7.seed", - :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil}, + :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, :timeout => @timeout, ) @@ -326,7 +326,7 @@ 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!).with( "debconf-set-selections /tmp/irssi-0.8.12-7.seed", - :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil}, + :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, :timeout => @timeout, ) file = @provider.get_preseed_file("irssi", "0.8.12-7") @@ -347,7 +347,7 @@ mpg123 1.12.1-0ubuntu1 it "should run dpkg-reconfigure package" do expect(@provider).to receive(:shell_out!).with( "dpkg-reconfigure irssi", - :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, + :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, :timeout => @timeout, ) @provider.reconfig_package("irssi", "0.8.12-7") @@ -359,7 +359,7 @@ mpg123 1.12.1-0ubuntu1 @provider.is_virtual_package["libmysqlclient-dev"] = true expect(@provider).to receive(:shell_out!).with( "apt-get -q -y install libmysqlclient-dev", - :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, + :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, :timeout => @timeout, ) @provider.install_package("libmysqlclient-dev", "not_a_real_version") @@ -373,7 +373,7 @@ mpg123 1.12.1-0ubuntu1 @provider.is_virtual_package["irssi"] = false expect(@provider).to receive(:shell_out!).with( "apt-get -q -y install libmysqlclient-dev irssi=0.8.12-7", - :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, + :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, :timeout => @timeout, ) @provider.install_package(["libmysqlclient-dev", "irssi"], ["not_a_real_version", "0.8.12-7"]) diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb index d550e55445..aeb420fa7a 100644 --- a/spec/unit/provider/package/chocolatey_spec.rb +++ b/spec/unit/provider/package/chocolatey_spec.rb @@ -45,7 +45,7 @@ ConEmu|15.10.25.0 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!).with("#{choco_exe} list -l -r", {:timeout => timeout}).and_return(local_list_obj) + allow(provider).to receive(:shell_out!).with("#{choco_exe} list -l -r", { :timeout => timeout }).and_return(local_list_obj) end def allow_remote_list(package_names, args = nil) @@ -57,7 +57,7 @@ Git|2.6.2 munin-node|1.6.1.20130823 EOF remote_list_obj = double(stdout: remote_list_stdout) - allow(provider).to receive(:shell_out!).with("#{choco_exe} list -ar #{package_names.join ' '}#{args}", {timeout: timeout}).and_return(remote_list_obj) + allow(provider).to receive(:shell_out!).with("#{choco_exe} list -ar #{package_names.join ' '}#{args}", { timeout: timeout }).and_return(remote_list_obj) end describe "#initialize" do @@ -86,7 +86,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git"]) new_resource.version("2.5.0") expect(provider.candidate_version).to eql([nil]) - end + end it "should set the candidate_version to nil if there is no candidate" do allow_remote_list(["vim"]) @@ -132,7 +132,7 @@ munin-node|1.6.1.20130823 it "should load and downcase names in the installed_packages hash" do provider.load_current_resource expect(provider.send(:installed_packages)).to eql( - {"chocolatey"=>"0.9.9.11", "conemu"=>"15.10.25.0"} + { "chocolatey" => "0.9.9.11", "conemu" => "15.10.25.0" } ) end @@ -140,7 +140,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git"]) provider.load_current_resource expect(provider.send(:available_packages)).to eql( - {"chocolatey"=>"0.9.9.11", "conemu"=>"15.10.25.1", "git"=>"2.6.2", "munin-node" => "1.6.1.20130823"} + { "chocolatey" => "0.9.9.11", "conemu" => "15.10.25.1", "git" => "2.6.2", "munin-node" => "1.6.1.20130823" } ) end @@ -184,7 +184,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!).with("#{choco_exe} install -y git", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :timeout => timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -195,7 +195,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!).with("#{choco_exe} install -y git", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :timeout => timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -224,7 +224,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!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -237,7 +237,7 @@ munin-node|1.6.1.20130823 new_resource.package_name(["chocolatey", "ConEmu"]) new_resource.version([nil, "15.10.25.1"]) provider.load_current_resource - expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -247,7 +247,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!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -257,8 +257,8 @@ munin-node|1.6.1.20130823 new_resource.package_name(["ConEmu", "git"]) new_resource.version(["15.10.25.1", nil]) provider.load_current_resource - expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", {:timeout=>timeout}).and_return(double) - expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :timeout => timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -267,7 +267,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!).with("#{choco_exe} install -y git munin-node", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git munin-node", { :timeout => timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -277,7 +277,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!).with("#{choco_exe} install -y -source localpackages git", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -source localpackages git", { :timeout => timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -287,7 +287,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!).with("#{choco_exe} install -y -force git", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -force git", { :timeout => timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -329,7 +329,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!).with("#{choco_exe} upgrade -y git", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y git", { :timeout => timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -338,7 +338,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!).with("#{choco_exe} upgrade -y conemu", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu", { :timeout => timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -347,7 +347,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!).with("#{choco_exe} upgrade -y conemu", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu", { :timeout => timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -356,7 +356,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!).with("#{choco_exe} upgrade -y chocolatey", {:timeout=>timeout}) + expect(provider).not_to receive(:shell_out!).with("#{choco_exe} upgrade -y chocolatey", { :timeout => timeout }) provider.run_action(:upgrade) expect(new_resource).not_to be_updated_by_last_action end @@ -365,7 +365,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!).with("#{choco_exe} upgrade -y -version 2.6.2 git", {:timeout=>timeout}) + expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y -version 2.6.2 git", { :timeout => timeout }) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -373,7 +373,7 @@ munin-node|1.6.1.20130823 it "upgrading multiple packages uses a single command" do allow_remote_list(["conemu", "git"]) new_resource.package_name(["conemu", "git"]) - expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu git", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu git", { :timeout => timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -425,7 +425,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!).with("#{choco_exe} uninstall -y ConEmu", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y ConEmu", { :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(["conemu"]) new_resource.package_name("conemu") provider.load_current_resource - expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", { :timeout => timeout }).and_return(double) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -444,7 +444,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git", "conemu"]) new_resource.package_name(["git", "conemu"]) provider.load_current_resource - expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", {:timeout=>timeout}).and_return(double) + expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", { :timeout => timeout }).and_return(double) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb index a249f24793..613f7a326e 100644 --- a/spec/unit/provider/package/dpkg_spec.rb +++ b/spec/unit/provider/package/dpkg_spec.rb @@ -52,7 +52,7 @@ Conflicts: wget-ssl before(:each) do allow(provider).to receive(:shell_out!).with("dpkg-deb -W #{source}", timeout: 900).and_return(dpkg_deb_status) - allow(provider).to receive(:shell_out!).with("dpkg -s #{package}", timeout: 900, returns: [0,1]).and_return(double(stdout: "", exitstatus: 1)) + allow(provider).to receive(:shell_out!).with("dpkg -s #{package}", timeout: 900, returns: [0, 1]).and_return(double(stdout: "", exitstatus: 1)) allow(::File).to receive(:exist?).with(source).and_return(true) end @@ -160,12 +160,12 @@ Conflicts: wget-ssl let(:source) { nil } it "should raise an exception if the source is not set but we are installing" do - expect { provider.run_action(:install)}.to raise_error(Chef::Exceptions::Package) + expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) end end it "should return the current version installed if found by dpkg" do - allow(provider).to receive(:shell_out!).with("dpkg -s #{package}", timeout: 900, returns: [0,1]).and_return(dpkg_s_status) + allow(provider).to receive(:shell_out!).with("dpkg -s #{package}", timeout: 900, returns: [0, 1]).and_return(dpkg_s_status) provider.load_current_resource expect(provider.current_resource.version).to eq(["1.11.4-1ubuntu1"]) end diff --git a/spec/unit/provider/package/freebsd/pkg_spec.rb b/spec/unit/provider/package/freebsd/pkg_spec.rb index 7c17177bec..8890f62f73 100644 --- a/spec/unit/provider/package/freebsd/pkg_spec.rb +++ b/spec/unit/provider/package/freebsd/pkg_spec.rb @@ -77,7 +77,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do it "should return the version number when it is installed" do pkg_info = OpenStruct.new(:stdout => "zsh-4.3.6_7") - expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0,1], timeout: 900).and_return(pkg_info) + expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info) #@provider.should_receive(:popen4).with('pkg_info -E "zsh*"').and_yield(@pid, @stdin, ["zsh-4.3.6_7"], @stderr).and_return(@status) allow(@provider).to receive(:package_name).and_return("zsh") expect(@provider.current_installed_version).to eq("4.3.6_7") @@ -85,7 +85,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do it "does not set the current version number when the package is not installed" do pkg_info = OpenStruct.new(:stdout => "") - expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0,1], timeout: 900).and_return(pkg_info) + expect(@provider).to receive(:shell_out!).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 @@ -102,7 +102,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do 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) - expect(@provider).to receive(:shell_out!).with("make -V PORTVERSION", {cwd: "/usr/ports/shells/zsh", returns: [0, 1], env: nil, timeout: 900}).and_return(make_v) + expect(@provider).to receive(:shell_out!).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 @@ -110,7 +110,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" 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) - expect(@provider).to receive(:shell_out!).with("make -V PKGNAME", {cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900}).and_return(make_v) + expect(@provider).to receive(:shell_out!).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") end @@ -220,7 +220,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do it "should return the version number when it is installed" do pkg_info = OpenStruct.new(:stdout => "bonnie++-1.96") - expect(@provider).to receive(:shell_out!).with('pkg_info -E "bonnie++*"', env: nil, returns: [0,1], timeout: 900).and_return(pkg_info) + expect(@provider).to receive(:shell_out!).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") end diff --git a/spec/unit/provider/package/freebsd/pkgng_spec.rb b/spec/unit/provider/package/freebsd/pkgng_spec.rb index d89bf24eb8..a2bd833d9e 100644 --- a/spec/unit/provider/package/freebsd/pkgng_spec.rb +++ b/spec/unit/provider/package/freebsd/pkgng_spec.rb @@ -16,7 +16,6 @@ # limitations under the License. # - require "spec_helper" require "ostruct" @@ -30,7 +29,6 @@ describe Chef::Provider::Package::Freebsd::Port do @provider = Chef::Provider::Package::Freebsd::Pkgng.new(@new_resource, @run_context) end - describe "initialization" do it "should create a current resource with the name of the new resource" do expect(@provider.current_resource.is_a?(Chef::Resource::Package)).to be_truthy @@ -38,7 +36,6 @@ describe Chef::Provider::Package::Freebsd::Port do end end - describe "loading current resource" do before(:each) do allow(@provider).to receive(:current_installed_version) @@ -63,7 +60,6 @@ describe Chef::Provider::Package::Freebsd::Port do end end - describe "determining current installed version" do before(:each) do allow(@provider).to receive(:supports_pkgng?) @@ -71,12 +67,11 @@ describe Chef::Provider::Package::Freebsd::Port do end it "should query pkg database" do - expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0,70], timeout: 900).and_return(@pkg_info) + expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info) expect(@provider.current_installed_version).to eq("3.1.7") end end - describe "determining candidate version" do it "should query repository" do pkg_query = OpenStruct.new(:stdout => "5.0.5\n", :exitstatus => 0) @@ -97,7 +92,6 @@ describe Chef::Provider::Package::Freebsd::Port do end end - describe "installing a binary package" do before(:each) do @install_result = OpenStruct.new(:status => true) @@ -133,7 +127,6 @@ describe Chef::Provider::Package::Freebsd::Port do end end - describe "removing a binary package" do before(:each) do @install_result = OpenStruct.new(:status => true) diff --git a/spec/unit/provider/package/freebsd/port_spec.rb b/spec/unit/provider/package/freebsd/port_spec.rb index b12d4eb063..b593da4ff1 100644 --- a/spec/unit/provider/package/freebsd/port_spec.rb +++ b/spec/unit/provider/package/freebsd/port_spec.rb @@ -16,7 +16,6 @@ # limitations under the License. # - require "spec_helper" require "ostruct" @@ -30,7 +29,6 @@ describe Chef::Provider::Package::Freebsd::Port do @provider = Chef::Provider::Package::Freebsd::Port.new(@new_resource, @run_context) end - describe "initialization" do it "should create a current resource with the name of the new resource" do expect(@provider.current_resource.is_a?(Chef::Resource::Package)).to be_truthy @@ -38,7 +36,6 @@ describe Chef::Provider::Package::Freebsd::Port do end end - describe "loading current resource" do before(:each) do allow(@provider).to receive(:current_installed_version) @@ -63,7 +60,6 @@ describe Chef::Provider::Package::Freebsd::Port do end end - describe "determining current installed version" do before(:each) do @pkg_info = OpenStruct.new(:stdout => "zsh-3.1.7\n") @@ -72,7 +68,7 @@ describe Chef::Provider::Package::Freebsd::Port do it "should check 'pkg_info' if system uses pkg_* tools" do allow(@new_resource).to receive(:supports_pkgng?) expect(@new_resource).to receive(:supports_pkgng?).and_return(false) - expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0,1], timeout: 900).and_return(@pkg_info) + expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0, 1], timeout: 900).and_return(@pkg_info) expect(@provider.current_installed_version).to eq("3.1.7") end @@ -81,7 +77,7 @@ describe Chef::Provider::Package::Freebsd::Port do [1000016, 1000000, 901503, 902506, 802511].each do |__freebsd_version| @node.automatic_attrs[:os_version] = __freebsd_version expect(@new_resource).to receive(:shell_out!).with("make -V WITH_PKGNG", env: nil).and_return(pkg_enabled) - expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0,70], timeout: 900).and_return(@pkg_info) + expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info) expect(@provider.current_installed_version).to eq("3.1.7") end end @@ -89,7 +85,7 @@ describe Chef::Provider::Package::Freebsd::Port do it "should check 'pkg info' if the freebsd version is greater than or equal to 1000017" do __freebsd_version = 1000017 @node.automatic_attrs[:os_version] = __freebsd_version - expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0,70], timeout: 900).and_return(@pkg_info) + expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info) expect(@provider.current_installed_version).to eq("3.1.7") end end @@ -102,7 +98,7 @@ describe Chef::Provider::Package::Freebsd::Port do it "should return candidate version if port exists" do allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true) allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh") - expect(@provider).to receive(:shell_out!).with("make -V PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0,1], timeout: 900). + expect(@provider).to receive(:shell_out!).with("make -V PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900). and_return(@port_version) expect(@provider.candidate_version).to eq("5.0.5") end @@ -113,7 +109,6 @@ describe Chef::Provider::Package::Freebsd::Port do end end - describe "determining port directory" do it "should return name if package name is absolute path" do allow(@provider.new_resource).to receive(:package_name).and_return("/var/ports/shells/zsh") @@ -138,7 +133,6 @@ describe Chef::Provider::Package::Freebsd::Port do end end - describe "building a binary package" do before(:each) do @install_result = OpenStruct.new(:status => true) @@ -153,7 +147,6 @@ describe Chef::Provider::Package::Freebsd::Port do end end - describe "removing a binary package" do before(:each) do @install_result = OpenStruct.new(:status => true) diff --git a/spec/unit/provider/package/homebrew_spec.rb b/spec/unit/provider/package/homebrew_spec.rb index ab842eea60..17ed5ccc41 100644 --- a/spec/unit/provider/package/homebrew_spec.rb +++ b/spec/unit/provider/package/homebrew_spec.rb @@ -22,7 +22,7 @@ describe Chef::Provider::Package::Homebrew do let(:events) { double("Chef::Events").as_null_object } let(:run_context) { double("Chef::RunContext", node: node, events: events) } let(:new_resource) { Chef::Resource::HomebrewPackage.new("emacs") } - let(:current_resource) { Chef::Resource::HomebrewPackage.new("emacs")} + let(:current_resource) { Chef::Resource::HomebrewPackage.new("emacs") } let(:provider) do Chef::Provider::Package::Homebrew.new(new_resource, run_context) diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb index 732e42a7bc..f47385da09 100644 --- a/spec/unit/provider/package/ips_spec.rb +++ b/spec/unit/provider/package/ips_spec.rb @@ -35,17 +35,16 @@ describe Chef::Provider::Package::Ips do def local_output stdin = StringIO.new stdout = "" - stderr =<<-PKG_STATUS + stderr = <<-PKG_STATUS pkg: info: no packages matching the following patterns you specified are installed on the system. Try specifying -r to query remotely: crypto/gnupg PKG_STATUS - return OpenStruct.new(:stdout => stdout,:stdin => stdin,:stderr => stderr,:status => @status,:exitstatus => 1) + return OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 1) end def remote_output - stdout = <<-PKG_STATUS Name: security/sudo Summary: sudo - authority delegation tool @@ -58,9 +57,9 @@ Packaging Date: April 1, 2012 05:55:52 PM Size: 2.57 MB FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z PKG_STATUS - stdin = StringIO.new - stderr = "" - return OpenStruct.new(:stdout => stdout,:stdin => stdin,:stderr => stderr,:status => @status,:exitstatus => 0) + stdin = StringIO.new + stderr = "" + return 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 ff9e669aa8..b90cf89047 100644 --- a/spec/unit/provider/package/macports_spec.rb +++ b/spec/unit/provider/package/macports_spec.rb @@ -70,7 +70,7 @@ describe Chef::Provider::Package::Macports do describe "current_installed_version" do it "should return the current version if the package is installed" do - stdout = <<EOF + stdout = <<EOF The following ports are currently installed: openssl @0.9.8k_0 (active) EOF diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb index 3a7aab55ac..3e1c1c90b6 100644 --- a/spec/unit/provider/package/openbsd_spec.rb +++ b/spec/unit/provider/package/openbsd_spec.rb @@ -23,7 +23,7 @@ describe Chef::Provider::Package::Openbsd do let(:node) do node = Chef::Node.new - node.default["kernel"] = {"name" => "OpenBSD", "release" => "5.5", "machine" => "amd64"} + node.default["kernel"] = { "name" => "OpenBSD", "release" => "5.5", "machine" => "amd64" } node end @@ -33,7 +33,7 @@ describe Chef::Provider::Package::Openbsd do Chef::Provider::Package::Openbsd.new(new_resource, run_context) end - let(:new_resource) { Chef::Resource::Package.new(name)} + let(:new_resource) { Chef::Resource::Package.new(name) } before(:each) do ENV["PKG_PATH"] = nil @@ -41,7 +41,7 @@ describe Chef::Provider::Package::Openbsd do describe "install a package" do let(:name) { "ihavetoes" } - let(:version) {"0.0"} + let(:version) { "0.0" } context "when not already installed" do before do @@ -56,8 +56,8 @@ describe Chef::Provider::Package::Openbsd do instance_double("shellout", :stdout => "#{name}-#{version}\n")) expect(provider).to receive(:shell_out!).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 @@ -78,7 +78,7 @@ describe Chef::Provider::Package::Openbsd do context "if a flavor is specified" do let(:flavor) { "flavora" } - let(:package_name) {"ihavetoes" } + let(:package_name) { "ihavetoes" } let(:name) { "#{package_name}--#{flavor}" } context "if no version is specified" do @@ -88,8 +88,8 @@ describe Chef::Provider::Package::Openbsd do instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor}\n")) expect(provider).to receive(:shell_out!).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} + { 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 @@ -104,8 +104,8 @@ describe Chef::Provider::Package::Openbsd do new_resource.version("#{version}-#{flavor_b}") expect(provider).to receive(:shell_out!).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} + { 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 @@ -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!).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 4d3339767c..ce9107f31b 100644 --- a/spec/unit/provider/package/pacman_spec.rb +++ b/spec/unit/provider/package/pacman_spec.rb @@ -51,7 +51,7 @@ ERR end it "should run pacman query with the package name" do - expect(@provider).to receive(:shell_out).with("pacman -Qi #{@new_resource.package_name}", {timeout: 900}).and_return(@status) + expect(@provider).to receive(:shell_out).with("pacman -Qi #{@new_resource.package_name}", { timeout: 900 }).and_return(@status) @provider.load_current_resource end @@ -102,7 +102,7 @@ PACMAN end it "should use pacman.conf to determine valid repo names for package versions" do - @pacman_conf = <<-PACMAN_CONF + @pacman_conf = <<-PACMAN_CONF [options] HoldPkg = pacman glibc Architecture = auto @@ -151,12 +151,12 @@ PACMAN_CONF describe Chef::Provider::Package::Pacman, "install_package" do it "should run pacman install with the package name and version" do - expect(@provider).to receive(:shell_out!).with("pacman --sync --noconfirm --noprogressbar nano", {timeout: 900}) + expect(@provider).to receive(:shell_out!).with("pacman --sync --noconfirm --noprogressbar nano", { timeout: 900 }) @provider.install_package("nano", "1.0") end it "should run pacman install with the package name and version and options if specified" do - expect(@provider).to receive(:shell_out!).with("pacman --sync --noconfirm --noprogressbar --debug nano", {timeout: 900}) + expect(@provider).to receive(:shell_out!).with("pacman --sync --noconfirm --noprogressbar --debug nano", { timeout: 900 }) allow(@new_resource).to receive(:options).and_return("--debug") @provider.install_package("nano", "1.0") @@ -172,12 +172,12 @@ PACMAN_CONF describe Chef::Provider::Package::Pacman, "remove_package" do it "should run pacman remove with the package name" do - expect(@provider).to receive(:shell_out!).with("pacman --remove --noconfirm --noprogressbar nano", {timeout: 900}) + expect(@provider).to receive(:shell_out!).with("pacman --remove --noconfirm --noprogressbar nano", { timeout: 900 }) @provider.remove_package("nano", "1.0") end it "should run pacman remove with the package name and options if specified" do - expect(@provider).to receive(:shell_out!).with("pacman --remove --noconfirm --noprogressbar --debug nano", {timeout: 900}) + expect(@provider).to receive(:shell_out!).with("pacman --remove --noconfirm --noprogressbar --debug nano", { timeout: 900 }) allow(@new_resource).to receive(:options).and_return("--debug") @provider.remove_package("nano", "1.0") diff --git a/spec/unit/provider/package/paludis_spec.rb b/spec/unit/provider/package/paludis_spec.rb index 8ca6a881e1..b984aeb83f 100644 --- a/spec/unit/provider/package/paludis_spec.rb +++ b/spec/unit/provider/package/paludis_spec.rb @@ -33,7 +33,7 @@ describe Chef::Provider::Package::Paludis do @stdin = StringIO.new @stderr = StringIO.new - @stdout =<<-PKG_STATUS + @stdout = <<-PKG_STATUS group/ntp 0 accounts group/ntp 0 installed-accounts net/ntp 4.2.6_p5-r2 arbor @@ -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,13 +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!).with("cave -L warning resolve -x \"=net/ntp-4.2.6_p5-r2\"", {:timeout=>@new_resource.timeout}) + expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x \"=net/ntp-4.2.6_p5-r2\"", { :timeout => @new_resource.timeout }) @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!).with("cave -L warning resolve -x --preserve-world \"=net/ntp-4.2.6_p5-r2\"", {:timeout=>@new_resource.timeout}) + expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x --preserve-world \"=net/ntp-4.2.6_p5-r2\"", { :timeout => @new_resource.timeout }) allow(@new_resource).to receive(:options).and_return("--preserve-world") @provider.install_package("net/ntp", "4.2.6_p5-r2") end @@ -102,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!).with("cave -L warning resolve -x \"=sys-process/lsof-4.87\"", {:timeout=>@new_resource.timeout}) + expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x \"=sys-process/lsof-4.87\"", { :timeout => @new_resource.timeout }) @provider.install_package("sys-process/lsof", "4.87") end @@ -120,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!).with("cave -L warning resolve -x \"=net/ntp-4.2.6_p5-r2\"", {:timeout=>@new_resource.timeout}) + expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x \"=net/ntp-4.2.6_p5-r2\"", { :timeout => @new_resource.timeout }) @provider.upgrade_package("net/ntp", "4.2.6_p5-r2") end end diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb index 2f2c44a5d5..1d179edf76 100644 --- a/spec/unit/provider/package/rpm_spec.rb +++ b/spec/unit/provider/package/rpm_spec.rb @@ -116,7 +116,6 @@ describe Chef::Provider::Package::Rpm do end end - context "when the package is installed" do let(:rpm_qp_stdout) { "ImageMagick-c++ 6.5.4.7-7.el6_5" } @@ -237,7 +236,6 @@ describe Chef::Provider::Package::Rpm do end end - context "when the package name contains a tilde (chef#3503)" do let(:package_name) { "supermarket" } @@ -396,7 +394,6 @@ describe Chef::Provider::Package::Rpm do end - end end @@ -429,5 +426,4 @@ describe Chef::Provider::Package::Rpm do end end - end diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index 7f81656eb3..141e2bd383 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -192,7 +192,7 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do it "uses the cached result for gem paths when available" do expect(@gem_env).not_to receive(:shell_out!) expected = ["/path/to/gems", "/another/path/to/gems"] - Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache["/usr/weird/bin/gem"]= expected + Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache["/usr/weird/bin/gem"] = expected expect(@gem_env.gem_paths).to eq(["/path/to/gems", "/another/path/to/gems"]) end @@ -235,7 +235,7 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do end it "detects when the target gem environment is the jruby platform" do - gem_env_out=<<-JRUBY_GEM_ENV + gem_env_out = <<-JRUBY_GEM_ENV RubyGems Environment: - RUBYGEMS VERSION: 1.3.6 - RUBY VERSION: 1.8.7 (2010-05-12 patchlevel 249) [java] @@ -272,12 +272,12 @@ RubyGems Environment: it "uses the cached result for gem platforms if available" do expect(@gem_env).not_to receive(:shell_out!) expected = ["ruby", Gem::Platform.new("universal-java-1.6")] - Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"]= expected + Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"] = expected expect(@gem_env.gem_platforms).to eq(expected) end it "uses the current gem platforms when the target env is not jruby" do - gem_env_out=<<-RBX_GEM_ENV + gem_env_out = <<-RBX_GEM_ENV RubyGems Environment: - RUBYGEMS VERSION: 1.3.6 - RUBY VERSION: 1.8.7 (2010-05-14 patchlevel 174) [x86_64-apple-darwin10.3.0] @@ -394,10 +394,10 @@ describe Chef::Provider::Package::Rubygems do end context "when you try to use a hash of install options" do - let(:options) { {:fail => :burger } } + let(:options) { { :fail => :burger } } it "smites you" do - expect {provider}.to raise_error(ArgumentError) + expect { provider }.to raise_error(ArgumentError) end end end @@ -473,8 +473,8 @@ describe Chef::Provider::Package::Rubygems do expect(provider.current_resource.version).to eq(current_version) end - context "if the requested version is not installed" do - let(:target_version) { "9000.0.2" } + context "if the requested version is not installed" do + let(:target_version) { "9000.0.2" } it "sets the current version to the highest installed version if the requested version is not installed" do expect(provider.current_resource.version).to eq(current_version) @@ -539,8 +539,8 @@ describe Chef::Provider::Package::Rubygems do args = [gem_dep] args << source if source allow(provider.gem_env).to receive(:candidate_version_from_remote). - with(*args). - and_return(version) + with(*args). + and_return(version) end describe "in the current gem environment" do @@ -594,7 +594,7 @@ describe Chef::Provider::Package::Rubygems do let(:options) { "-i /alt/install/location" } it "installs the gem by shelling out when options are provided as a String" do - expected ="gem install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" #{options}" + expected = "gem install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" #{options}" expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action @@ -606,7 +606,7 @@ describe Chef::Provider::Package::Rubygems do let(:gem_binary) { "/foo/bar" } it "installs the gem with rubygems.org as an added source" do - expected ="#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=#{source} --source=https://rubygems.org" + expected = "#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=#{source} --source=https://rubygems.org" expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action @@ -619,7 +619,7 @@ describe Chef::Provider::Package::Rubygems do it "installs the gem" do new_resource.clear_sources(true) - expected ="#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --clear-sources --source=#{source}" + expected = "#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --clear-sources --source=#{source}" expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action @@ -631,7 +631,7 @@ describe Chef::Provider::Package::Rubygems do let(:options) { "-i /alt/install/location" } it "installs the gem by shelling out when options are provided but no version is given" do - expected ="gem install rspec-core -q --no-rdoc --no-ri -v \"#{candidate_version}\" #{options}" + expected = "gem install rspec-core -q --no-rdoc --no-ri -v \"#{candidate_version}\" #{options}" expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb index 6746395dd2..51bffa17b6 100644 --- a/spec/unit/provider/package/smartos_spec.rb +++ b/spec/unit/provider/package/smartos_spec.rb @@ -28,7 +28,6 @@ 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) @provider = Chef::Provider::Package::SmartOS.new(@new_resource, @run_context) allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource) @@ -66,7 +65,6 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do expect(@current_resource.version).to eq(nil) end - end describe "candidate_version" do @@ -82,7 +80,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do 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!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0,1], :timeout=>900).and_return(@shell_out) + expect(@provider).to receive(:shell_out!).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 @@ -92,7 +90,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do 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!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0,1], :timeout=>900).and_return(@shell_out) + expect(@provider).to receive(:shell_out!).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 @@ -101,8 +99,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do it "run pkgin and install the package" do out = OpenStruct.new(:stdout => nil) - expect(@provider).to receive(:shell_out!).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!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", {:env=>nil, :timeout=>900}).and_return(out) + expect(@provider).to receive(:shell_out!).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!).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 b0a007b0cf..9cc8deeb2a 100644 --- a/spec/unit/provider/package/solaris_spec.rb +++ b/spec/unit/provider/package/solaris_spec.rb @@ -32,7 +32,7 @@ describe Chef::Provider::Package::Solaris do describe "assessing the current package status" do before do - @pkginfo =<<-PKGINFO + @pkginfo = <<-PKGINFO PKGINST: SUNWbash NAME: GNU Bourne-Again shell (bash) CATEGORY: system @@ -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 diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb index 22be2d3497..e29508ca7b 100644 --- a/spec/unit/provider/package/windows/msi_spec.rb +++ b/spec/unit/provider/package/windows/msi_spec.rb @@ -21,7 +21,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(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:package_name) { "calculator" } let(:resource_source) { "calculator.msi" } @@ -85,7 +85,7 @@ describe Chef::Provider::Package::Windows::MSI do context "version is explicitly provided" do let(:resource_version) { "given_version" } - + it "returns the given version" do expect(provider.package_version).to eql("given_version") end @@ -95,7 +95,7 @@ describe Chef::Provider::Package::Windows::MSI do before do allow(::File).to receive(:exist?).with(Chef::Util::PathHelper.canonical_path(resource_source, false)).and_return(false) end - + it "returns nil" do expect(provider.package_version).to eql(nil) end diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb index 948e138ae2..62e40e7b6a 100644 --- a/spec/unit/provider/package/windows_spec.rb +++ b/spec/unit/provider/package/windows_spec.rb @@ -27,7 +27,7 @@ describe Chef::Provider::Package::Windows, :windows_only do end let(:node) { double("Chef::Node") } - let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:resource_source) { "calculator.msi" } let(:resource_name) { "calculator" } @@ -327,7 +327,7 @@ describe Chef::Provider::Package::Windows, :windows_only do new_resource.version("5.5.5") allow(provider).to receive(:current_version_array).and_return([ ["5.5.5", "4.3.0", "1.1.1"] ]) end - + it "does not install" do expect(provider).not_to receive(:install_package) provider.run_action(:install) @@ -339,7 +339,7 @@ describe Chef::Provider::Package::Windows, :windows_only do new_resource.version("5.5.5") allow(provider).to receive(:current_version_array).and_return([ ["5.5.0", "4.3.0", "1.1.1"] ]) end - + it "installs given version" do expect(provider).to receive(:install_package).with("blah", "5.5.5") provider.run_action(:install) @@ -353,7 +353,7 @@ describe Chef::Provider::Package::Windows, :windows_only do new_resource.version("5.5.5") allow(provider).to receive(:current_version_array).and_return(["5.5.5"]) end - + it "does not install" do expect(provider).not_to receive(:install_package) provider.run_action(:install) @@ -365,7 +365,7 @@ describe Chef::Provider::Package::Windows, :windows_only do new_resource.version("5.5.5") allow(provider).to receive(:current_version_array).and_return(["5.5.0"]) end - + it "installs given version" do expect(provider).to receive(:install_package).with("blah", "5.5.5") provider.run_action(:install) diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb index f60bcd1405..98fe9551a6 100644 --- a/spec/unit/provider/package/yum_spec.rb +++ b/spec/unit/provider/package/yum_spec.rb @@ -258,10 +258,10 @@ describe Chef::Provider::Package::Yum do @yum_cache = double( "Chef::Provider::Yum::YumCache" ) - allow(@yum_cache).to receive(:installed_version) do |package_name, arch| - # nothing installed for package_name/new_package_name - nil - end + allow(@yum_cache).to receive(:installed_version) do |package_name, arch| + # nothing installed for package_name/new_package_name + nil + end allow(@yum_cache).to receive(:candidate_version) do |package_name, arch| if package_name == "testing.noarch" nil @@ -282,13 +282,13 @@ describe Chef::Provider::Package::Yum do end it "should flush the cache if :before is true" do - allow(@new_resource).to receive(:flush_cache).and_return({:after => false, :before => true}) + allow(@new_resource).to receive(:flush_cache).and_return({ :after => false, :before => true }) expect(@yum_cache).to receive(:reload).once @provider.load_current_resource end it "should flush the cache if :before is false" do - allow(@new_resource).to receive(:flush_cache).and_return({:after => false, :before => false}) + allow(@new_resource).to receive(:flush_cache).and_return({ :after => false, :before => false }) expect(@yum_cache).not_to receive(:reload) @provider.load_current_resource end @@ -346,7 +346,6 @@ describe Chef::Provider::Package::Yum do expect(@new_resource.version).to eq("2.0.1.el5") end - it "should search provides then set version to match if a requirement was passed in the version" do @new_resource = Chef::Resource::YumPackage.new("test-package") @new_resource.version("= 2.0.1.el5") @@ -356,7 +355,6 @@ describe Chef::Provider::Package::Yum do expect(@new_resource.version).to eq("2.0.1.el5") end - it "should search provides and not set the version to match if a specific version was requested" do @new_resource = Chef::Resource::YumPackage.new("test-package") @new_resource.version("3.0.1.el5") @@ -398,7 +396,7 @@ describe Chef::Provider::Package::Yum do :disable_extra_repo_control => true, ) allow(Chef::Provider::Package::Yum::YumCache).to receive(:instance).and_return(@yum_cache) - allow(@yum_cache).to receive(:yum_binary=).with("yum") + allow(@yum_cache).to receive(:yum_binary=).with("yum") pkg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "2.0.1.el5", "x86_64", []) expect(@yum_cache).to receive(:packages_from_require).and_return([pkg]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @@ -420,7 +418,7 @@ describe Chef::Provider::Package::Yum do :disable_extra_repo_control => true, ) allow(Chef::Provider::Package::Yum::YumCache).to receive(:instance).and_return(@yum_cache) - allow(@yum_cache).to receive(:yum_binary=).with("yum") + allow(@yum_cache).to receive(:yum_binary=).with("yum") pkg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "2.0.1.el5", "x86_64", []) expect(@yum_cache).to receive(:packages_from_require).and_return([pkg]) @new_resource = Chef::Resource::YumPackage.new("test-package = 2.0.1.el5") @@ -448,12 +446,12 @@ describe Chef::Provider::Package::Yum do expect(@yum_cache).to receive(:packages_from_require).exactly(4).times.and_return([]) expect(@yum_cache).to receive(:reload_provides).twice - @new_resource = Chef::Resource::YumPackage.new(["test-package","test-package2"]) - @new_resource.version(["2.0.1.el5","3.0.1.el5"]) + @new_resource = Chef::Resource::YumPackage.new(["test-package", "test-package2"]) + @new_resource.version(["2.0.1.el5", "3.0.1.el5"]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq(["test-package","test-package2"]) - expect(@new_resource.version).to eq(["2.0.1.el5","3.0.1.el5"]) + expect(@new_resource.package_name).to eq(["test-package", "test-package2"]) + expect(@new_resource.version).to eq(["2.0.1.el5", "3.0.1.el5"]) end it "should search provides if no package is available - if no match in installed provides then load the complete set" do @@ -656,7 +654,7 @@ describe Chef::Provider::Package::Yum do end it "should run yum install then flush the cache if :after is true" do - allow(@new_resource).to receive(:flush_cache).and_return({:after => true, :before => false}) + allow(@new_resource).to receive(:flush_cache).and_return({ :after => true, :before => false }) @provider.load_current_resource allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( @@ -667,7 +665,7 @@ describe Chef::Provider::Package::Yum do end it "should run yum install then not flush the cache if :after is false" do - allow(@new_resource).to receive(:flush_cache).and_return({:after => false, :before => false}) + allow(@new_resource).to receive(:flush_cache).and_return({ :after => false, :before => false }) @provider.load_current_resource allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( @@ -792,7 +790,7 @@ describe Chef::Provider::Package::Yum do allow(@provider).to receive(:shell_out).and_return(@status) expect(@provider).to receive(:shell_out).once.with( "yum -d0 -e0 -y install emacs-1.0", - {:timeout => Chef::Config[:yum_timeout]}, + { :timeout => Chef::Config[:yum_timeout] }, ) @provider.yum_command("-d0 -e0 -y install emacs-1.0") end @@ -802,18 +800,18 @@ describe Chef::Provider::Package::Yum do allow(@provider).to receive(:shell_out).and_return(@status) expect(@provider).to receive(:shell_out).once.with( "yum -d0 -e0 -y install emacs-1.0", - {:timeout => Chef::Config[:yum_timeout]}, + { :timeout => Chef::Config[:yum_timeout] }, ) expect { @provider.yum_command("-d0 -e0 -y install emacs-1.0") }.to raise_error(Chef::Exceptions::Exec) end it "should run yum once if it exits with a return code of 1 and %pre scriptlet failures" do @status = double("Status", :exitstatus => 1, :stdout => "error: %pre(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", - :stderr => "") + :stderr => "") allow(@provider).to receive(:shell_out).and_return(@status) expect(@provider).to receive(:shell_out).once.with( "yum -d0 -e0 -y install emacs-1.0", - {:timeout => Chef::Config[:yum_timeout]}, + { :timeout => Chef::Config[:yum_timeout] }, ) # will still raise an exception, can't stub out the subsequent call expect { @provider.yum_command("-d0 -e0 -y install emacs-1.0") }.to raise_error(Chef::Exceptions::Exec) @@ -821,11 +819,11 @@ describe Chef::Provider::Package::Yum do it "should run yum twice if it exits with a return code of 1 and %post scriptlet failures" do @status = double("Status", :exitstatus => 1, :stdout => "error: %post(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", - :stderr => "") + :stderr => "") allow(@provider).to receive(:shell_out).and_return(@status) expect(@provider).to receive(:shell_out).twice.with( "yum -d0 -e0 -y install emacs-1.0", - {:timeout => Chef::Config[:yum_timeout]}, + { :timeout => Chef::Config[:yum_timeout] }, ) # will still raise an exception, can't stub out the subsequent call expect { @provider.yum_command("-d0 -e0 -y install emacs-1.0") }.to raise_error(Chef::Exceptions::Exec) @@ -839,7 +837,7 @@ describe Chef::Provider::Package::Yum do allow(@provider).to receive(:shell_out).and_return(@status) expect(@provider).to receive(:shell_out).once.with( "yum-deprecated -d0 -e0 -y install emacs-1.0", - {:timeout => Chef::Config[:yum_timeout]}, + { :timeout => Chef::Config[:yum_timeout] }, ) @provider.yum_command("-d0 -e0 -y install emacs-1.0") end @@ -965,7 +963,7 @@ describe Chef::Provider::Package::Yum::RPMUtils do [ "0.0.1aa", "0.0.1aa", 0 ], [ "0.0.1a", "0.0.1aa", -1 ], ].each do |x, y, result| - expect(@rpmutils.rpmvercmp(x,y)).to eq(result) + expect(@rpmutils.rpmvercmp(x, y)).to eq(result) end end @@ -984,7 +982,7 @@ describe Chef::Provider::Package::Yum::RPMUtils do [ "", "", 0 ], [ "", "1.0.1", -1 ], ].each do |x, y, result| - expect(@rpmutils.rpmvercmp(x,y)).to eq(result) + expect(@rpmutils.rpmvercmp(x, y)).to eq(result) end end @@ -1840,19 +1838,19 @@ EOF end it "should return the default python if the yum-executable doesn't start with #!" do - allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(bin_exe); bin_exe.rewind; r} + allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(bin_exe); bin_exe.rewind; r } expect(@yc.python_bin).to eq("/usr/bin/python") end it "should return /usr/bin/python if the interpreter is /bin/bash" do other = StringIO.new("#!/bin/bash\n# The yum executable redirecting to dnf from dnf-yum compatible package.") - allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r} + allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r } expect(@yc.python_bin).to eq("/usr/bin/python") end it "should return the interpreter for yum" do other = StringIO.new("#!/usr/bin/super_python\n\nlasjdfdsaljf\nlasdjfs") - allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r} + allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r } expect(@yc.python_bin).to eq("/usr/bin/super_python") end end @@ -1867,32 +1865,32 @@ EOF it "should run yum-dump.py using the system python when next_refresh is for :all" do @yc.reload - expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout]) + expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --yum-lock-timeout 30$}, :timeout => Chef::Config[:yum_timeout]) @yc.refresh end it "should run yum-dump.py with the installed flag when next_refresh is for :installed" do @yc.reload_installed - expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --installed --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout]) + expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --installed --yum-lock-timeout 30$}, :timeout => Chef::Config[:yum_timeout]) @yc.refresh end it "should run yum-dump.py with the all-provides flag when next_refresh is for :provides" do @yc.reload_provides - expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --all-provides --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout]) + expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --all-provides --yum-lock-timeout 30$}, :timeout => Chef::Config[:yum_timeout]) @yc.refresh end it "should pass extra_repo_control args to yum-dump.py" do @yc.enable_extra_repo_control("--enablerepo=foo --disablerepo=bar") - expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout]) + expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar --yum-lock-timeout 30$}, :timeout => Chef::Config[:yum_timeout]) @yc.refresh end it "should pass extra_repo_control args and configured yum lock timeout to yum-dump.py" do Chef::Config[:yum_lock_timeout] = 999 @yc.enable_extra_repo_control("--enablerepo=foo --disablerepo=bar") - expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar --yum-lock-timeout 999$}, :timeout=>Chef::Config[:yum_timeout]) + expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar --yum-lock-timeout 999$}, :timeout => Chef::Config[:yum_timeout]) @yc.refresh end @@ -1920,7 +1918,7 @@ EOF it "should raise exception yum-dump.py exits with a non zero status" do @status = double("Status", :exitstatus => 1, :stdin => @stdin, :stdout => @stdout_no_output, :stderr => @stderr) allow(@yc).to receive(:shell_out!).and_return(@status) - expect { @yc.refresh}.to raise_error(Chef::Exceptions::Package, %r{CentOS-Base.repo, line: 12}) + expect { @yc.refresh }.to raise_error(Chef::Exceptions::Package, %r{CentOS-Base.repo, line: 12}) end it "should parse type 'i' into an installed state for a package" do diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index f5e2c5e8a5..c998c93d6e 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -38,12 +38,12 @@ describe Chef::Provider::Package::Zypper do allow(provider).to receive(:`).and_return("2.0") end - def shell_out_expectation(command, options=nil) + def shell_out_expectation(command, options = nil) options ||= { timeout: 900 } expect(provider).to receive(:shell_out).with(command, options) end - def shell_out_expectation!(command, options=nil) + def shell_out_expectation!(command, options = nil) options ||= { timeout: 900 } expect(provider).to receive(:shell_out!).with(command, options) end @@ -104,8 +104,7 @@ describe Chef::Provider::Package::Zypper do it "should run zypper install without gpg checks" do allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false) shell_out_expectation!( - "zypper --non-interactive --no-gpg-checks install "+ - "--auto-agree-with-licenses emacs=1.0" + "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0" ) provider.install_package(["emacs"], ["1.0"]) end @@ -114,8 +113,7 @@ describe Chef::Provider::Package::Zypper do /All packages will be installed without gpg signature checks/ ) shell_out_expectation!( - "zypper --non-interactive --no-gpg-checks install "+ - "--auto-agree-with-licenses emacs=1.0" + "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0" ) provider.install_package(["emacs"], ["1.0"]) end @@ -132,8 +130,7 @@ describe Chef::Provider::Package::Zypper do it "should run zypper update without gpg checks" do allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false) shell_out_expectation!( - "zypper --non-interactive --no-gpg-checks install "+ - "--auto-agree-with-licenses emacs=1.0" + "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0" ) provider.upgrade_package(["emacs"], ["1.0"]) end @@ -142,15 +139,13 @@ describe Chef::Provider::Package::Zypper do /All packages will be installed without gpg signature checks/ ) shell_out_expectation!( - "zypper --non-interactive --no-gpg-checks install "+ - "--auto-agree-with-licenses emacs=1.0" + "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0" ) provider.upgrade_package(["emacs"], ["1.0"]) end it "should run zypper upgrade without gpg checks" do shell_out_expectation!( - "zypper --non-interactive --no-gpg-checks install "+ - "--auto-agree-with-licenses emacs=1.0" + "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0" ) provider.upgrade_package(["emacs"], ["1.0"]) end @@ -257,8 +252,7 @@ describe Chef::Provider::Package::Zypper do it "should install an array of package names and versions" do allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false) shell_out_expectation!( - "zypper --non-interactive --no-gpg-checks install "+ - "--auto-agree-with-licenses emacs=1.0 vim=2.0" + "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0 vim=2.0" ) provider.install_package(["emacs", "vim"], ["1.0", "2.0"]) end diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb index c0361eaea1..c44c445fd8 100644 --- a/spec/unit/provider/powershell_script_spec.rb +++ b/spec/unit/provider/powershell_script_spec.rb @@ -72,7 +72,7 @@ describe Chef::Provider::PowershellScript, "action_run" do provider_flags = provider.flags.split(" ") execution_policy_specified = false - provider_flags.find do | value | + provider_flags.find do |value| execution_policy_index += 1 execution_policy_specified = value.downcase == "-ExecutionPolicy".downcase end @@ -92,7 +92,7 @@ describe Chef::Provider::PowershellScript, "action_run" do "3.0" => "Bypass", "3.6" => "Bypass", "4.0" => "Bypass", - "5.0" => "Bypass" }.each do | version_policy | + "5.0" => "Bypass" }.each do |version_policy| let(:powershell_version) { version_policy[0].to_f } context "when running PowerShell version #{version_policy[0]}" do let(:powershell_version) { version_policy[0].to_f } diff --git a/spec/unit/provider/remote_directory_spec.rb b/spec/unit/provider/remote_directory_spec.rb index e91bd22739..710d6613fc 100644 --- a/spec/unit/provider/remote_directory_spec.rb +++ b/spec/unit/provider/remote_directory_spec.rb @@ -110,7 +110,7 @@ describe Chef::Provider::RemoteDirectory do @resource.path(@destination_dir) end - after {FileUtils.rm_rf(@destination_dir)} + after { FileUtils.rm_rf(@destination_dir) } # CHEF-3552 it "creates the toplevel directory without error " do @@ -134,8 +134,8 @@ describe Chef::Provider::RemoteDirectory do @resource.overwrite(true) @provider.run_action(:create) - File.open(@destination_dir + "/remote_dir_file1.txt", "a") {|f| f.puts "blah blah blah" } - File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") {|f| f.puts "blah blah blah" } + File.open(@destination_dir + "/remote_dir_file1.txt", "a") { |f| f.puts "blah blah blah" } + File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") { |f| f.puts "blah blah blah" } file1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + "/remote_dir_file1.txt")) subdirfile1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")) @@ -147,7 +147,7 @@ describe Chef::Provider::RemoteDirectory do end describe "with purging enabled" do - before {@resource.purge(true)} + before { @resource.purge(true) } it "removes existing files if purge is true" do @provider.run_action(:create) @@ -202,13 +202,13 @@ describe Chef::Provider::RemoteDirectory do end describe "with overwrite disabled" do - before {@resource.purge(false)} - before {@resource.overwrite(false)} + before { @resource.purge(false) } + before { @resource.overwrite(false) } it "leaves modifications alone" do @provider.run_action(:create) - ::File.open(@destination_dir + "/remote_dir_file1.txt", "a") {|f| f.puts "blah blah blah" } - ::File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") {|f| f.puts "blah blah blah" } + ::File.open(@destination_dir + "/remote_dir_file1.txt", "a") { |f| f.puts "blah blah blah" } + ::File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") { |f| f.puts "blah blah blah" } file1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + "/remote_dir_file1.txt")) subdirfile1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")) @provider.run_action(:create) diff --git a/spec/unit/provider/remote_file/cache_control_data_spec.rb b/spec/unit/provider/remote_file/cache_control_data_spec.rb index 5d31863274..a80aa38e77 100644 --- a/spec/unit/provider/remote_file/cache_control_data_spec.rb +++ b/spec/unit/provider/remote_file/cache_control_data_spec.rb @@ -214,7 +214,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do # local file system path limits resulting in exceptions from # file system API's on both Windows and Unix systems. context "and the URI results in a file cache path that exceeds #{CACHE_FILE_PATH_LIMIT} characters in length" do - let(:long_remote_path) { "http://www.bing.com/" + ("0" * (CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH * 2 )) } + let(:long_remote_path) { "http://www.bing.com/" + ("0" * (CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH * 2 )) } let(:uri) { URI.parse(long_remote_path) } let(:truncated_remote_uri) { URI.parse(long_remote_path[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]) } let(:truncated_file_cache_path) do @@ -243,4 +243,3 @@ describe Chef::Provider::RemoteFile::CacheControlData do end end - diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb index a562c1c742..c6a560b123 100644 --- a/spec/unit/provider/remote_file/content_spec.rb +++ b/spec/unit/provider/remote_file/content_spec.rb @@ -141,7 +141,6 @@ describe Chef::Provider::RemoteFile::Content do it_behaves_like "the resource needs fetching" end - describe "when the fetcher throws an exception" do before do allow(new_resource).to receive(:checksum).and_return(nil) @@ -163,7 +162,7 @@ describe Chef::Provider::RemoteFile::Content do # https://github.com/opscode/chef/pull/1358#issuecomment-40853299 def create_exception(exception_class) if [ Net::HTTPServerException, Net::HTTPFatalError ].include? exception_class - exception_class.new("message", {"something" => 1}) + exception_class.new("message", { "something" => 1 }) else exception_class.new end diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb index a8d65b0156..c044621ed4 100644 --- a/spec/unit/provider/remote_file/ftp_spec.rb +++ b/spec/unit/provider/remote_file/ftp_spec.rb @@ -38,7 +38,7 @@ describe Chef::Provider::RemoteFile::FTP do end let(:ftp) do - ftp = double(Net::FTP, { }) + ftp = double(Net::FTP, {}) allow(ftp).to receive(:connect) allow(ftp).to receive(:login) allow(ftp).to receive(:voidcmd) diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb index 89f2964076..60ecd45dbb 100644 --- a/spec/unit/provider/remote_file/http_spec.rb +++ b/spec/unit/provider/remote_file/http_spec.rb @@ -61,7 +61,7 @@ describe Chef::Provider::RemoteFile::HTTP do end it "has the user-specified custom headers" do - expect(fetcher.headers).to eq({"x-myapp-header" => "custom-header-value"}) + expect(fetcher.headers).to eq({ "x-myapp-header" => "custom-header-value" }) end end @@ -178,7 +178,6 @@ describe Chef::Provider::RemoteFile::HTTP do expect(Chef::HTTP::Simple).to receive(:new).with(*expected_http_args).and_return(rest) end - describe "and the request does not return new content" do it "should return a nil tempfile for a 304 HTTPNotModifed" do @@ -207,7 +206,7 @@ describe Chef::Provider::RemoteFile::HTTP do end context "and the response does not contain an etag" do - let(:last_response) { {"etag" => nil} } + let(:last_response) { { "etag" => nil } } it "does not include an etag in the result" do fetcher.fetch expect(cache_control_data.etag).to be_nil @@ -217,7 +216,7 @@ describe Chef::Provider::RemoteFile::HTTP do end context "and the response has an etag header" do - let(:last_response) { {"etag" => "abc123"} } + let(:last_response) { { "etag" => "abc123" } } it "includes the etag value in the response" do fetcher.fetch @@ -229,7 +228,7 @@ describe Chef::Provider::RemoteFile::HTTP do end context "and the response has no Date or Last-Modified header" do - let(:last_response) { {"date" => nil, "last_modified" => nil} } + let(:last_response) { { "date" => nil, "last_modified" => nil } } it "does not set an mtime in the result" do # RFC 2616 suggests that servers that do not set a Date header do not # have a reliable clock, so no use in making them deal with dates. @@ -243,7 +242,7 @@ describe Chef::Provider::RemoteFile::HTTP do context "and the response has a Last-Modified header" do let(:last_response) do # Last-Modified should be preferred to Date if both are set - {"date" => "Fri, 17 May 2013 23:23:23 GMT", "last_modified" => "Fri, 17 May 2013 11:11:11 GMT"} + { "date" => "Fri, 17 May 2013 23:23:23 GMT", "last_modified" => "Fri, 17 May 2013 11:11:11 GMT" } end it "sets the mtime to the Last-Modified time in the response" do @@ -255,7 +254,7 @@ describe Chef::Provider::RemoteFile::HTTP do context "and the response has a Date header but no Last-Modified header" do let(:last_response) do - {"date" => "Fri, 17 May 2013 23:23:23 GMT", "last_modified" => nil} + { "date" => "Fri, 17 May 2013 23:23:23 GMT", "last_modified" => nil } end it "sets the mtime to the Date in the response" do @@ -270,7 +269,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 @@ -300,4 +299,3 @@ describe Chef::Provider::RemoteFile::HTTP do end end - diff --git a/spec/unit/provider/remote_file_spec.rb b/spec/unit/provider/remote_file_spec.rb index de5036eb41..6107f93c41 100644 --- a/spec/unit/provider/remote_file_spec.rb +++ b/spec/unit/provider/remote_file_spec.rb @@ -21,7 +21,6 @@ require "spec_helper" require "support/shared/unit/provider/file" - describe Chef::Provider::RemoteFile do let(:resource) do resource = Chef::Resource::RemoteFile.new("seattle", @run_context) @@ -36,7 +35,7 @@ describe Chef::Provider::RemoteFile do end let(:node) { double("Chef::Node") } - let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:enclosing_directory) { canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) @@ -60,4 +59,3 @@ describe Chef::Provider::RemoteFile do it_behaves_like "a file provider with source field" end - diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb index 3ef3affde2..bd1e637570 100644 --- a/spec/unit/provider/route_spec.rb +++ b/spec/unit/provider/route_spec.rb @@ -47,7 +47,6 @@ describe Chef::Provider::Route do end end - describe Chef::Provider::Route, "load_current_resource" do context "on linux" do before do @@ -188,15 +187,15 @@ describe Chef::Provider::Route do describe Chef::Provider::Route, "config_file_contents for action_add" do it "should include a netmask when a one is specified" do allow(@new_resource).to receive(:netmask).and_return("255.255.0.0") - expect(@provider.config_file_contents(:add, { :target => @new_resource.target, :netmask => @new_resource.netmask})).to match(/\/\d{1,2}.*\n$/) + expect(@provider.config_file_contents(:add, { :target => @new_resource.target, :netmask => @new_resource.netmask })).to match(/\/\d{1,2}.*\n$/) end it "should not include a netmask when a one is specified" do - expect(@provider.config_file_contents(:add, { :target => @new_resource.target})).not_to match(/\/\d{1,2}.*\n$/) + expect(@provider.config_file_contents(:add, { :target => @new_resource.target })).not_to match(/\/\d{1,2}.*\n$/) end it "should include ' via $gateway ' when a gateway is specified" do - expect(@provider.config_file_contents(:add, { :target => @new_resource.target, :gateway => @new_resource.gateway})).to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}\n/) + expect(@provider.config_file_contents(:add, { :target => @new_resource.target, :gateway => @new_resource.gateway })).to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}\n/) end it "should not include ' via $gateway ' when a gateway is not specified" do diff --git a/spec/unit/provider/ruby_block_spec.rb b/spec/unit/provider/ruby_block_spec.rb index d9fd3e2548..b49aef9243 100644 --- a/spec/unit/provider/ruby_block_spec.rb +++ b/spec/unit/provider/ruby_block_spec.rb @@ -25,7 +25,7 @@ describe Chef::Provider::RubyBlock, "initialize" do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::RubyBlock.new("bloc party") - @new_resource.block { $evil_global_evil_laugh = :mwahahaha} + @new_resource.block { $evil_global_evil_laugh = :mwahahaha } @provider = Chef::Provider::RubyBlock.new(@new_resource, @run_context) end @@ -43,4 +43,3 @@ describe Chef::Provider::RubyBlock, "initialize" do expect(@new_resource).to be_updated end end - diff --git a/spec/unit/provider/script_spec.rb b/spec/unit/provider/script_spec.rb index ef1ccf4ea5..4e8d8bdf59 100644 --- a/spec/unit/provider/script_spec.rb +++ b/spec/unit/provider/script_spec.rb @@ -72,7 +72,7 @@ describe Chef::Provider::Script, "action_run" do describe "when writing the script to the file" do it "should put the contents of the script in the temp file" do - allow(provider).to receive(:unlink_script_file) # stub to avoid remove + allow(provider).to receive(:unlink_script_file) # stub to avoid remove provider.action_run expect(IO.read(tempfile.path)).to eq("$| = 1; print 'i like beans'\n") provider.unlink_script_file diff --git a/spec/unit/provider/service/aix_service_spec.rb b/spec/unit/provider/service/aix_service_spec.rb index 78c0ed3bb3..802ccee2c7 100644 --- a/spec/unit/provider/service/aix_service_spec.rb +++ b/spec/unit/provider/service/aix_service_spec.rb @@ -193,4 +193,3 @@ describe Chef::Provider::Service::Aix do end end end - diff --git a/spec/unit/provider/service/aixinit_service_spec.rb b/spec/unit/provider/service/aixinit_service_spec.rb index 085652a6a4..09c177903b 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) @@ -102,7 +102,7 @@ describe Chef::Provider::Service::AixInit do context "when the service doesn't set a priority" do it "creates symlink with status S" do - expect(@provider).to receive(:create_symlink).with(2,"S","") + expect(@provider).to receive(:create_symlink).with(2, "S", "") @provider.enable_service end @@ -114,7 +114,7 @@ describe Chef::Provider::Service::AixInit do end it "creates a symlink with status S and a priority" do - expect(@provider).to receive(:create_symlink).with(2,"S",75) + expect(@provider).to receive(:create_symlink).with(2, "S", 75) @provider.enable_service end @@ -122,13 +122,13 @@ describe Chef::Provider::Service::AixInit do context "when the service sets complex priorities (hash)" do before do - priority = {2 => [:start, 20], 3 => [:stop, 10]} + priority = { 2 => [:start, 20], 3 => [:stop, 10] } @new_resource.priority(priority) end it "create symlink with status start (S) or stop (K) and a priority " do - expect(@provider).to receive(:create_symlink).with(2,"S",20) - expect(@provider).to receive(:create_symlink).with(3,"K",10) + expect(@provider).to receive(:create_symlink).with(2, "S", 20) + expect(@provider).to receive(:create_symlink).with(3, "K", 10) @provider.enable_service end @@ -142,7 +142,7 @@ describe Chef::Provider::Service::AixInit do context "when the service doesn't set a priority" do it "creates symlinks with status stop (K)" do - expect(@provider).to receive(:create_symlink).with(2,"K","") + expect(@provider).to receive(:create_symlink).with(2, "K", "") @provider.disable_service end @@ -154,7 +154,7 @@ describe Chef::Provider::Service::AixInit do end it "create symlink with status stop (k) and a priority " do - expect(@provider).to receive(:create_symlink).with(2,"K",25) + expect(@provider).to receive(:create_symlink).with(2, "K", 25) @provider.disable_service end @@ -162,12 +162,12 @@ describe Chef::Provider::Service::AixInit do context "when the service sets complex priorities (hash)" do before do - @priority = {2 => [:start, 20], 3 => [:stop, 10]} + @priority = { 2 => [:start, 20], 3 => [:stop, 10] } @new_resource.priority(@priority) end it "create symlink with status stop (k) and a priority " do - expect(@provider).to receive(:create_symlink).with(3,"K",90) + expect(@provider).to receive(:create_symlink).with(3, "K", 90) @provider.disable_service end @@ -183,17 +183,17 @@ describe Chef::Provider::Service::AixInit do end it "the service is enabled" do - expect(@provider.current_resource).to receive(:enabled).with(true) - expect(@provider.current_resource).to receive(:priority).with(20) + expect(@provider.current_resource).to receive(:enabled).with(true) + expect(@provider.current_resource).to receive(:priority).with(20) - @provider.set_current_resource_attributes + @provider.set_current_resource_attributes end end context "when rc2.d contains only stop script" do before do files = ["/etc/rc.d/rc2.d/K20apache"] - @priority = {2 => [:stop, 20]} + @priority = { 2 => [:stop, 20] } allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]chef"]).and_return(files) end @@ -210,7 +210,7 @@ describe Chef::Provider::Service::AixInit do @files = ["/etc/rc.d/rc2.d/S20apache", "/etc/rc.d/rc2.d/K80apache"] # FIXME: this is clearly buggy the duplicated keys do not work #@priority = {2 => [:start, 20], 2 => [:stop, 80]} - @priority = {2 => [:stop, 80]} + @priority = { 2 => [:stop, 80] } allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]chef"]).and_return(@files) end @@ -230,17 +230,17 @@ describe Chef::Provider::Service::AixInit do end it "the service is enabled" do - expect(@provider.current_resource).to receive(:enabled).with(true) - expect(@provider.current_resource).to receive(:priority).with("") + expect(@provider.current_resource).to receive(:enabled).with(true) + expect(@provider.current_resource).to receive(:priority).with("") - @provider.set_current_resource_attributes + @provider.set_current_resource_attributes end end context "when rc2.d contains only stop script (without priority)" do before do files = ["/etc/rc.d/rc2.d/Kapache"] - @priority = {2 => [:stop, ""]} + @priority = { 2 => [:stop, ""] } allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).and_return(files) end @@ -257,7 +257,7 @@ describe Chef::Provider::Service::AixInit do files = ["/etc/rc.d/rc2.d/Sapache", "/etc/rc.d/rc2.d/Kapache"] # FIXME: this is clearly buggy the duplicated keys do not work #@priority = {2 => [:start, ''], 2 => [:stop, '']} - @priority = {2 => [:stop, ""]} + @priority = { 2 => [:stop, ""] } allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).and_return(files) end diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb index 9272a8bd96..47f874cc0e 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) @@ -51,7 +51,7 @@ 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 @@ -92,14 +92,14 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do 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) @@ -125,7 +125,7 @@ DEFAULT_PS @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 - allow(@new_resource).to receive(:supports).and_return({:restart => true}) + allow(@new_resource).to receive(:supports).and_return({ :restart => true }) expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} restart") @provider.restart_service() end @@ -309,7 +309,7 @@ RUNNING_PS # end it "should call 'reload' on the service if it supports it" do - allow(@new_resource).to receive(:supports).and_return({:reload => true}) + allow(@new_resource).to receive(:supports).and_return({ :reload => true }) expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} reload") @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 2400676b84..2192671370 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) @@ -114,7 +114,7 @@ describe Chef::Provider::Service::Debian do end end - {"Debian/Lenny and older" => { + { "Debian/Lenny and older" => { "linked" => { "stdout" => <<-STDOUT, Removing any system startup links for /etc/init.d/chef ... @@ -128,13 +128,13 @@ describe Chef::Provider::Service::Debian do STDOUT "stderr" => "", "priorities" => { - "0"=>[:stop, "20"], - "1"=>[:stop, "20"], - "2"=>[:start, "20"], - "3"=>[:start, "20"], - "4"=>[:start, "20"], - "5"=>[:start, "20"], - "6"=>[:stop, "20"], + "0" => [:stop, "20"], + "1" => [:stop, "20"], + "2" => [:start, "20"], + "3" => [:start, "20"], + "4" => [:start, "20"], + "5" => [:start, "20"], + "6" => [:stop, "20"], }, }, "not linked" => { @@ -156,13 +156,13 @@ insserv: remove service /etc/init.d/../rc0.d/K20chef-client insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop STDERR "priorities" => { - "0"=>[:stop, "20"], - "1"=>[:stop, "20"], - "2"=>[:start, "20"], - "3"=>[:start, "20"], - "4"=>[:start, "20"], - "5"=>[:start, "20"], - "6"=>[:stop, "20"], + "0" => [:stop, "20"], + "1" => [:stop, "20"], + "2" => [:start, "20"], + "3" => [:start, "20"], + "4" => [:start, "20"], + "5" => [:start, "20"], + "6" => [:stop, "20"], }, }, "not linked" => { @@ -181,10 +181,10 @@ insserv: remove service /etc/init.d/../rcS.d/S13rpcbind insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop STDERR "priorities" => { - "0"=>[:stop, "06"], - "1"=>[:stop, "06"], - "6"=>[:stop, "06"], - "S"=>[:start, "13"], + "0" => [:stop, "06"], + "1" => [:stop, "06"], + "6" => [:stop, "06"], + "S" => [:start, "13"], }, }, "not linked" => { @@ -276,7 +276,7 @@ insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop context "when the service is enabled" do before do @current_resource.enabled(true) - @current_resource.priority(80) + @current_resource.priority(80) end context "and the service sets no priority" do diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb index 9729c1ddbc..e64aa517e2 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 @@ -46,7 +46,7 @@ describe Chef::Provider::Service::Freebsd do let(:provider) do events = Chef::EventDispatch::Dispatcher.new run_context = Chef::RunContext.new(node, {}, events) - provider = Chef::Provider::Service::Freebsd.new(new_resource,run_context) + provider = Chef::Provider::Service::Freebsd.new(new_resource, run_context) provider.action = :start provider end @@ -115,7 +115,7 @@ describe Chef::Provider::Service::Freebsd do 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 @@ -147,7 +147,7 @@ PS_SAMPLE 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 @@ -465,7 +465,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_systems_locale!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart") provider.restart_service() end diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb index 47c1aa7215..4b31e9c399 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) @@ -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_systems_locale!).with("/etc/init.d/#{@new_resource.service_name} restart") @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_systems_locale!).with("/etc/init.d/chef reload") @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 de0c546ff1..3b2b19c432 100644 --- a/spec/unit/provider/service/insserv_service_spec.rb +++ b/spec/unit/provider/service/insserv_service_spec.rb @@ -23,7 +23,7 @@ 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") diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb index 6503e542f9..57b13d0c51 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) @@ -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) @@ -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_systems_locale!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restart") @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_systems_locale!).with("/usr/sbin/invoke-rc.d chef reload") @provider.reload_service() end diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb index fab7a11248..29ebf2da11 100644 --- a/spec/unit/provider/service/macosx_spec.rb +++ b/spec/unit/provider/service/macosx_spec.rb @@ -43,7 +43,7 @@ describe Chef::Provider::Service::Macosx do context "when service name is given as" do let(:node) { Chef::Node.new } - let(:events) {Chef::EventDispatch::Dispatcher.new} + let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } let(:provider) { described_class.new(new_resource, run_context) } let(:launchctl_stdout) { StringIO.new } @@ -61,30 +61,30 @@ XML ["Daemon", "Agent"].each do |service_type| ["redis-server", "io.redis.redis-server"].each do |service_name| ["10.9", "10.10", "10.11"].each do |platform_version| - let(:plist) {"/Library/LaunchDaemons/io.redis.redis-server.plist"} + let(:plist) { "/Library/LaunchDaemons/io.redis.redis-server.plist" } let(:session) { StringIO.new } if service_type == "Agent" - let(:plist) {"/Library/LaunchAgents/io.redis.redis-server.plist"} - let(:session) {"-S Aqua "} - let(:su_cmd) {"su -l igor -c"} + let(:plist) { "/Library/LaunchAgents/io.redis.redis-server.plist" } + let(:session) { "-S Aqua " } + let(:su_cmd) { "su -l igor -c" } if platform_version == "10.9" - let(:su_cmd) {"su igor -c"} + let(:su_cmd) { "su igor -c" } end end - let(:service_label) {"io.redis.redis-server"} + let(:service_label) { "io.redis.redis-server" } before do allow(Dir).to receive(:glob).and_return([plist], []) allow(Etc).to receive(:getlogin).and_return("igor") allow(node).to receive(:[]).with("platform_version").and_return(platform_version) cmd = "launchctl list #{service_label}" allow(provider).to receive(:shell_out_with_systems_locale). - with(/(#{su_cmd} '#{cmd}'|#{cmd})/). - and_return(double("Status", + with(/(#{su_cmd} '#{cmd}'|#{cmd})/). + and_return(double("Status", :stdout => launchctl_stdout, :exitstatus => 0)) allow(File).to receive(:exists?).and_return([true], []) allow(provider).to receive(:shell_out_with_systems_locale!). - with(/plutil -convert xml1 -o/). - and_return(double("Status", :stdout => plutil_stdout)) + with(/plutil -convert xml1 -o/). + and_return(double("Status", :stdout => plutil_stdout)) end context "#{service_name} that is a #{service_type} running Osx #{platform_version}" do @@ -109,8 +109,8 @@ XML allow(Dir).to receive(:glob).and_return([]) allow(File).to receive(:exists?).and_return([true], []) allow(provider).to receive(:shell_out!). - with(/plutil -convert xml1 -o/). - and_raise(Mixlib::ShellOut::ShellCommandFailed) + with(/plutil -convert xml1 -o/). + and_raise(Mixlib::ShellOut::ShellCommandFailed) end it "works for action :nothing" do @@ -166,7 +166,7 @@ SVC_LIST allow(File).to receive(:exists?).and_return([true], []) end it "should throw an exception when reload action is attempted" do - expect {provider.run_action(:reload)}.to raise_error(Chef::Exceptions::UnsupportedAction) + expect { provider.run_action(:reload) }.to raise_error(Chef::Exceptions::UnsupportedAction) end end context "when launchctl returns empty service pid" do @@ -265,8 +265,8 @@ SVC_LIST it "starts service via launchctl if service found" do cmd = "launchctl load -w " + session + plist expect(provider).to receive(:shell_out_with_systems_locale). - with(/(#{su_cmd} .#{cmd}.|#{cmd})/). - and_return(0) + with(/(#{su_cmd} .#{cmd}.|#{cmd})/). + and_return(0) provider.start_service end @@ -295,10 +295,10 @@ SVC_LIST end it "stops the service via launchctl if service found" do - cmd = "launchctl unload -w "+ plist + cmd = "launchctl unload -w " + plist expect(provider).to receive(:shell_out_with_systems_locale). - with(/(#{su_cmd} .#{cmd}.|#{cmd})/). - and_return(0) + with(/(#{su_cmd} .#{cmd}.|#{cmd})/). + and_return(0) provider.stop_service end diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb index 73e0960901..7b64214e65 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") @@ -54,7 +54,7 @@ describe Chef::Provider::Service::Openbsd do run_context = Chef::RunContext.new(node, {}, events) allow(::File).to receive(:read).with("/etc/rc.conf").and_return("") allow(::File).to receive(:read).with("/etc/rc.conf.local").and_return("") - provider = Chef::Provider::Service::Openbsd.new(new_resource,run_context) + provider = Chef::Provider::Service::Openbsd.new(new_resource, run_context) provider.action = :start provider end diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index 110a38d04b..5d03c688fc 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -23,7 +23,7 @@ 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) @@ -33,7 +33,7 @@ shared_examples_for "define_resource_requirements_common" do 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) + 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) @@ -71,7 +71,7 @@ describe "Chef::Provider::Service::Redhat" do 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) + 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 @@ -81,7 +81,7 @@ describe "Chef::Provider::Service::Redhat" 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) + 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 @@ -92,7 +92,7 @@ describe "Chef::Provider::Service::Redhat" do 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) + 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 @@ -100,7 +100,7 @@ describe "Chef::Provider::Service::Redhat" do 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) + 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 @@ -109,7 +109,7 @@ 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) + 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 @@ -119,7 +119,7 @@ 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) + 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 @@ -129,7 +129,7 @@ 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) + 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 @@ -144,8 +144,8 @@ describe "Chef::Provider::Service::Redhat" do before do 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 @@ -182,8 +182,8 @@ describe "Chef::Provider::Service::Redhat" do it "should not raise an error if the service does not exist" do 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 2318bed95a..499e0cc2d3 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) @@ -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 diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb index 94d123ef1a..c6835bed64 100644 --- a/spec/unit/provider/service/solaris_smf_service_spec.rb +++ b/spec/unit/provider/service/solaris_smf_service_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Provider::Service::Solaris do before(:each) do - @node =Chef::Node.new + @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -116,18 +116,18 @@ 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) @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 @@ -162,7 +162,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm enable -s chef" 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).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 @@ -172,7 +172,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!).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).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 @@ -182,7 +182,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!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@maintenance_svc_status) + expect(@provider).to receive(:shell_out!).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) @@ -191,7 +191,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 @@ -204,7 +204,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 @@ -212,7 +212,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.stop_service).to be_truthy @@ -224,7 +224,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 @@ -237,7 +237,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/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index e98284a8fd..fd9ea0573c 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -24,7 +24,7 @@ describe Chef::Provider::Service::Upstart do end before(:each) do - @node =Chef::Node.new + @node = Chef::Node.new @node.name("upstarter") @node.automatic_attrs[:platform] = "ubuntu" @node.automatic_attrs[:platform_version] = "9.10" @@ -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) diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb index cbda70c9bb..f944d8f6c6 100644 --- a/spec/unit/provider/service/windows_spec.rb +++ b/spec/unit/provider/service/windows_spec.rb @@ -369,7 +369,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do end describe Chef::Provider::Service::Windows, "action_configure_startup" do - { :automatic => "auto start", :manual => "demand start", :disabled => "disabled" }.each do |type,win32| + { :automatic => "auto start", :manual => "demand start", :disabled => "disabled" }.each do |type, win32| it "sets the startup type to #{type} if it is something else" do new_resource.startup_type(type) allow(provider).to receive(:current_start_type).and_return("fire") diff --git a/spec/unit/provider/service_spec.rb b/spec/unit/provider/service_spec.rb index 5746bcde89..d775297658 100644 --- a/spec/unit/provider/service_spec.rb +++ b/spec/unit/provider/service_spec.rb @@ -49,7 +49,6 @@ describe Chef::Provider::Service do end end - describe "when disabling the service" do it "should disable the service if enabled and set the resource as updated" do allow(@current_resource).to receive(:enabled).and_return(true) diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb index 1a92c40ab1..372f3499c4 100644 --- a/spec/unit/provider/subversion_spec.rb +++ b/spec/unit/provider/subversion_spec.rb @@ -37,7 +37,7 @@ describe Chef::Provider::Subversion do it "converts resource attributes to options for run_command and popen4" 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 @@ -64,18 +64,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 @@ -119,19 +119,19 @@ 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 => "")) - expect {@provider.revision_int}.to raise_error(RuntimeError, "Could not parse `svn info` data: some random text from an error message\n") + 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 @@ -154,8 +154,7 @@ describe Chef::Provider::Subversion do it "generates a checkout command with arbitrary options" do @resource.svn_arguments "--no-auth-cache" - expect(@provider.checkout_command).to eql("svn checkout --no-auth-cache -q -r12345 "+ - "http://svn.example.org/trunk/ /my/deploy/dir") + expect(@provider.checkout_command).to eql("svn checkout --no-auth-cache -q -r12345 " + "http://svn.example.org/trunk/ /my/deploy/dir") end it "generates a sync command with default options" do @@ -195,14 +194,14 @@ describe Chef::Provider::Subversion do end it "raises an error if the svn checkout command would fail because the enclosing directory doesn't exist" do - expect {@provider.run_action(:sync)}.to raise_error(Chef::Exceptions::MissingParentDirectory) + expect { @provider.run_action(:sync) }.to raise_error(Chef::Exceptions::MissingParentDirectory) end it "should not checkout if the destination exists or is a non empty directory" do allow(::File).to receive(:exist?).with("/my/deploy/dir/.svn").and_return(false) allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".","..","foo","bar"]) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".", "..", "foo", "bar"]) expect(@provider).not_to receive(:checkout_command) @provider.run_action(:checkout) expect(@resource).not_to be_updated @@ -213,7 +212,7 @@ describe Chef::Provider::Subversion do @resource.user "whois" @resource.group "thisis" expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir" - expect(@provider).to receive(:shell_out!).with(expected_cmd, {user: "whois", group: "thisis"}) + expect(@provider).to receive(:shell_out!).with(expected_cmd, { user: "whois", group: "thisis" }) @provider.run_action(:checkout) expect(@resource).to be_updated end diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb index 5d885267c7..4f7b4c256c 100644 --- a/spec/unit/provider/template/content_spec.rb +++ b/spec/unit/provider/template/content_spec.rb @@ -113,7 +113,7 @@ describe Chef::Provider::Template::Content do it "fails when :file_desployment_uses_destdir is set" do Chef::Config[:file_staging_uses_destdir] = true - expect{content.tempfile}.to raise_error(Chef::Exceptions::FileContentStagingError) + expect { content.tempfile }.to raise_error(Chef::Exceptions::FileContentStagingError) end it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb index bf1fcd1cc3..488039ad18 100644 --- a/spec/unit/provider/template_spec.rb +++ b/spec/unit/provider/template_spec.rb @@ -23,10 +23,9 @@ require "etc" require "ostruct" require "support/shared/unit/provider/file" - describe Chef::Provider::Template do let(:node) { double("Chef::Node") } - let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:enclosing_directory) { canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) @@ -60,7 +59,7 @@ describe Chef::Provider::Template do context "when creating the template" do let(:node) { double("Chef::Node") } - let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:enclosing_directory) { canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb index 5465e3b225..712fbfc76c 100644 --- a/spec/unit/provider/user/dscl_spec.rb +++ b/spec/unit/provider/user/dscl_spec.rb @@ -230,7 +230,6 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30" provider.dscl_set_home end - it "raises InvalidHomeDirectory when the resource's home directory doesn't look right" do new_resource.home("epic-fail") expect { provider.dscl_set_home }.to raise_error(Chef::Exceptions::InvalidHomeDirectory) @@ -248,16 +247,16 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30" expect(FileUtils).to receive(:mkdir_p).with("/Users/toor").and_return(true) expect(FileUtils).to receive(:rmdir).with(current_home) - expect(::Dir).to receive(:glob).with("#{CHEF_SPEC_DATA}/old_home_dir/*",::File::FNM_DOTMATCH).and_return(current_home_files) + expect(::Dir).to receive(:glob).with("#{CHEF_SPEC_DATA}/old_home_dir/*", ::File::FNM_DOTMATCH).and_return(current_home_files) expect(FileUtils).to receive(:mv).with(current_home_files, "/Users/toor", :force => true) - expect(FileUtils).to receive(:chown_R).with("toor","23","/Users/toor") + expect(FileUtils).to receive(:chown_R).with("toor", "23", "/Users/toor") expect(provider).to receive(:run_dscl).with("create /Users/toor NFSHomeDirectory '/Users/toor'") provider.dscl_set_home end it "should raise an exception when the systems user template dir (skel) cannot be found" do - allow(::File).to receive(:exists?).and_return(false,false,false) + allow(::File).to receive(:exists?).and_return(false, false, false) expect { provider.dscl_set_home }.to raise_error(Chef::Exceptions::User) end @@ -720,7 +719,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30") end it "should sleep and flush the dscl cache before saving the password" do - expect(provider).to receive(:prepare_password_shadow_info).and_return({ }) + expect(provider).to receive(:prepare_password_shadow_info).and_return({}) mock_shellout = double("Mock::Shellout") allow(mock_shellout).to receive(:run_command) expect(Mixlib::ShellOut).to receive(:new).and_return(mock_shellout) diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb index dd9564ff1a..1e9fda9f7e 100644 --- a/spec/unit/provider/user/pw_spec.rb +++ b/spec/unit/provider/user/pw_spec.rb @@ -67,7 +67,7 @@ describe Chef::Provider::User::Pw do end it "should set the option for #{attribute} if the new resources #{attribute} is not null, without homedir management" do - allow(@new_resource).to receive(:supports).and_return({:manage_home => false}) + allow(@new_resource).to receive(:supports).and_return({ :manage_home => false }) allow(@new_resource).to receive(attribute).and_return("hola") expect(@provider.set_options).to eql(" #{@new_resource.username} #{option} '#{@new_resource.send(attribute)}'") end @@ -75,7 +75,7 @@ describe Chef::Provider::User::Pw do it "should combine all the possible options" do match_string = " adam" - field_list.sort{ |a,b| a[0] <=> b[0] }.each do |attribute, option| + field_list.sort { |a, b| a[0] <=> b[0] }.each do |attribute, option| allow(@new_resource).to receive(attribute).and_return("hola") match_string << " #{option} 'hola'" end @@ -126,7 +126,7 @@ describe Chef::Provider::User::Pw do end it "should run pw userdel with the new resources user name and -r if manage_home is true" do - expect(@provider).to receive(:run_command).with({ :command => "pw userdel #{@new_resource.username} -r"}).and_return(true) + expect(@provider).to receive(:run_command).with({ :command => "pw userdel #{@new_resource.username} -r" }).and_return(true) @provider.remove_user end end @@ -145,14 +145,14 @@ describe Chef::Provider::User::Pw do describe "when locking the user" do it "should run pw lock with the new resources username" do - expect(@provider).to receive(:run_command).with({ :command => "pw lock #{@new_resource.username}"}) + expect(@provider).to receive(:run_command).with({ :command => "pw lock #{@new_resource.username}" }) @provider.lock_user end end describe "when unlocking the user" do it "should run pw unlock with the new resources username" do - expect(@provider).to receive(:run_command).with({ :command => "pw unlock #{@new_resource.username}"}) + expect(@provider).to receive(:run_command).with({ :command => "pw unlock #{@new_resource.username}" }) @provider.unlock_user end end diff --git a/spec/unit/provider/user/windows_spec.rb b/spec/unit/provider/user/windows_spec.rb index 37c8655416..4a62e6ec9d 100644 --- a/spec/unit/provider/user/windows_spec.rb +++ b/spec/unit/provider/user/windows_spec.rb @@ -127,19 +127,19 @@ describe Chef::Provider::User::Windows do describe "when creating the user" do it "should call @net_user.add with the return of set_options" do - allow(@provider).to receive(:set_options).and_return(:name=> "monkey") - expect(@net_user).to receive(:add).with(:name=> "monkey") + allow(@provider).to receive(:set_options).and_return(:name => "monkey") + expect(@net_user).to receive(:add).with(:name => "monkey") @provider.create_user end end describe "manage_user" do before(:each) do - allow(@provider).to receive(:set_options).and_return(:name=> "monkey") + allow(@provider).to receive(:set_options).and_return(:name => "monkey") end it "should call @net_user.update with the return of set_options" do - expect(@net_user).to receive(:update).with(:name=> "monkey") + expect(@net_user).to receive(:update).with(:name => "monkey") @provider.manage_user end end diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb index ce10e8b73d..0794ce0328 100644 --- a/spec/unit/provider/user_spec.rb +++ b/spec/unit/provider/user_spec.rb @@ -183,7 +183,7 @@ describe Chef::Provider::User do expect(@provider).to receive(:require).with("shadow") { raise LoadError } @provider.load_current_resource @provider.define_resource_requirements - expect {@provider.process_resource_requirements}.to raise_error Chef::Exceptions::MissingLibrary + expect { @provider.process_resource_requirements }.to raise_error Chef::Exceptions::MissingLibrary end end @@ -197,8 +197,8 @@ describe Chef::Provider::User do "uid" => [1000, 1001], "gid" => [1000, 1001], "home" => ["/home/adam", "/Users/adam"], - "shell"=> ["/usr/bin/zsh", "/bin/bash"], - "password"=> ["abcd","12345"], + "shell" => ["/usr/bin/zsh", "/bin/bash"], + "password" => ["abcd", "12345"], } } @@ -380,7 +380,6 @@ describe Chef::Provider::User do end end - describe "action_lock" do before(:each) do allow(@provider).to receive(:load_current_resource) diff --git a/spec/unit/provider/whyrun_safe_ruby_block_spec.rb b/spec/unit/provider/whyrun_safe_ruby_block_spec.rb index ccd3358e2a..29d49ff90b 100644 --- a/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +++ b/spec/unit/provider/whyrun_safe_ruby_block_spec.rb @@ -25,7 +25,7 @@ describe Chef::Provider::WhyrunSafeRubyBlock, "initialize" do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::WhyrunSafeRubyBlock.new("bloc party") - @new_resource.block { $evil_global_evil_laugh = :mwahahaha} + @new_resource.block { $evil_global_evil_laugh = :mwahahaha } @provider = Chef::Provider::WhyrunSafeRubyBlock.new(@new_resource, @run_context) end @@ -44,4 +44,3 @@ describe Chef::Provider::WhyrunSafeRubyBlock, "initialize" do end end - |