diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2018-07-02 16:20:22 -0700 |
---|---|---|
committer | Noah Kantrowitz <noah@coderanger.net> | 2018-07-02 16:20:22 -0700 |
commit | 5b2be9fdde75ddaffa3447bc354806b2efb4b095 (patch) | |
tree | a078e952e444ac5d5be69779e5414e99ac66df85 /spec/unit/provider | |
parent | a4b8940d2690eb92d54d7d56a0c638fca6f3808f (diff) | |
parent | f23bc124f577ee628879079754331724593a82a3 (diff) | |
download | chef-5b2be9fdde75ddaffa3447bc354806b2efb4b095.tar.gz |
Merge branch 'master' into yet-more-creds
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Diffstat (limited to 'spec/unit/provider')
86 files changed, 1780 insertions, 1780 deletions
diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb index d881d01124..8ea2b9b823 100644 --- a/spec/unit/provider/apt_repository_spec.rb +++ b/spec/unit/provider/apt_repository_spec.rb @@ -23,25 +23,25 @@ require "spec_helper" # # Output of the command: # => apt-key adv --list-public-keys --with-fingerprint --with-colons -APT_KEY_FINGER = <<-EOF -tru:t:1:1488924856:0:3:1:5 -pub:-:1024:17:40976EAF437D05B5:2004-09-12:::-:Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>::scESC: -fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5: -sub:-:2048:16:251BEFF479164387:2004-09-12::::::e: -pub:-:1024:17:46181433FBB75451:2004-12-30:::-:Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>::scSC: -fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451: -pub:-:4096:1:3B4FE6ACC0B21F32:2012-05-11:::-:Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>::scSC: -fpr:::::::::790BC7277767219C42C86F933B4FE6ACC0B21F32: -pub:-:4096:1:D94AA3F0EFE21092:2012-05-11:::-:Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>::scSC: -fpr:::::::::843938DF228D22F7B3742BC0D94AA3F0EFE21092: +APT_KEY_FINGER = <<~EOF + tru:t:1:1488924856:0:3:1:5 + pub:-:1024:17:40976EAF437D05B5:2004-09-12:::-:Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>::scESC: + fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5: + sub:-:2048:16:251BEFF479164387:2004-09-12::::::e: + pub:-:1024:17:46181433FBB75451:2004-12-30:::-:Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>::scSC: + fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451: + pub:-:4096:1:3B4FE6ACC0B21F32:2012-05-11:::-:Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>::scSC: + fpr:::::::::790BC7277767219C42C86F933B4FE6ACC0B21F32: + pub:-:4096:1:D94AA3F0EFE21092:2012-05-11:::-:Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>::scSC: + fpr:::::::::843938DF228D22F7B3742BC0D94AA3F0EFE21092: EOF # Output of the command: # => gpg --with-fingerprint --with-colons [FILE] -GPG_FINGER = <<-EOF -pub:-:1024:17:327574EE02A818DD:2009-04-22:::-:Cloudera Apt Repository: -fpr:::::::::F36A89E33CC1BD0F71079007327574EE02A818DD: -sub:-:2048:16:84080586D1CA74A1:2009-04-22:::: +GPG_FINGER = <<~EOF + pub:-:1024:17:327574EE02A818DD:2009-04-22:::-:Cloudera Apt Repository: + fpr:::::::::F36A89E33CC1BD0F71079007327574EE02A818DD: + sub:-:2048:16:84080586D1CA74A1:2009-04-22:::: EOF describe Chef::Provider::AptRepository do @@ -67,14 +67,14 @@ describe Chef::Provider::AptRepository do end let(:gpg_shell_out_success) do - double("shell_out", :stdout => "pub 2048R/7BD9BF62 2011-08-19 nginx signing key <signing-key@nginx.com>", - :exitstatus => 0, :error? => false) + double("shell_out", stdout: "pub 2048R/7BD9BF62 2011-08-19 nginx signing key <signing-key@nginx.com>", + exitstatus: 0, error?: false) end let(:gpg_shell_out_failure) do - double("shell_out", :stderr => "gpg: no valid OpenPGP data found.\n + double("shell_out", stderr: "gpg: no valid OpenPGP data found.\n gpg: processing message failed: eof", - :exitstatus => 1, :error? => true) + exitstatus: 1, error?: true) end let(:apt_fingerprints) do diff --git a/spec/unit/provider/cookbook_file/content_spec.rb b/spec/unit/provider/cookbook_file/content_spec.rb index 096ac85b64..4e07915a95 100644 --- a/spec/unit/provider/cookbook_file/content_spec.rb +++ b/spec/unit/provider/cookbook_file/content_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Provider::CookbookFile::Content do - let(:new_resource) { double("Chef::Resource::CookbookFile (new)", :cookbook_name => "apache2", :cookbook => "apache2") } + let(:new_resource) { double("Chef::Resource::CookbookFile (new)", cookbook_name: "apache2", cookbook: "apache2") } let(:content) do @run_context = double("Chef::RunContext") @current_resource = double("Chef::Resource::CookbookFile (current)") diff --git a/spec/unit/provider/cookbook_file_spec.rb b/spec/unit/provider/cookbook_file_spec.rb index f27392de5d..e1ef3c63d8 100644 --- a/spec/unit/provider/cookbook_file_spec.rb +++ b/spec/unit/provider/cookbook_file_spec.rb @@ -26,7 +26,7 @@ describe Chef::Provider::CookbookFile do let(:node) { double("Chef::Node") } let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:logger) { double("Mixlib::Log::Child").as_null_object } - let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) } + let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) } let(:enclosing_directory) do canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) end diff --git a/spec/unit/provider/cron/unix_spec.rb b/spec/unit/provider/cron/unix_spec.rb index 62b941c4aa..c77b0e0528 100644 --- a/spec/unit/provider/cron/unix_spec.rb +++ b/spec/unit/provider/cron/unix_spec.rb @@ -37,9 +37,9 @@ describe Chef::Provider::Cron::Unix do end end - let(:status) { double("Process::Status", :exitstatus => exitstatus) } + let(:status) { double("Process::Status", exitstatus: exitstatus) } let(:exitstatus) { 0 } - let(:shell_out) { double("Mixlib::ShellOut", :status => status, :stdout => stdout, :stderr => stderr) } + let(:shell_out) { double("Mixlib::ShellOut", status: status, stdout: stdout, stderr: stderr) } let(:logger) { double("Mixlib::Log::Child").as_null_object } @@ -53,25 +53,25 @@ describe Chef::Provider::Cron::Unix do describe "read_crontab" do let(:stderr) { "" } let(:stdout) do - String.new(<<-CRONTAB) -0 2 * * * /some/other/command + String.new(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: something else -* 5 * * * /bin/true + # Chef Name: something else + * 5 * * * /bin/true -# Another comment + # Another comment CRONTAB end before do allow(logger).to receive(:trace) allow(shell_out).to receive(:format_for_exception).and_return("formatted command output") - allow(provider).to receive(:shell_out).with("/usr/bin/crontab -l", :user => username).and_return(shell_out) + allow(provider).to receive(:shell_out).with("/usr/bin/crontab -l", user: username).and_return(shell_out) end it "should call crontab -l with the user" do provider.send(:read_crontab) - expect(provider).to have_received(:shell_out).with("/usr/bin/crontab -l", :user => username) + expect(provider).to have_received(:shell_out).with("/usr/bin/crontab -l", user: username) end it "should return the contents of the crontab" do @@ -111,7 +111,7 @@ describe Chef::Provider::Cron::Unix do describe "write_crontab" do let(:stdout) { "" } let(:stderr) { "" } - let(:tempfile) { double("foo", :path => "/tmp/foo", :close => true) } + let(:tempfile) { double("foo", path: "/tmp/foo", close: true) } before do expect(Tempfile).to receive(:new).and_return(tempfile) @@ -119,12 +119,12 @@ describe Chef::Provider::Cron::Unix do expect(tempfile).to receive(:chmod).with(420) expect(tempfile).to receive(:close!) allow(tempfile).to receive(:<<) - allow(provider).to receive(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username).and_return(shell_out) + allow(provider).to receive(:shell_out).with("/usr/bin/crontab #{tempfile.path}", user: username).and_return(shell_out) end it "should call crontab for the user" do provider.send(:write_crontab, "Foo") - expect(provider).to have_received(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username) + expect(provider).to have_received(:shell_out).with("/usr/bin/crontab #{tempfile.path}", user: username) end it "should call crontab with a file containing the crontab" do diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb index 5673ecc317..67d578e2ea 100644 --- a/spec/unit/provider/cron_spec.rb +++ b/spec/unit/provider/cron_spec.rb @@ -42,15 +42,15 @@ describe Chef::Provider::Cron do context "with a matching entry in the user's crontab" do before :each do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -@reboot /bin/true param1 param2 -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + @reboot /bin/true param1 param2 + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB end @@ -67,19 +67,19 @@ CRONTAB end it "should pull env vars out" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command - -# Chef Name: cronhole some stuff -MAILTO=foo@example.com -SHELL=/bin/foosh -PATH=/bin:/foo -HOME=/home/foo -@reboot /bin/true param1 param2 -# Chef Name: something else -2 * 1 * * /bin/false - -# Another comment + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command + + # Chef Name: cronhole some stuff + MAILTO=foo@example.com + SHELL=/bin/foosh + PATH=/bin:/foo + HOME=/home/foo + @reboot /bin/true param1 param2 + # Chef Name: something else + 2 * 1 * * /bin/false + + # Another comment CRONTAB cron = @provider.load_current_resource expect(cron.mailto).to eq("foo@example.com") @@ -91,12 +91,12 @@ CRONTAB end it "should parse and load generic and standard environment variables from cron entry" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -# Chef Name: cronhole some stuff -MAILTO=warn@example.com -TEST=lol -FLAG=1 -@reboot /bin/true + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + # Chef Name: cronhole some stuff + MAILTO=warn@example.com + TEST=lol + FLAG=1 + @reboot /bin/true CRONTAB cron = @provider.load_current_resource @@ -105,13 +105,13 @@ CRONTAB end it "should not break with variables that match the cron resource internals" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -# Chef Name: cronhole some stuff -MINUTE=40 -REBOOT=midnight -TEST=lol -ENVIRONMENT=production -@reboot /bin/true + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + # Chef Name: cronhole some stuff + MINUTE=40 + REBOOT=midnight + TEST=lol + ENVIRONMENT=production + @reboot /bin/true CRONTAB cron = @provider.load_current_resource @@ -137,9 +137,9 @@ CRONTAB end it "should create a crontab with the entry" do - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -# Chef Name: cronhole some stuff -@reboot /bin/true + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + # Chef Name: cronhole some stuff + @reboot /bin/true ENDCRON @provider.run_action(:create) end @@ -168,13 +168,13 @@ CRONTAB context "with no matching entry in the user's crontab" do before :each do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: something else -* 5 * * * /bin/true + # Chef Name: something else + * 5 * * * /bin/true -# Another comment + # Another comment CRONTAB end @@ -190,9 +190,9 @@ CRONTAB end it "should not fail if there's an existing cron with a numerical argument" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -# Chef Name: foo[bar] (baz) -21 */4 * * * some_prog 1234567 + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + # Chef Name: foo[bar] (baz) + 21 */4 * * * some_prog 1234567 CRONTAB expect do @provider.load_current_resource @@ -202,15 +202,15 @@ CRONTAB context "with a matching entry in the user's crontab" do before :each do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -* 5 * 1 * /bin/true param1 param2 -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + * 5 * 1 * /bin/true param1 param2 + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB end @@ -232,19 +232,19 @@ CRONTAB end it "should pull env vars out" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command - -# Chef Name: cronhole some stuff -MAILTO=foo@example.com -SHELL=/bin/foosh -PATH=/bin:/foo -HOME=/home/foo -* 5 * 1 * /bin/true param1 param2 -# Chef Name: something else -2 * 1 * * /bin/false - -# Another comment + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command + + # Chef Name: cronhole some stuff + MAILTO=foo@example.com + SHELL=/bin/foosh + PATH=/bin:/foo + HOME=/home/foo + * 5 * 1 * /bin/true param1 param2 + # Chef Name: something else + 2 * 1 * * /bin/false + + # Another comment CRONTAB cron = @provider.load_current_resource expect(cron.mailto).to eq("foo@example.com") @@ -261,12 +261,12 @@ CRONTAB end it "should parse and load generic and standard environment variables from cron entry" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -# Chef Name: cronhole some stuff -MAILTO=warn@example.com -TEST=lol -FLAG=1 -* 5 * * * /bin/true + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + # Chef Name: cronhole some stuff + MAILTO=warn@example.com + TEST=lol + FLAG=1 + * 5 * * * /bin/true CRONTAB cron = @provider.load_current_resource @@ -275,13 +275,13 @@ CRONTAB end it "should not break with variabels that match the cron resource internals" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -# Chef Name: cronhole some stuff -MINUTE=40 -HOUR=midnight -TEST=lol -ENVIRONMENT=production -* 5 * * * /bin/true + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + # Chef Name: cronhole some stuff + MINUTE=40 + HOUR=midnight + TEST=lol + ENVIRONMENT=production + * 5 * * * /bin/true CRONTAB cron = @provider.load_current_resource @@ -298,15 +298,15 @@ CRONTAB context "with a matching entry in the user's crontab using month names and weekday names (#CHEF-3178)" do before :each do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -* 5 * Jan Mon /bin/true param1 param2 -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + * 5 * Jan Mon /bin/true param1 param2 + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB end @@ -334,10 +334,10 @@ CRONTAB context "with a matching entry without a crontab line" do it "should set cron_exists and leave current_resource values at defaults" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff + # Chef Name: cronhole some stuff CRONTAB cron = @provider.load_current_resource expect(@provider.cron_exists).to eq(true) @@ -351,11 +351,11 @@ CRONTAB end it "should not pick up a commented out crontab line" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -#* 5 * 1 * /bin/true param1 param2 + # Chef Name: cronhole some stuff + #* 5 * 1 * /bin/true param1 param2 CRONTAB cron = @provider.load_current_resource expect(@provider.cron_exists).to eq(true) @@ -369,15 +369,15 @@ CRONTAB end it "should not pick up a later crontab entry" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -#* 5 * 1 * /bin/true param1 param2 -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + #* 5 * 1 * /bin/true param1 param2 + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB cron = @provider.load_current_resource expect(@provider.cron_exists).to eq(true) @@ -442,9 +442,9 @@ CRONTAB end it "should create a crontab with the entry" do - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -# Chef Name: cronhole some stuff -30 * * * * /bin/true + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + # Chef Name: cronhole some stuff + 30 * * * * /bin/true ENDCRON @provider.run_action(:create) end @@ -455,14 +455,14 @@ CRONTAB @new_resource.shell "/bin/foosh" @new_resource.home "/home/foo" @new_resource.environment "TEST" => "LOL" - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -# Chef Name: cronhole some stuff -MAILTO="foo@example.com" -PATH="/usr/bin:/my/custom/path" -SHELL="/bin/foosh" -HOME="/home/foo" -TEST=LOL -30 * * * * /bin/true + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + # Chef Name: cronhole some stuff + MAILTO="foo@example.com" + PATH="/usr/bin:/my/custom/path" + SHELL="/bin/foosh" + HOME="/home/foo" + TEST=LOL + 30 * * * * /bin/true ENDCRON @provider.run_action(:create) end @@ -481,26 +481,26 @@ TEST=LOL context "when there is a crontab with no matching section" do before :each do @provider.cron_exists = false - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB end it "should add the entry to the crontab" do - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment -# Chef Name: cronhole some stuff -30 * * * * /bin/true + # Another comment + # Chef Name: cronhole some stuff + 30 * * * * /bin/true ENDCRON @provider.run_action(:create) end @@ -511,20 +511,20 @@ TEST=LOL @new_resource.shell "/bin/foosh" @new_resource.home "/home/foo" @new_resource.environment "TEST" => "LOL" - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command - -# Chef Name: something else -2 * 1 * * /bin/false - -# Another comment -# Chef Name: cronhole some stuff -MAILTO="foo@example.com" -PATH="/usr/bin:/my/custom/path" -SHELL="/bin/foosh" -HOME="/home/foo" -TEST=LOL -30 * * * * /bin/true + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command + + # Chef Name: something else + 2 * 1 * * /bin/false + + # Another comment + # Chef Name: cronhole some stuff + MAILTO="foo@example.com" + PATH="/usr/bin:/my/custom/path" + SHELL="/bin/foosh" + HOME="/home/foo" + TEST=LOL + 30 * * * * /bin/true ENDCRON @provider.run_action(:create) end @@ -544,28 +544,28 @@ TEST=LOL before :each do @provider.cron_exists = true allow(@provider).to receive(:cron_different?).and_return(true) - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -30 * * 3 * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + 30 * * 3 * /bin/true + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB end it "should update the crontab entry" do - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -30 * * * * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + 30 * * * * /bin/true + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment ENDCRON @provider.run_action(:create) end @@ -576,20 +576,20 @@ TEST=LOL @new_resource.shell "/bin/foosh" @new_resource.home "/home/foo" @new_resource.environment "TEST" => "LOL" - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command - -# Chef Name: cronhole some stuff -MAILTO="foo@example.com" -PATH="/usr/bin:/my/custom/path" -SHELL="/bin/foosh" -HOME="/home/foo" -TEST=LOL -30 * * * * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false - -# Another comment + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command + + # Chef Name: cronhole some stuff + MAILTO="foo@example.com" + PATH="/usr/bin:/my/custom/path" + SHELL="/bin/foosh" + HOME="/home/foo" + TEST=LOL + 30 * * * * /bin/true + # Chef Name: something else + 2 * 1 * * /bin/false + + # Another comment ENDCRON @provider.run_action(:create) end @@ -612,78 +612,78 @@ TEST=LOL end it "should add the crontab to the entry" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff + # Chef Name: cronhole some stuff CRONTAB - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -30 * * * * /bin/true + # Chef Name: cronhole some stuff + 30 * * * * /bin/true ENDCRON @provider.run_action(:create) end it "should not blat any following entries" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -#30 * * * * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + #30 * * * * /bin/true + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -30 * * * * /bin/true -#30 * * * * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + 30 * * * * /bin/true + #30 * * * * /bin/true + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment ENDCRON @provider.run_action(:create) end it "should handle env vars with no crontab" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -MAILTO=bar@example.com -PATH=/usr/bin:/my/custom/path -SHELL=/bin/barsh -HOME=/home/foo + # Chef Name: cronhole some stuff + MAILTO=bar@example.com + PATH=/usr/bin:/my/custom/path + SHELL=/bin/barsh + HOME=/home/foo -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB @new_resource.mailto "foo@example.com" @new_resource.path "/usr/bin:/my/custom/path" @new_resource.shell "/bin/foosh" @new_resource.home "/home/foo" - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -MAILTO="foo@example.com" -PATH="/usr/bin:/my/custom/path" -SHELL="/bin/foosh" -HOME="/home/foo" -30 * * * * /bin/true + # Chef Name: cronhole some stuff + MAILTO="foo@example.com" + PATH="/usr/bin:/my/custom/path" + SHELL="/bin/foosh" + HOME="/home/foo" + 30 * * * * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment ENDCRON @provider.run_action(:create) end @@ -693,13 +693,13 @@ HOME="/home/foo" before :each do @provider.cron_exists = true allow(@provider).to receive(:cron_different?).and_return(false) - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -* 5 * * * /bin/true + # Chef Name: cronhole some stuff + * 5 * * * /bin/true -# Another comment + # Another comment CRONTAB end @@ -747,50 +747,50 @@ CRONTAB context "when the user has a crontab with a matching section" do before :each do @provider.cron_exists = true - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -30 * * 3 * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + 30 * * 3 * /bin/true + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB end it "should remove the entry" do - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment ENDCRON @provider.run_action(:delete) end it "should remove any env vars with the entry" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -MAILTO=foo@example.com -FOO=test -30 * * 3 * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + MAILTO=foo@example.com + FOO=test + 30 * * 3 * /bin/true + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment ENDCRON @provider.run_action(:delete) end @@ -812,61 +812,61 @@ FOO=test end it "should remove the section" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff + # Chef Name: cronhole some stuff CRONTAB - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command ENDCRON @provider.run_action(:delete) end it "should not blat following sections" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -#30 * * 3 * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + #30 * * 3 * /bin/true + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command -#30 * * 3 * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false + #30 * * 3 * /bin/true + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment ENDCRON @provider.run_action(:delete) end it "should remove any envvars with the section" do - allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB) -0 2 * * * /some/other/command + allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) + 0 2 * * * /some/other/command -# Chef Name: cronhole some stuff -MAILTO=foo@example.com -#30 * * 3 * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false + # Chef Name: cronhole some stuff + MAILTO=foo@example.com + #30 * * 3 * /bin/true + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment CRONTAB - expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) -0 2 * * * /some/other/command + expect(@provider).to receive(:write_crontab).with(<<~ENDCRON) + 0 2 * * * /some/other/command -#30 * * 3 * /bin/true -# Chef Name: something else -2 * 1 * * /bin/false + #30 * * 3 * /bin/true + # Chef Name: something else + 2 * 1 * * /bin/false -# Another comment + # Another comment ENDCRON @provider.run_action(:delete) end @@ -875,13 +875,13 @@ MAILTO=foo@example.com describe "read_crontab" do before :each do - @stdout = <<-CRONTAB -0 2 * * * /some/other/command + @stdout = <<~CRONTAB + 0 2 * * * /some/other/command -# Chef Name: something else -* 5 * * * /bin/true + # Chef Name: something else + * 5 * * * /bin/true -# Another comment + # Another comment CRONTAB @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) @@ -894,13 +894,13 @@ MAILTO=foo@example.com it "should return the contents of the crontab" do crontab = @provider.send(:read_crontab) - expect(crontab).to eq <<-CRONTAB -0 2 * * * /some/other/command + expect(crontab).to eq <<~CRONTAB + 0 2 * * * /some/other/command -# Chef Name: something else -* 5 * * * /bin/true + # Chef Name: something else + * 5 * * * /bin/true -# Another comment + # Another comment CRONTAB end diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb index 747e37f308..411dc50cc9 100644 --- a/spec/unit/provider/dsc_resource_spec.rb +++ b/spec/unit/provider/dsc_resource_spec.rb @@ -103,8 +103,8 @@ describe Chef::Provider::DscResource do it "flags the resource as reboot required when required" do expect(provider).to receive(:test_resource).and_return(false) - expect(provider).to receive(:invoke_resource). - and_return(double(:stdout => "", :return_value => nil)) + expect(provider).to receive(:invoke_resource) + .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) @@ -113,8 +113,8 @@ describe Chef::Provider::DscResource do it "does not flag the resource as reboot required when not required" do expect(provider).to receive(:test_resource).and_return(false) - expect(provider).to receive(:invoke_resource). - and_return(double(:stdout => "", :return_value => nil)) + expect(provider).to receive(:invoke_resource) + .and_return(double(stdout: "", return_value: nil)) expect(provider).to receive(:add_dsc_verbose_log) expect(provider).to receive(:return_dsc_resource_result).and_return(false) expect(provider).to_not receive(:create_reboot_resource) @@ -293,12 +293,12 @@ describe Chef::Provider::DscResource do set_node_object end - let(:cmdlet) { double(:run! => nil) } + let(:cmdlet) { double(run!: nil) } before(:each) do allow(provider).to receive(:translate_type).and_return("my_properties") provider.instance_variable_set(:@new_resource, double( - :properties => "my_properties", :resource => "my_resource", :timeout => 123 + properties: "my_properties", resource: "my_resource", timeout: 123 )) end diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb index 78534bfb57..48cee78462 100644 --- a/spec/unit/provider/execute_spec.rb +++ b/spec/unit/provider/execute_spec.rb @@ -26,7 +26,7 @@ describe Chef::Provider::Execute do let(:provider) { Chef::Provider::Execute.new(new_resource, run_context) } let(:current_resource) { Chef::Resource::Ifconfig.new("foo_resource", run_context) } # You will be the same object, I promise. - @live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, :name => :execute) + @live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, name: :execute) let(:opts) do { diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb index f840d92dbb..e65d094327 100644 --- a/spec/unit/provider/file/content_spec.rb +++ b/spec/unit/provider/file/content_spec.rb @@ -36,7 +36,7 @@ describe Chef::Provider::File::Content do end let(:new_resource) do - double("Chef::Provider::File::Resource (new)", :name => "seattle.txt", :path => resource_path) + double("Chef::Provider::File::Resource (new)", name: "seattle.txt", path: resource_path) end let(:run_context) do diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb index fed9cd5ece..311ef4c55a 100644 --- a/spec/unit/provider/file_spec.rb +++ b/spec/unit/provider/file_spec.rb @@ -35,7 +35,7 @@ describe Chef::Provider::File do let(:node) { double("Chef::Node") } let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:logger) { double("Mixlib::Log::Child").as_null_object } - let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) } + let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) } let(:enclosing_directory) do canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) end diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb index a20c7a838c..4a6266b58a 100644 --- a/spec/unit/provider/git_spec.rb +++ b/spec/unit/provider/git_spec.rb @@ -58,7 +58,7 @@ describe Chef::Provider::Git do it "determines the current revision when there is one" do expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true) @stdout = "9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\n" - expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", { :cwd => "/my/deploy/dir", :returns => [0, 128], :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", { cwd: "/my/deploy/dir", returns: [0, 128], log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.find_current_revision).to eql("9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13") end @@ -66,7 +66,7 @@ describe Chef::Provider::Git do expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true) @stderr = "fatal: Not a git repository (or any of the parent directories): .git" @stdout = "" - expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", :cwd => "/my/deploy/dir", :returns => [0, 128], :log_tag => "git[web2.0 app]" ).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr)) + expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", cwd: "/my/deploy/dir", returns: [0, 128], log_tag: "git[web2.0 app]" ).and_return(double("ShellOut result", stdout: "", stderr: @stderr)) expect(@provider.find_current_revision).to be_nil end end @@ -152,7 +152,7 @@ describe Chef::Provider::Git do @resource.revision "v1.0" @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -161,7 +161,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0^{}\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53") end @@ -170,7 +170,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/releases/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -179,7 +179,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53") end @@ -188,7 +188,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.1\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -198,7 +198,7 @@ describe Chef::Provider::Git do "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + "805c22a5e41f5ae3193460cca044ed1435029f53\trefs/pulls/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("805c22a5e41f5ae3193460cca044ed1435029f53") end @@ -207,7 +207,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -222,21 +222,21 @@ describe Chef::Provider::Git do it "raises an unresolvable git reference error if the revision can't be resolved to any revision and assertions are run" do @resource.revision "FAIL, that's the revision I want" @provider.action = :checkout - expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", :stdout => "\n")) + expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", stdout: "\n")) @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::UnresolvableGitReference) end it "does not raise an error if the revision can't be resolved when assertions are not run" do @resource.revision "FAIL, that's the revision I want" - expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", :stdout => "\n")) + expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", stdout: "\n")) expect(@provider.target_revision).to eq(nil) end it "does not raise an error when the revision is valid and assertions are run." do @resource.revision "0.8-alpha" @stdout = "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) @provider.action = :checkout allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) @provider.define_resource_requirements @@ -244,24 +244,24 @@ describe Chef::Provider::Git do end it "gives the latest HEAD revision SHA if nothing is specified" do - @stdout = <<-SHAS -28af684d8460ba4793eda3e7ac238c864a5d029a\tHEAD -503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha -28af684d8460ba4793eda3e7ac238c864a5d029a\trefs/heads/master -c44fe79bb5e36941ce799cee6b9de3a2ef89afee\trefs/tags/0.5.2 -14534f0e0bf133dc9ff6dbe74f8a0c863ff3ac6d\trefs/tags/0.5.4 -d36fddb4291341a1ff2ecc3c560494e398881354\trefs/tags/0.5.6 -9e5ce9031cbee81015de680d010b603bce2dd15f\trefs/tags/0.6.0 -9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\trefs/tags/0.6.2 -014a69af1cdce619de82afaf6cdb4e6ac658fede\trefs/tags/0.7.0 -fa8097ff666af3ce64761d8e1f1c2aa292a11378\trefs/tags/0.7.2 -44f9be0b33ba5c10027ddb030a5b2f0faa3eeb8d\trefs/tags/0.7.4 -d7b9957f67236fa54e660cc3ab45ffecd6e0ba38\trefs/tags/0.7.8 -b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{} -ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package + @stdout = <<~SHAS + 28af684d8460ba4793eda3e7ac238c864a5d029a\tHEAD + 503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha + 28af684d8460ba4793eda3e7ac238c864a5d029a\trefs/heads/master + c44fe79bb5e36941ce799cee6b9de3a2ef89afee\trefs/tags/0.5.2 + 14534f0e0bf133dc9ff6dbe74f8a0c863ff3ac6d\trefs/tags/0.5.4 + d36fddb4291341a1ff2ecc3c560494e398881354\trefs/tags/0.5.6 + 9e5ce9031cbee81015de680d010b603bce2dd15f\trefs/tags/0.6.0 + 9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\trefs/tags/0.6.2 + 014a69af1cdce619de82afaf6cdb4e6ac658fede\trefs/tags/0.7.0 + fa8097ff666af3ce64761d8e1f1c2aa292a11378\trefs/tags/0.7.2 + 44f9be0b33ba5c10027ddb030a5b2f0faa3eeb8d\trefs/tags/0.7.4 + d7b9957f67236fa54e660cc3ab45ffecd6e0ba38\trefs/tags/0.7.8 + b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{} + ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package SHAS @resource.revision "" - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("28af684d8460ba4793eda3e7ac238c864a5d029a") end end @@ -276,15 +276,15 @@ SHAS let(:expected_cmd) { 'git clone "git://github.com/opscode/chef.git" "/my/deploy/dir"' } let(:default_options) do { - :user => deploy_user, - :environment => { "GIT_SSH" => wrapper, "HOME" => "/home/deployNinja" }, - :log_tag => "git[web2.0 app]", + user: deploy_user, + environment: { "GIT_SSH" => wrapper, "HOME" => "/home/deployNinja" }, + log_tag: "git[web2.0 app]", } end before do @resource.user deploy_user @resource.ssh_wrapper wrapper - allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja")) + allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja")) end context "without a timeout set" do it "clones a repo with default git options" do @@ -296,7 +296,7 @@ SHAS let (:seconds) { 10 } before { @resource.timeout(seconds) } it "clones a repo with amended git options" do - expect(@provider).to receive(:shell_out!).with(expected_cmd, default_options.merge(:timeout => seconds)) + expect(@provider).to receive(:shell_out!).with(expected_cmd, default_options.merge(timeout: seconds)) @provider.clone end end @@ -306,9 +306,9 @@ SHAS end let(:overrided_options) do { - :user => deploy_user, - :environment => { "GIT_SSH" => wrapper, "HOME" => "/home/masterNinja" }, - :log_tag => "git[web2.0 app]", + user: deploy_user, + environment: { "GIT_SSH" => wrapper, "HOME" => "/home/masterNinja" }, + log_tag: "git[web2.0 app]", } end before do @@ -327,14 +327,14 @@ SHAS let(:expected_cmd) { 'git clone "git://github.com/opscode/chef.git" "/my/deploy/dir"' } let(:default_options) do { - :user => 123, - :environment => { "HOME" => "/home/deployNinja" }, - :log_tag => "git[web2.0 app]", + user: 123, + environment: { "HOME" => "/home/deployNinja" }, + log_tag: "git[web2.0 app]", } end before do @resource.user deploy_user - allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja")) + allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja")) end context "with a specific home" do let (:override_home) do @@ -342,9 +342,9 @@ SHAS end let(:overrided_options) do { - :user => 123, - :environment => { "HOME" => "/home/masterNinja" }, - :log_tag => "git[web2.0 app]", + user: 123, + environment: { "HOME" => "/home/masterNinja" }, + log_tag: "git[web2.0 app]", } end before do @@ -360,14 +360,14 @@ SHAS it "runs a clone command with escaped destination" do @resource.user "deployNinja" - allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja")) + allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja")) @resource.destination "/Application Support/with/space" @resource.ssh_wrapper "do_it_this_way.sh" expected_cmd = "git clone \"git://github.com/opscode/chef.git\" \"/Application Support/with/space\"" - expect(@provider).to receive(:shell_out!).with(expected_cmd, :user => "deployNinja", - :log_tag => "git[web2.0 app]", - :environment => { "HOME" => "/home/deployNinja", - "GIT_SSH" => "do_it_this_way.sh" }) + expect(@provider).to receive(:shell_out!).with(expected_cmd, user: "deployNinja", + log_tag: "git[web2.0 app]", + environment: { "HOME" => "/home/deployNinja", + "GIT_SSH" => "do_it_this_way.sh" }) @provider.clone end @@ -377,8 +377,8 @@ SHAS version_response = double("shell_out") allow(version_response).to receive(:stdout) { "git version 1.7.9" } expect(@provider).to receive(:shell_out!).with("git --version", - :log_tag => "git[web2.0 app]").and_return(version_response) - expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]") + log_tag: "git[web2.0 app]").and_return(version_response) + expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]") @provider.clone end @@ -388,33 +388,33 @@ SHAS version_response = double("shell_out") allow(version_response).to receive(:stdout) { "git version 1.7.10" } expect(@provider).to receive(:shell_out!).with("git --version", - :log_tag => "git[web2.0 app]").and_return(version_response) - expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]") + log_tag: "git[web2.0 app]").and_return(version_response) + expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]") @provider.clone end it "compiles a clone command with a remote other than ``origin''" do @resource.remote "opscode" expected_cmd = "git clone -o opscode \"git://github.com/opscode/chef.git\" \"/my/deploy/dir\"" - expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]") @provider.clone end it "runs a checkout command with default options" do - expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]").ordered - expect(@provider).to receive(:shell_out!).with("git checkout deploy", :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]").ordered + expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]").ordered + expect(@provider).to receive(:shell_out!).with("git checkout deploy", cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]").ordered @provider.checkout end it "runs an enable_submodule command" do @resource.enable_submodules true expected_cmd = "git submodule sync" - expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd, cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") expected_cmd = "git submodule update --init --recursive" - expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") @provider.enable_submodules end @@ -426,35 +426,35 @@ SHAS it "runs a sync command with default options" do expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) expected_cmd1 = "git fetch --prune origin" - expect(@provider).to receive(:shell_out!).with(expected_cmd1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") expected_cmd2 = "git fetch origin --tags" - expect(@provider).to receive(:shell_out!).with(expected_cmd2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") expected_cmd3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - expect(@provider).to receive(:shell_out!).with(expected_cmd3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") @provider.fetch_updates end it "runs a sync command with the user and group specified in the resource" do @resource.user("whois") - allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois")) + allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/whois")) @resource.group("thisis") expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) expected_cmd1 = "git fetch --prune origin" - expect(@provider).to receive(:shell_out!).with(expected_cmd1, :cwd => "/my/deploy/dir", - :user => "whois", :group => "thisis", - :log_tag => "git[web2.0 app]", - :environment => { "HOME" => "/home/whois" }) + expect(@provider).to receive(:shell_out!).with(expected_cmd1, cwd: "/my/deploy/dir", + user: "whois", group: "thisis", + log_tag: "git[web2.0 app]", + environment: { "HOME" => "/home/whois" }) expected_cmd2 = "git fetch origin --tags" - expect(@provider).to receive(:shell_out!).with(expected_cmd2, :cwd => "/my/deploy/dir", - :user => "whois", :group => "thisis", - :log_tag => "git[web2.0 app]", - :environment => { "HOME" => "/home/whois" }) + expect(@provider).to receive(:shell_out!).with(expected_cmd2, cwd: "/my/deploy/dir", + user: "whois", group: "thisis", + log_tag: "git[web2.0 app]", + environment: { "HOME" => "/home/whois" }) expected_cmd3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - expect(@provider).to receive(:shell_out!).with(expected_cmd3, :cwd => "/my/deploy/dir", - :user => "whois", :group => "thisis", - :log_tag => "git[web2.0 app]", - :environment => { "HOME" => "/home/whois" }) + expect(@provider).to receive(:shell_out!).with(expected_cmd3, cwd: "/my/deploy/dir", + user: "whois", group: "thisis", + log_tag: "git[web2.0 app]", + environment: { "HOME" => "/home/whois" }) @provider.fetch_updates end @@ -462,11 +462,11 @@ SHAS @resource.remote "origin" expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) fetch_command1 = "git fetch --prune origin" - expect(@provider).to receive(:shell_out!).with(fetch_command1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") fetch_command2 = "git fetch origin --tags" - expect(@provider).to receive(:shell_out!).with(fetch_command2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") fetch_command3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - expect(@provider).to receive(:shell_out!).with(fetch_command3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") @provider.fetch_updates end @@ -474,11 +474,11 @@ SHAS @resource.remote "opscode" expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) fetch_command1 = "git fetch --prune opscode" - expect(@provider).to receive(:shell_out!).with(fetch_command1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") fetch_command2 = "git fetch opscode --tags" - expect(@provider).to receive(:shell_out!).with(fetch_command2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") fetch_command3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - expect(@provider).to receive(:shell_out!).with(fetch_command3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(fetch_command3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]") @provider.fetch_updates end @@ -489,37 +489,37 @@ SHAS allow(command_response).to receive(:exitstatus) { 1 } expected_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(expected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(add_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end it "runs the config with the user and group specified in the resource" do @resource.user("whois") @resource.group("thisis") - allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois")) + allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/whois")) command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 1 } expected_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(expected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :user => "whois", - :group => "thisis", - :environment => { "HOME" => "/home/whois" }, - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + user: "whois", + group: "thisis", + environment: { "HOME" => "/home/whois" }, + returns: [0, 1, 2]).and_return(command_response) add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(add_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :user => "whois", - :group => "thisis", - :environment => { "HOME" => "/home/whois" }) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + user: "whois", + group: "thisis", + environment: { "HOME" => "/home/whois" }) @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -529,13 +529,13 @@ SHAS allow(command_response).to receive(:exitstatus) { 1 } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) expected_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(expected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end end @@ -547,13 +547,13 @@ SHAS allow(command_response).to receive(:stdout) { "some_other_url" } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) expected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\"" expect(@provider).to receive(:shell_out!).with(expected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -563,13 +563,13 @@ SHAS allow(command_response).to receive(:stdout) { @resource.repository } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) unexpected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\"" expect(@provider).not_to receive(:shell_out!).with(unexpected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -578,13 +578,13 @@ SHAS allow(command_response).to receive(:exitstatus) { 2 } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]", - :returns => [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) expected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\"" expect(@provider).to receive(:shell_out!).with(expected_command, - :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end end @@ -705,9 +705,9 @@ SHAS allow(::File).to receive(:directory?).with("/my/deploy/dir").and_return(true) allow(@provider).to receive(:sync_command).and_return("huzzah!") expect(@provider).to receive(:action_checkout) - expect(@provider).not_to receive(:shell_out!).with("huzzah!", :cwd => "/my/deploy/dir") + expect(@provider).not_to receive(:shell_out!).with("huzzah!", cwd: "/my/deploy/dir") @provider.run_action(:sync) - #@resource.should be_updated + # @resource.should be_updated end it "does an export by cloning the repo then removing the .git directory" do @@ -719,8 +719,8 @@ SHAS describe "calling add_remotes" do it "adds a new remote for each entry in additional remotes hash" do - @resource.additional_remotes({ :opscode => "opscode_repo_url", - :another_repo => "some_other_repo_url" }) + @resource.additional_remotes({ opscode: "opscode_repo_url", + another_repo: "some_other_repo_url" }) allow(STDOUT).to receive(:tty?).and_return(false) command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 0 } diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb index b6748fd5f8..4d18a8c2b0 100644 --- a/spec/unit/provider/group/dscl_spec.rb +++ b/spec/unit/provider/group/dscl_spec.rb @@ -309,19 +309,19 @@ describe "Test DSCL loading" do @new_resource = Chef::Resource::Group.new("group name aj") @new_resource.group_name("aj") @provider = Chef::Provider::Group::Dscl.new(@new_resource, @run_context) - @output = <<-EOF -AppleMetaNodeLocation: /Local/Default -Comment: - Test Group -GeneratedUID: AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA -NestedGroups: AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAB -Password: * -PrimaryGroupID: 999 -RealName: - TestGroup -RecordName: com.apple.aj -RecordType: dsRecTypeStandard:Groups -GroupMembership: waka bar + @output = <<~EOF + AppleMetaNodeLocation: /Local/Default + Comment: + Test Group + GeneratedUID: AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA + NestedGroups: AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAB + Password: * + PrimaryGroupID: 999 + RealName: + TestGroup + RecordName: com.apple.aj + RecordType: dsRecTypeStandard:Groups + GroupMembership: waka bar EOF allow(@provider).to receive(:safe_dscl).with(*"read /Groups/aj".split(" ")).and_return(@output) @current_resource = @provider.load_current_resource diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb index c3e0d4b345..437b8c45ea 100644 --- a/spec/unit/provider/group_spec.rb +++ b/spec/unit/provider/group_spec.rb @@ -37,9 +37,9 @@ describe Chef::Provider::User do @provider.current_resource = @current_resource @pw_group = double("Struct::Group", - :name => "wheel", - :gid => 20, - :mem => %w{root aj} + name: "wheel", + gid: 20, + mem: %w{root aj} ) allow(Etc).to receive(:getgrnam).with("wheel").and_return(@pw_group) end diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb index 3eb4228c51..654b08b2c9 100644 --- a/spec/unit/provider/ifconfig/aix_spec.rb +++ b/spec/unit/provider/ifconfig/aix_spec.rb @@ -22,16 +22,16 @@ require "chef/exceptions" describe Chef::Provider::Ifconfig::Aix do before(:all) do - @ifconfig_output = <<-IFCONFIG -en1: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN> - inet 10.153.11.59 netmask 0xffff0000 broadcast 10.153.255.255 - tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1 -en0: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN> metric 1 - inet 172.29.174.58 netmask 0xffffc000 broadcast 172.29.191.255 - tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1 -lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN> - inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255 - inet6 ::1%1/0 + @ifconfig_output = <<~IFCONFIG + en1: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN> + inet 10.153.11.59 netmask 0xffff0000 broadcast 10.153.255.255 + tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1 + en0: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN> metric 1 + inet 172.29.174.58 netmask 0xffffc000 broadcast 172.29.191.255 + tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1 + lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN> + inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255 + inet6 ::1%1/0 IFCONFIG end diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb index 9a90dc1e0a..93b0008e8b 100644 --- a/spec/unit/provider/ifconfig/debian_spec.rb +++ b/spec/unit/provider/ifconfig/debian_spec.rb @@ -119,10 +119,10 @@ describe Chef::Provider::Ifconfig::Debian do context "when the /etc/network/interfaces file has the source line" do let(:expected_string) do - <<-EOF -a line -source #{tempdir_path}/* -another line + <<~EOF + a line + source #{tempdir_path}/* + another line EOF end @@ -142,10 +142,10 @@ EOF context "when the /etc/network/interfaces file does not have the source line" do let(:expected_string) do - <<-EOF -a line -another line -source #{tempdir_path}/* + <<~EOF + a line + another line + source #{tempdir_path}/* EOF end @@ -246,10 +246,10 @@ EOF context "when the /etc/network/interfaces file has the source line" do let(:expected_string) do - <<-EOF -a line -source #{tempdir_path}/* -another line + <<~EOF + a line + source #{tempdir_path}/* + another line EOF end @@ -267,10 +267,10 @@ another line context "when the /etc/network/interfaces file does not have the source line" do let(:expected_string) do - <<-EOF -a line -another line -source #{tempdir_path}/* + <<~EOF + a line + another line + source #{tempdir_path}/* EOF end diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb index 748b4d897e..0b8db90428 100644 --- a/spec/unit/provider/ifconfig_spec.rb +++ b/spec/unit/provider/ifconfig_spec.rb @@ -41,9 +41,9 @@ describe Chef::Provider::Ifconfig do end describe Chef::Provider::Ifconfig, "load_current_resource" do - let(:net_tools_version) { StringIO.new <<-EOS } -net-tools 1.60 -ifconfig 1.42 (2001-04-13) + let(:net_tools_version) { StringIO.new <<~EOS } + net-tools 1.60 + ifconfig 1.42 (2001-04-13) EOS before do diff --git a/spec/unit/provider/launchd_spec.rb b/spec/unit/provider/launchd_spec.rb index 693801f99b..3031ea36c3 100644 --- a/spec/unit/provider/launchd_spec.rb +++ b/spec/unit/provider/launchd_spec.rb @@ -29,55 +29,55 @@ describe Chef::Provider::Launchd do let(:label) { "call.mom.weekly" } let(:new_resource) { Chef::Resource::Launchd.new(label) } let!(:current_resource) { Chef::Resource::Launchd.new(label) } - let(:test_plist) { String.new <<-XML } -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> -\t<key>Label</key> -\t<string>call.mom.weekly</string> -\t<key>Program</key> -\t<string>/Library/scripts/call_mom.sh</string> -\t<key>StartCalendarInterval</key> -\t<dict> -\t\t<key>Hour</key> -\t\t<integer>10</integer> -\t\t<key>Weekday</key> -\t\t<integer>7</integer> -\t</dict> -\t<key>TimeOut</key> -\t<integer>300</integer> -</dict> -</plist> + let(:test_plist) { String.new <<~XML } + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> + <plist version="1.0"> + <dict> + \t<key>Label</key> + \t<string>call.mom.weekly</string> + \t<key>Program</key> + \t<string>/Library/scripts/call_mom.sh</string> + \t<key>StartCalendarInterval</key> + \t<dict> + \t\t<key>Hour</key> + \t\t<integer>10</integer> + \t\t<key>Weekday</key> + \t\t<integer>7</integer> + \t</dict> + \t<key>TimeOut</key> + \t<integer>300</integer> + </dict> + </plist> XML - let(:test_plist_multiple_intervals) { String.new <<-XML } -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> -\t<key>Label</key> -\t<string>call.mom.weekly</string> -\t<key>Program</key> -\t<string>/Library/scripts/call_mom.sh</string> -\t<key>StartCalendarInterval</key> -\t<array> -\t\t<dict> -\t\t\t<key>Hour</key> -\t\t\t<integer>11</integer> -\t\t\t<key>Weekday</key> -\t\t\t<integer>1</integer> -\t\t</dict> -\t\t<dict> -\t\t\t<key>Hour</key> -\t\t\t<integer>12</integer> -\t\t\t<key>Weekday</key> -\t\t\t<integer>2</integer> -\t\t</dict> -\t</array> -\t<key>TimeOut</key> -\t<integer>300</integer> -</dict> -</plist> + let(:test_plist_multiple_intervals) { String.new <<~XML } + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> + <plist version="1.0"> + <dict> + \t<key>Label</key> + \t<string>call.mom.weekly</string> + \t<key>Program</key> + \t<string>/Library/scripts/call_mom.sh</string> + \t<key>StartCalendarInterval</key> + \t<array> + \t\t<dict> + \t\t\t<key>Hour</key> + \t\t\t<integer>11</integer> + \t\t\t<key>Weekday</key> + \t\t\t<integer>1</integer> + \t\t</dict> + \t\t<dict> + \t\t\t<key>Hour</key> + \t\t\t<integer>12</integer> + \t\t\t<key>Weekday</key> + \t\t\t<integer>2</integer> + \t\t</dict> + \t</array> + \t<key>TimeOut</key> + \t<integer>300</integer> + </dict> + </plist> XML let(:test_hash) do @@ -112,14 +112,14 @@ XML describe "agent" do it "path should be /Library/LaunchAgents/call.mom.weekly.plist" do new_resource.type "agent" - expect(provider.gen_path_from_type). - to eq("/Library/LaunchAgents/call.mom.weekly.plist") + expect(provider.gen_path_from_type) + .to eq("/Library/LaunchAgents/call.mom.weekly.plist") end end describe "daemon" do it "path should be /Library/LaunchDaemons/call.mom.weekly.plist" do - expect(provider.gen_path_from_type). - to eq("/Library/LaunchDaemons/call.mom.weekly.plist") + expect(provider.gen_path_from_type) + .to eq("/Library/LaunchDaemons/call.mom.weekly.plist") end end end diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb index 10dbdc1766..027b318c7e 100644 --- a/spec/unit/provider/link_spec.rb +++ b/spec/unit/provider/link_spec.rb @@ -22,7 +22,7 @@ require "ostruct" require "spec_helper" if Chef::Platform.windows? - require "chef/win32/file" #probably need this in spec_helper + require "chef/win32/file" # probably need this in spec_helper end describe Chef::Resource::Link do @@ -46,7 +46,7 @@ describe Chef::Resource::Link do describe "when the target is a symlink" do before(:each) do - lstat = double("stats", :ino => 5) + lstat = double("stats", ino: 5) allow(lstat).to receive(:uid).and_return(501) allow(lstat).to receive(:gid).and_return(501) allow(lstat).to receive(:mode).and_return(0777) @@ -146,7 +146,7 @@ describe Chef::Resource::Link do describe "when the target is a regular old file" do before do - stat = double("stats", :ino => 5) + stat = double("stats", ino: 5) allow(stat).to receive(:uid).and_return(501) allow(stat).to receive(:gid).and_return(501) allow(stat).to receive(:mode).and_return(0755) @@ -178,7 +178,7 @@ describe Chef::Resource::Link do describe "and the source exists" do before do - stat = double("stats", :ino => 6) + stat = double("stats", ino: 6) allow(stat).to receive(:uid).and_return(502) allow(stat).to receive(:gid).and_return(502) allow(stat).to receive(:mode).and_return(0644) @@ -205,7 +205,7 @@ describe Chef::Resource::Link do describe "and is hardlinked to the source" do before do - stat = double("stats", :ino => 5) + stat = double("stats", ino: 5) allow(stat).to receive(:uid).and_return(502) allow(stat).to receive(:gid).and_return(502) allow(stat).to receive(:mode).and_return(0644) @@ -254,7 +254,7 @@ describe Chef::Resource::Link do describe "action_delete" do before(:each) do - stat = double("stats", :ino => 5) + stat = double("stats", ino: 5) allow(stat).to receive(:uid).and_return(501) allow(stat).to receive(:gid).and_return(501) allow(stat).to receive(:mode).and_return(0755) @@ -321,7 +321,7 @@ describe Chef::Resource::Link do end before(:each) do - stat = double("stats", :ino => 5) + stat = double("stats", ino: 5) allow(stat).to receive(:uid).and_return(502) allow(stat).to receive(:gid).and_return(502) allow(stat).to receive(:mode).and_return(0644) diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb index 8ef884e131..17824c4fb8 100644 --- a/spec/unit/provider/mdadm_spec.rb +++ b/spec/unit/provider/mdadm_spec.rb @@ -32,20 +32,20 @@ describe Chef::Provider::Mdadm do describe "when determining the current metadevice status" do it "should set the current resources mount point to the new resources mount point" do - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:status => 0)) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(status: 0)) @provider.load_current_resource expect(@provider.current_resource.name).to eq("/dev/md1") expect(@provider.current_resource.raid_device).to eq("/dev/md1") end it "determines that the metadevice exists when mdadm exit code is zero" do - allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 0)) + allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", returns: [0, 4]).and_return(OpenStruct.new(status: 0)) @provider.load_current_resource expect(@provider.current_resource.exists).to be_truthy end it "determines that the metadevice does not exist when mdadm exit code is 4" do - allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 4)) + allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", returns: [0, 4]).and_return(OpenStruct.new(status: 4)) @provider.load_current_resource expect(@provider.current_resource.exists).to be_falsey end diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb index 615f3c3304..80a83130e9 100644 --- a/spec/unit/provider/mount/aix_spec.rb +++ b/spec/unit/provider/mount/aix_spec.rb @@ -22,32 +22,32 @@ require "ostruct" describe Chef::Provider::Mount::Aix do before(:all) do - @mounted_output = <<-MOUNT - node mounted mounted over vfs date options --------- --------------- --------------- ------ ------------ --------------- - /dev/sdz1 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8 + @mounted_output = <<~MOUNT + node mounted mounted over vfs date options + -------- --------------- --------------- ------ ------------ --------------- + /dev/sdz1 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8 MOUNT - @unmounted_output = <<-UNMOUNTED - node mounted mounted over vfs date options --------- --------------- --------------- ------ ------------ --------------- - /dev/sdz2 / jfs2 Jul 17 13:22 rw,log=/dev/hd8 + @unmounted_output = <<~UNMOUNTED + node mounted mounted over vfs date options + -------- --------------- --------------- ------ ------------ --------------- + /dev/sdz2 / jfs2 Jul 17 13:22 rw,log=/dev/hd8 UNMOUNTED - @conflict_mounted_output = <<-MOUNT - node mounted mounted over vfs date options --------- --------------- --------------- ------ ------------ --------------- - /dev/sdz3 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8 + @conflict_mounted_output = <<~MOUNT + node mounted mounted over vfs date options + -------- --------------- --------------- ------ ------------ --------------- + /dev/sdz3 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8 MOUNT - @enabled_output = <<-ENABLED -#MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct -/tmp/foo:/dev/sdz1:jfs2::bootfs:10485760:rw:yes:no + @enabled_output = <<~ENABLED + #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct + /tmp/foo:/dev/sdz1:jfs2::bootfs:10485760:rw:yes:no ENABLED - @test_wrong_output = <<-WRONG -#MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct -/tmp/foo::/dev/sdz1:jfs2:bootfs:10485760:rw:yes:no + @test_wrong_output = <<~WRONG + #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct + /tmp/foo::/dev/sdz1:jfs2:bootfs:10485760:rw:yes:no WRONG end @@ -61,7 +61,7 @@ WRONG @new_resource.device_type :device @new_resource.fstype "jfs2" - @new_resource.supports :remount => false + @new_resource.supports remount: false @provider = Chef::Provider::Mount::Aix.new(@new_resource, @run_context) @@ -70,12 +70,12 @@ WRONG end def stub_mounted(provider, mounted_output) - response = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => mounted_output, :stderr => "") + response = double("Mixlib::ShellOut command", exitstatus: 0, stdout: mounted_output, stderr: "") expect(provider).to receive(:shell_out!).with("mount").and_return(response) end def stub_enabled(provider, enabled_output) - response = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => enabled_output, :stderr => "") + response = double("Mixlib::ShellOut command", exitstatus: 0, stdout: enabled_output, stderr: "") expect(provider).to receive(:shell_out).with("lsfs -c #{@new_resource.mount_point}").and_return(response) end @@ -179,7 +179,7 @@ WRONG describe "remount_fs" do it "should remount resource if it is already mounted and it supports remounting" do - @new_resource.supports({ :remount => true }) + @new_resource.supports({ remount: true }) stub_mounted_enabled(@provider, @mounted_output, "") expect(@provider).to receive(:shell_out!).with("mount -o remount #{@new_resource.device} #{@new_resource.mount_point}") @@ -188,7 +188,7 @@ WRONG end it "should remount with new mount options if it is already mounted and it supports remounting" do - @new_resource.supports({ :remount => true }) + @new_resource.supports({ remount: true }) @new_resource.options("nodev,rw") stub_mounted_enabled(@provider, @mounted_output, "") @@ -232,22 +232,22 @@ WRONG it "should disable mount if it is mounted and enabled" do stub_mounted_enabled(@provider, @mounted_output, @enabled_output) - allow(::File).to receive(:open).with("/etc/filesystems", "r").and_return(<<-ETCFILESYSTEMS) -/tmp/foo: - dev = /dev/sdz1 - vfs = jfs2 - log = /dev/hd8 - mount = true - check = true - vol = /opt - free = false - quota = no - -/tmp/abc: - dev = /dev/sdz2 - vfs = jfs2 - mount = true - options = rw + allow(::File).to receive(:open).with("/etc/filesystems", "r").and_return(<<~ETCFILESYSTEMS) + /tmp/foo: + dev = /dev/sdz1 + vfs = jfs2 + log = /dev/hd8 + mount = true + check = true + vol = /opt + free = false + quota = no + + /tmp/abc: + dev = /dev/sdz2 + vfs = jfs2 + mount = true + options = rw ETCFILESYSTEMS filesystems = StringIO.new diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index af7916e5bd..562dbcdc5d 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -30,7 +30,7 @@ describe Chef::Provider::Mount::Mount do @new_resource.device_type :device @new_resource.fstype "ext3" - @new_resource.supports :remount => false + @new_resource.supports remount: false @provider = Chef::Provider::Mount::Mount.new(@new_resource, @run_context) @@ -42,7 +42,7 @@ describe Chef::Provider::Mount::Mount do describe "when discovering the current fs state" do before do - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "")) allow(::File).to receive(:foreach).with("/etc/fstab") end @@ -54,10 +54,10 @@ describe Chef::Provider::Mount::Mount do end it "should accept device_type :uuid", :not_supported_on_solaris do - @status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1) + @status = double(stdout: "/dev/sdz1\n", exitstatus: 1) @new_resource.device_type :uuid @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" - @stdout_findfs = double("STDOUT", :first => "/dev/sdz1") + @stdout_findfs = double("STDOUT", first: "/dev/sdz1") expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(@status) @provider.load_current_resource @provider.mountable? @@ -73,7 +73,7 @@ describe Chef::Provider::Mount::Mount do it "should ignore trailing slash and set mounted to true for network mount (#{type})" do @new_resource.device fs_spec - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n")) @provider.load_current_resource expect(@provider.current_resource.mounted).to be_truthy end @@ -94,7 +94,7 @@ describe Chef::Provider::Mount::Mount do end it "should raise an error if the mount device (uuid) does not exist", :not_supported_on_solaris do - status = double(:stdout => "", :exitstatus => 1) + status = double(stdout: "", exitstatus: 1) @new_resource.device_type :uuid @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status) @@ -121,13 +121,13 @@ describe Chef::Provider::Mount::Mount do end it "should set mounted true if the mount point is found in the mounts list" do - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdz1 on /tmp/foo type ext3 (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdz1 on /tmp/foo type ext3 (rw)\n")) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_truthy end it "should set mounted false if another mount point beginning with the same path is found in the mounts list" do - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdz1 on /tmp/foobar type ext3 (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdz1 on /tmp/foobar type ext3 (rw)\n")) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_falsey end @@ -136,10 +136,10 @@ describe Chef::Provider::Mount::Mount do # expand the target path to correct specs on Windows target = ::File.expand_path("/dev/mapper/target") - allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true) - allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target) + allow(::File).to receive(:symlink?).with((@new_resource.device).to_s).and_return(true) + allow(::File).to receive(:readlink).with((@new_resource.device).to_s).and_return(target) - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{target} on /tmp/foo type ext3 (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{target} on /tmp/foo type ext3 (rw)\n")) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_truthy end @@ -150,10 +150,10 @@ describe Chef::Provider::Mount::Mount do # expand the target path to correct specs on Windows absolute_target = ::File.expand_path("/dev/xsdz1") - allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true) - allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target) + allow(::File).to receive(:symlink?).with((@new_resource.device).to_s).and_return(true) + allow(::File).to receive(:readlink).with((@new_resource.device).to_s).and_return(target) - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{absolute_target} on /tmp/foo type ext3 (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{absolute_target} on /tmp/foo type ext3 (rw)\n")) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_truthy end @@ -162,7 +162,7 @@ describe Chef::Provider::Mount::Mount do mount = "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n" mount << "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n" - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => mount)) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: mount)) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_truthy end @@ -171,13 +171,13 @@ describe Chef::Provider::Mount::Mount do mount = "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n" mount << "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n" - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => mount)) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: mount)) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_falsey end it "mounted should be false if the mount point is not found in the mounts list" do - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdy1 on /tmp/foo type ext3 (rw)\n")) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdy1 on /tmp/foo type ext3 (rw)\n")) @provider.load_current_resource() expect(@provider.current_resource.mounted).to be_falsey end @@ -205,8 +205,8 @@ describe Chef::Provider::Mount::Mount do it "should set enabled to true if the symlink target is in fstab" do target = "/dev/mapper/target" - allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true) - allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target) + allow(::File).to receive(:symlink?).with((@new_resource.device).to_s).and_return(true) + allow(::File).to receive(:readlink).with((@new_resource.device).to_s).and_return(target) fstab = "/dev/sdz1 /tmp/foo ext3 defaults 1 2\n" @@ -219,8 +219,8 @@ describe Chef::Provider::Mount::Mount do it "should set enabled to true if the symlink target is relative and is in fstab - CHEF-4957" do target = "xsdz1" - allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true) - allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target) + allow(::File).to receive(:symlink?).with((@new_resource.device).to_s).and_return(true) + allow(::File).to receive(:readlink).with((@new_resource.device).to_s).and_return(target) fstab = "/dev/sdz1 /tmp/foo ext3 defaults 1 2\n" @@ -307,7 +307,7 @@ describe Chef::Provider::Mount::Mount do end it "should mount the filesystem specified by uuid", :not_supported_on_solaris do - status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1) + status = double(stdout: "/dev/sdz1\n", exitstatus: 1) @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" @new_resource.device_type :uuid allow(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status) @@ -341,14 +341,14 @@ describe Chef::Provider::Mount::Mount do describe "remount_fs" do it "should use mount -o remount if remount is supported" do - @new_resource.supports({ :remount => true }) + @new_resource.supports({ remount: true }) @current_resource.mounted(true) expect(@provider).to receive(:shell_out!).with("mount -o remount,defaults #{@new_resource.mount_point}") @provider.remount_fs end it "should use mount -o remount with new mount options if remount is supported" do - @new_resource.supports({ :remount => true }) + @new_resource.supports({ remount: true }) options = "rw,noexec,noauto" @new_resource.options(%w{rw noexec noauto}) @current_resource.mounted(true) @@ -357,7 +357,7 @@ describe Chef::Provider::Mount::Mount do end it "should umount and mount if remount is not supported" do - @new_resource.supports({ :remount => false }) + @new_resource.supports({ remount: false }) @current_resource.mounted(true) expect(@provider).to receive(:umount_fs) expect(@provider).to receive(:sleep).with(1) @@ -499,7 +499,7 @@ describe Chef::Provider::Mount::Mount do context "when the device is described differently", :not_supported_on_solaris do it "should update the existing line" do @current_resource.enabled(true) - status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1) + status = double(stdout: "/dev/sdz1\n", exitstatus: 1) expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status) filesystems = [%q{/dev/sdy1 /tmp/foo ext3 defaults 1 2}, diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb index 2ec9feaf3b..e489b9001a 100644 --- a/spec/unit/provider/mount/solaris_spec.rb +++ b/spec/unit/provider/mount/solaris_spec.rb @@ -48,7 +48,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do new_resource.fsck_device fsck_device new_resource.fstype fstype new_resource.options options - new_resource.supports :remount => false + new_resource.supports remount: false new_resource end @@ -92,7 +92,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do before do stub_const("Chef::Provider::Mount::Solaris::VFSTAB", vfstab_file.path ) - allow(provider).to receive(:shell_out!).with("mount -v").and_return(OpenStruct.new(:stdout => mount_output)) + allow(provider).to receive(:shell_out!).with("mount -v").and_return(OpenStruct.new(stdout: mount_output)) allow(File).to receive(:symlink?).with(device).and_return(false) allow(File).to receive(:exist?).and_call_original # Tempfile.open on ruby 1.8.7 calls File.exist? allow(File).to receive(:exist?).with(device).and_return(true) diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb index fdb44836b5..6d55fb958c 100644 --- a/spec/unit/provider/mount/windows_spec.rb +++ b/spec/unit/provider/mount/windows_spec.rb @@ -99,10 +99,10 @@ describe Chef::Provider::Mount::Windows do end it "should mount the filesystem if it is not mounted" do - expect(@vol).to receive(:add).with(:remote => @new_resource.device, - :username => @new_resource.username, - :domainname => @new_resource.domain, - :password => @new_resource.password) + expect(@vol).to receive(:add).with(remote: @new_resource.device, + username: @new_resource.username, + domainname: @new_resource.domain, + password: @new_resource.password) @provider.mount_fs end diff --git a/spec/unit/provider/ohai_spec.rb b/spec/unit/provider/ohai_spec.rb index fad08ba589..518523dca2 100644 --- a/spec/unit/provider/ohai_spec.rb +++ b/spec/unit/provider/ohai_spec.rb @@ -29,16 +29,16 @@ describe Chef::Provider::Ohai do @platform_version = "example-platform" Chef::Config[:node_name] = @fqdn mock_ohai = { - :fqdn => @fqdn, - :hostname => @hostname, - :platform => @platform, - :platform_version => @platform_version, - :data => { - :origdata => "somevalue", + fqdn: @fqdn, + hostname: @hostname, + platform: @platform, + platform_version: @platform_version, + data: { + origdata: "somevalue", }, - :data2 => { - :origdata => "somevalue", - :newdata => "somevalue", + data2: { + origdata: "somevalue", + newdata: "somevalue", }, } allow(mock_ohai).to receive(:all_plugins).and_return(true) diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb index a1dcf3ecd6..dce52fd598 100644 --- a/spec/unit/provider/osx_profile_spec.rb +++ b/spec/unit/provider/osx_profile_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Provider::OsxProfile do let(:shell_out_success) do - double("shell_out", :exitstatus => 0, :error? => false) + double("shell_out", exitstatus: 0, error?: false) end describe "action_create" do let(:node) { Chef::Node.new } diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb index f15929880d..05be08f332 100644 --- a/spec/unit/provider/package/apt_spec.rb +++ b/spec/unit/provider/package/apt_spec.rb @@ -31,19 +31,19 @@ describe Chef::Provider::Package::Apt do allow(@run_context).to receive(:logger).and_return(logger) @new_resource = Chef::Resource::AptPackage.new("irssi", @run_context) - @status = double("Status", :exitstatus => 0) + @status = double("Status", exitstatus: 0) @provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context) @stdin = StringIO.new - @stdout = <<-PKG_STATUS -irssi: - Installed: (none) - Candidate: 0.8.14-1ubuntu4 - Version table: - 0.8.14-1ubuntu4 0 - 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages + @stdout = <<~PKG_STATUS + irssi: + Installed: (none) + Candidate: 0.8.14-1ubuntu4 + Version table: + 0.8.14-1ubuntu4 0 + 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages PKG_STATUS @stderr = "" - @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0) + @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0) @timeout = 900 end @@ -52,8 +52,8 @@ irssi: it "should create a current resource with the name of the new_resource" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "policy", @new_resource.package_name, - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(@shell_out) @provider.load_current_resource @@ -65,17 +65,17 @@ irssi: end it "should set the installed version if package has one" do - @stdout.replace(<<-INSTALLED) -sudo: - Installed: 1.7.2p1-1ubuntu5.3 - Candidate: 1.7.2p1-1ubuntu5.3 - Version table: - *** 1.7.2p1-1ubuntu5.3 0 - 500 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages - 500 http://security.ubuntu.com/ubuntu/ lucid-security/main Packages - 100 /var/lib/dpkg/status - 1.7.2p1-1ubuntu5 0 - 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages + @stdout.replace(<<~INSTALLED) + sudo: + Installed: 1.7.2p1-1ubuntu5.3 + Candidate: 1.7.2p1-1ubuntu5.3 + Version table: + *** 1.7.2p1-1ubuntu5.3 0 + 500 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages + 500 http://security.ubuntu.com/ubuntu/ lucid-security/main Packages + 100 /var/lib/dpkg/status + 1.7.2p1-1ubuntu5 0 + 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages INSTALLED expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out) @provider.load_current_resource @@ -86,23 +86,23 @@ sudo: # it is the superclasses responsibility to throw most exceptions it "if the package does not exist in the cache sets installed + candidate version to nil" do @new_resource.package_name("conic-smarms") - policy_out = <<-POLICY_STDOUT -N: Unable to locate package conic-smarms + policy_out = <<~POLICY_STDOUT + N: Unable to locate package conic-smarms POLICY_STDOUT - policy = double(:stdout => policy_out, :exitstatus => 0) + policy = double(stdout: policy_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "policy", "conic-smarms", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(policy) - showpkg_out = <<-SHOWPKG_STDOUT -N: Unable to locate package conic-smarms + showpkg_out = <<~SHOWPKG_STDOUT + N: Unable to locate package conic-smarms SHOWPKG_STDOUT - showpkg = double(:stdout => showpkg_out, :exitstatus => 0) + showpkg = double(stdout: showpkg_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "showpkg", "conic-smarms", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(showpkg) @provider.load_current_resource end @@ -111,104 +111,104 @@ N: Unable to locate package conic-smarms # 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 -libmysqlclient15-dev: - Installed: (none) - Candidate: (none) - Version table: + 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_compacted!).with( "apt-cache", "policy", "libmysqlclient15-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(virtual_package) - showpkg_out = <<-SHOWPKG_STDOUT -Package: libmysqlclient15-dev -Versions: - -Reverse Depends: - libmysqlclient-dev,libmysqlclient15-dev - libmysqlclient-dev,libmysqlclient15-dev - libmysqlclient-dev,libmysqlclient15-dev - libmysqlclient-dev,libmysqlclient15-dev - libmysqlclient-dev,libmysqlclient15-dev - libmysqlclient-dev,libmysqlclient15-dev -Dependencies: -Provides: -Reverse Provides: -libmysqlclient-dev 5.1.41-3ubuntu12.7 -libmysqlclient-dev 5.1.41-3ubuntu12.10 -libmysqlclient-dev 5.1.41-3ubuntu12 + showpkg_out = <<~SHOWPKG_STDOUT + Package: libmysqlclient15-dev + Versions: + + Reverse Depends: + libmysqlclient-dev,libmysqlclient15-dev + libmysqlclient-dev,libmysqlclient15-dev + libmysqlclient-dev,libmysqlclient15-dev + libmysqlclient-dev,libmysqlclient15-dev + libmysqlclient-dev,libmysqlclient15-dev + libmysqlclient-dev,libmysqlclient15-dev + Dependencies: + Provides: + Reverse Provides: + libmysqlclient-dev 5.1.41-3ubuntu12.7 + libmysqlclient-dev 5.1.41-3ubuntu12.10 + libmysqlclient-dev 5.1.41-3ubuntu12 SHOWPKG_STDOUT - showpkg = double(:stdout => showpkg_out, :exitstatus => 0) + showpkg = double(stdout: showpkg_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "showpkg", "libmysqlclient15-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(showpkg) - real_package_out = <<-RPKG_STDOUT -libmysqlclient-dev: - Installed: 5.1.41-3ubuntu12.10 - Candidate: 5.1.41-3ubuntu12.10 - Version table: - *** 5.1.41-3ubuntu12.10 0 - 500 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages - 100 /var/lib/dpkg/status - 5.1.41-3ubuntu12.7 0 - 500 http://security.ubuntu.com/ubuntu/ lucid-security/main Packages - 5.1.41-3ubuntu12 0 - 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages + real_package_out = <<~RPKG_STDOUT + libmysqlclient-dev: + Installed: 5.1.41-3ubuntu12.10 + Candidate: 5.1.41-3ubuntu12.10 + Version table: + *** 5.1.41-3ubuntu12.10 0 + 500 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages + 100 /var/lib/dpkg/status + 5.1.41-3ubuntu12.7 0 + 500 http://security.ubuntu.com/ubuntu/ lucid-security/main Packages + 5.1.41-3ubuntu12 0 + 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages RPKG_STDOUT - real_package = double(:stdout => real_package_out, :exitstatus => 0) + real_package = double(stdout: real_package_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "policy", "libmysqlclient-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(real_package) @provider.load_current_resource end 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 -mp3-decoder: - Installed: (none) - Candidate: (none) - Version table: + 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_compacted!).with( "apt-cache", "policy", "mp3-decoder", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(virtual_package) - showpkg_out = <<-SHOWPKG_STDOUT -Package: mp3-decoder -Versions: - -Reverse Depends: - nautilus,mp3-decoder - vux,mp3-decoder - plait,mp3-decoder - ecasound,mp3-decoder - nautilus,mp3-decoder -Dependencies: -Provides: -Reverse Provides: -vlc-nox 1.0.6-1ubuntu1.8 -vlc 1.0.6-1ubuntu1.8 -vlc-nox 1.0.6-1ubuntu1 -vlc 1.0.6-1ubuntu1 -opencubicplayer 1:0.1.17-2 -mpg321 0.2.10.6 -mpg123 1.12.1-0ubuntu1 + showpkg_out = <<~SHOWPKG_STDOUT + Package: mp3-decoder + Versions: + + Reverse Depends: + nautilus,mp3-decoder + vux,mp3-decoder + plait,mp3-decoder + ecasound,mp3-decoder + nautilus,mp3-decoder + Dependencies: + Provides: + Reverse Provides: + vlc-nox 1.0.6-1ubuntu1.8 + vlc 1.0.6-1ubuntu1.8 + vlc-nox 1.0.6-1ubuntu1 + vlc 1.0.6-1ubuntu1 + opencubicplayer 1:0.1.17-2 + mpg321 0.2.10.6 + mpg123 1.12.1-0ubuntu1 SHOWPKG_STDOUT - showpkg = double(:stdout => showpkg_out, :exitstatus => 0) + showpkg = double(stdout: showpkg_out, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "showpkg", "mp3-decoder", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(showpkg) expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package) end @@ -221,8 +221,8 @@ mpg123 1.12.1-0ubuntu1 @new_resource.provider(nil) expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "-o", "APT::Default-Release=lenny-backports", "policy", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ).and_return(@shell_out) @provider.load_current_resource end @@ -231,8 +231,8 @@ mpg123 1.12.1-0ubuntu1 @new_resource.source "pluto" expect(@provider).to receive(:shell_out_compacted!).with( "apt-cache", "policy", @new_resource.package_name, - :env => { "DEBIAN_FRONTEND" => "noninteractive" } , - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" } , + timeout: @timeout ).and_return(@shell_out) expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) end @@ -260,8 +260,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get install with the package name and version" do expect(@provider).to receive(:shell_out_compacted!). with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.install_package(["irssi"], ["0.8.12-7"]) end @@ -269,8 +269,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get install with the package name and version and options if specified" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "--force-yes", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @new_resource.options("--force-yes") @provider.install_package(["irssi"], ["0.8.12-7"]) @@ -285,8 +285,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "-o", "APT::Default-Release=lenny-backports", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.install_package(["irssi"], ["0.8.12-7"]) @@ -295,8 +295,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get install with the package name and quotes options if specified" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "--force-yes", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confnew", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @new_resource.options('--force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew"') @provider.install_package(["irssi"], ["0.8.12-7"]) @@ -316,8 +316,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get remove with the package name" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "remove", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.remove_package(["irssi"], ["0.8.12-7"]) end @@ -325,8 +325,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get remove with the package name and options if specified" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "--force-yes", "remove", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @new_resource.options("--force-yes") @@ -339,8 +339,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get purge with the package name" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "purge", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.purge_package(["irssi"], ["0.8.12-7"]) end @@ -348,8 +348,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-get purge with the package name and options if specified" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "--force-yes", "purge", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @new_resource.options("--force-yes") @@ -367,8 +367,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:shell_out_compacted!).with( "debconf-set-selections", "/tmp/irssi-0.8.12-7.seed", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.preseed_package(file) @@ -377,8 +377,8 @@ mpg123 1.12.1-0ubuntu1 it "should run debconf-set-selections on the preseed file if it has changed" do expect(@provider).to receive(:shell_out_compacted!).with( "debconf-set-selections", "/tmp/irssi-0.8.12-7.seed", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) file = @provider.get_preseed_file("irssi", "0.8.12-7") @provider.preseed_package(file) @@ -398,8 +398,8 @@ mpg123 1.12.1-0ubuntu1 it "should run dpkg-reconfigure package" do expect(@provider).to receive(:shell_out_compacted!).with( "dpkg-reconfigure", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.reconfig_package("irssi", "0.8.12-7") end @@ -409,8 +409,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-mark hold package" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-mark", "hold", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.lock_package("irssi", "0.8.12-7") end @@ -430,8 +430,8 @@ mpg123 1.12.1-0ubuntu1 it "should run apt-mark unhold package" do expect(@provider).to receive(:shell_out_compacted!).with( "apt-mark", "unhold", "irssi", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.unlock_package("irssi", "0.8.12-7") end @@ -452,8 +452,8 @@ mpg123 1.12.1-0ubuntu1 @provider.package_data["libmysqlclient15-dev"][:virtual] = true expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "libmysqlclient15-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.install_package(["libmysqlclient15-dev"], ["not_a_real_version"]) end @@ -464,8 +464,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:resolve_virtual_package_name).with("libmysqlclient15-dev").and_return("libmysqlclient-dev") expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "remove", "libmysqlclient-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.remove_package(["libmysqlclient15-dev"], ["not_a_real_version"]) end @@ -476,8 +476,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:resolve_virtual_package_name).with("libmysqlclient15-dev").and_return("libmysqlclient-dev") expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "purge", "libmysqlclient-dev", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.purge_package(["libmysqlclient15-dev"], ["not_a_real_version"]) end @@ -488,8 +488,8 @@ mpg123 1.12.1-0ubuntu1 # https://github.com/chef/chef/issues/2914 expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "libmysqlclient15-dev", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.install_package(["libmysqlclient15-dev", "irssi"], ["not_a_real_version", "0.8.12-7"]) end @@ -511,8 +511,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).to receive(:version_compare).and_return(-1) expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.run_action(:upgrade) end @@ -523,8 +523,8 @@ mpg123 1.12.1-0ubuntu1 expect(@provider).not_to receive(:version_compare) expect(@provider).to receive(:shell_out_compacted!).with( "apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7", - :env => { "DEBIAN_FRONTEND" => "noninteractive" }, - :timeout => @timeout + env: { "DEBIAN_FRONTEND" => "noninteractive" }, + timeout: @timeout ) @provider.run_action(:upgrade) end diff --git a/spec/unit/provider/package/bff_spec.rb b/spec/unit/provider/package/bff_spec.rb index df407914d3..7606092762 100644 --- a/spec/unit/provider/package/bff_spec.rb +++ b/spec/unit/provider/package/bff_spec.rb @@ -38,11 +38,11 @@ describe Chef::Provider::Package::Bff do @bffinfo = "/usr/lib/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX: /etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:" - @empty_status = double("Status", :stdout => "", :exitstatus => 0) + @empty_status = double("Status", stdout: "", exitstatus: 0) end it "should create a current resource with the name of new_resource" do - status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + status = double("Status", stdout: @bffinfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status) @provider.load_current_resource @@ -50,7 +50,7 @@ describe Chef::Provider::Package::Bff do end it "should set the current resource bff package name to the new resource bff package name" do - status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + status = double("Status", stdout: @bffinfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status) @provider.load_current_resource @@ -66,7 +66,7 @@ describe Chef::Provider::Package::Bff do end it "should get the source package version from lslpp if provided" do - status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + status = double("Status", stdout: @bffinfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status) @provider.load_current_resource @@ -78,7 +78,7 @@ describe Chef::Provider::Package::Bff do it "should warn if the package is not a fileset" do info = "samba.base:samba.base.samples:3.3.12.0::COMMITTED:I:Samba for AIX: /etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:" - status = double("Status", :stdout => info, :exitstatus => 0) + status = double("Status", stdout: info, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status) expect(logger).to receive(:warn).once.with(%r{bff package by product name}) @@ -89,7 +89,7 @@ describe Chef::Provider::Package::Bff do end it "should return the current version installed if found by lslpp" do - status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + status = double("Status", stdout: @bffinfo, exitstatus: 0) @stdout = StringIO.new(@bffinfo) @stdin, @stderr = StringIO.new, StringIO.new expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) @@ -99,7 +99,7 @@ describe Chef::Provider::Package::Bff do end it "should raise an exception if the source is not set but we are installing" do - status = double("Status", :stdout => "", :exitstatus => 1, :format_for_exception => "") + status = double("Status", stdout: "", exitstatus: 1, format_for_exception: "") @new_resource = Chef::Resource::Package.new("samba.base") @provider = Chef::Provider::Package::Bff.new(@new_resource, @run_context) allow(@provider).to receive(:shell_out_compacted).and_return(status) @@ -107,13 +107,13 @@ describe Chef::Provider::Package::Bff do end it "should raise an exception if installp/lslpp fails to run" do - status = double(:stdout => "", :exitstatus => -1, :format_for_exception => "") + status = double(stdout: "", exitstatus: -1, format_for_exception: "") allow(@provider).to receive(:shell_out_compacted).and_return(status) expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package) end it "should return a current resource with a nil version if the package is not found" do - status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + status = double("Status", stdout: @bffinfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status) @provider.load_current_resource @@ -123,7 +123,7 @@ describe Chef::Provider::Package::Bff do it "should raise an exception if the source doesn't provide the requested package" do wrongbffinfo = "/usr/lib/objrepos:openssl.base:0.9.8.2400::COMMITTED:I:Open Secure Socket Layer: /etc/objrepos:openssl.base:0.9.8.2400::COMMITTED:I:Open Secure Socket Layer:" - status = double("Status", :stdout => wrongbffinfo, :exitstatus => 0) + status = double("Status", stdout: wrongbffinfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package) end @@ -137,13 +137,13 @@ describe Chef::Provider::Package::Bff do end it "should lookup the candidate_version if the variable is not already set" do - status = double(:stdout => "", :exitstatus => 0) + status = double(stdout: "", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) @provider.candidate_version end it "should throw and exception if the exitstatus is not 0" do - @status = double(:stdout => "", :exitstatus => 1, :format_for_exception => "") + @status = double(stdout: "", exitstatus: 1, format_for_exception: "") allow(@provider).to receive(:shell_out_compacted).and_return(@status) expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package) end diff --git a/spec/unit/provider/package/cab_spec.rb b/spec/unit/provider/package/cab_spec.rb index 5c86f781f3..2ed40566f4 100644 --- a/spec/unit/provider/package/cab_spec.rb +++ b/spec/unit/provider/package/cab_spec.rb @@ -31,25 +31,25 @@ describe Chef::Provider::Package::Cab do end let(:installed_package_list_stdout) do - <<-EOF -Packages listing: -Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0 -Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0 + <<~EOF + Packages listing: + Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0 + Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0 EOF end let(:package_version_stdout) do - <<-EOF -Package information: -Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 -State : Installed -Dependency : Language Pack -The operation completed successfully + <<~EOF + Package information: + Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 + State : Installed + Dependency : Language Pack + The operation completed successfully EOF end before do - new_resource.source = File.join("#{ENV['TEMP']}", "test6.1-kb2664825-v3-x64.cab") + new_resource.source = File.join((ENV["TEMP"]).to_s, "test6.1-kb2664825-v3-x64.cab") installed_package_list_obj = double(stdout: installed_package_list_stdout) allow(provider).to receive(:dism_command).with("/Get-Packages").and_return(installed_package_list_obj) package_version_obj = double(stdout: package_version_stdout) @@ -57,20 +57,20 @@ The operation completed successfully end def allow_package_info(package_path = nil, package_name = nil) - get_package_info_stdout = <<-EOF -Deployment Image Servicing and Management tool -Version: 6.1.7600.16385 - -Image Version: 6.1.7600.16385 - -Package information: -Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 -Applicable : Yes -Copyright : Microsoft Corporation -Company : Microsoft Corporation -State : Installed -Dependency : Language Pack -The operation completed successfully + get_package_info_stdout = <<~EOF + Deployment Image Servicing and Management tool + Version: 6.1.7600.16385 + + Image Version: 6.1.7600.16385 + + Package information: + Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 + Applicable : Yes + Copyright : Microsoft Corporation + Company : Microsoft Corporation + State : Installed + Dependency : Language Pack + The operation completed successfully EOF get_package_info_obj = double(stdout: get_package_info_stdout) if package_path @@ -81,30 +81,30 @@ The operation completed successfully end def allow_get_packages - get_packages_stdout = <<-EOF -Deployment Image Servicing and Management tool -Version: 6.1.7600.16385 + get_packages_stdout = <<~EOF + Deployment Image Servicing and Management tool + Version: 6.1.7600.16385 -Image Version: 6.1.7600.16385 + Image Version: 6.1.7600.16385 -Packages listing: + Packages listing: -Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0 -State : Installed -Release Type : Language Pack -Install Time : 2/11/2015 11:33 PM + Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0 + State : Installed + Release Type : Language Pack + Install Time : 2/11/2015 11:33 PM -Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0 -State : Installed -Release Type : Language Pack -Install Time : 2/11/2015 11:33 PM + Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0 + State : Installed + Release Type : Language Pack + Install Time : 2/11/2015 11:33 PM -Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 -State : Installed -Release Type : Feature Pack -Install Time : 11/21/2010 3:40 AM + Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 + State : Installed + Release Type : Feature Pack + Install Time : 11/21/2010 3:40 AM -The operation completed successfully. + The operation completed successfully. EOF get_packages_obj = double(stdout: get_packages_stdout) allow(provider).to receive(:dism_command).with("/Get-Packages").and_return(get_packages_obj) @@ -151,9 +151,9 @@ The operation completed successfully. allow(Chef::FileCache).to receive(:create_cache_path).and_return(ENV["TEMP"]) path = provider.default_download_cache_path if windows? - expect(path).to be == File.join("#{ENV['TEMP']}", "\\", "Test6.1-KB2664825-v3-x64.cab") + expect(path).to be == File.join((ENV["TEMP"]).to_s, "\\", "Test6.1-KB2664825-v3-x64.cab") else - expect(path).to be == File.join("#{ENV['TEMP']}", "Test6.1-KB2664825-v3-x64.cab") + expect(path).to be == File.join((ENV["TEMP"]).to_s, "Test6.1-KB2664825-v3-x64.cab") end end end @@ -161,12 +161,12 @@ The operation completed successfully. describe "#cab_file_source" do context "when local file path is set" do it "returns local cab file source path" do - new_resource.source = File.join("#{ENV['TEMP']}", "test6.1-kb2664825-v3-x64.cab") + new_resource.source = File.join((ENV["TEMP"]).to_s, "test6.1-kb2664825-v3-x64.cab") path = provider.cab_file_source if windows? - expect(path).to be == File.join("#{ENV['TEMP'].downcase}", "\\", "test6.1-kb2664825-v3-x64.cab") + expect(path).to be == File.join((ENV["TEMP"].downcase).to_s, "\\", "test6.1-kb2664825-v3-x64.cab") else - expect(path).to be == File.join("#{ENV['TEMP']}", "test6.1-kb2664825-v3-x64.cab") + expect(path).to be == File.join((ENV["TEMP"]).to_s, "test6.1-kb2664825-v3-x64.cab") end end end @@ -174,9 +174,9 @@ The operation completed successfully. it "calls download_source_file method" do new_resource.source = "https://www.something.com/test6.1-kb2664825-v3-x64.cab" if windows? - expect(provider).to receive(:download_source_file).and_return(File.join("#{ENV['TEMP'].downcase}", "\\", "test6.1-kb2664825-v3-x64.cab")) + expect(provider).to receive(:download_source_file).and_return(File.join((ENV["TEMP"].downcase).to_s, "\\", "test6.1-kb2664825-v3-x64.cab")) else - expect(provider).to receive(:download_source_file).and_return(File.join("#{ENV['TEMP']}", "test6.1-kb2664825-v3-x64.cab")) + expect(provider).to receive(:download_source_file).and_return(File.join((ENV["TEMP"]).to_s, "test6.1-kb2664825-v3-x64.cab")) end provider.cab_file_source end @@ -248,14 +248,14 @@ The operation completed successfully. context "Invalid package source" do def package_version_stdout - package_version_stdout = <<-EOF -Deployment Image Servicing and Management tool -Version: 6.1.7600.16385 -Image Version: 6.1.7600.16385 -An error occurred trying to open - c:\\temp\\test6.1-KB2664825-v3-x64.cab Error: 0x80070003 -Error: 3 -The system cannot find the path specified. -The DISM log file can be found at C:\\Windows\\Logs\\DISM\\dism.log. + package_version_stdout = <<~EOF + Deployment Image Servicing and Management tool + Version: 6.1.7600.16385 + Image Version: 6.1.7600.16385 + An error occurred trying to open - c:\\temp\\test6.1-KB2664825-v3-x64.cab Error: 0x80070003 + Error: 3 + The system cannot find the path specified. + The DISM log file can be found at C:\\Windows\\Logs\\DISM\\dism.log. EOF end diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb index a0a73c445a..48f8a562de 100644 --- a/spec/unit/provider/package/chocolatey_spec.rb +++ b/spec/unit/provider/package/chocolatey_spec.rb @@ -35,32 +35,32 @@ describe Chef::Provider::Package::Chocolatey do # installed packages (ConEmu is upgradable) let(:local_list_stdout) do - <<-EOF -Chocolatey v0.9.9.11 -chocolatey|0.9.9.11 -ConEmu|15.10.25.0 + <<~EOF + Chocolatey v0.9.9.11 + chocolatey|0.9.9.11 + ConEmu|15.10.25.0 EOF end before do allow(provider).to receive(:choco_install_path).and_return(choco_install_path) allow(provider).to receive(:choco_exe).and_return(choco_exe) - local_list_obj = double(:stdout => local_list_stdout) - allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -l -r", { :returns => [0], :timeout => timeout }).and_return(local_list_obj) + local_list_obj = double(stdout: local_list_stdout) + allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -l -r", { returns: [0], timeout: timeout }).and_return(local_list_obj) end def allow_remote_list(package_names, args = nil) - remote_list_stdout = <<-EOF -Chocolatey v0.9.9.11 -chocolatey|0.9.9.11 -ConEmu|15.10.25.1 -Git|2.6.1 -Git|2.6.2 -munin-node|1.6.1.20130823 + remote_list_stdout = <<~EOF + Chocolatey v0.9.9.11 + chocolatey|0.9.9.11 + ConEmu|15.10.25.1 + Git|2.6.1 + Git|2.6.2 + munin-node|1.6.1.20130823 EOF remote_list_obj = double(stdout: remote_list_stdout) package_names.each do |pkg| - allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -r #{pkg}#{args}", { :returns => [0], timeout: timeout }).and_return(remote_list_obj) + allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -r #{pkg}#{args}", { returns: [0], timeout: timeout }).and_return(remote_list_obj) end end @@ -182,7 +182,7 @@ munin-node|1.6.1.20130823 it "should install a single package" do allow_remote_list(["git"]) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -193,7 +193,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git"]) new_resource.timeout(timeout) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -222,7 +222,7 @@ munin-node|1.6.1.20130823 new_resource.package_name("ConEmu") new_resource.version("15.10.25.1") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -235,7 +235,7 @@ munin-node|1.6.1.20130823 new_resource.package_name(%w{chocolatey ConEmu}) new_resource.version([nil, "15.10.25.1"]) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -245,7 +245,7 @@ munin-node|1.6.1.20130823 new_resource.package_name("conemu") new_resource.version("15.10.25.1") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -255,8 +255,8 @@ munin-node|1.6.1.20130823 new_resource.package_name(%w{ConEmu git}) new_resource.version(["15.10.25.1", nil]) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double) - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -265,7 +265,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git", "munin-node"]) new_resource.package_name(["git", "munin-node"]) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git munin-node", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git munin-node", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -275,7 +275,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git"], " -source localpackages") new_resource.source("localpackages") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -source localpackages git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -source localpackages git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -285,7 +285,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git"]) new_resource.options("-force") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -force git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -force git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -319,7 +319,7 @@ munin-node|1.6.1.20130823 it "should install a package that is not installed" do allow_remote_list(["git"]) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -328,7 +328,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["ConEmu"]) new_resource.package_name("ConEmu") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -337,7 +337,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["conemu"]) new_resource.package_name("conemu") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -346,7 +346,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["chocolatey"]) new_resource.package_name("chocolatey") provider.load_current_resource - expect(provider).not_to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y chocolatey", { :returns => [0], :timeout => timeout }) + expect(provider).not_to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y chocolatey", { returns: [0], timeout: timeout }) provider.run_action(:upgrade) expect(new_resource).not_to be_updated_by_last_action end @@ -355,7 +355,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["git"]) new_resource.version("2.6.2") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y --version 2.6.2 git", { :returns => [0], :timeout => timeout }) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y --version 2.6.2 git", { returns: [0], timeout: timeout }) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -363,7 +363,7 @@ munin-node|1.6.1.20130823 it "upgrading multiple packages uses a single command" do allow_remote_list(%w{conemu git}) new_resource.package_name(%w{conemu git}) - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu git", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu git", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action end @@ -415,7 +415,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["ConEmu"]) new_resource.package_name("ConEmu") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y ConEmu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y ConEmu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -424,7 +424,7 @@ munin-node|1.6.1.20130823 allow_remote_list(["conemu"]) new_resource.package_name("conemu") provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -434,7 +434,7 @@ munin-node|1.6.1.20130823 allow_remote_list(%w{git conemu}) new_resource.package_name(%w{git conemu}) provider.load_current_resource - expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { :returns => [0], :timeout => timeout }).and_return(double) + expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -457,7 +457,7 @@ describe "behavior when Chocolatey is not installed" do provider.instance_variable_set("@choco_install_path", nil) # we don't care what this returns, but we have to let it be called. - allow(provider).to receive(:shell_out_compacted!).and_return(double(:stdout => "")) + allow(provider).to receive(:shell_out_compacted!).and_return(double(stdout: "")) end let(:error_regex) do diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb index c99e91dd46..9df19f0f1b 100644 --- a/spec/unit/provider/package/dpkg_spec.rb +++ b/spec/unit/provider/package/dpkg_spec.rb @@ -31,23 +31,23 @@ describe Chef::Provider::Package::Dpkg do let(:provider) { Chef::Provider::Package::Dpkg.new(new_resource, run_context) } let(:dpkg_deb_version) { "1.11.4" } - let(:dpkg_deb_status) { status = double(:stdout => "#{package}\t#{dpkg_deb_version}", :exitstatus => 0) } + let(:dpkg_deb_status) { status = double(stdout: "#{package}\t#{dpkg_deb_version}", exitstatus: 0) } let(:dpkg_s_version) { "1.11.4-1ubuntu1" } let(:dpkg_s_status) do - stdout = <<-DPKG_S -Package: #{package} -Status: install ok installed -Priority: important -Section: web -Installed-Size: 1944 -Maintainer: Ubuntu Core developers <ubuntu-devel-discuss@lists.ubuntu.com> -Architecture: amd64 -Version: #{dpkg_s_version} -Config-Version: #{dpkg_s_version} -Depends: libc6 (>= 2.8~20080505), libssl0.9.8 (>= 0.9.8f-5) -Conflicts: wget-ssl + stdout = <<~DPKG_S + Package: #{package} + Status: install ok installed + Priority: important + Section: web + Installed-Size: 1944 + Maintainer: Ubuntu Core developers <ubuntu-devel-discuss@lists.ubuntu.com> + Architecture: amd64 + Version: #{dpkg_s_version} + Config-Version: #{dpkg_s_version} + Depends: libc6 (>= 2.8~20080505), libssl0.9.8 (>= 0.9.8f-5) + Conflicts: wget-ssl DPKG_S - status = double(:stdout => stdout, :exitstatus => 1) + status = double(stdout: stdout, exitstatus: 1) end before(:each) do @@ -112,7 +112,7 @@ Conflicts: wget-ssl describe "gets the source package version from dpkg-deb" do def check_version(version) - status = double(:stdout => "wget\t#{version}", :exitstatus => 0) + status = double(stdout: "wget\t#{version}", exitstatus: 0) expect(provider).to receive(:shell_out_compacted!).with("dpkg-deb", "-W", source, timeout: 900).and_return(status) provider.load_current_resource expect(provider.current_resource.package_name).to eq(["wget"]) @@ -172,10 +172,10 @@ Conflicts: wget-ssl it "on new debian/ubuntu we get an exit(1) and no stdout from dpkg -s for uninstalled" do dpkg_s_status = double( - exitstatus: 1, stdout: "", stderr: <<-EOF -dpkg-query: package '#{package}' is not installed and no information is available -Use dpkg --info (= dpkg-deb --info) to examine archive files, -and dpkg --contents (= dpkg-deb --contents) to list their contents. + exitstatus: 1, stdout: "", stderr: <<~EOF + dpkg-query: package '#{package}' is not installed and no information is available + Use dpkg --info (= dpkg-deb --info) to examine archive files, + and dpkg --contents (= dpkg-deb --contents) to list their contents. EOF ) expect(provider).to receive(:shell_out_compacted!).with("dpkg", "-s", package, returns: [0, 1], timeout: 900).and_return(dpkg_s_status) @@ -185,11 +185,11 @@ and dpkg --contents (= dpkg-deb --contents) to list their contents. it "on old debian/ubuntu we get an exit(0) and we get info on stdout from dpkg -s for uninstalled" do dpkg_s_status = double( - exitstatus: 0, stderr: "", stdout: <<-EOF -Package: #{package} -Status: unknown ok not-installed -Priority: extra -Section: ruby + exitstatus: 0, stderr: "", stdout: <<~EOF + Package: #{package} + Status: unknown ok not-installed + Priority: extra + Section: ruby EOF ) expect(provider).to receive(:shell_out_compacted!).with("dpkg", "-s", package, returns: [0, 1], timeout: 900).and_return(dpkg_s_status) @@ -206,7 +206,7 @@ Section: ruby end it "should raise an exception if dpkg-deb -W fails to run" do - status = double(:stdout => "", :exitstatus => -1) + status = double(stdout: "", exitstatus: -1) expect(provider).to receive(:shell_out_compacted!).with("dpkg-deb", "-W", "/tmp/wget_1.11.4-1ubuntu1_amd64.deb", timeout: 900).and_raise(Mixlib::ShellOut::ShellCommandFailed) expect { provider.load_current_resource }.to raise_error(Mixlib::ShellOut::ShellCommandFailed) end diff --git a/spec/unit/provider/package/freebsd/pkg_spec.rb b/spec/unit/provider/package/freebsd/pkg_spec.rb index 259bd7a4c4..8c3e25a0f9 100644 --- a/spec/unit/provider/package/freebsd/pkg_spec.rb +++ b/spec/unit/provider/package/freebsd/pkg_spec.rb @@ -66,33 +66,33 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do describe "when querying for package state and attributes" do before do - #@new_resource = Chef::Resource::Package.new("zsh") + # @new_resource = Chef::Resource::Package.new("zsh") - #@provider = Chef::Provider::Package::Freebsd::Pkg.new(@node, @new_resource) + # @provider = Chef::Provider::Package::Freebsd::Pkg.new(@node, @new_resource) - #@status = double("Status", :exitstatus => 0) - #@stdin = double("STDIN", :null_object => true) - #@stdout = double("STDOUT", :null_object => true) - #@stderr = double("STDERR", :null_object => true) - #@pid = double("PID", :null_object => true) + # @status = double("Status", :exitstatus => 0) + # @stdin = double("STDIN", :null_object => true) + # @stdout = double("STDOUT", :null_object => true) + # @stderr = double("STDERR", :null_object => true) + # @pid = double("PID", :null_object => true) end it "should return the version number when it is installed" do - pkg_info = OpenStruct.new(:stdout => "zsh-4.3.6_7") + pkg_info = OpenStruct.new(stdout: "zsh-4.3.6_7") expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info) allow(@provider).to receive(:package_name).and_return("zsh") expect(@provider.current_installed_version).to eq("4.3.6_7") end it "does not set the current version number when the package is not installed" do - pkg_info = OpenStruct.new(:stdout => "") + pkg_info = OpenStruct.new(stdout: "") expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info) allow(@provider).to receive(:package_name).and_return("zsh") expect(@provider.current_installed_version).to be_nil end it "should return the port path for a valid port name" do - whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh") + whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh") expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis) allow(@provider).to receive(:port_name).and_return("zsh") expect(@provider.port_path).to eq("/usr/ports/shells/zsh") @@ -101,7 +101,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do # Not happy with the form of these tests as they are far too closely tied to the implementation and so very fragile. it "should return the ports candidate version when given a valid port path" do allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh") - make_v = OpenStruct.new(:stdout => "4.3.6\n", :exitstatus => 0) + make_v = OpenStruct.new(stdout: "4.3.6\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PORTVERSION", { cwd: "/usr/ports/shells/zsh", returns: [0, 1], env: nil, timeout: 900 }).and_return(make_v) expect(@provider.ports_candidate_version).to eq("4.3.6") end @@ -109,16 +109,16 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do it "should figure out the package name when we have ports" do allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true) allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh") - make_v = OpenStruct.new(:stdout => "zsh-4.3.6_7\n", :exitstatus => 0) + make_v = OpenStruct.new(stdout: "zsh-4.3.6_7\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PKGNAME", { cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900 }).and_return(make_v) - #@provider.should_receive(:ports_makefile_variable_value).with("PKGNAME").and_return("zsh-4.3.6_7") + # @provider.should_receive(:ports_makefile_variable_value).with("PKGNAME").and_return("zsh-4.3.6_7") expect(@provider.package_name).to eq("zsh") end end describe Chef::Provider::Package::Freebsd::Pkg, "install_package" do before(:each) do - @cmd_result = OpenStruct.new(:status => true) + @cmd_result = OpenStruct.new(status: true) @provider.current_resource = @current_resource allow(@provider).to receive(:package_name).and_return("zsh") @@ -134,14 +134,14 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do describe Chef::Provider::Package::Freebsd::Pkg, "port path" do before do - #@node = Chef::Node.new + # @node = Chef::Node.new @new_resource = Chef::Resource::Package.new("zsh") @new_resource.cookbook_name = "adventureclub" @provider = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context) end it "should figure out the port path from the package_name using whereis" do - whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh") + whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh") expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis) expect(@provider.port_path).to eq("/usr/ports/shells/zsh") end @@ -174,7 +174,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do allow(@provider).to receive(:package_name).and_return("ruby18-iconv") allow(@provider).to receive(:latest_link_name).and_return("ruby18-iconv") - @install_result = OpenStruct.new(:status => true) + @install_result = OpenStruct.new(status: true) end it "should run pkg_add -r with the package name" do @@ -185,7 +185,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do describe Chef::Provider::Package::Freebsd::Pkg, "remove_package" do before(:each) do - @pkg_delete = OpenStruct.new(:status => true) + @pkg_delete = OpenStruct.new(status: true) @new_resource.version "4.3.6_7" @current_resource.version "4.3.6_7" @provider.current_resource = @current_resource @@ -212,14 +212,14 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do end it "should return the port path for a valid port name" do - whereis = OpenStruct.new(:stdout => "bonnie++: /usr/ports/benchmarks/bonnie++") + whereis = OpenStruct.new(stdout: "bonnie++: /usr/ports/benchmarks/bonnie++") expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "bonnie++", env: nil, timeout: 900).and_return(whereis) allow(@provider).to receive(:port_name).and_return("bonnie++") expect(@provider.port_path).to eq("/usr/ports/benchmarks/bonnie++") end it "should return the version number when it is installed" do - pkg_info = OpenStruct.new(:stdout => "bonnie++-1.96") + pkg_info = OpenStruct.new(stdout: "bonnie++-1.96") expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "bonnie++*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info) allow(@provider).to receive(:package_name).and_return("bonnie++") expect(@provider.current_installed_version).to eq("1.96") @@ -252,7 +252,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do allow(@provider).to receive(:package_name).and_return("perl") allow(@provider).to receive(:latest_link_name).and_return("perl") - cmd = OpenStruct.new(:status => true) + cmd = OpenStruct.new(status: true) expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "perl", env: nil, timeout: 900).and_return(cmd) @provider.install_package("perl5.8", "5.8.8_1") end @@ -266,7 +266,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do allow(@provider).to receive(:package_name).and_return("mysql-server") allow(@provider).to receive(:latest_link_name).and_return("mysql50-server") - cmd = OpenStruct.new(:status => true) + cmd = OpenStruct.new(status: true) expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "mysql50-server", env: nil, timeout: 900).and_return(cmd) @provider.install_package("mysql50-server", "5.0.45_1") end diff --git a/spec/unit/provider/package/freebsd/pkgng_spec.rb b/spec/unit/provider/package/freebsd/pkgng_spec.rb index 2fdcb87758..13e5dd17fd 100644 --- a/spec/unit/provider/package/freebsd/pkgng_spec.rb +++ b/spec/unit/provider/package/freebsd/pkgng_spec.rb @@ -63,7 +63,7 @@ describe Chef::Provider::Package::Freebsd::Port do describe "determining current installed version" do before(:each) do allow(@provider).to receive(:supports_pkgng?) - @pkg_info = OpenStruct.new(:stdout => "zsh-3.1.7\nVersion : 3.1.7\n") + @pkg_info = OpenStruct.new(stdout: "zsh-3.1.7\nVersion : 3.1.7\n") end it "should query pkg database" do @@ -74,14 +74,14 @@ describe Chef::Provider::Package::Freebsd::Port do describe "determining candidate version" do it "should query repository" do - pkg_query = OpenStruct.new(:stdout => "5.0.5\n", :exitstatus => 0) + pkg_query = OpenStruct.new(stdout: "5.0.5\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with("pkg", "rquery", "%v", "zsh", env: nil, timeout: 900).and_return(pkg_query) expect(@provider.candidate_version).to eq("5.0.5") end it "should query specified repository when given option" do @provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration. - pkg_query = OpenStruct.new(:stdout => "5.0.3\n", :exitstatus => 0) + pkg_query = OpenStruct.new(stdout: "5.0.3\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted!).with("pkg", "rquery", "-r", "LocalMirror", "%v", "zsh", env: nil, timeout: 900).and_return(pkg_query) expect(@provider.candidate_version).to eq("5.0.3") end @@ -94,54 +94,54 @@ describe Chef::Provider::Package::Freebsd::Port do describe "installing a binary package" do before(:each) do - @install_result = OpenStruct.new(:status => true) + @install_result = OpenStruct.new(status: true) end it "should handle package source from file" do @provider.new_resource.source("/nas/pkg/repo/zsh-5.0.1.txz") - expect(@provider).to receive(:shell_out_compacted!). - with("pkg", "add", "/nas/pkg/repo/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900). - and_return(@install_result) + expect(@provider).to receive(:shell_out_compacted!) + .with("pkg", "add", "/nas/pkg/repo/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900) + .and_return(@install_result) @provider.install_package("zsh", "5.0.1") end it "should handle package source over ftp or http" do @provider.new_resource.source("http://repo.example.com/zsh-5.0.1.txz") - expect(@provider).to receive(:shell_out_compacted!). - with("pkg", "add", "http://repo.example.com/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900). - and_return(@install_result) + expect(@provider).to receive(:shell_out_compacted!) + .with("pkg", "add", "http://repo.example.com/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900) + .and_return(@install_result) @provider.install_package("zsh", "5.0.1") end it "should handle a package name" do - expect(@provider).to receive(:shell_out_compacted!). - with("pkg", "install", "-y", "zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result) + expect(@provider).to receive(:shell_out_compacted!) + .with("pkg", "install", "-y", "zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result) @provider.install_package("zsh", "5.0.1") end it "should handle a package name with a specified repo" do @provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration. - expect(@provider).to receive(:shell_out_compacted!). - with("pkg", "install", "-y", "-r", "LocalMirror", "zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result) + expect(@provider).to receive(:shell_out_compacted!) + .with("pkg", "install", "-y", "-r", "LocalMirror", "zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result) @provider.install_package("zsh", "5.0.1") end end describe "removing a binary package" do before(:each) do - @install_result = OpenStruct.new(:status => true) + @install_result = OpenStruct.new(status: true) end it "should call pkg delete" do - expect(@provider).to receive(:shell_out_compacted!). - with("pkg", "delete", "-y", "zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result) + expect(@provider).to receive(:shell_out_compacted!) + .with("pkg", "delete", "-y", "zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result) @provider.remove_package("zsh", "5.0.1") end it "should not include repo option in pkg delete" do @provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration. - expect(@provider).to receive(:shell_out_compacted!). - with("pkg", "delete", "-y", "zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result) + expect(@provider).to receive(:shell_out_compacted!) + .with("pkg", "delete", "-y", "zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result) @provider.remove_package("zsh", "5.0.1") end end diff --git a/spec/unit/provider/package/freebsd/port_spec.rb b/spec/unit/provider/package/freebsd/port_spec.rb index 26a960dedc..af5216dc04 100644 --- a/spec/unit/provider/package/freebsd/port_spec.rb +++ b/spec/unit/provider/package/freebsd/port_spec.rb @@ -62,7 +62,7 @@ describe Chef::Provider::Package::Freebsd::Port do describe "determining current installed version" do before(:each) do - @pkg_info = OpenStruct.new(:stdout => "zsh-3.1.7\n") + @pkg_info = OpenStruct.new(stdout: "zsh-3.1.7\n") end it "should check 'pkg_info' if system uses pkg_* tools" do @@ -73,7 +73,7 @@ describe Chef::Provider::Package::Freebsd::Port do end it "should check 'pkg info' if make supports WITH_PKGNG if freebsd version is < 1000017" do - pkg_enabled = OpenStruct.new(:stdout => "yes\n") + pkg_enabled = OpenStruct.new(stdout: "yes\n") [1000016, 1000000, 901503, 902506, 802511].each do |freebsd_version| @node.automatic_attrs[:os_version] = freebsd_version expect(@new_resource).to receive(:shell_out_compacted!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled) @@ -92,14 +92,14 @@ describe Chef::Provider::Package::Freebsd::Port do describe "determining candidate version" do before(:each) do - @port_version = OpenStruct.new(:stdout => "5.0.5\n", :exitstatus => 0) + @port_version = OpenStruct.new(stdout: "5.0.5\n", exitstatus: 0) end it "should return candidate version if port exists" do 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_compacted!).with("make", "-V", "PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900). - and_return(@port_version) + expect(@provider).to receive(:shell_out_compacted!).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 @@ -121,13 +121,13 @@ describe Chef::Provider::Package::Freebsd::Port do end it "should query system for path given just a name" do - whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh\n") + whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh\n") expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis) expect(@provider.port_dir).to eq("/usr/ports/shells/zsh") end it "should raise exception if not found" do - whereis = OpenStruct.new(:stdout => "zsh:\n") + whereis = OpenStruct.new(stdout: "zsh:\n") expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis) expect { @provider.port_dir }.to raise_error(Chef::Exceptions::Package, "Could not find port with the name zsh") end @@ -135,28 +135,28 @@ describe Chef::Provider::Package::Freebsd::Port do describe "building a binary package" do before(:each) do - @install_result = OpenStruct.new(:status => true) + @install_result = OpenStruct.new(status: true) end it "should run make install in port directory" do allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh") - expect(@provider).to receive(:shell_out_compacted!). - with("make", "-DBATCH", "install", "clean", :timeout => 1800, :cwd => "/usr/ports/shells/zsh", :env => nil). - and_return(@install_result) + expect(@provider).to receive(:shell_out_compacted!) + .with("make", "-DBATCH", "install", "clean", timeout: 1800, cwd: "/usr/ports/shells/zsh", env: nil) + .and_return(@install_result) @provider.install_package("zsh", "5.0.5") end end describe "removing a binary package" do before(:each) do - @install_result = OpenStruct.new(:status => true) + @install_result = OpenStruct.new(status: true) end it "should run make deinstall in port directory" do allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh") - expect(@provider).to receive(:shell_out_compacted!). - with("make", "deinstall", :timeout => 300, :cwd => "/usr/ports/shells/zsh", :env => nil). - and_return(@install_result) + expect(@provider).to receive(:shell_out_compacted!) + .with("make", "deinstall", timeout: 300, cwd: "/usr/ports/shells/zsh", env: nil) + .and_return(@install_result) @provider.remove_package("zsh", "5.0.5") end end diff --git a/spec/unit/provider/package/homebrew_spec.rb b/spec/unit/provider/package/homebrew_spec.rb index 833fa7bd3e..903aebc93e 100644 --- a/spec/unit/provider/package/homebrew_spec.rb +++ b/spec/unit/provider/package/homebrew_spec.rb @@ -173,16 +173,16 @@ describe Chef::Provider::Package::Homebrew do describe "brew" do before do expect(provider).to receive(:find_homebrew_uid).and_return(homebrew_uid) - expect(Etc).to receive(:getpwuid).with(homebrew_uid).and_return(OpenStruct.new(:name => "name", :dir => "/")) + expect(Etc).to receive(:getpwuid).with(homebrew_uid).and_return(OpenStruct.new(name: "name", dir: "/")) end it "passes a single to the brew command and return stdout" do - allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo")) + allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "zombo")) expect(provider.brew).to eql("zombo") end it "takes multiple arguments as an array" do - allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "homestarrunner")) + allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "homestarrunner")) expect(provider.brew("info", "opts", "bananas")).to eql("homestarrunner") end @@ -190,7 +190,7 @@ describe Chef::Provider::Package::Homebrew do let(:new_resource) { Chef::Resource::Package.new("emacs") } it "does not try to read homebrew_user from Package, which does not have it" do - allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo")) + allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "zombo")) expect(provider.brew).to eql("zombo") end end diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb index eac0fd90f3..70e1c3fe32 100644 --- a/spec/unit/provider/package/ips_spec.rb +++ b/spec/unit/provider/package/ips_spec.rb @@ -35,31 +35,31 @@ describe Chef::Provider::Package::Ips do def local_output stdin = StringIO.new stdout = "" - stderr = <<-PKG_STATUS -pkg: info: no packages matching the following patterns you specified are -installed on the system. Try specifying -r to query remotely: + 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 + crypto/gnupg PKG_STATUS - OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 1) + OpenStruct.new(stdout: stdout, stdin: stdin, stderr: stderr, status: @status, exitstatus: 1) end def remote_output - stdout = <<-PKG_STATUS - Name: security/sudo - Summary: sudo - authority delegation tool - State: Not Installed - Publisher: omnios - Version: 1.8.4.1 (1.8.4p1) - Build Release: 5.11 - Branch: 0.151002 -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 + stdout = <<~PKG_STATUS + Name: security/sudo + Summary: sudo - authority delegation tool + State: Not Installed + Publisher: omnios + Version: 1.8.4.1 (1.8.4p1) + Build Release: 5.11 + Branch: 0.151002 + 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 = "" - OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 0) + OpenStruct.new(stdout: stdout, stdin: stdin, stderr: stderr, status: @status, exitstatus: 0) end context "when loading current resource" do @@ -92,20 +92,20 @@ PKG_STATUS it "should set the installed version if package has one" do local = local_output - local.stdout = <<-INSTALLED - Name: crypto/gnupg - Summary: GNU Privacy Guard - Description: A complete and free implementation of the OpenPGP Standard as - defined by RFC4880. - Category: Applications/System Utilities - State: Installed - Publisher: solaris - Version: 2.0.17 - Build Release: 5.11 - Branch: 0.175.0.0.0.2.537 -Packaging Date: October 19, 2011 09:14:50 AM - Size: 8.07 MB - FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z + local.stdout = <<~INSTALLED + Name: crypto/gnupg + Summary: GNU Privacy Guard + Description: A complete and free implementation of the OpenPGP Standard as + defined by RFC4880. + Category: Applications/System Utilities + State: Installed + Publisher: solaris + Version: 2.0.17 + Build Release: 5.11 + Branch: 0.175.0.0.0.2.537 + Packaging Date: October 19, 2011 09:14:50 AM + Size: 8.07 MB + FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z INSTALLED expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local) expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output) @@ -140,17 +140,17 @@ INSTALLED it "should not include the human-readable version in the candidate_version" do remote = remote_output - remote.stdout = <<-PKG_STATUS - Name: security/sudo - Summary: sudo - authority delegation tool - State: Not Installed - Publisher: omnios - Version: 1.8.4.1 (1.8.4p1) - Build Release: 5.11 - Branch: 0.151002 -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 + remote.stdout = <<~PKG_STATUS + Name: security/sudo + Summary: sudo - authority delegation tool + State: Not Installed + Publisher: omnios + Version: 1.8.4.1 (1.8.4p1) + Build Release: 5.11 + Branch: 0.151002 + 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 expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output) expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote) @@ -161,36 +161,36 @@ PKG_STATUS it "should not upgrade the package if it is already installed" do local = local_output - local.stdout = <<-INSTALLED - Name: crypto/gnupg - Summary: GNU Privacy Guard - Description: A complete and free implementation of the OpenPGP Standard as - defined by RFC4880. - Category: Applications/System Utilities - State: Installed - Publisher: solaris - Version: 2.0.17 - Build Release: 5.11 - Branch: 0.175.0.0.0.2.537 -Packaging Date: October 19, 2011 09:14:50 AM - Size: 8.07 MB - FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z + local.stdout = <<~INSTALLED + Name: crypto/gnupg + Summary: GNU Privacy Guard + Description: A complete and free implementation of the OpenPGP Standard as + defined by RFC4880. + Category: Applications/System Utilities + State: Installed + Publisher: solaris + Version: 2.0.17 + Build Release: 5.11 + Branch: 0.175.0.0.0.2.537 + Packaging Date: October 19, 2011 09:14:50 AM + Size: 8.07 MB + FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z INSTALLED remote = remote_output - remote.stdout = <<-REMOTE - Name: crypto/gnupg - Summary: GNU Privacy Guard - Description: A complete and free implementation of the OpenPGP Standard as - defined by RFC4880. - Category: Applications/System Utilities - State: Not Installed - Publisher: solaris - Version: 2.0.18 - Build Release: 5.11 - Branch: 0.175.0.0.0.2.537 -Packaging Date: October 19, 2011 09:14:50 AM - Size: 8.07 MB - FMRI: pkg://solaris/crypto/gnupg@2.0.18,5.11-0.175.0.0.0.2.537:20111019T091450Z + remote.stdout = <<~REMOTE + Name: crypto/gnupg + Summary: GNU Privacy Guard + Description: A complete and free implementation of the OpenPGP Standard as + defined by RFC4880. + Category: Applications/System Utilities + State: Not Installed + Publisher: solaris + Version: 2.0.18 + Build Release: 5.11 + Branch: 0.175.0.0.0.2.537 + Packaging Date: October 19, 2011 09:14:50 AM + Size: 8.07 MB + FMRI: pkg://solaris/crypto/gnupg@2.0.18,5.11-0.175.0.0.0.2.537:20111019T091450Z REMOTE expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local) diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb index 04e0a9177e..8b75e40d72 100644 --- a/spec/unit/provider/package/macports_spec.rb +++ b/spec/unit/provider/package/macports_spec.rb @@ -70,18 +70,18 @@ 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 -The following ports are currently installed: - openssl @0.9.8k_0 (active) + stdout = <<~EOF + The following ports are currently installed: + openssl @0.9.8k_0 (active) EOF - status = double(:stdout => stdout, :exitstatus => 0) + status = double(stdout: stdout, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.current_installed_version).to eq("0.9.8k_0") end it "should return nil if a package is not currently installed" do - status = double(:stdout => " \n", :exitstatus => 0) + status = double(stdout: " \n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.current_installed_version).to be_nil end @@ -89,13 +89,13 @@ EOF describe "macports_candidate_version" do it "should return the latest available version of a given package" do - status = double(:stdout => "version: 4.2.7\n", :exitstatus => 0) + status = double(stdout: "version: 4.2.7\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.macports_candidate_version).to eq("4.2.7") end it "should return nil if there is no version for a given package" do - status = double(:stdout => "Error: port fadsfadsfads not found\n", :exitstatus => 0) + status = double(stdout: "Error: port fadsfadsfads not found\n", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.macports_candidate_version).to be_nil end diff --git a/spec/unit/provider/package/msu_spec.rb b/spec/unit/provider/package/msu_spec.rb index de805fcb39..b2f0b22963 100644 --- a/spec/unit/provider/package/msu_spec.rb +++ b/spec/unit/provider/package/msu_spec.rb @@ -31,66 +31,66 @@ describe Chef::Provider::Package::Msu, :windows_only do end let(:installed_package_list_stdout) do - <<-EOF -Packages listing: -Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0 -Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0 + <<~EOF + Packages listing: + Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0 + Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0 EOF end let(:package_version_stdout) do - <<-EOF -Package information: -Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 -State : Installed -Dependency : Language Pack -The operation completed successfully + <<~EOF + Package information: + Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 + State : Installed + Dependency : Language Pack + The operation completed successfully EOF end let(:get_package_info_stdout) do - <<-EOF -Deployment Image Servicing and Management tool -Version: 6.1.7600.16385 - -Image Version: 6.1.7600.16385 - -Package information: -Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 -Applicable : Yes -Copyright : Microsoft Corporation -Company : Microsoft Corporation -State : Installed -Dependency : Language Pack -The operation completed successfully + <<~EOF + Deployment Image Servicing and Management tool + Version: 6.1.7600.16385 + + Image Version: 6.1.7600.16385 + + Package information: + Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 + Applicable : Yes + Copyright : Microsoft Corporation + Company : Microsoft Corporation + State : Installed + Dependency : Language Pack + The operation completed successfully EOF end def allow_get_packages - get_packages_stdout = <<-EOF -Deployment Image Servicing and Management tool -Version: 6.1.7600.16385 + get_packages_stdout = <<~EOF + Deployment Image Servicing and Management tool + Version: 6.1.7600.16385 -Image Version: 6.1.7600.16385 + Image Version: 6.1.7600.16385 -Packages listing: + Packages listing: -Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0 -State : Installed -Release Type : Language Pack -Install Time : 2/11/2015 11:33 PM + Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0 + State : Installed + Release Type : Language Pack + Install Time : 2/11/2015 11:33 PM -Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0 -State : Installed -Release Type : Language Pack -Install Time : 2/11/2015 11:33 PM + Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0 + State : Installed + Release Type : Language Pack + Install Time : 2/11/2015 11:33 PM -Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 -State : Installed -Release Type : Feature Pack -Install Time : 11/21/2010 3:40 AM + Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0 + State : Installed + Release Type : Feature Pack + Install Time : 11/21/2010 3:40 AM -The operation completed successfully. + The operation completed successfully. EOF get_packages_obj = double(stdout: get_packages_stdout) allow_any_instance_of(Chef::Provider::Package::Cab).to receive(:dism_command).with("/Get-Packages").and_return(get_packages_obj) diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb index 07950acf6e..01d6571f65 100644 --- a/spec/unit/provider/package/openbsd_spec.rb +++ b/spec/unit/provider/package/openbsd_spec.rb @@ -45,7 +45,7 @@ describe Chef::Provider::Package::Openbsd do context "when not already installed" do before do - allow(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{name}->0", anything()).and_return(instance_double("shellout", :stdout => "")) + allow(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{name}->0", anything()).and_return(instance_double("shellout", stdout: "")) end context "when there is a single candidate" do @@ -53,11 +53,11 @@ describe Chef::Provider::Package::Openbsd do context "when source is not provided" do it "should run the installation command" do expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return( - instance_double("shellout", :stdout => "#{name}-#{version}\n")) + instance_double("shellout", stdout: "#{name}-#{version}\n")) expect(provider).to receive(:shell_out_compacted!).with( "pkg_add", "-r", "#{name}-#{version}", - { :env => { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 } - ) { OpenStruct.new :status => true } + { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 } + ) { OpenStruct.new status: true } provider.run_action(:install) end end @@ -70,7 +70,7 @@ describe Chef::Provider::Package::Openbsd do context "if no version is specified" do it "should raise an exception" do expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return( - instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n")) + instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n")) expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /multiple matching candidates/) end end @@ -83,13 +83,13 @@ describe Chef::Provider::Package::Openbsd do context "if no version is specified" do it "should run the installation command" do - expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{package_name}->0", anything()).and_return(instance_double("shellout", :stdout => "")) + expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{package_name}->0", anything()).and_return(instance_double("shellout", stdout: "")) expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return( - instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor}\n")) + instance_double("shellout", stdout: "#{name}-#{version}-#{flavor}\n")) expect(provider).to receive(:shell_out_compacted!).with( "pkg_add", "-r", "#{name}-#{version}-#{flavor}", { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 } - ) { OpenStruct.new :status => true } + ) { OpenStruct.new status: true } provider.run_action(:install) end end @@ -99,13 +99,13 @@ describe Chef::Provider::Package::Openbsd do context "if a version is specified" do it "should use the flavor from the version" do expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", "#{name}-#{version}-#{flavor_b}", anything()).and_return( - instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n")) + instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n")) new_resource.version("#{version}-#{flavor_b}") expect(provider).to receive(:shell_out_compacted!).with( "pkg_add", "-r", "#{name}-#{version}-#{flavor_b}", { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 } - ) { OpenStruct.new :status => true } + ) { OpenStruct.new status: true } provider.run_action(:install) end end @@ -124,7 +124,7 @@ describe Chef::Provider::Package::Openbsd do it "should run the command to delete the installed package" do expect(@provider).to receive(:shell_out_compacted!).with( "pkg_delete", @name, env: nil, timeout: 900 - ) { OpenStruct.new :status => true } + ) { OpenStruct.new status: true } @provider.remove_package(@name, nil) end end diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb index d41df8c24b..10bb3492b2 100644 --- a/spec/unit/provider/package/pacman_spec.rb +++ b/spec/unit/provider/package/pacman_spec.rb @@ -26,14 +26,14 @@ describe Chef::Provider::Package::Pacman do @new_resource = Chef::Resource::Package.new("nano") @current_resource = Chef::Resource::Package.new("nano") - @status = double(:stdout => "", :exitstatus => 0) + @status = double(stdout: "", exitstatus: 0) @provider = Chef::Provider::Package::Pacman.new(@new_resource, @run_context) allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource) allow(@provider).to receive(:shell_out_compacted).and_return(@status) @stdin = StringIO.new - @stdout = StringIO.new(<<-ERR) -error: package "nano" not found + @stdout = StringIO.new(<<~ERR) + error: package "nano" not found ERR @stderr = StringIO.new @pid = 2342 @@ -66,61 +66,61 @@ ERR end it "should set the installed version if pacman has one" do - stdout = <<-PACMAN -Name : nano -Version : 2.2.2-1 -URL : http://www.nano-editor.org -Licenses : GPL -Groups : base -Provides : None -Depends On : glibc ncurses -Optional Deps : None -Required By : None -Conflicts With : None -Replaces : None -Installed Size : 1496.00 K -Packager : Andreas Radke <andyrtr@archlinux.org> -Architecture : i686 -Build Date : Mon 18 Jan 2010 06:16:16 PM CET -Install Date : Mon 01 Feb 2010 10:06:30 PM CET -Install Reason : Explicitly installed -Install Script : Yes -Description : Pico editor clone with enhancements + stdout = <<~PACMAN + Name : nano + Version : 2.2.2-1 + URL : http://www.nano-editor.org + Licenses : GPL + Groups : base + Provides : None + Depends On : glibc ncurses + Optional Deps : None + Required By : None + Conflicts With : None + Replaces : None + Installed Size : 1496.00 K + Packager : Andreas Radke <andyrtr@archlinux.org> + Architecture : i686 + Build Date : Mon 18 Jan 2010 06:16:16 PM CET + Install Date : Mon 01 Feb 2010 10:06:30 PM CET + Install Reason : Explicitly installed + Install Script : Yes + Description : Pico editor clone with enhancements PACMAN - status = double(:stdout => stdout, :exitstatus => 0) + status = double(stdout: stdout, exitstatus: 0) allow(@provider).to receive(:shell_out_compacted).and_return(status) @provider.load_current_resource expect(@current_resource.version).to eq("2.2.2-1") end it "should set the candidate version if pacman has one" do - status = double(:stdout => "core nano 2.2.3-1", :exitstatus => 0) + status = double(stdout: "core nano 2.2.3-1", exitstatus: 0) allow(@provider).to receive(:shell_out_compacted).and_return(status) @provider.load_current_resource expect(@provider.candidate_version).to eql("2.2.3-1") end it "should use pacman.conf to determine valid repo names for package versions" do - @pacman_conf = <<-PACMAN_CONF -[options] -HoldPkg = pacman glibc -Architecture = auto + @pacman_conf = <<~PACMAN_CONF + [options] + HoldPkg = pacman glibc + Architecture = auto -[customrepo] -Server = https://my.custom.repo + [customrepo] + Server = https://my.custom.repo -[core] -Include = /etc/pacman.d/mirrorlist + [core] + Include = /etc/pacman.d/mirrorlist -[extra] -Include = /etc/pacman.d/mirrorlist + [extra] + Include = /etc/pacman.d/mirrorlist -[community] -Include = /etc/pacman.d/mirrorlist + [community] + Include = /etc/pacman.d/mirrorlist PACMAN_CONF - status = double(:stdout => "customrepo nano 1.2.3-4", :exitstatus => 0) + status = double(stdout: "customrepo nano 1.2.3-4", exitstatus: 0) allow(::File).to receive(:exist?).with("/etc/pacman.conf").and_return(true) allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(@pacman_conf) allow(@provider).to receive(:shell_out_compacted).and_return(status) diff --git a/spec/unit/provider/package/paludis_spec.rb b/spec/unit/provider/package/paludis_spec.rb index 5481a33c0d..10c0d0f7e8 100644 --- a/spec/unit/provider/package/paludis_spec.rb +++ b/spec/unit/provider/package/paludis_spec.rb @@ -33,16 +33,16 @@ describe Chef::Provider::Package::Paludis do @stdin = StringIO.new @stderr = StringIO.new - @stdout = <<-PKG_STATUS -group/ntp 0 accounts -group/ntp 0 installed-accounts -net/ntp 4.2.6_p5-r2 arbor -user/ntp 0 accounts -user/ntp 0 installed-accounts -net/ntp 4.2.6_p5-r1 installed + @stdout = <<~PKG_STATUS + group/ntp 0 accounts + group/ntp 0 installed-accounts + net/ntp 4.2.6_p5-r2 arbor + user/ntp 0 accounts + 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 @@ -64,13 +64,13 @@ PKG_STATUS end it "should return new version if package is installed" do - @stdout.replace(<<-INSTALLED) -group/ntp 0 accounts -group/ntp 0 installed-accounts -net/ntp 4.2.6_p5-r2 arbor -user/ntp 0 accounts -user/ntp 0 installed-accounts -net/ntp 4.2.6_p5-r1 installed + @stdout.replace(<<~INSTALLED) + group/ntp 0 accounts + group/ntp 0 installed-accounts + net/ntp 4.2.6_p5-r2 arbor + user/ntp 0 accounts + user/ntp 0 installed-accounts + net/ntp 4.2.6_p5-r1 installed INSTALLED expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out) @provider.load_current_resource @@ -86,29 +86,29 @@ INSTALLED context "when installing a package" do it "should run pkg install with the package name and version" do - expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 }) + expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 }) @provider.install_package("net/ntp", "4.2.6_p5-r2") end it "should run pkg install with the package name and version and options if specified" do - expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "--preserve-world", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 }) + expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "--preserve-world", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 }) @new_resource.options "--preserve-world" @provider.install_package("net/ntp", "4.2.6_p5-r2") end it "should not contain invalid characters for the version string" do - @stdout.replace(<<-PKG_STATUS) -sys-process/lsof 4.87 arbor -sys-process/lsof 4.87 x86_64 + @stdout.replace(<<~PKG_STATUS) + sys-process/lsof 4.87 arbor + sys-process/lsof 4.87 x86_64 PKG_STATUS - expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=sys-process/lsof-4.87", { :timeout => @new_resource.timeout || 900 }) + expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=sys-process/lsof-4.87", { timeout: @new_resource.timeout || 900 }) @provider.install_package("sys-process/lsof", "4.87") end it "should not include the human-readable version in the candidate_version" do - @stdout.replace(<<-PKG_STATUS) -sys-process/lsof 4.87 arbor -sys-process/lsof 4.87 x86_64 + @stdout.replace(<<~PKG_STATUS) + sys-process/lsof 4.87 arbor + sys-process/lsof 4.87 x86_64 PKG_STATUS expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out) @provider.load_current_resource @@ -119,7 +119,7 @@ PKG_STATUS context "when upgrading a package" do it "should run pkg install with the package name and version" do - expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 }) + expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 }) @provider.upgrade_package("net/ntp", "4.2.6_p5-r2") end end diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb index 7bf8e7f2e8..e1036bea74 100644 --- a/spec/unit/provider/package/portage_spec.rb +++ b/spec/unit/provider/package/portage_spec.rb @@ -113,33 +113,33 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do end it "should throw an exception if the exitstatus is not 0" do - status = double(:stdout => "", :stderr => "", :exitstatus => 1) + status = double(stdout: "", stderr: "", exitstatus: 1) allow(@provider).to receive(:shell_out_compacted).and_return(status) expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package) end it "should find the candidate_version if a category is specifed and there are no duplicates" do - status = double(:stdout => "dev-vcs/git-2.16.2", :exitstatus => 0) + status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.candidate_version).to eq("2.16.2") end it "should find the candidate_version if a category is not specifed and there are no duplicates" do - status = double(:stdout => "dev-vcs/git-2.16.2", :exitstatus => 0) + status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0) @provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider.candidate_version).to eq("2.16.2") end it "should throw an exception if a category is not specified and there are duplicates" do - stderr_output = <<EOF -You specified an unqualified atom that matched multiple packages: -* app-misc/sphinx -* dev-python/sphinx + stderr_output = <<~EOF + You specified an unqualified atom that matched multiple packages: + * app-misc/sphinx + * dev-python/sphinx -Please use a more specific atom. + Please use a more specific atom. EOF - status = double(:stdout => "", :stderr => stderr_output, :exitstatus => 1) + status = double(stdout: "", stderr: stderr_output, exitstatus: 1) @provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context) expect(@provider).to receive(:shell_out_compacted).and_return(status) expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package) diff --git a/spec/unit/provider/package/powershell_spec.rb b/spec/unit/provider/package/powershell_spec.rb index 63f611ac23..c7a16acaa2 100644 --- a/spec/unit/provider/package/powershell_spec.rb +++ b/spec/unit/provider/package/powershell_spec.rb @@ -34,63 +34,63 @@ describe Chef::Provider::Package::Powershell do end let(:package_xcertificate_installed) do - double("powershell_out", :stdout => "2.1.0.0\r\n") + double("powershell_out", stdout: "2.1.0.0\r\n") end let(:package_xcertificate_installed_2_0_0_0) do - double("powershell_out", :stdout => "2.0.0.0\r\n") + double("powershell_out", stdout: "2.0.0.0\r\n") end let(:package_xcertificate_available) do - double("powershell_out", :stdout => "2.1.0.0\r\n") + double("powershell_out", stdout: "2.1.0.0\r\n") end let(:package_xcertificate_available_2_0_0_0) do - double("powershell_out", :stdout => "2.0.0.0\r\n") + double("powershell_out", stdout: "2.0.0.0\r\n") end let(:package_xcertificate_not_installed) do - double("powershell_out", :stdout => "") + double("powershell_out", stdout: "") end let(:package_xcertificate_not_available) do - double("powershell_out", :stdout => "") + double("powershell_out", stdout: "") end let(:package_xnetworking_installed) do - double("powershell_out", :stdout => "2.12.0.0\r\n") + double("powershell_out", stdout: "2.12.0.0\r\n") end let(:package_xnetworking_installed_2_11_0_0) do - double("powershell_out", :stdout => "2.11.0.0\r\n") + double("powershell_out", stdout: "2.11.0.0\r\n") end let(:package_xnetworking_available) do - double("powershell_out", :stdout => "2.12.0.0\r\n") + double("powershell_out", stdout: "2.12.0.0\r\n") end let(:package_xnetworking_available_2_11_0_0) do - double("powershell_out", :stdout => "2.11.0.0\r\n") + double("powershell_out", stdout: "2.11.0.0\r\n") end let(:package_xnetworking_not_installed) do - double("powershell_out", :stdout => "") + double("powershell_out", stdout: "") end let(:package_xnetworking_not_available) do - double("powershell_out", :stdout => "") + double("powershell_out", stdout: "") end let(:package_7zip_available) do - double("powershell_out", :stdout => "16.02\r\n") + double("powershell_out", stdout: "16.02\r\n") end let(:package_7zip_not_installed) do - double("powershell_out", :stdout => "") + double("powershell_out", stdout: "") end let(:powershell_installed_version) do - double("powershell_out", :stdout => "5") + double("powershell_out", stdout: "5") end let(:generated_command) { "( Get-Package posh-git -Force -ForceBootstrap ).Version" } @@ -116,14 +116,14 @@ describe Chef::Provider::Package::Powershell do describe "#candidate_version" do it "should set the candidate_version to the latest version when not pinning" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) new_resource.package_name(["xNetworking"]) new_resource.version(nil) expect(provider.candidate_version).to eql(["2.12.0.0"]) end it "should use the candidate_version from the correct source" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) new_resource.package_name(["xNetworking"]) new_resource.version(nil) new_resource.source("MyGallery") @@ -131,60 +131,60 @@ describe Chef::Provider::Package::Powershell do end it "should set the candidate_version to the latest version when not pinning and package name is space seperated" do - allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_available) + allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available) new_resource.package_name(["7-Zip 16.02 (x64)"]) new_resource.version(nil) expect(provider.candidate_version).to eql(["16.02"]) end it "should set the candidate_version to pinned version if available" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.0.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.0.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0) new_resource.package_name(["xCertificate"]) new_resource.version(["2.0.0.0"]) expect(provider.candidate_version).to eql(["2.0.0.0"]) end it "should set the candidate_version to nil if there is no candidate" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) new_resource.package_name(["xCertificate"]) expect(provider.candidate_version).to eql([nil]) end it "should set the candidate_version correctly when there are two packages to install" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) expect(provider.candidate_version).to eql(["2.1.0.0", "2.12.0.0"]) end it "should set the candidate_version correctly when only the first is installable" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) expect(provider.candidate_version).to eql(["2.1.0.0", nil]) end it "should set the candidate_version correctly when only the last is installable" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) expect(provider.candidate_version).to eql([nil, "2.12.0.0"]) end it "should set the candidate_version correctly when neither are is installable and version is passed as nil array" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) new_resource.package_name(%w{xNetworking xCertificate}) new_resource.version([nil, nil]) expect(provider.candidate_version).to eql([nil, nil]) end it "should set the candidate_version correctly when neither are is installable and version is not passed" do - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) new_resource.package_name(%w{xNetworking xCertificate}) new_resource.version(nil) expect(provider.candidate_version).to eql([nil, nil]) @@ -283,10 +283,10 @@ describe Chef::Provider::Package::Powershell do provider.load_current_resource new_resource.package_name(["xCertificate"]) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -296,10 +296,10 @@ describe Chef::Provider::Package::Powershell do new_resource.package_name(["xCertificate"]) new_resource.version(nil) new_resource.source("MyGallery") - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout }) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -309,10 +309,10 @@ describe Chef::Provider::Package::Powershell do new_resource.package_name(["xCertificate"]) new_resource.version(nil) new_resource.skip_publisher_check(true) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -321,10 +321,10 @@ describe Chef::Provider::Package::Powershell do provider.load_current_resource new_resource.package_name(["7-Zip 16.02 (x64)"]) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_available) - allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_not_installed) + allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available) + allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_not_installed) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -RequiredVersion 16.02 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -RequiredVersion 16.02 ).Version", { timeout: new_resource.timeout }) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -336,10 +336,10 @@ describe Chef::Provider::Package::Powershell do provider.load_current_resource new_resource.package_name(["xCertificate"]) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -348,8 +348,8 @@ describe Chef::Provider::Package::Powershell do it "should not install packages that are up-to-date" do new_resource.package_name(["xCertificate"]) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource expect(provider).not_to receive(:install_package) @@ -360,8 +360,8 @@ describe Chef::Provider::Package::Powershell do it "should not install packages that are up-to-date" do new_resource.package_name(["xNetworking"]) new_resource.version(["2.11.0.0"]) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource expect(provider).not_to receive(:install_package) @@ -374,13 +374,13 @@ describe Chef::Provider::Package::Powershell do # new_version.resource[0] new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version([nil, "2.11.0.0"]) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }) provider.load_current_resource provider.run_action(:install) expect(new_resource).to be_updated_by_last_action @@ -389,13 +389,13 @@ describe Chef::Provider::Package::Powershell do it "should split up commands when given two packages, one with a version pin" do new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(["2.1.0.0", nil]) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout }) provider.load_current_resource provider.run_action(:install) @@ -405,13 +405,13 @@ describe Chef::Provider::Package::Powershell do it "should do multipackage installs when given two packages without constraints" do new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout }) provider.load_current_resource provider.run_action(:install) expect(new_resource).to be_updated_by_last_action @@ -421,13 +421,13 @@ describe Chef::Provider::Package::Powershell do new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) new_resource.source("MyGallery") - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout }) - expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout }) provider.load_current_resource provider.run_action(:install) expect(new_resource).to be_updated_by_last_action @@ -439,8 +439,8 @@ describe Chef::Provider::Package::Powershell do provider.load_current_resource new_resource.package_name(["xCertificate"]) new_resource.version(["2.1.0.0"]) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) expect(provider).not_to receive(:remove_package) provider.run_action(:remove) @@ -451,11 +451,11 @@ describe Chef::Provider::Package::Powershell do new_resource.package_name(["xCertificate"]) new_resource.version(["2.1.0.0"]) new_resource.source("MyGallery") - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource - expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -463,10 +463,10 @@ describe Chef::Provider::Package::Powershell do it "does nothing when all the packages are already removed" do new_resource.package_name(%w{xCertificate xNetworking}) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource expect(provider).not_to receive(:remove_package) @@ -477,11 +477,11 @@ describe Chef::Provider::Package::Powershell do it "removes a package when version is specified" do new_resource.package_name(["xCertificate"]) new_resource.version(["2.1.0.0"]) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource - expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }) + expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -489,11 +489,11 @@ describe Chef::Provider::Package::Powershell do it "removes a package when version is not specified" do new_resource.package_name(["xCertificate"]) new_resource.version(nil) - allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) - allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available) allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) provider.load_current_resource - expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb index 91d4ca69b4..3682043dcd 100644 --- a/spec/unit/provider/package/rpm_spec.rb +++ b/spec/unit/provider/package/rpm_spec.rb @@ -85,13 +85,13 @@ describe Chef::Provider::Package::Rpm do describe "when the package source is valid" do before do - expect(provider).to receive(:shell_out_compacted!). - with("rpm", "-qp", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_source, timeout: 900). - and_return(rpm_qp_status) + expect(provider).to receive(:shell_out_compacted!) + .with("rpm", "-qp", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_source, timeout: 900) + .and_return(rpm_qp_status) - expect(provider).to receive(:shell_out_compacted). - with("rpm", "-q", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_name, timeout: 900). - and_return(rpm_q_status) + expect(provider).to receive(:shell_out_compacted) + .with("rpm", "-q", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_name, timeout: 900) + .and_return(rpm_q_status) end context "when rpm fails when querying package installed state" do diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index 3b1a13e49c..6b33ab97f9 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -253,32 +253,32 @@ 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 -RubyGems Environment: - - RUBYGEMS VERSION: 1.3.6 - - RUBY VERSION: 1.8.7 (2010-05-12 patchlevel 249) [java] - - INSTALLATION DIRECTORY: /Users/you/.rvm/gems/jruby-1.5.0 - - RUBY EXECUTABLE: /Users/you/.rvm/rubies/jruby-1.5.0/bin/jruby - - EXECUTABLE DIRECTORY: /Users/you/.rvm/gems/jruby-1.5.0/bin - - RUBYGEMS PLATFORMS: - - ruby - - universal-java-1.6 - - GEM PATHS: - - /Users/you/.rvm/gems/jruby-1.5.0 - - /Users/you/.rvm/gems/jruby-1.5.0@global - - GEM CONFIGURATION: - - :update_sources => true - - :verbose => true - - :benchmark => false - - :backtrace => false - - :bulk_threshold => 1000 - - "install" => "--env-shebang" - - "update" => "--env-shebang" - - "gem" => "--no-rdoc --no-ri" - - :sources => ["https://rubygems.org/", "http://gems.github.com/"] - - REMOTE SOURCES: - - https://rubygems.org/ - - http://gems.github.com/ + gem_env_out = <<~JRUBY_GEM_ENV + RubyGems Environment: + - RUBYGEMS VERSION: 1.3.6 + - RUBY VERSION: 1.8.7 (2010-05-12 patchlevel 249) [java] + - INSTALLATION DIRECTORY: /Users/you/.rvm/gems/jruby-1.5.0 + - RUBY EXECUTABLE: /Users/you/.rvm/rubies/jruby-1.5.0/bin/jruby + - EXECUTABLE DIRECTORY: /Users/you/.rvm/gems/jruby-1.5.0/bin + - RUBYGEMS PLATFORMS: + - ruby + - universal-java-1.6 + - GEM PATHS: + - /Users/you/.rvm/gems/jruby-1.5.0 + - /Users/you/.rvm/gems/jruby-1.5.0@global + - GEM CONFIGURATION: + - :update_sources => true + - :verbose => true + - :benchmark => false + - :backtrace => false + - :bulk_threshold => 1000 + - "install" => "--env-shebang" + - "update" => "--env-shebang" + - "gem" => "--no-rdoc --no-ri" + - :sources => ["https://rubygems.org/", "http://gems.github.com/"] + - REMOTE SOURCES: + - https://rubygems.org/ + - http://gems.github.com/ JRUBY_GEM_ENV expect(@gem_env).to receive(:shell_out_compacted!).with("/usr/weird/bin/gem env").and_return(double("jruby_gem_env", stdout: gem_env_out)) expected = ["ruby", Gem::Platform.new("universal-java-1.6")] @@ -295,32 +295,32 @@ RubyGems Environment: end it "uses the current gem platforms when the target env is not jruby" do - 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] - - INSTALLATION DIRECTORY: /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514 - - RUBYGEMS PREFIX: /Users/ddeleo/.rvm/rubies/rbx-1.0.0-20100514 - - RUBY EXECUTABLE: /Users/ddeleo/.rvm/rubies/rbx-1.0.0-20100514/bin/rbx - - EXECUTABLE DIRECTORY: /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514/bin - - RUBYGEMS PLATFORMS: - - ruby - - x86_64-darwin-10 - - x86_64-rubinius-1.0 - - GEM PATHS: - - /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514 - - /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514@global - - GEM CONFIGURATION: - - :update_sources => true - - :verbose => true - - :benchmark => false - - :backtrace => false - - :bulk_threshold => 1000 - - :sources => ["https://rubygems.org/", "http://gems.github.com/"] - - "gem" => "--no-rdoc --no-ri" - - REMOTE SOURCES: - - https://rubygems.org/ - - http://gems.github.com/ + 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] + - INSTALLATION DIRECTORY: /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514 + - RUBYGEMS PREFIX: /Users/ddeleo/.rvm/rubies/rbx-1.0.0-20100514 + - RUBY EXECUTABLE: /Users/ddeleo/.rvm/rubies/rbx-1.0.0-20100514/bin/rbx + - EXECUTABLE DIRECTORY: /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514/bin + - RUBYGEMS PLATFORMS: + - ruby + - x86_64-darwin-10 + - x86_64-rubinius-1.0 + - GEM PATHS: + - /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514 + - /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514@global + - GEM CONFIGURATION: + - :update_sources => true + - :verbose => true + - :benchmark => false + - :backtrace => false + - :bulk_threshold => 1000 + - :sources => ["https://rubygems.org/", "http://gems.github.com/"] + - "gem" => "--no-rdoc --no-ri" + - REMOTE SOURCES: + - https://rubygems.org/ + - http://gems.github.com/ RBX_GEM_ENV expect(@gem_env).to receive(:shell_out_compacted!).with("/usr/weird/bin/gem env").and_return(double("rbx_gem_env", stdout: gem_env_out)) expect(@gem_env.gem_platforms).to eq(Gem.platforms) diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb index cb5e987a85..cd85e1b3d9 100644 --- a/spec/unit/provider/package/smartos_spec.rb +++ b/spec/unit/provider/package/smartos_spec.rb @@ -28,14 +28,14 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do @new_resource = Chef::Resource::Package.new("varnish") @current_resource = Chef::Resource::Package.new("varnish") - @status = double("Status", :exitstatus => 0) + @status = double("Status", exitstatus: 0) @provider = Chef::Provider::Package::SmartOS.new(@new_resource, @run_context) allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource) @stdin = StringIO.new @stdout = "varnish-2.1.5nb2\n" @stderr = StringIO.new @pid = 10 - @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0) + @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0) end describe "when loading current resource" do @@ -59,7 +59,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do end it "should set the installed version to nil if it's not installed" do - out = OpenStruct.new(:stdout => nil) + out = OpenStruct.new(stdout: nil) expect(@provider).to receive(:shell_out_compacted!).and_return(out) @provider.load_current_resource expect(@current_resource.version).to eq(nil) @@ -76,21 +76,21 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do it "should lookup the candidate_version if the variable is not already set (pkgin separated by spaces)" do search = double() - expect(search).to receive(:each_line). - and_yield("something-varnish-1.1.1 something varnish like\n"). - and_yield("varnish-2.3.4 actual varnish\n") - @shell_out = double("shell_out!", :stdout => search) - expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out) + expect(search).to receive(:each_line) + .and_yield("something-varnish-1.1.1 something varnish like\n") + .and_yield("varnish-2.3.4 actual varnish\n") + @shell_out = double("shell_out!", stdout: search) + expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", env: nil, returns: [0, 1], timeout: 900).and_return(@shell_out) expect(@provider.candidate_version).to eq("2.3.4") end it "should lookup the candidate_version if the variable is not already set (pkgin separated by semicolons)" do search = double() - expect(search).to receive(:each_line). - and_yield("something-varnish-1.1.1;;something varnish like\n"). - and_yield("varnish-2.3.4;;actual varnish\n") - @shell_out = double("shell_out!", :stdout => search) - expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out) + expect(search).to receive(:each_line) + .and_yield("something-varnish-1.1.1;;something varnish like\n") + .and_yield("varnish-2.3.4;;actual varnish\n") + @shell_out = double("shell_out!", stdout: search) + expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", env: nil, returns: [0, 1], timeout: 900).and_return(@shell_out) expect(@provider.candidate_version).to eq("2.3.4") end end @@ -98,9 +98,9 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do describe "when manipulating a resource" do it "run pkgin and install the package" do - out = OpenStruct.new(:stdout => nil) - expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/sbin/pkg_info", "-E", "varnish*", { :env => nil, :returns => [0, 1], :timeout => 900 }).and_return(@shell_out) - expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", { :env => nil, :timeout => 900 }).and_return(out) + out = OpenStruct.new(stdout: nil) + expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/sbin/pkg_info", "-E", "varnish*", { env: nil, returns: [0, 1], timeout: 900 }).and_return(@shell_out) + expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", { env: nil, timeout: 900 }).and_return(out) @provider.load_current_resource @provider.install_package("varnish", "2.1.5nb2") end diff --git a/spec/unit/provider/package/solaris_spec.rb b/spec/unit/provider/package/solaris_spec.rb index 57a0288f58..2aa37fe8b3 100644 --- a/spec/unit/provider/package/solaris_spec.rb +++ b/spec/unit/provider/package/solaris_spec.rb @@ -32,21 +32,21 @@ describe Chef::Provider::Package::Solaris do describe "assessing the current package status" do before do - @pkginfo = <<-PKGINFO -PKGINST: SUNWbash -NAME: GNU Bourne-Again shell (bash) -CATEGORY: system -ARCH: sparc -VERSION: 11.10.0,REV=2005.01.08.05.16 -BASEDIR: / -VENDOR: Sun Microsystems, Inc. -DESC: GNU Bourne-Again shell (bash) version 3.0 -PSTAMP: sfw10-patch20070430084444 -INSTDATE: Nov 04 2009 01:02 -HOTLINE: Please contact your local service provider + @pkginfo = <<~PKGINFO + PKGINST: SUNWbash + NAME: GNU Bourne-Again shell (bash) + CATEGORY: system + ARCH: sparc + VERSION: 11.10.0,REV=2005.01.08.05.16 + BASEDIR: / + VENDOR: Sun Microsystems, Inc. + DESC: GNU Bourne-Again shell (bash) version 3.0 + PSTAMP: sfw10-patch20070430084444 + INSTDATE: Nov 04 2009 01:02 + HOTLINE: Please contact your local service provider PKGINFO - @status = double("Status", :stdout => "", :exitstatus => 0) + @status = double("Status", stdout: "", exitstatus: 0) end it "should create a current resource with the name of new_resource" do @@ -70,7 +70,7 @@ PKGINFO end it "should get the source package version from pkginfo if provided" do - status = double(:stdout => @pkginfo, :exitstatus => 0) + status = double(stdout: @pkginfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "-d", "/tmp/bash.pkg", "SUNWbash", { timeout: 900 }).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "SUNWbash", { timeout: 900 }).and_return(@status) @provider.load_current_resource @@ -80,7 +80,7 @@ PKGINFO end it "should return the current version installed if found by pkginfo" do - status = double(:stdout => @pkginfo, :exitstatus => 0) + status = double(stdout: @pkginfo, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "-d", "/tmp/bash.pkg", "SUNWbash", { timeout: 900 }).and_return(@status) expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "SUNWbash", { timeout: 900 }).and_return(status) @provider.load_current_resource @@ -95,7 +95,7 @@ PKGINFO end it "should raise an exception if pkginfo fails to run" do - status = double(:stdout => "", :exitstatus => -1) + status = double(stdout: "", exitstatus: -1) allow(@provider).to receive(:shell_out_compacted).and_return(status) expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package) end @@ -116,14 +116,14 @@ PKGINFO end it "should lookup the candidate_version if the variable is not already set" do - status = double(:stdout => "", :exitstatus => 0) + status = double(stdout: "", exitstatus: 0) allow(@provider).to receive(:shell_out_compacted).and_return(status) expect(@provider).to receive(:shell_out_compacted) @provider.candidate_version end it "should throw and exception if the exitstatus is not 0" do - status = double(:stdout => "", :exitstatus => 1) + status = double(stdout: "", exitstatus: 1) allow(@provider).to receive(:shell_out_compacted).and_return(status) expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package) end diff --git a/spec/unit/provider/package/windows/exe_spec.rb b/spec/unit/provider/package/windows/exe_spec.rb index f18cbf3dca..f8c4e83fc5 100644 --- a/spec/unit/provider/package/windows/exe_spec.rb +++ b/spec/unit/provider/package/windows/exe_spec.rb @@ -126,7 +126,7 @@ describe Chef::Provider::Package::Windows::Exe do it "removes installed package and quotes uninstall string" do new_resource.timeout = 300 allow(::File).to receive(:exist?).with("uninst_dir/uninst_file").and_return(true) - expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir\/uninst_file\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, :timeout => 300, :returns => [0]) + expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir\/uninst_file\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, timeout: 300, returns: [0]) provider.remove_package end end diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb index aa528ab90e..0e939610db 100644 --- a/spec/unit/provider/package/windows/msi_spec.rb +++ b/spec/unit/provider/package/windows/msi_spec.rb @@ -22,7 +22,7 @@ require "chef/provider/package/windows/msi" describe Chef::Provider::Package::Windows::MSI do let(:node) { double("Chef::Node") } let(:events) { double("Chef::Events").as_null_object } # mock all the methods - let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } + let(:run_context) { double("Chef::RunContext", node: node, events: events) } let(:package_name) { "calculator" } let(:resource_source) { "calculator.msi" } let(:resource_version) { nil } diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb index aed0ca88be..3030b7f04a 100644 --- a/spec/unit/provider/package/windows_spec.rb +++ b/spec/unit/provider/package/windows_spec.rb @@ -50,7 +50,7 @@ describe Chef::Provider::Package::Windows, :windows_only do before(:each) do allow(Chef::Util::PathHelper).to receive(:validate_path) allow(provider).to receive(:package_provider).and_return(double("package_provider", - :installed_version => "1.0", :package_version => "2.0")) + installed_version: "1.0", package_version: "2.0")) end it "creates a current resource with the name of the new resource" do diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index 4ba8ac36ac..6795f9e051 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -30,7 +30,7 @@ describe Chef::Provider::Package::Zypper do Chef::Provider::Package::Zypper.new(new_resource, run_context) end - let(:status) { double(:stdout => "\n", :exitstatus => 0) } + let(:status) { double(stdout: "\n", exitstatus: 0) } before(:each) do allow(Chef::Resource::Package).to receive(:new).and_return(current_resource) @@ -73,7 +73,7 @@ describe Chef::Provider::Package::Zypper do end it "should set the installed version if zypper info has one (zypper version < 1.13.0)" do - status = double(:stdout => "Version: 1.0\nInstalled: Yes\n", :exitstatus => 0) + status = double(stdout: "Version: 1.0\nInstalled: Yes\n", exitstatus: 0) allow(provider).to receive(:shell_out_compacted!).and_return(status) expect(current_resource).to receive(:version).with(["1.0"]).and_return(true) @@ -81,7 +81,7 @@ describe Chef::Provider::Package::Zypper do end it "should set the installed version if zypper info has one (zypper version >= 1.13.0)" do - status = double(:stdout => "Version : 1.0 \nInstalled : Yes \n", :exitstatus => 0) + status = double(stdout: "Version : 1.0 \nInstalled : Yes \n", exitstatus: 0) allow(provider).to receive(:shell_out_compacted!).and_return(status) expect(current_resource).to receive(:version).with(["1.0"]).and_return(true) @@ -89,7 +89,7 @@ describe Chef::Provider::Package::Zypper do end it "should set the installed version if zypper info has one (zypper version >= 1.13.17)" do - status = double(:stdout => "Version : 1.0\nInstalled : Yes (automatically)\n", :exitstatus => 0) + status = double(stdout: "Version : 1.0\nInstalled : Yes (automatically)\n", exitstatus: 0) allow(provider).to receive(:shell_out_compacted!).and_return(status) expect(current_resource).to receive(:version).with(["1.0"]).and_return(true) @@ -97,7 +97,7 @@ describe Chef::Provider::Package::Zypper do end it "should set the candidate version if zypper info has one (zypper version < 1.13.0)" do - status = double(:stdout => "Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)", :exitstatus => 0) + status = double(stdout: "Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)", exitstatus: 0) allow(provider).to receive(:shell_out_compacted!).and_return(status) provider.load_current_resource @@ -105,7 +105,7 @@ describe Chef::Provider::Package::Zypper do end it "should set the candidate version if zypper info has one (zypper version >= 1.13.0)" do - status = double(:stdout => "Version : 1.0 \nInstalled : No \nStatus : out-of-date (version 0.9 installed)", :exitstatus => 0) + status = double(stdout: "Version : 1.0 \nInstalled : No \nStatus : out-of-date (version 0.9 installed)", exitstatus: 0) allow(provider).to receive(:shell_out_compacted!).and_return(status) provider.load_current_resource diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb index f4663861c6..79d84e61dc 100644 --- a/spec/unit/provider/powershell_script_spec.rb +++ b/spec/unit/provider/powershell_script_spec.rb @@ -25,7 +25,7 @@ describe Chef::Provider::PowershellScript, "action_run" do node.default["kernel"] = Hash.new node.default["kernel"][:machine] = :x86_64.to_s if ! powershell_version.nil? - node.default[:languages] = { :powershell => { :version => powershell_version } } + node.default[:languages] = { powershell: { version: powershell_version } } end node end diff --git a/spec/unit/provider/registry_key_spec.rb b/spec/unit/provider/registry_key_spec.rb index 096fe9b9ed..3563af4dc4 100644 --- a/spec/unit/provider/registry_key_spec.rb +++ b/spec/unit/provider/registry_key_spec.rb @@ -275,20 +275,20 @@ describe Chef::Provider::RegistryKey do context "when the key data is safe" do let(:keyname) { 'HKLM\Software\Opscode\Testing\Safe' } - let(:testval1) { { :name => "one", :type => :string, :data => "1" } } - let(:testval1_wrong_type) { { :name => "one", :type => :multi_string, :data => "1" } } - let(:testval1_wrong_data) { { :name => "one", :type => :string, :data => "2" } } - let(:testval2) { { :name => "two", :type => :string, :data => "2" } } + let(:testval1) { { name: "one", type: :string, data: "1" } } + let(:testval1_wrong_type) { { name: "one", type: :multi_string, data: "1" } } + let(:testval1_wrong_data) { { name: "one", type: :string, data: "2" } } + let(:testval2) { { name: "two", type: :string, data: "2" } } it_should_behave_like "a registry key" end context "when the key data is unsafe" do let(:keyname) { 'HKLM\Software\Opscode\Testing\Unsafe' } - let(:testval1) { { :name => "one", :type => :binary, :data => 255.chr * 1 } } - let(:testval1_wrong_type) { { :name => "one", :type => :string, :data => 255.chr * 1 } } - let(:testval1_wrong_data) { { :name => "one", :type => :binary, :data => 254.chr * 1 } } - let(:testval2) { { :name => "two", :type => :binary, :data => 0.chr * 1 } } + let(:testval1) { { name: "one", type: :binary, data: 255.chr * 1 } } + let(:testval1_wrong_type) { { name: "one", type: :string, data: 255.chr * 1 } } + let(:testval1_wrong_data) { { name: "one", type: :binary, data: 254.chr * 1 } } + let(:testval2) { { name: "two", type: :binary, data: 0.chr * 1 } } it_should_behave_like "a registry key" end @@ -296,8 +296,8 @@ describe Chef::Provider::RegistryKey do describe "action_create" do context "when key exists and type matches" do let(:keyname) { 'hklm\\software\\opscode\\testing\\dword' } - let(:dword_passed_as_integer) { { :name => "one", :type => :dword, :data => 12345 } } - let(:testval1) { { :name => "one", :type => :dword, :data => "12345" } } + let(:dword_passed_as_integer) { { name: "one", type: :dword, data: 12345 } } + let(:testval1) { { name: "one", type: :dword, data: "12345" } } before do expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true) end @@ -321,33 +321,33 @@ describe Chef::Provider::RegistryKey, "key_missing?" do let(:provider) { Chef::Provider::RegistryKey.new(new_resource, run_context) } let(:all_keys_present_in_all_hash) do - [ { :name => "input1_value1", :type => :string, :data => "my_value1" }, - { :name => "input1_value2", :type => :string, :data => "my_value2" }, + [ { name: "input1_value1", type: :string, data: "my_value1" }, + { name: "input1_value2", type: :string, data: "my_value2" }, ] end let(:type_key_not_present_in_any_hash) do - [ { :name => "input2_value1", :data => "my_value1" }, - { :name => "input2_value2", :data => "my_value2" }, + [ { name: "input2_value1", data: "my_value1" }, + { name: "input2_value2", data: "my_value2" }, ] end let(:type_key_not_present_in_some_hash) do - [ { :name => "input3_value1", :data => "my_value1" }, - { :name => "input3_value2", :type => :string, :data => "my_value2" }, + [ { name: "input3_value1", data: "my_value1" }, + { name: "input3_value2", type: :string, data: "my_value2" }, ] end let(:data_key_not_present_in_any_hash) do - [ { :name => "input4_value1", :type => :string }, - { :name => "input4_value2", :type => :string }, + [ { name: "input4_value1", type: :string }, + { name: "input4_value2", type: :string }, ] end let(:data_key_not_present_in_some_hash) do - [ { :name => "input5_value1", :type => :string, :data => "my_value1" }, - { :name => "input5_value2", :type => :string }, + [ { name: "input5_value1", type: :string, data: "my_value1" }, + { name: "input5_value2", type: :string }, ] end let(:only_name_key_present_in_all_hash) do - [ { :name => "input6_value1" }, - { :name => "input6_value2" }, + [ { name: "input6_value1" }, + { name: "input6_value2" }, ] end diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb index 307eb98187..1afc95fa48 100644 --- a/spec/unit/provider/remote_file/content_spec.rb +++ b/spec/unit/provider/remote_file/content_spec.rb @@ -84,7 +84,7 @@ describe Chef::Provider::RemoteFile::Content do describe "when the fetcher returns nil for the tempfile" do before do - http_fetcher = double("Chef::Provider::RemoteFile::HTTP", :fetch => nil) + http_fetcher = double("Chef::Provider::RemoteFile::HTTP", fetch: nil) expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher) end @@ -97,7 +97,7 @@ describe Chef::Provider::RemoteFile::Content do let(:mtime) { Time.now } let(:tempfile) { double("Tempfile") } - let(:http_fetcher) { double("Chef::Provider::RemoteFile::HTTP", :fetch => tempfile) } + let(:http_fetcher) { double("Chef::Provider::RemoteFile::HTTP", fetch: tempfile) } before do expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher) @@ -199,7 +199,7 @@ describe Chef::Provider::RemoteFile::Content do before do @tempfile = double("Tempfile") mtime = Time.now - http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile) + http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", fetch: @tempfile) expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(http_fetcher_works) end @@ -236,7 +236,7 @@ describe Chef::Provider::RemoteFile::Content do expect(URI).not_to receive(:parse).with(new_resource.source[1]) @tempfile = double("Tempfile") mtime = Time.now - http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile) + http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", fetch: @tempfile) expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri0, new_resource, current_resource).and_return(http_fetcher_works) end diff --git a/spec/unit/provider/remote_file/fetcher_spec.rb b/spec/unit/provider/remote_file/fetcher_spec.rb index f5b32800f2..b110e2c03a 100644 --- a/spec/unit/provider/remote_file/fetcher_spec.rb +++ b/spec/unit/provider/remote_file/fetcher_spec.rb @@ -46,7 +46,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed an http url" do - let(:uri) { double("uri", :scheme => "http" ) } + let(:uri) { double("uri", scheme: "http" ) } before do expect(Chef::Provider::RemoteFile::HTTP).to receive(:new).and_return(fetcher_instance) end @@ -56,7 +56,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed an https url" do - let(:uri) { double("uri", :scheme => "https" ) } + let(:uri) { double("uri", scheme: "https" ) } before do expect(Chef::Provider::RemoteFile::HTTP).to receive(:new).and_return(fetcher_instance) end @@ -66,7 +66,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed an ftp url" do - let(:uri) { double("uri", :scheme => "ftp" ) } + let(:uri) { double("uri", scheme: "ftp" ) } before do expect(Chef::Provider::RemoteFile::FTP).to receive(:new).and_return(fetcher_instance) end @@ -76,7 +76,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed a file url" do - let(:uri) { double("uri", :scheme => "file" ) } + let(:uri) { double("uri", scheme: "file" ) } before do expect(Chef::Provider::RemoteFile::LocalFile).to receive(:new).and_return(fetcher_instance) end @@ -86,7 +86,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed a url we do not recognize" do - let(:uri) { double("uri", :scheme => "xyzzy" ) } + let(:uri) { double("uri", scheme: "xyzzy" ) } it "throws an ArgumentError exception" do expect { described_class.for_resource(uri, new_resource, current_resource) }.to raise_error(ArgumentError) end diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb index b2fbb7300c..72bb910e66 100644 --- a/spec/unit/provider/remote_file/ftp_spec.rb +++ b/spec/unit/provider/remote_file/ftp_spec.rb @@ -108,7 +108,7 @@ describe Chef::Provider::RemoteFile::FTP do before do current_resource.checksum(current_resource_checksum) - #Chef::Provider::RemoteFile::CacheControlData.should_receive(:load_and_validate).with(uri, current_resource_checksum).and_return(cache_control_data) + # Chef::Provider::RemoteFile::CacheControlData.should_receive(:load_and_validate).with(uri, current_resource_checksum).and_return(cache_control_data) end it "should connect to the host from the uri on the default port 21" do diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb index e1f74bd35a..8ece1a854b 100644 --- a/spec/unit/provider/remote_file/http_spec.rb +++ b/spec/unit/provider/remote_file/http_spec.rb @@ -292,7 +292,7 @@ describe Chef::Provider::RemoteFile::HTTP do context "and the target file is a tarball [CHEF-3140]" do let(:uri) { URI.parse("http://opscode.com/tarball.tgz") } - let(:expected_http_opts) { { :disable_gzip => true } } + let(:expected_http_opts) { { disable_gzip: true } } # CHEF-3140 # Some servers return tarballs as content type tar and encoding gzip, which diff --git a/spec/unit/provider/remote_file/local_file_spec.rb b/spec/unit/provider/remote_file/local_file_spec.rb index 6f345cadd1..6dad6a57f2 100644 --- a/spec/unit/provider/remote_file/local_file_spec.rb +++ b/spec/unit/provider/remote_file/local_file_spec.rb @@ -84,8 +84,8 @@ describe Chef::Provider::RemoteFile::LocalFile do describe "when fetching the object" do - let(:tempfile) { double("Tempfile", :path => "/tmp/foo/bar/nyan.png", :close => nil) } - let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", :tempfile => tempfile) } + let(:tempfile) { double("Tempfile", path: "/tmp/foo/bar/nyan.png", close: nil) } + let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", tempfile: tempfile) } before do current_resource.source("file:///nyan_cat.png") diff --git a/spec/unit/provider/remote_file/network_file_spec.rb b/spec/unit/provider/remote_file/network_file_spec.rb index ecb326fc64..1c2bcc5911 100644 --- a/spec/unit/provider/remote_file/network_file_spec.rb +++ b/spec/unit/provider/remote_file/network_file_spec.rb @@ -28,9 +28,9 @@ describe Chef::Provider::RemoteFile::NetworkFile do describe "when fetching the object" do - let(:tempfile) { double("Tempfile", :path => "/tmp/foo/bar/Foo.tar.gz", :close => nil) } - let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", :tempfile => tempfile) } - let(:source_file) { double("::File", :read => nil) } + let(:tempfile) { double("Tempfile", path: "/tmp/foo/bar/Foo.tar.gz", close: nil) } + let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", tempfile: tempfile) } + let(:source_file) { double("::File", read: nil) } before do allow(Chef::Platform).to receive(:windows?).and_return(true) diff --git a/spec/unit/provider/remote_file/sftp_spec.rb b/spec/unit/provider/remote_file/sftp_spec.rb index ddab1605f0..244440d5c3 100644 --- a/spec/unit/provider/remote_file/sftp_spec.rb +++ b/spec/unit/provider/remote_file/sftp_spec.rb @@ -19,7 +19,7 @@ require "spec_helper" describe Chef::Provider::RemoteFile::SFTP do - #built out dependencies + # built out dependencies let(:enclosing_directory) do canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) end @@ -120,7 +120,7 @@ describe Chef::Provider::RemoteFile::SFTP do let(:uri) { URI.parse("sftp://conan:cthu1hu@opscode.com:8021/seattle.txt") } it "should connect on an alternate port when one is provided" do - expect(Net::SFTP).to receive(:start).with("opscode.com:8021", "conan", :password => "cthu1hu") + expect(Net::SFTP).to receive(:start).with("opscode.com:8021", "conan", password: "cthu1hu") fetcher.fetch end diff --git a/spec/unit/provider/remote_file_spec.rb b/spec/unit/provider/remote_file_spec.rb index 3f91377c60..07b854da6b 100644 --- a/spec/unit/provider/remote_file_spec.rb +++ b/spec/unit/provider/remote_file_spec.rb @@ -37,7 +37,7 @@ describe Chef::Provider::RemoteFile do let(:node) { double("Chef::Node") } let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:logger) { double("Mixlib::Log::Child").as_null_object } - let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) } + let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) } let(:enclosing_directory) do canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) end diff --git a/spec/unit/provider/script_spec.rb b/spec/unit/provider/script_spec.rb index 651e5130e0..08b19730a7 100644 --- a/spec/unit/provider/script_spec.rb +++ b/spec/unit/provider/script_spec.rb @@ -93,7 +93,7 @@ describe Chef::Provider::Script, "action_run" do end context "when an alternate user is specified" do - let(:security_descriptor) { instance_double("Chef::ReservedNames::Win32::Security::SecurityDescriptor", :dacl => []) } + let(:security_descriptor) { instance_double("Chef::ReservedNames::Win32::Security::SecurityDescriptor", dacl: []) } let(:securable_object) { instance_double("Chef::ReservedNames::Win32::Security::SecurableObject", :security_descriptor => security_descriptor, :dacl= => nil) } it "sets the script file's security descriptor" do new_resource.user("toor") diff --git a/spec/unit/provider/service/aix_service_spec.rb b/spec/unit/provider/service/aix_service_spec.rb index 802ccee2c7..cf6309e82a 100644 --- a/spec/unit/provider/service/aix_service_spec.rb +++ b/spec/unit/provider/service/aix_service_spec.rb @@ -33,7 +33,7 @@ describe Chef::Provider::Service::Aix do describe "load current resource" do it "should create a current resource with the name of the new resource and determine the status" do - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) expect(Chef::Resource::Service).to receive(:new).and_return(@current_resource) @@ -47,7 +47,7 @@ describe Chef::Provider::Service::Aix do describe "determine current status" do context "when the service is active" do before do - @status = double("Status", :exitstatus => 0, :stdout => "chef chef 12345 active\n") + @status = double("Status", exitstatus: 0, stdout: "chef chef 12345 active\n") end it "current resource is running" do @@ -61,7 +61,7 @@ describe Chef::Provider::Service::Aix do context "when the service is inoperative" do before do - @status = double("Status", :exitstatus => 0, :stdout => "chef chef inoperative\n") + @status = double("Status", exitstatus: 0, stdout: "chef chef inoperative\n") end it "current resource is not running" do @@ -75,7 +75,7 @@ describe Chef::Provider::Service::Aix do context "when there is no such service" do before do - @status = double("Status", :exitstatus => 1, :stdout => "0513-085 The chef Subsystem is not on file.\n") + @status = double("Status", exitstatus: 1, stdout: "0513-085 The chef Subsystem is not on file.\n") end it "current resource is not running" do expect(@provider).to receive(:shell_out!).with("lssrc -s chef").and_return(@status) @@ -90,7 +90,7 @@ describe Chef::Provider::Service::Aix do describe "is resource group" do context "when there are multiple subsystems associated with group" do before do - @status = double("Status", :exitstatus => 0, :stdout => "chef1 chef 12345 active\nchef2 chef 12334 active\nchef3 chef inoperative") + @status = double("Status", exitstatus: 0, stdout: "chef1 chef 12345 active\nchef2 chef 12334 active\nchef3 chef inoperative") end it "service is a group" do @@ -102,7 +102,7 @@ describe Chef::Provider::Service::Aix do context "when there is a single subsystem in the group" do before do - @status = double("Status", :exitstatus => 0, :stdout => "chef1 chef inoperative\n") + @status = double("Status", exitstatus: 0, stdout: "chef1 chef inoperative\n") end it "service is a group" do @@ -114,8 +114,8 @@ describe Chef::Provider::Service::Aix do context "when the service is a subsystem" do before do - @group_status = double("Status", :exitstatus => 1, :stdout => "0513-086 The chef Group is not on file.\n") - @service_status = double("Status", :exitstatus => 0, :stdout => "chef chef inoperative\n") + @group_status = double("Status", exitstatus: 1, stdout: "0513-086 The chef Group is not on file.\n") + @service_status = double("Status", exitstatus: 0, stdout: "chef chef inoperative\n") end it "service is a subsystem" do diff --git a/spec/unit/provider/service/aixinit_service_spec.rb b/spec/unit/provider/service/aixinit_service_spec.rb index 09c177903b..6a586a0240 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) @@ -209,7 +209,7 @@ describe Chef::Provider::Service::AixInit do before 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 => [:start, 20], 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) @@ -256,7 +256,7 @@ describe Chef::Provider::Service::AixInit do before 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 => [:start, ''], 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) diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb index 2139e31818..18db25fef9 100644 --- a/spec/unit/provider/service/arch_service_spec.rb +++ b/spec/unit/provider/service/arch_service_spec.rb @@ -26,14 +26,14 @@ require "ostruct" describe Chef::Provider::Service::Arch, "load_current_resource" do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = { :ps => "ps -ef" } + @node.automatic_attrs[:command] = { ps: "ps -ef" } @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::Service.new("chef") @new_resource.pattern("chef") - @new_resource.supports({ :status => false }) + @new_resource.supports({ status: false }) @provider = Chef::Provider::Service::Arch.new(@new_resource, @run_context) @@ -43,7 +43,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do describe "when first created" do it "should set the current resources service name to the new resources service name" do - allow(@provider).to receive(:shell_out).and_return(OpenStruct.new(:exitstatus => 0, :stdout => "")) + allow(@provider).to receive(:shell_out).and_return(OpenStruct.new(exitstatus: 0, stdout: "")) @provider.load_current_resource expect(@provider.current_resource.service_name).to eq("chef") end @@ -51,22 +51,22 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do describe "when the service supports status" do before do - @new_resource.supports({ :status => true }) + @new_resource.supports({ status: true }) end it "should run '/etc/rc.d/service_name status'" do - expect(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0)) + expect(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 0)) @provider.load_current_resource end it "should set running to true if the status command returns 0" do - allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0)) + allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 0)) @provider.load_current_resource expect(@provider.current_resource.running).to be_truthy end it "should set running to false if the status command returns anything except 0" do - allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 1)) + allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 1)) @provider.load_current_resource expect(@provider.current_resource.running).to be_falsey end @@ -85,21 +85,21 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do end it "should run the services status command if one has been specified" do - expect(@provider).to receive(:shell_out).with("/etc/rc.d/chefhasmonkeypants status").and_return(OpenStruct.new(:exitstatus => 0)) + expect(@provider).to receive(:shell_out).with("/etc/rc.d/chefhasmonkeypants status").and_return(OpenStruct.new(exitstatus: 0)) @provider.load_current_resource end end it "should raise error if the node has a nil ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => nil } + @node.automatic_attrs[:command] = { ps: nil } @provider.define_resource_requirements @provider.action = :start expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end it "should raise error if the node has an empty ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => "" } + @node.automatic_attrs[:command] = { ps: "" } @provider.define_resource_requirements @provider.action = :start expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) @@ -117,21 +117,21 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do describe "when discovering service status with ps" do before do - @stdout = StringIO.new(<<-DEFAULT_PS) -aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb -aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash -aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb + @stdout = StringIO.new(<<~DEFAULT_PS) + aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb + aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash + aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb DEFAULT_PS - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) - @node.automatic_attrs[:command] = { :ps => "ps -ef" } + @node.automatic_attrs[:command] = { ps: "ps -ef" } end it "determines the service is running when it appears in ps" do - @stdout = StringIO.new(<<-RUNNING_PS) -aj 7842 5057 0 21:26 pts/2 00:00:06 chef -aj 7842 5057 0 21:26 pts/2 00:00:06 poos + @stdout = StringIO.new(<<~RUNNING_PS) + aj 7842 5057 0 21:26 pts/2 00:00:06 chef + aj 7842 5057 0 21:26 pts/2 00:00:06 poos RUNNING_PS allow(@status).to receive(:stdout).and_return(@stdout) @provider.load_current_resource @@ -274,7 +274,7 @@ RUNNING_PS # end it "should call 'restart' on the service_name if the resource supports it" do - @new_resource.supports({ :restart => true }) + @new_resource.supports({ restart: true }) expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restart", default_env: false) @provider.restart_service() end @@ -309,7 +309,7 @@ RUNNING_PS # end it "should call 'reload' on the service if it supports it" do - @new_resource.supports({ :reload => true }) + @new_resource.supports({ reload: true }) expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} reload", default_env: false) @provider.reload_service() end diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb index 25e7c9acc2..626abb10f7 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) @@ -88,7 +88,7 @@ describe Chef::Provider::Service::Debian do "5" => [:start, "20"], "0" => [:stop, "20"], "1" => [:stop, "20"], - "6" => [:stop, "20"] + "6" => [:stop, "20"], }) end end diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb index 511962f432..954ef3d153 100644 --- a/spec/unit/provider/service/freebsd_service_spec.rb +++ b/spec/unit/provider/service/freebsd_service_spec.rb @@ -27,14 +27,14 @@ end describe Chef::Provider::Service::Freebsd do let(:node) do node = Chef::Node.new - node.automatic_attrs[:command] = { :ps => "ps -ax" } + node.automatic_attrs[:command] = { ps: "ps -ax" } node end let(:new_resource) do new_resource = Chef::Resource::Service.new("apache22") new_resource.pattern("httpd") - new_resource.supports({ :status => false }) + new_resource.supports({ status: false }) new_resource end @@ -99,7 +99,7 @@ describe Chef::Provider::Service::Freebsd do end context "when a status command has been specified" do - let(:status) { double(:stdout => "", :exitstatus => 0) } + let(:status) { double(stdout: "", exitstatus: 0) } before do new_resource.status_command("/bin/chefhasmonkeypants status") @@ -112,10 +112,10 @@ describe Chef::Provider::Service::Freebsd do end context "when the service supports status" do - let(:status) { double(:stdout => "", :exitstatus => 0) } + let(:status) { double(stdout: "", exitstatus: 0) } before do - new_resource.supports({ :status => true }) + new_resource.supports({ status: true }) end it "should run '/etc/init.d/service_name status'" do @@ -138,16 +138,16 @@ describe Chef::Provider::Service::Freebsd do context "when we have a 'ps' attribute" do let(:stdout) do - StringIO.new(<<-PS_SAMPLE) -413 ?? Ss 0:02.51 /usr/sbin/syslogd -s -539 ?? Is 0:00.14 /usr/sbin/sshd -545 ?? Ss 0:17.53 sendmail: accepting connections (sendmail) + StringIO.new(<<~PS_SAMPLE) + 413 ?? Ss 0:02.51 /usr/sbin/syslogd -s + 539 ?? Is 0:00.14 /usr/sbin/sshd + 545 ?? Ss 0:17.53 sendmail: accepting connections (sendmail) PS_SAMPLE end - let(:status) { double(:stdout => stdout, :exitstatus => 0) } + let(:status) { double(stdout: stdout, exitstatus: 0) } before do - node.automatic_attrs[:command] = { :ps => "ps -ax" } + node.automatic_attrs[:command] = { ps: "ps -ax" } end it "should shell_out! the node's ps command" do @@ -163,9 +163,9 @@ PS_SAMPLE context "when the regex matches the output" do let(:stdout) do - StringIO.new(<<-PS_SAMPLE) -555 ?? Ss 0:05.16 /usr/sbin/cron -s - 9881 ?? Ss 0:06.67 /usr/local/sbin/httpd -DNOHTTPACCEPT + StringIO.new(<<~PS_SAMPLE) + 555 ?? Ss 0:05.16 /usr/sbin/cron -s + 9881 ?? Ss 0:06.67 /usr/local/sbin/httpd -DNOHTTPACCEPT PS_SAMPLE end @@ -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 @@ -341,9 +341,9 @@ PS_SAMPLE context "when the rc script has a 'name' variable" do let(:rcscript) do - StringIO.new(<<-EOF) -name="#{new_resource.service_name}" -rcvar=`set_rcvar` + StringIO.new(<<~EOF) + name="#{new_resource.service_name}" + rcvar=`set_rcvar` EOF end @@ -363,23 +363,23 @@ EOF describe "when the rcscript does not have a name variable" do let(:rcscript) do - StringIO.new <<-EOF -rcvar=`set_rcvar` + StringIO.new <<~EOF + rcvar=`set_rcvar` EOF end before do - status = double(:stdout => rcvar_stdout, :exitstatus => 0) + status = double(stdout: rcvar_stdout, exitstatus: 0) allow(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} rcvar").and_return(status) end describe "when rcvar returns foobar_enable" do let(:rcvar_stdout) do - rcvar_stdout = <<-EOF -# apache22 -# -# #{new_resource.service_name}_enable="YES" -# (default: "") + rcvar_stdout = <<~EOF + # apache22 + # + # #{new_resource.service_name}_enable="YES" + # (default: "") EOF end @@ -394,9 +394,9 @@ EOF describe "when rcvar does not return foobar_enable" do let(:rcvar_stdout) do - rcvar_stdout = <<-EOF -# service_with_noname -# + rcvar_stdout = <<~EOF + # service_with_noname + # EOF end @@ -469,7 +469,7 @@ EOF describe Chef::Provider::Service::Freebsd, "restart_service" do it "should call 'restart' on the service_name if the resource supports it" do - new_resource.supports({ :restart => true }) + new_resource.supports({ restart: true }) expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart", default_env: false) provider.restart_service() end diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb index a00ca7aadd..6a928d849b 100644 --- a/spec/unit/provider/service/gentoo_service_spec.rb +++ b/spec/unit/provider/service/gentoo_service_spec.rb @@ -30,7 +30,7 @@ describe Chef::Provider::Service::Gentoo do @provider = Chef::Provider::Service::Gentoo.new(@new_resource, @run_context) allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource) - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out).and_return(@status) allow(File).to receive(:exists?).with("/etc/init.d/chef").and_return(true) allow(File).to receive(:exists?).with("/sbin/rc-update").and_return(true) diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb index ff7fae767a..7bbe2c6363 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) @@ -32,12 +32,12 @@ describe Chef::Provider::Service::Init, "load_current_resource" do @provider = Chef::Provider::Service::Init.new(@new_resource, @run_context) allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource) - @stdout = StringIO.new(<<-PS) -aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb -aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash -aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb + @stdout = StringIO.new(<<~PS) + aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb + aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash + aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb PS - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) end @@ -53,7 +53,7 @@ PS describe "when the service supports status" do before do - @new_resource.supports({ :status => true }) + @new_resource.supports({ status: true }) end it "should run '/etc/init.d/service_name status'" do @@ -109,7 +109,7 @@ PS describe "when the node has not specified a ps command" do it "should raise an error if the node has a nil ps attribute" do - @node.automatic_attrs[:command] = { :ps => nil } + @node.automatic_attrs[:command] = { ps: nil } @provider.load_current_resource @provider.action = :start @provider.define_resource_requirements @@ -117,7 +117,7 @@ PS end it "should raise an error if the node has an empty ps attribute" do - @node.automatic_attrs[:command] = { :ps => "" } + @node.automatic_attrs[:command] = { ps: "" } @provider.load_current_resource @provider.action = :start @provider.define_resource_requirements @@ -133,9 +133,9 @@ PS end it "should set running to true if the regex matches the output" do - @stdout = StringIO.new(<<-RUNNING_PS) -aj 7842 5057 0 21:26 pts/2 00:00:06 chef -aj 7842 5057 0 21:26 pts/2 00:00:06 poos + @stdout = StringIO.new(<<~RUNNING_PS) + aj 7842 5057 0 21:26 pts/2 00:00:06 chef + aj 7842 5057 0 21:26 pts/2 00:00:06 poos RUNNING_PS allow(@status).to receive(:stdout).and_return(@stdout) @provider.load_current_resource @@ -189,7 +189,7 @@ RUNNING_PS describe "when restarting a service" do it "should call 'restart' on the service_name if the resource supports it" do - @new_resource.supports({ :restart => true }) + @new_resource.supports({ restart: true }) expect(@provider).to receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} restart", default_env: false) @provider.restart_service() end @@ -210,7 +210,7 @@ RUNNING_PS describe "when reloading a service" do it "should call 'reload' on the service if it supports it" do - @new_resource.supports({ :reload => true }) + @new_resource.supports({ reload: true }) expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef reload", default_env: false) @provider.reload_service() end diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb index 3b2b19c432..f2fe19db59 100644 --- a/spec/unit/provider/service/insserv_service_spec.rb +++ b/spec/unit/provider/service/insserv_service_spec.rb @@ -23,13 +23,13 @@ describe Chef::Provider::Service::Insserv do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @node.automatic_attrs[:command] = { :ps => "ps -ax" } + @node.automatic_attrs[:command] = { ps: "ps -ax" } @new_resource = Chef::Resource::Service.new("initgrediant") @current_resource = Chef::Resource::Service.new("initgrediant") @provider = Chef::Provider::Service::Insserv.new(@new_resource, @run_context) - @status = double("Process::Status mock", :exitstatus => 0, :stdout => "") + @status = double("Process::Status mock", exitstatus: 0, stdout: "") allow(@provider).to receive(:shell_out!).and_return(@status) end diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb index e70ba7e094..2e30c16da4 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) @@ -32,12 +32,12 @@ describe Chef::Provider::Service::Invokercd, "load_current_resource" do @provider = Chef::Provider::Service::Invokercd.new(@new_resource, @run_context) allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource) - @stdout = StringIO.new(<<-PS) -aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb -aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash -aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb + @stdout = StringIO.new(<<~PS) + aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb + aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash + aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb PS - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) end @@ -53,7 +53,7 @@ PS describe "when the service supports status" do before do - @new_resource.supports({ :status => true }) + @new_resource.supports({ status: true }) end it "should run '/usr/sbin/invoke-rc.d service_name status'" do @@ -95,14 +95,14 @@ PS describe "when the node has not specified a ps command" do it "should raise error if the node has a nil ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => nil } + @node.automatic_attrs[:command] = { ps: nil } @provider.action = :start @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end it "should raise error if the node has an empty ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => "" } + @node.automatic_attrs[:command] = { ps: "" } @provider.action = :start @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) @@ -112,24 +112,24 @@ PS describe "when we have a 'ps' attribute" do it "should shell_out! the node's ps command" do - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) expect(@provider).to receive(:shell_out!).with(@node[:command][:ps]).and_return(@status) @provider.load_current_resource end it "should set running to true if the regex matches the output" do - @stdout = StringIO.new(<<-RUNNING_PS) -aj 7842 5057 0 21:26 pts/2 00:00:06 chef -aj 7842 5057 0 21:26 pts/2 00:00:06 poos + @stdout = StringIO.new(<<~RUNNING_PS) + aj 7842 5057 0 21:26 pts/2 00:00:06 chef + aj 7842 5057 0 21:26 pts/2 00:00:06 poos RUNNING_PS - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) expect(@provider).to receive(:shell_out!).and_return(@status) @provider.load_current_resource expect(@current_resource.running).to be_truthy end it "should set running to false if the regex doesn't match" do - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) expect(@provider).to receive(:shell_out!).and_return(@status) @provider.load_current_resource expect(@current_resource.running).to be_falsey @@ -176,7 +176,7 @@ RUNNING_PS describe "when restarting a service" do it "should call 'restart' on the service_name if the resource supports it" do - @new_resource.supports({ :restart => true }) + @new_resource.supports({ restart: true }) expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restart", default_env: false) @provider.restart_service() end @@ -197,7 +197,7 @@ RUNNING_PS describe "when reloading a service" do it "should call 'reload' on the service if it supports it" do - @new_resource.supports({ :reload => true }) + @new_resource.supports({ reload: true }) expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef reload", default_env: false) @provider.reload_service() end diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb index 283512108a..9864fb0185 100644 --- a/spec/unit/provider/service/macosx_spec.rb +++ b/spec/unit/provider/service/macosx_spec.rb @@ -48,15 +48,15 @@ describe Chef::Provider::Service::Macosx do let(:run_context) { Chef::RunContext.new(node, {}, events) } let(:provider) { described_class.new(new_resource, run_context) } let(:launchctl_stdout) { StringIO.new } - let(:plutil_stdout) { String.new <<-XML } -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> - <key>Label</key> - <string>io.redis.redis-server</string> -</dict> -</plist> + let(:plutil_stdout) { String.new <<~XML } + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> + <plist version="1.0"> + <dict> + <key>Label</key> + <string>io.redis.redis-server</string> + </dict> + </plist> XML %w{Daemon Agent}.each do |service_type| @@ -76,20 +76,20 @@ XML before do allow(run_context).to receive(:logger).and_return(logger) allow(Dir).to receive(:glob).and_return([plist], []) - @stat = double("File::Stat", { :uid => 501 }) + @stat = double("File::Stat", { uid: 501 }) allow(File).to receive(:stat).and_return(@stat) - @getpwuid = double("Etc::Passwd", { :name => "mikedodge04" }) + @getpwuid = double("Etc::Passwd", { name: "mikedodge04" }) allow(Etc).to receive(:getpwuid).and_return(@getpwuid) allow(node).to receive(:[]).with("platform_version").and_return(platform_version) cmd = "launchctl list #{service_label}" - allow(provider).to receive(:shell_out). - with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false). - and_return(double("Status", - :stdout => launchctl_stdout, :exitstatus => 0)) + allow(provider).to receive(:shell_out) + .with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false) + .and_return(double("Status", + stdout: launchctl_stdout, exitstatus: 0)) allow(File).to receive(:exists?).and_return([true], []) - allow(provider).to receive(:shell_out!). - with(/plutil -convert xml1 -o/, default_env: false). - and_return(double("Status", :stdout => plutil_stdout)) + allow(provider).to receive(:shell_out!) + .with(/plutil -convert xml1 -o/, default_env: false) + .and_return(double("Status", stdout: plutil_stdout)) end context "#{service_name} that is a #{service_type} running Osx #{platform_version}" do @@ -113,9 +113,9 @@ XML before do 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) + allow(provider).to receive(:shell_out!) + .with(/plutil -convert xml1 -o/) + .and_raise(Mixlib::ShellOut::ShellCommandFailed) end it "works for action :nothing" do @@ -136,20 +136,20 @@ XML end context "when launchctl returns pid in service list" do - let(:launchctl_stdout) { StringIO.new <<-SVC_LIST } -{ - "LimitLoadToSessionType" = "System"; - "Label" = "io.redis.redis-server"; - "TimeOut" = 30; - "OnDemand" = false; - "LastExitStatus" = 0; - "PID" = 62803; - "Program" = "do_some.sh"; - "ProgramArguments" = ( - "path/to/do_something.sh"; - "-f"; - ); -}; + let(:launchctl_stdout) { StringIO.new <<~SVC_LIST } + { + "LimitLoadToSessionType" = "System"; + "Label" = "io.redis.redis-server"; + "TimeOut" = 30; + "OnDemand" = false; + "LastExitStatus" = 0; + "PID" = 62803; + "Program" = "do_some.sh"; + "ProgramArguments" = ( + "path/to/do_something.sh"; + "-f"; + ); + }; SVC_LIST before do @@ -167,7 +167,7 @@ SVC_LIST describe "running unsupported actions" do before do - allow(Dir).to receive(:glob).and_return(["#{plist}"], []) + allow(Dir).to receive(:glob).and_return([(plist).to_s], []) allow(File).to receive(:exists?).and_return([true], []) end it "should throw an exception when reload action is attempted" do @@ -175,19 +175,19 @@ SVC_LIST end end context "when launchctl returns empty service pid" do - let(:launchctl_stdout) { StringIO.new <<-SVC_LIST } -{ - "LimitLoadToSessionType" = "System"; - "Label" = "io.redis.redis-server"; - "TimeOut" = 30; - "OnDemand" = false; - "LastExitStatus" = 0; - "Program" = "do_some.sh"; - "ProgramArguments" = ( - "path/to/do_something.sh"; - "-f"; - ); -}; + let(:launchctl_stdout) { StringIO.new <<~SVC_LIST } + { + "LimitLoadToSessionType" = "System"; + "Label" = "io.redis.redis-server"; + "TimeOut" = 30; + "OnDemand" = false; + "LastExitStatus" = 0; + "Program" = "do_some.sh"; + "ProgramArguments" = ( + "path/to/do_something.sh"; + "-f"; + ); + }; SVC_LIST before do @@ -204,8 +204,8 @@ SVC_LIST end context "when launchctl doesn't return service entry at all" do - let(:launchctl_stdout) { StringIO.new <<-SVC_LIST } -Could not find service "io.redis.redis-server" in domain for system + let(:launchctl_stdout) { StringIO.new <<~SVC_LIST } + Could not find service "io.redis.redis-server" in domain for system SVC_LIST it "sets service running state to false" do @@ -226,7 +226,7 @@ SVC_LIST context "and plist for service is available" do before do - allow(Dir).to receive(:glob).and_return(["#{plist}"], []) + allow(Dir).to receive(:glob).and_return([(plist).to_s], []) provider.load_current_resource end @@ -237,7 +237,7 @@ SVC_LIST describe "and several plists match service name" do it "throws exception" do - allow(Dir).to receive(:glob).and_return(["#{plist}", + allow(Dir).to receive(:glob).and_return([(plist).to_s, "/Users/wtf/something.plist"]) provider.load_current_resource provider.define_resource_requirements @@ -269,9 +269,9 @@ SVC_LIST it "starts service via launchctl if service found" do cmd = "launchctl load -w " + session + plist - expect(provider).to receive(:shell_out). - with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false). - and_return(0) + expect(provider).to receive(:shell_out) + .with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false) + .and_return(0) provider.start_service end @@ -301,9 +301,9 @@ SVC_LIST it "stops the service via launchctl if service found" do cmd = "launchctl unload -w " + plist - expect(provider).to receive(:shell_out). - with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false). - and_return(0) + expect(provider).to receive(:shell_out) + .with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false) + .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 b990532aaf..913fddc1cf 100644 --- a/spec/unit/provider/service/openbsd_service_spec.rb +++ b/spec/unit/provider/service/openbsd_service_spec.rb @@ -31,11 +31,11 @@ end describe Chef::Provider::Service::Openbsd do let(:node) do node = Chef::Node.new - node.automatic_attrs[:command] = { :ps => "ps -ax" } + node.automatic_attrs[:command] = { ps: "ps -ax" } node end - let(:supports) { { :status => false } } + let(:supports) { { status: false } } let(:new_resource) do new_resource = Chef::Resource::Service.new("sndiod") @@ -93,7 +93,7 @@ describe Chef::Provider::Service::Openbsd do end context "when a status command has been specified" do - let(:status) { double(:stdout => "", :exitstatus => 0) } + let(:status) { double(stdout: "", exitstatus: 0) } before do new_resource.status_command("/bin/chefhasmonkeypants status") @@ -106,9 +106,9 @@ describe Chef::Provider::Service::Openbsd do end context "when the service supports status" do - let(:status) { double(:stdout => "", :exitstatus => 0) } + let(:status) { double(stdout: "", exitstatus: 0) } - let(:supports) { { :status => true } } + let(:supports) { { status: true } } it "should run '/etc/rc.d/service_name status'" do expect(provider).to receive(:shell_out).with("/etc/rc.d/#{new_resource.service_name} check").and_return(status) @@ -189,7 +189,7 @@ describe Chef::Provider::Service::Openbsd do let(:lines) do [ %Q{#{provider.builtin_service_enable_variable_name}_thing="YES"}, - %Q{#{provider.builtin_service_enable_variable_name}}, + (provider.builtin_service_enable_variable_name).to_s, ] end it "sets enabled based on the exact match (false)" do provider.determine_enabled_status! diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index 40f9bc3a91..b965183d14 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -23,17 +23,17 @@ shared_examples_for "define_resource_requirements_common" do it "should raise an error if /sbin/chkconfig does not exist" do allow(File).to receive(:exists?).with("/sbin/chkconfig").and_return(false) allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_raise(Errno::ENOENT) - allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_raise(Errno::ENOENT) + allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_raise(Errno::ENOENT) @provider.load_current_resource @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end it "should not raise an error if the service exists but is not added to any runlevels" do - status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "") + status = double("Status", exitstatus: 0, stdout: "" , stderr: "") expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status) - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "", :stderr => "service chef supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add chef')") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "", stderr: "service chef supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add chef')") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) @provider.load_current_resource @provider.define_resource_requirements expect { @provider.process_resource_requirements }.not_to raise_error @@ -44,7 +44,7 @@ describe "Chef::Provider::Service::Redhat" do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = { :ps => "foo" } + @node.automatic_attrs[:command] = { ps: "foo" } @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -65,13 +65,13 @@ describe "Chef::Provider::Service::Redhat" do describe "load current resource" do before do - status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "") + status = double("Status", exitstatus: 0, stdout: "" , stderr: "") allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status) end it "sets supports[:status] to true by default" do - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false @provider.load_current_resource expect(@provider.supports[:status]).to be true @@ -80,9 +80,9 @@ describe "Chef::Provider::Service::Redhat" do it "lets the user override supports[:status] in the new_resource" do @new_resource.supports( { status: false } ) @new_resource.pattern "myservice" - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) - foo_out = double("ps_command", :exitstatus => 0, :stdout => "a line that matches myservice", :stderr => "") + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) + foo_out = double("ps_command", exitstatus: 0, stdout: "a line that matches myservice", stderr: "") expect(@provider).to receive(:shell_out!).with("foo").and_return(foo_out) expect(@provider.service_missing).to be false expect(@provider).not_to receive(:shell_out).with("/sbin/service chef status") @@ -91,16 +91,16 @@ describe "Chef::Provider::Service::Redhat" do end it "sets the current enabled status to true if the service is enabled for any run level" do - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false @provider.load_current_resource expect(@current_resource.enabled).to be true end it "sets the current enabled status to false if the regex does not match" do - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false expect(@provider.load_current_resource).to eql(@current_resource) expect(@current_resource.enabled).to be false @@ -108,8 +108,8 @@ describe "Chef::Provider::Service::Redhat" do it "sets the current enabled status to true if the service is enabled at specified run levels" do @new_resource.run_levels([1, 2]) - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false @provider.load_current_resource expect(@current_resource.enabled).to be true @@ -118,8 +118,8 @@ describe "Chef::Provider::Service::Redhat" do it "sets the current enabled status to false if the service is enabled at a run level it should not" do @new_resource.run_levels([1, 2]) - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:on 4:off 5:off 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:on 3:on 4:off 5:off 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false @provider.load_current_resource expect(@current_resource.enabled).to be false @@ -128,8 +128,8 @@ describe "Chef::Provider::Service::Redhat" do it "sets the current enabled status to false if the service is not enabled at specified run levels" do @new_resource.run_levels([ 2 ]) - chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", :stderr => "") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", stderr: "") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) expect(@provider.service_missing).to be false @provider.load_current_resource expect(@current_resource.enabled).to be false @@ -142,10 +142,10 @@ describe "Chef::Provider::Service::Redhat" do context "when the service does not exist" do before do - status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service") + status = double("Status", exitstatus: 1, stdout: "", stderr: "chef: unrecognized service") expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status) - chkconfig = double("Chkconfig", :existatus => 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", existatus: 1, stdout: "", stderr: "error reading information on service chef: No such file or directory") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) @provider.load_current_resource @provider.define_resource_requirements end @@ -194,10 +194,10 @@ describe "Chef::Provider::Service::Redhat" do it_should_behave_like "define_resource_requirements_common" it "should not raise an error if the service does not exist" do - status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service") + status = double("Status", exitstatus: 1, stdout: "", stderr: "chef: unrecognized service") expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status) - chkconfig = double("Chkconfig", :existatus => 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory") - expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig) + chkconfig = double("Chkconfig", existatus: 1, stdout: "", stderr: "error reading information on service chef: No such file or directory") + expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig) @provider.load_current_resource @provider.define_resource_requirements expect { @provider.process_resource_requirements }.not_to raise_error diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb index 8a03c0552d..0529462d2f 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) @@ -31,12 +31,12 @@ describe Chef::Provider::Service::Simple, "load_current_resource" do @provider = Chef::Provider::Service::Simple.new(@new_resource, @run_context) allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource) - @stdout = StringIO.new(<<-NOMOCKINGSTRINGSPLZ) -aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb -aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash -aj 8119 6041 0 21:34 pts/3 00:00:03 vi simple_service_spec.rb + @stdout = StringIO.new(<<~NOMOCKINGSTRINGSPLZ) + aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb + aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash + aj 8119 6041 0 21:34 pts/3 00:00:03 vi simple_service_spec.rb NOMOCKINGSTRINGSPLZ - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) end @@ -51,13 +51,13 @@ NOMOCKINGSTRINGSPLZ end it "should raise error if the node has a nil ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => nil } + @node.automatic_attrs[:command] = { ps: nil } @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end it "should raise error if the node has an empty ps attribute and no other means to get status" do - @node.automatic_attrs[:command] = { :ps => "" } + @node.automatic_attrs[:command] = { ps: "" } @provider.define_resource_requirements expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end @@ -75,11 +75,11 @@ NOMOCKINGSTRINGSPLZ end it "should set running to true if the regex matches the output" do - @stdout = StringIO.new(<<-NOMOCKINGSTRINGSPLZ) -aj 7842 5057 0 21:26 pts/2 00:00:06 chef -aj 7842 5057 0 21:26 pts/2 00:00:06 poos + @stdout = StringIO.new(<<~NOMOCKINGSTRINGSPLZ) + aj 7842 5057 0 21:26 pts/2 00:00:06 chef + aj 7842 5057 0 21:26 pts/2 00:00:06 poos NOMOCKINGSTRINGSPLZ - @status = double("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) @provider.load_current_resource expect(@current_resource.running).to be_truthy @@ -106,8 +106,8 @@ NOMOCKINGSTRINGSPLZ describe "when starting the service" do it "should call the start command if one is specified" do - @new_resource.start_command("#{@new_resource.start_command}") - expect(@provider).to receive(:shell_out!).with("#{@new_resource.start_command}", default_env: false) + @new_resource.start_command((@new_resource.start_command).to_s) + expect(@provider).to receive(:shell_out!).with((@new_resource.start_command).to_s, default_env: false) @provider.start_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 a5148c236a..7b8bd950d2 100644 --- a/spec/unit/provider/service/solaris_smf_service_spec.rb +++ b/spec/unit/provider/service/solaris_smf_service_spec.rb @@ -74,19 +74,19 @@ describe Chef::Provider::Service::Solaris do ].join("\n") # shell_out! return value for a service that is running - @enabled_svc_status = double("Status", :exitstatus => 0, :stdout => enabled_svc_stdout, :stdin => "", :stderr => "") + @enabled_svc_status = double("Status", exitstatus: 0, stdout: enabled_svc_stdout, stdin: "", stderr: "") # shell_out! return value for a service that is disabled - @disabled_svc_status = double("Status", :exitstatus => 0, :stdout => disabled_svc_stdout, :stdin => "", :stderr => "") + @disabled_svc_status = double("Status", exitstatus: 0, stdout: disabled_svc_stdout, stdin: "", stderr: "") # shell_out! return value for a service that is in maintenance mode - @maintenance_svc_status = double("Status", :exitstatus => 0, :stdout => maintenance_svc_stdout, :stdin => "", :stderr => "") + @maintenance_svc_status = double("Status", exitstatus: 0, stdout: maintenance_svc_stdout, stdin: "", stderr: "") # shell_out! return value for a service that does not exist - @no_svc_status = double("Status", :exitstatus => 1, :stdout => "", :stdin => "", :stderr => "svcs: Pattern 'chef' doesn't match any instances\n") + @no_svc_status = double("Status", exitstatus: 1, stdout: "", stdin: "", stderr: "svcs: Pattern 'chef' doesn't match any instances\n") # shell_out! return value for a successful execution - @success = double("clear", :exitstatus => 0, :stdout => "", :stdin => "", :stderr => "") + @success = double("clear", exitstatus: 0, stdout: "", stdin: "", stderr: "") end it "should raise an error if /bin/svcs and /usr/sbin/svcadm are not executable" do @@ -116,19 +116,19 @@ describe Chef::Provider::Service::Solaris do describe "when discovering the current service state" do it "should create a current resource with the name of the new resource" do - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(Chef::Resource::Service).to receive(:new).and_return(@current_resource) expect(@provider.maintenance).to be_falsey @provider.load_current_resource end it "should return the current resource" do - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(@provider.load_current_resource).to eql(@current_resource) end it "should call '/bin/svcs -l service_name'" do - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) @provider.load_current_resource end @@ -163,7 +163,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm enable -s chef" do - expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success) @provider.load_current_resource @@ -173,7 +173,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm enable -s chef for start_service" do - expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success) @provider.load_current_resource @@ -183,7 +183,7 @@ describe Chef::Provider::Service::Solaris do it "should call svcadm clear chef for start_service when state maintenance" do # we are in maint mode - expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@maintenance_svc_status) + expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@maintenance_svc_status) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name).and_return(@success) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success) @@ -192,7 +192,7 @@ describe Chef::Provider::Service::Solaris do expect(@provider.enable_service).to be_truthy # now we are enabled - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) @provider.load_current_resource expect(@current_resource.enabled).to be_truthy @@ -206,7 +206,7 @@ describe Chef::Provider::Service::Solaris do it "should call svcadm enable -s -r chef" do @new_resource.options("-r") - expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", @current_resource.service_name).and_return(@success) @provider.load_current_resource @@ -216,7 +216,7 @@ describe Chef::Provider::Service::Solaris do it "should call svcadm enable -s -r -t chef when passed an array of options" do @new_resource.options(["-r", "-t"]) - expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", "-t", @current_resource.service_name).and_return(@success) @provider.load_current_resource @@ -232,7 +232,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm disable -s chef" do - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success) @provider.load_current_resource expect(@provider.disable_service).to be_truthy @@ -240,7 +240,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm disable -s chef for stop_service" do - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success) @provider.load_current_resource expect(@provider.disable_service).to be_truthy @@ -249,7 +249,7 @@ describe Chef::Provider::Service::Solaris do it "should call svcadm disable chef with options" do @new_resource.options("-t") - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "-t", "chef").and_return(@success) @provider.load_current_resource expect(@provider.disable_service).to be_truthy @@ -261,7 +261,7 @@ describe Chef::Provider::Service::Solaris do describe "when reloading the service" do before(:each) do @provider.current_resource = @current_resource - allow(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + allow(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status) end it "should call svcadm refresh chef" do @@ -274,7 +274,7 @@ describe Chef::Provider::Service::Solaris do describe "when the service doesn't exist" do before(:each) do @provider.current_resource = @current_resource - expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@no_svc_status) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@no_svc_status) end it "should be marked not running" do diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb index 1082bdfdc4..15b79922b0 100644 --- a/spec/unit/provider/service/systemd_service_spec.rb +++ b/spec/unit/provider/service/systemd_service_spec.rb @@ -36,11 +36,11 @@ describe Chef::Provider::Service::Systemd do let(:provider) { Chef::Provider::Service::Systemd.new(new_resource, run_context) } let(:shell_out_success) do - double("shell_out", :exitstatus => 0, :error? => false) + double("shell_out", exitstatus: 0, error?: false) end let(:shell_out_failure) do - double("shell_out", :exitstatus => 1, :error? => true) + double("shell_out", exitstatus: 1, error?: true) end let(:current_resource) { Chef::Resource::Service.new(service_name) } @@ -190,14 +190,14 @@ describe Chef::Provider::Service::Systemd do context "when a user is specified" do it "should call '#{systemctl_path} --user start service_name' if no start command is specified" do current_resource.user("joe") - expect(provider).to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe", default_env: false }).and_return(shell_out_success) + expect(provider).to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, user: "joe", default_env: false }).and_return(shell_out_success) provider.start_service end it "should not call '#{systemctl_path} --user start service_name' if it is already running" do current_resource.running(true) current_resource.user("joe") - expect(provider).not_to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe" }) + expect(provider).not_to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, user: "joe" }) provider.start_service end end @@ -264,7 +264,7 @@ describe Chef::Provider::Service::Systemd do before(:each) do provider.current_resource = current_resource current_resource.service_name(service_name) - allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}") + allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s) end it "should call '#{systemctl_path} --system enable service_name' to enable the service" do @@ -282,7 +282,7 @@ describe Chef::Provider::Service::Systemd do before(:each) do provider.current_resource = current_resource current_resource.service_name(service_name) - allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}") + allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s) end it "should call '#{systemctl_path} --system mask service_name' to mask the service" do @@ -300,7 +300,7 @@ describe Chef::Provider::Service::Systemd do before(:each) do provider.current_resource = current_resource current_resource.service_name(service_name) - allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}") + allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s) end it "should return true if '#{systemctl_path} --system is-active service_name' returns 0" do @@ -318,7 +318,7 @@ describe Chef::Provider::Service::Systemd do before(:each) do provider.current_resource = current_resource current_resource.service_name(service_name) - allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}") + allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s) end it "should return true if '#{systemctl_path} --system is-enabled service_name' returns 0" do @@ -336,26 +336,26 @@ describe Chef::Provider::Service::Systemd do before(:each) do provider.current_resource = current_resource current_resource.service_name(service_name) - allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}") + allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s) end it "should return true if '#{systemctl_path} --system is-enabled service_name' returns 'masked' and returns anything except 0" do - expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "masked", :exitstatus => shell_out_failure)) + expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "masked", exitstatus: shell_out_failure)) expect(provider.is_masked?).to be true end it "should return true if '#{systemctl_path} --system is-enabled service_name' outputs 'masked-runtime' and returns anything except 0" do - expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "masked-runtime", :exitstatus => shell_out_failure)) + expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "masked-runtime", exitstatus: shell_out_failure)) expect(provider.is_masked?).to be true end it "should return false if '#{systemctl_path} --system is-enabled service_name' returns 0" do - expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "enabled", :exitstatus => shell_out_success)) + expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "enabled", exitstatus: shell_out_success)) expect(provider.is_masked?).to be false end it "should return false if '#{systemctl_path} --system is-enabled service_name' returns anything except 0 and outputs an error'" do - expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "Failed to get unit file state for #{service_name}: No such file or directory", :exitstatus => shell_out_failure)) + expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "Failed to get unit file state for #{service_name}: No such file or directory", exitstatus: shell_out_failure)) expect(provider.is_masked?).to be false end end diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index a95f9c494e..365201cb38 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Provider::Service::Upstart do let(:shell_out_success) do - double("shell_out", :exitstatus => 0, :error? => false) + double("shell_out", exitstatus: 0, error?: false) end before(:each) do @@ -43,7 +43,7 @@ describe Chef::Provider::Service::Upstart do it "should return /etc/event.d as the upstart job directory when running on Ubuntu 9.04" do @node.automatic_attrs[:platform_version] = "9.04" - #Chef::Platform.stub(:find_platform_and_version).and_return([ "ubuntu", "9.04" ]) + # Chef::Platform.stub(:find_platform_and_version).and_return([ "ubuntu", "9.04" ]) @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context) expect(@provider.instance_variable_get(:@upstart_job_dir)).to eq("/etc/event.d") expect(@provider.instance_variable_get(:@upstart_conf_suffix)).to eq("") @@ -66,7 +66,7 @@ describe Chef::Provider::Service::Upstart do describe "load_current_resource" do before(:each) do - @node.automatic_attrs[:command] = { :ps => "ps -ax" } + @node.automatic_attrs[:command] = { ps: "ps -ax" } @current_resource = Chef::Resource::Service.new("rsyslog") allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource) @@ -167,14 +167,14 @@ describe Chef::Provider::Service::Upstart do end it "should set enabled to true when it finds 'starts on'" do - @lines = double("start on filesystem", :gets => "start on filesystem") + @lines = double("start on filesystem", gets: "start on filesystem") allow(::File).to receive(:open).and_yield(@lines) expect(@current_resource).to receive(:running).with(false) @provider.load_current_resource end it "should set enabled to false when it finds '#starts on'" do - @lines = double("start on filesystem", :gets => "#start on filesystem") + @lines = double("start on filesystem", gets: "#start on filesystem") allow(::File).to receive(:open).and_yield(@lines) expect(@current_resource).to receive(:running).with(false) @provider.load_current_resource diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb index 18ea004795..dd59089418 100644 --- a/spec/unit/provider/service/windows_spec.rb +++ b/spec/unit/provider/service/windows_spec.rb @@ -98,7 +98,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl Win32::Service::DISABLED = 0x00000004 allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "running")) allow(Win32::Service).to receive(:config_info).with(new_resource.service_name) .and_return(chef_service_config_info) @@ -502,13 +502,13 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "start_service" do before(:each) do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "stopped"), - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "stopped"), + double("StatusStruct", current_state: "running")) end it "calls the start command if one is specified" do new_resource.start_command "sc start #{chef_service_name}" - expect(provider).to receive(:shell_out!).with("#{new_resource.start_command}").and_return("Starting custom service") + expect(provider).to receive(:shell_out!).with((new_resource.start_command).to_s).and_return("Starting custom service") provider.start_service expect(new_resource.updated_by_last_action?).to be_truthy end @@ -528,7 +528,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "does nothing if the service is running" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "running")) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) provider.start_service @@ -537,7 +537,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "raises an error if the service is paused" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "paused")) + double("StatusStruct", current_state: "paused")) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) expect { provider.start_service }.to raise_error( Chef::Exceptions::Service ) @@ -546,9 +546,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "waits and continues if the service is in start_pending" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "start pending"), - double("StatusStruct", :current_state => "start pending"), - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "start pending"), + double("StatusStruct", current_state: "start pending"), + double("StatusStruct", current_state: "running")) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) provider.start_service @@ -557,7 +557,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "fails if the service is in stop_pending" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "stop pending")) + double("StatusStruct", current_state: "stop pending")) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) expect { provider.start_service }.to raise_error( Chef::Exceptions::Service ) @@ -597,13 +597,13 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl before(:each) do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "running"), - double("StatusStruct", :current_state => "stopped")) + double("StatusStruct", current_state: "running"), + double("StatusStruct", current_state: "stopped")) end it "calls the stop command if one is specified" do new_resource.stop_command "sc stop #{chef_service_name}" - expect(provider).to receive(:shell_out!).with("#{new_resource.stop_command}").and_return("Stopping custom service") + expect(provider).to receive(:shell_out!).with((new_resource.stop_command).to_s).and_return("Stopping custom service") provider.stop_service expect(new_resource.updated_by_last_action?).to be_truthy end @@ -623,7 +623,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "does nothing if the service is stopped" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "stopped")) + double("StatusStruct", current_state: "stopped")) provider.load_current_resource expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name) provider.stop_service @@ -632,7 +632,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "raises an error if the service is paused" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "paused")) + double("StatusStruct", current_state: "paused")) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service ) @@ -641,9 +641,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "waits and continue if the service is in stop_pending" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "stop pending"), - double("StatusStruct", :current_state => "stop pending"), - double("StatusStruct", :current_state => "stopped")) + double("StatusStruct", current_state: "stop pending"), + double("StatusStruct", current_state: "stop pending"), + double("StatusStruct", current_state: "stopped")) provider.load_current_resource expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name) provider.stop_service @@ -652,7 +652,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "fails if the service is in start_pending" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "start pending")) + double("StatusStruct", current_state: "start pending")) provider.load_current_resource expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name) expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service ) @@ -661,7 +661,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "passes custom timeout to the stop command if provided" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "running")) new_resource.timeout 1 expect(Win32::Service).to receive(:stop).with(new_resource.service_name) Timeout.timeout(2) do @@ -676,17 +676,17 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "calls the restart command if one is specified" do new_resource.restart_command "sc restart" - expect(provider).to receive(:shell_out!).with("#{new_resource.restart_command}") + expect(provider).to receive(:shell_out!).with((new_resource.restart_command).to_s) provider.restart_service expect(new_resource.updated_by_last_action?).to be_truthy end it "stops then starts the service if it is running" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "running"), - double("StatusStruct", :current_state => "stopped"), - double("StatusStruct", :current_state => "stopped"), - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "running"), + double("StatusStruct", current_state: "stopped"), + double("StatusStruct", current_state: "stopped"), + double("StatusStruct", current_state: "running")) expect(Win32::Service).to receive(:stop).with(new_resource.service_name) expect(Win32::Service).to receive(:start).with(new_resource.service_name) provider.restart_service @@ -695,9 +695,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "just starts the service if it is stopped" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", :current_state => "stopped"), - double("StatusStruct", :current_state => "stopped"), - double("StatusStruct", :current_state => "running")) + double("StatusStruct", current_state: "stopped"), + double("StatusStruct", current_state: "stopped"), + double("StatusStruct", current_state: "running")) expect(Win32::Service).to receive(:start).with(new_resource.service_name) provider.restart_service expect(new_resource.updated_by_last_action?).to be_truthy @@ -716,11 +716,11 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "enable_service" do before(:each) do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "disabled")) + double("ConfigStruct", start_type: "disabled")) end it "enables service" do - expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START) + expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::AUTO_START) provider.enable_service expect(new_resource.updated_by_last_action?).to be_truthy end @@ -736,14 +736,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "action_enable" do it "does nothing if the service is enabled" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "auto start")) + double("ConfigStruct", start_type: "auto start")) expect(provider).not_to receive(:enable_service) provider.action_enable end it "enables the service if it is not set to automatic start" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "disabled")) + double("ConfigStruct", start_type: "disabled")) expect(provider).to receive(:enable_service) provider.action_enable end @@ -752,14 +752,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "action_disable" do it "does nothing if the service is disabled" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "disabled")) + double("ConfigStruct", start_type: "disabled")) expect(provider).not_to receive(:disable_service) provider.action_disable end it "disables the service if it is not set to disabled" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "auto start")) + double("ConfigStruct", start_type: "auto start")) expect(provider).to receive(:disable_service) provider.action_disable end @@ -768,7 +768,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "disable_service" do before(:each) do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", :start_type => "auto start")) + double("ConfigStruct", start_type: "auto start")) end it "disables service" do @@ -810,17 +810,17 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "set_start_type" do it "when called with :automatic it calls Win32::Service#configure with Win32::Service::AUTO_START" do - expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START) + expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::AUTO_START) provider.send(:set_startup_type, :automatic) end it "when called with :manual it calls Win32::Service#configure with Win32::Service::DEMAND_START" do - expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DEMAND_START) + expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::DEMAND_START) provider.send(:set_startup_type, :manual) end it "when called with :disabled it calls Win32::Service#configure with Win32::Service::DISABLED" do - expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DISABLED) + expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::DISABLED) provider.send(:set_startup_type, :disabled) end diff --git a/spec/unit/provider/service_spec.rb b/spec/unit/provider/service_spec.rb index c788cb223e..f3e725abb6 100644 --- a/spec/unit/provider/service_spec.rb +++ b/spec/unit/provider/service_spec.rb @@ -99,7 +99,7 @@ describe Chef::Provider::Service do describe "action_restart" do before do - @current_resource.supports(:restart => true) + @current_resource.supports(restart: true) end it "should restart the service if it's supported and set the resource as updated" do @@ -118,11 +118,11 @@ describe Chef::Provider::Service do describe "action_reload" do before do - @new_resource.supports(:reload => true) + @new_resource.supports(reload: true) end it "should raise an exception if reload isn't supported" do - @new_resource.supports(:reload => false) + @new_resource.supports(reload: false) @new_resource.reload_command(false) expect { @provider.run_action(:reload) }.to raise_error(Chef::Exceptions::UnsupportedAction) end diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb index 55d6dc5d24..5233ecb229 100644 --- a/spec/unit/provider/subversion_spec.rb +++ b/spec/unit/provider/subversion_spec.rb @@ -46,7 +46,7 @@ describe Chef::Provider::Subversion do it "converts resource attributes to options for shell_out" do expect(@provider.run_options).to eq({}) @resource.user "deployninja" - expect(@provider.run_options).to eq({ :user => "deployninja" }) + expect(@provider.run_options).to eq({ user: "deployninja" }) end context "determining the revision of the currently deployed code" do @@ -73,18 +73,18 @@ describe Chef::Provider::Subversion do "Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision "Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n" expect(::File).to receive(:exist?).at_least(1).times.with("/my/deploy/dir/.svn").and_return(true) - expected_command = ["svn info", { :cwd => "/my/deploy/dir", :returns => [0, 1] }] - expect(@provider).to receive(:shell_out!).with(*expected_command). - and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) + 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: "")) 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] }] - expect(@provider).to receive(:shell_out!).with(*expected_command). - and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) + 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: "")) expect(@provider.find_current_revision).to be_nil end @@ -128,18 +128,18 @@ describe Chef::Provider::Subversion do "Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision "Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n" @resource.revision "HEAD" - expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { :cwd => "/my/deploy/dir", :returns => [0, 1] }] - expect(@provider).to receive(:shell_out!).with(*expected_command). - and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) + 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 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] }] - expect(@provider).to receive(:shell_out!).with(*expected_command). - and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) + 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") end diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb index 5e57cbb840..93f624933f 100644 --- a/spec/unit/provider/systemd_unit_spec.rb +++ b/spec/unit/provider/systemd_unit_spec.rb @@ -50,27 +50,27 @@ describe Chef::Provider::SystemdUnit do let(:user_cmd_opts) do { - :user => "joe", - :environment => { + user: "joe", + environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/1000/bus", }, } end let(:shell_out_success) do - double("shell_out", :exitstatus => 0, :error? => false) + double("shell_out", exitstatus: 0, error?: false) end let(:shell_out_failure) do - double("shell_out", :exitstatus => 1, :error? => true) + double("shell_out", exitstatus: 1, error?: true) end let(:shell_out_masked) do - double("shell_out", :exit_status => 0, :error? => false, :stdout => "masked") + double("shell_out", exit_status: 0, error?: false, stdout: "masked") end let(:shell_out_static) do - double("shell_out", :exit_status => 0, :error? => false, :stdout => "static") + double("shell_out", exit_status: 0, error?: false, stdout: "static") end before(:each) do @@ -803,7 +803,7 @@ describe Chef::Provider::SystemdUnit do describe "#active?" do before(:each) do provider.current_resource = current_resource - allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}") + allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s) end context "when a user is specified" do @@ -844,7 +844,7 @@ describe Chef::Provider::SystemdUnit do describe "#enabled?" do before(:each) do provider.current_resource = current_resource - allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}") + allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s) end context "when a user is specified" do @@ -885,7 +885,7 @@ describe Chef::Provider::SystemdUnit do describe "#masked?" do before(:each) do provider.current_resource = current_resource - allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}") + allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s) end context "when a user is specified" do @@ -926,7 +926,7 @@ describe Chef::Provider::SystemdUnit do describe "#static?" do before(:each) do provider.current_resource = current_resource - allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}") + allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s) end context "when a user is specified" do diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb index 8f30d8f868..67d4eba138 100644 --- a/spec/unit/provider/template/content_spec.rb +++ b/spec/unit/provider/template/content_spec.rb @@ -30,20 +30,20 @@ describe Chef::Provider::Template::Content do let(:new_resource) do double("Chef::Resource::Template (new)", - :cookbook_name => "openldap", - :recipe_name => "default", - :source_line => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'", - :source_line_file => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb", - :source_line_number => "2", - :source => "openldap_stuff.conf.erb", - :name => "openldap_stuff.conf", - :path => resource_path, - :local => false, - :cookbook => nil, - :variables => {}, - :inline_helper_blocks => {}, - :inline_helper_modules => [], - :helper_modules => []) + cookbook_name: "openldap", + recipe_name: "default", + source_line: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'", + source_line_file: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb", + source_line_number: "2", + source: "openldap_stuff.conf.erb", + name: "openldap_stuff.conf", + path: resource_path, + local: false, + cookbook: nil, + variables: {}, + inline_helper_blocks: {}, + inline_helper_modules: [], + helper_modules: []) end let(:rendered_file_locations) do @@ -58,7 +58,7 @@ describe Chef::Provider::Template::Content do cl.load_cookbooks cookbook_collection = Chef::CookbookCollection.new(cl) node = Chef::Node.new - double("Chef::Resource::RunContext", :node => node, :cookbook_collection => cookbook_collection) + double("Chef::Resource::RunContext", node: node, cookbook_collection: cookbook_collection) end let(:content) do @@ -130,38 +130,38 @@ describe Chef::Provider::Template::Content do describe "when using location helpers" do let(:new_resource) do double("Chef::Resource::Template (new)", - :cookbook_name => "openldap", - :recipe_name => "default", - :source_line => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'", - :source_line_file => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb", - :source_line_number => "2", - :source => "helpers.erb", - :name => "helpers.erb", - :path => CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb", - :local => false, - :cookbook => nil, - :variables => {}, - :inline_helper_blocks => {}, - :inline_helper_modules => [], - :helper_modules => []) + cookbook_name: "openldap", + recipe_name: "default", + source_line: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'", + source_line_file: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb", + source_line_number: "2", + source: "helpers.erb", + name: "helpers.erb", + path: CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb", + local: false, + cookbook: nil, + variables: {}, + inline_helper_blocks: {}, + inline_helper_modules: [], + helper_modules: []) end it "creates the template with the rendered content" do - expect(IO.read(content.tempfile.path)).to eql <<EOF -openldap -default -#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb:2:in `from_file' -#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb -2 -helpers.erb -#{CHEF_SPEC_DATA}/cookbooks/openldap/templates/default/helpers.erb -openldap -default -#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb:2:in `from_file' -#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb -2 -helpers.erb -#{CHEF_SPEC_DATA}/cookbooks/openldap/templates/default/helpers.erb + expect(IO.read(content.tempfile.path)).to eql <<~EOF + openldap + default + #{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb:2:in `from_file' + #{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb + 2 + helpers.erb + #{CHEF_SPEC_DATA}/cookbooks/openldap/templates/default/helpers.erb + openldap + default + #{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb:2:in `from_file' + #{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb + 2 + helpers.erb + #{CHEF_SPEC_DATA}/cookbooks/openldap/templates/default/helpers.erb EOF end diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb index 9f69772bc8..a65846ecb2 100644 --- a/spec/unit/provider/template_spec.rb +++ b/spec/unit/provider/template_spec.rb @@ -27,7 +27,7 @@ describe Chef::Provider::Template do let(:node) { double("Chef::Node") } let(:events) { double("Chef::Events").as_null_object } # mock all the methods let(:logger) { double("Mixlib::Log::Child").as_null_object } - let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) } + let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) } let(:enclosing_directory) do canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) end @@ -50,7 +50,7 @@ describe Chef::Provider::Template do end let(:content) do - content = double("Chef::Provider::File::Content::Template", :template_location => "/foo/bar/baz") + content = double("Chef::Provider::File::Content::Template", template_location: "/foo/bar/baz") allow(File).to receive(:exists?).with("/foo/bar/baz").and_return(true) content end diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb index 8cc69f88af..7c6948bf84 100644 --- a/spec/unit/provider/user/pw_spec.rb +++ b/spec/unit/provider/user/pw_spec.rb @@ -202,7 +202,7 @@ describe Chef::Provider::User::Pw do end it "should run pw usermod with the username and the option -H 0" do - expect(@provider).to receive(:shell_out_compacted!).with( "pw usermod adam -H 0", { :input => "abracadabra" }).and_return(@status) + expect(@provider).to receive(:shell_out_compacted!).with( "pw usermod adam -H 0", { input: "abracadabra" }).and_return(@status) @provider.modify_password end diff --git a/spec/unit/provider/windows_env_spec.rb b/spec/unit/provider/windows_env_spec.rb index a42a0509c5..0e6cb02d48 100644 --- a/spec/unit/provider/windows_env_spec.rb +++ b/spec/unit/provider/windows_env_spec.rb @@ -36,8 +36,8 @@ describe Chef::Provider::WindowsEnv, :windows_only do describe "when loading the current status" do before do - #@current_resource = @new_resource.clone - #Chef::Resource::Env.stub(:new).and_return(@current_resource) + # @current_resource = @new_resource.clone + # Chef::Resource::Env.stub(:new).and_return(@current_resource) @provider.current_resource = @current_resource allow(@provider).to receive(:env_value).with("FOO").and_return("bar") allow(@provider).to receive(:env_key_exists).and_return(true) diff --git a/spec/unit/provider/windows_task_spec.rb b/spec/unit/provider/windows_task_spec.rb index 66bd6854b6..3a046ab5de 100644 --- a/spec/unit/provider/windows_task_spec.rb +++ b/spec/unit/provider/windows_task_spec.rb @@ -70,20 +70,20 @@ describe Chef::Provider::WindowsTask, :windows_only do new_resource.frequency_modifier 15 new_resource.random_delay 60 result = { - :start_year => 2017, - :start_month => 12, - :start_day => 2, - :start_hour => 17, - :start_minute => 30, - :end_month => 0, - :end_day => 0, - :end_year => 0, - :trigger_type => 1, - :type => { :once => nil }, - :random_minutes_interval => 60, - :minutes_interval => 15, - :run_on_last_day_of_month => false, - :run_on_last_week_of_month => false + start_year: 2017, + start_month: 12, + start_day: 2, + start_hour: 17, + start_minute: 30, + end_month: 0, + end_day: 0, + end_year: 0, + trigger_type: 1, + type: { once: nil }, + random_minutes_interval: 60, + minutes_interval: 15, + run_on_last_day_of_month: false, + run_on_last_week_of_month: false, } expect(provider.send(:trigger)).to eq(result) @@ -145,7 +145,7 @@ describe Chef::Provider::WindowsTask, :windows_only do new_resource.frequency_modifier 2 result = provider.send(:type) expect(result).to include(:once) - expect(result).to eq({ :once => nil }) + expect(result).to eq({ once: nil }) end it "returns type hash when frequency :daily" do @@ -286,7 +286,7 @@ describe Chef::Provider::WindowsTask, :windows_only do end end - #Ref : https://msdn.microsoft.com/en-us/library/windows/desktop/aa380729(v=vs.85).aspx + # Ref : https://msdn.microsoft.com/en-us/library/windows/desktop/aa380729(v=vs.85).aspx describe "#days_of_week" do it "returns the binary value 2 if day is set as 'Mon'" do new_resource.day "Mon" diff --git a/spec/unit/provider/zypper_repository_spec.rb b/spec/unit/provider/zypper_repository_spec.rb index 3a26876f99..fc8ff14afb 100644 --- a/spec/unit/provider/zypper_repository_spec.rb +++ b/spec/unit/provider/zypper_repository_spec.rb @@ -20,17 +20,17 @@ require "spec_helper" # Output of the command: # => rpm -qa gpg-pubkey* -RPM_KEYS = <<-EOF -gpg-pubkey-307e3d54-4be01a65 -gpg-pubkey-3dbdc284-53674dd4 +RPM_KEYS = <<~EOF + gpg-pubkey-307e3d54-4be01a65 + gpg-pubkey-3dbdc284-53674dd4 EOF # Output of the command: # => gpg --with-fingerprint [FILE] -GPG_FINGER = <<-EOF -pub 2048R/3DBDC284 2011-08-19 [expires: 2024-06-14] - Key fingerprint = 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 -uid nginx signing key <signing-key@nginx.com> +GPG_FINGER = <<~EOF + pub 2048R/3DBDC284 2011-08-19 [expires: 2024-06-14] + Key fingerprint = 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 + uid nginx signing key <signing-key@nginx.com> EOF describe Chef::Provider::ZypperRepository do |