summaryrefslogtreecommitdiff
path: root/spec/unit/provider
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider')
-rw-r--r--spec/unit/provider/apt_repository_spec.rb8
-rw-r--r--spec/unit/provider/cookbook_file/content_spec.rb2
-rw-r--r--spec/unit/provider/cookbook_file_spec.rb2
-rw-r--r--spec/unit/provider/cron/unix_spec.rb14
-rw-r--r--spec/unit/provider/dsc_resource_spec.rb8
-rw-r--r--spec/unit/provider/execute_spec.rb2
-rw-r--r--spec/unit/provider/file/content_spec.rb2
-rw-r--r--spec/unit/provider/file_spec.rb2
-rw-r--r--spec/unit/provider/git_spec.rb212
-rw-r--r--spec/unit/provider/group_spec.rb6
-rw-r--r--spec/unit/provider/link_spec.rb12
-rw-r--r--spec/unit/provider/mdadm_spec.rb6
-rw-r--r--spec/unit/provider/mount/aix_spec.rb10
-rw-r--r--spec/unit/provider/mount/mount_spec.rb36
-rw-r--r--spec/unit/provider/mount/solaris_spec.rb4
-rw-r--r--spec/unit/provider/mount/windows_spec.rb8
-rw-r--r--spec/unit/provider/ohai_spec.rb18
-rw-r--r--spec/unit/provider/osx_profile_spec.rb2
-rw-r--r--spec/unit/provider/package/apt_spec.rb134
-rw-r--r--spec/unit/provider/package/bff_spec.rb24
-rw-r--r--spec/unit/provider/package/chocolatey_spec.rb46
-rw-r--r--spec/unit/provider/package/dpkg_spec.rb8
-rw-r--r--spec/unit/provider/package/freebsd/pkg_spec.rb26
-rw-r--r--spec/unit/provider/package/freebsd/pkgng_spec.rb10
-rw-r--r--spec/unit/provider/package/freebsd/port_spec.rb18
-rw-r--r--spec/unit/provider/package/homebrew_spec.rb8
-rw-r--r--spec/unit/provider/package/ips_spec.rb4
-rw-r--r--spec/unit/provider/package/macports_spec.rb8
-rw-r--r--spec/unit/provider/package/openbsd_spec.rb22
-rw-r--r--spec/unit/provider/package/pacman_spec.rb8
-rw-r--r--spec/unit/provider/package/paludis_spec.rb10
-rw-r--r--spec/unit/provider/package/portage_spec.rb8
-rw-r--r--spec/unit/provider/package/powershell_spec.rb176
-rw-r--r--spec/unit/provider/package/smartos_spec.rb20
-rw-r--r--spec/unit/provider/package/solaris_spec.rb12
-rw-r--r--spec/unit/provider/package/windows/exe_spec.rb2
-rw-r--r--spec/unit/provider/package/windows/msi_spec.rb2
-rw-r--r--spec/unit/provider/package/windows_spec.rb2
-rw-r--r--spec/unit/provider/package/zypper_spec.rb12
-rw-r--r--spec/unit/provider/powershell_script_spec.rb2
-rw-r--r--spec/unit/provider/registry_key_spec.rb44
-rw-r--r--spec/unit/provider/remote_file/content_spec.rb8
-rw-r--r--spec/unit/provider/remote_file/fetcher_spec.rb10
-rw-r--r--spec/unit/provider/remote_file/http_spec.rb2
-rw-r--r--spec/unit/provider/remote_file/local_file_spec.rb4
-rw-r--r--spec/unit/provider/remote_file/network_file_spec.rb6
-rw-r--r--spec/unit/provider/remote_file/sftp_spec.rb2
-rw-r--r--spec/unit/provider/remote_file_spec.rb2
-rw-r--r--spec/unit/provider/script_spec.rb2
-rw-r--r--spec/unit/provider/service/aix_service_spec.rb16
-rw-r--r--spec/unit/provider/service/aixinit_service_spec.rb2
-rw-r--r--spec/unit/provider/service/arch_service_spec.rb28
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb2
-rw-r--r--spec/unit/provider/service/freebsd_service_spec.rb20
-rw-r--r--spec/unit/provider/service/gentoo_service_spec.rb2
-rw-r--r--spec/unit/provider/service/init_service_spec.rb14
-rw-r--r--spec/unit/provider/service/insserv_service_spec.rb4
-rw-r--r--spec/unit/provider/service/invokercd_service_spec.rb20
-rw-r--r--spec/unit/provider/service/macosx_spec.rb8
-rw-r--r--spec/unit/provider/service/openbsd_service_spec.rb10
-rw-r--r--spec/unit/provider/service/redhat_spec.rb54
-rw-r--r--spec/unit/provider/service/simple_service_spec.rb10
-rw-r--r--spec/unit/provider/service/solaris_smf_service_spec.rb38
-rw-r--r--spec/unit/provider/service/systemd_service_spec.rb16
-rw-r--r--spec/unit/provider/service/upstart_service_spec.rb8
-rw-r--r--spec/unit/provider/service/windows_spec.rb70
-rw-r--r--spec/unit/provider/service_spec.rb6
-rw-r--r--spec/unit/provider/subversion_spec.rb18
-rw-r--r--spec/unit/provider/systemd_unit_spec.rb12
-rw-r--r--spec/unit/provider/template/content_spec.rb58
-rw-r--r--spec/unit/provider/template_spec.rb4
-rw-r--r--spec/unit/provider/user/pw_spec.rb2
-rw-r--r--spec/unit/provider/windows_task_spec.rb30
73 files changed, 724 insertions, 724 deletions
diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb
index d881d01124..54f1f2df66 100644
--- a/spec/unit/provider/apt_repository_spec.rb
+++ b/spec/unit/provider/apt_repository_spec.rb
@@ -67,14 +67,14 @@ describe Chef::Provider::AptRepository do
end
let(:gpg_shell_out_success) do
- double("shell_out", :stdout => "pub 2048R/7BD9BF62 2011-08-19 nginx signing key <signing-key@nginx.com>",
- :exitstatus => 0, :error? => false)
+ double("shell_out", stdout: "pub 2048R/7BD9BF62 2011-08-19 nginx signing key <signing-key@nginx.com>",
+ exitstatus: 0, error?: false)
end
let(:gpg_shell_out_failure) do
- double("shell_out", :stderr => "gpg: no valid OpenPGP data found.\n
+ double("shell_out", stderr: "gpg: no valid OpenPGP data found.\n
gpg: processing message failed: eof",
- :exitstatus => 1, :error? => true)
+ exitstatus: 1, error?: true)
end
let(:apt_fingerprints) do
diff --git a/spec/unit/provider/cookbook_file/content_spec.rb b/spec/unit/provider/cookbook_file/content_spec.rb
index 096ac85b64..4e07915a95 100644
--- a/spec/unit/provider/cookbook_file/content_spec.rb
+++ b/spec/unit/provider/cookbook_file/content_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Provider::CookbookFile::Content do
- let(:new_resource) { double("Chef::Resource::CookbookFile (new)", :cookbook_name => "apache2", :cookbook => "apache2") }
+ let(:new_resource) { double("Chef::Resource::CookbookFile (new)", cookbook_name: "apache2", cookbook: "apache2") }
let(:content) do
@run_context = double("Chef::RunContext")
@current_resource = double("Chef::Resource::CookbookFile (current)")
diff --git a/spec/unit/provider/cookbook_file_spec.rb b/spec/unit/provider/cookbook_file_spec.rb
index f27392de5d..e1ef3c63d8 100644
--- a/spec/unit/provider/cookbook_file_spec.rb
+++ b/spec/unit/provider/cookbook_file_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Provider::CookbookFile do
let(:node) { double("Chef::Node") }
let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:logger) { double("Mixlib::Log::Child").as_null_object }
- let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) }
+ let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) }
let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
end
diff --git a/spec/unit/provider/cron/unix_spec.rb b/spec/unit/provider/cron/unix_spec.rb
index 62b941c4aa..843f3f3d8c 100644
--- a/spec/unit/provider/cron/unix_spec.rb
+++ b/spec/unit/provider/cron/unix_spec.rb
@@ -37,9 +37,9 @@ describe Chef::Provider::Cron::Unix do
end
end
- let(:status) { double("Process::Status", :exitstatus => exitstatus) }
+ let(:status) { double("Process::Status", exitstatus: exitstatus) }
let(:exitstatus) { 0 }
- let(:shell_out) { double("Mixlib::ShellOut", :status => status, :stdout => stdout, :stderr => stderr) }
+ let(:shell_out) { double("Mixlib::ShellOut", status: status, stdout: stdout, stderr: stderr) }
let(:logger) { double("Mixlib::Log::Child").as_null_object }
@@ -66,12 +66,12 @@ describe Chef::Provider::Cron::Unix do
before do
allow(logger).to receive(:trace)
allow(shell_out).to receive(:format_for_exception).and_return("formatted command output")
- allow(provider).to receive(:shell_out).with("/usr/bin/crontab -l", :user => username).and_return(shell_out)
+ allow(provider).to receive(:shell_out).with("/usr/bin/crontab -l", user: username).and_return(shell_out)
end
it "should call crontab -l with the user" do
provider.send(:read_crontab)
- expect(provider).to have_received(:shell_out).with("/usr/bin/crontab -l", :user => username)
+ expect(provider).to have_received(:shell_out).with("/usr/bin/crontab -l", user: username)
end
it "should return the contents of the crontab" do
@@ -111,7 +111,7 @@ describe Chef::Provider::Cron::Unix do
describe "write_crontab" do
let(:stdout) { "" }
let(:stderr) { "" }
- let(:tempfile) { double("foo", :path => "/tmp/foo", :close => true) }
+ let(:tempfile) { double("foo", path: "/tmp/foo", close: true) }
before do
expect(Tempfile).to receive(:new).and_return(tempfile)
@@ -119,12 +119,12 @@ describe Chef::Provider::Cron::Unix do
expect(tempfile).to receive(:chmod).with(420)
expect(tempfile).to receive(:close!)
allow(tempfile).to receive(:<<)
- allow(provider).to receive(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username).and_return(shell_out)
+ allow(provider).to receive(:shell_out).with("/usr/bin/crontab #{tempfile.path}", user: username).and_return(shell_out)
end
it "should call crontab for the user" do
provider.send(:write_crontab, "Foo")
- expect(provider).to have_received(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username)
+ expect(provider).to have_received(:shell_out).with("/usr/bin/crontab #{tempfile.path}", user: username)
end
it "should call crontab with a file containing the crontab" do
diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb
index 747e37f308..ab675c4ddd 100644
--- a/spec/unit/provider/dsc_resource_spec.rb
+++ b/spec/unit/provider/dsc_resource_spec.rb
@@ -104,7 +104,7 @@ describe Chef::Provider::DscResource do
it "flags the resource as reboot required when required" do
expect(provider).to receive(:test_resource).and_return(false)
expect(provider).to receive(:invoke_resource).
- and_return(double(:stdout => "", :return_value => nil))
+ and_return(double(stdout: "", return_value: nil))
expect(provider).to receive(:add_dsc_verbose_log)
expect(provider).to receive(:return_dsc_resource_result).and_return(true)
expect(provider).to receive(:create_reboot_resource)
@@ -114,7 +114,7 @@ describe Chef::Provider::DscResource do
it "does not flag the resource as reboot required when not required" do
expect(provider).to receive(:test_resource).and_return(false)
expect(provider).to receive(:invoke_resource).
- and_return(double(:stdout => "", :return_value => nil))
+ and_return(double(stdout: "", return_value: nil))
expect(provider).to receive(:add_dsc_verbose_log)
expect(provider).to receive(:return_dsc_resource_result).and_return(false)
expect(provider).to_not receive(:create_reboot_resource)
@@ -293,12 +293,12 @@ describe Chef::Provider::DscResource do
set_node_object
end
- let(:cmdlet) { double(:run! => nil) }
+ let(:cmdlet) { double(run!: nil) }
before(:each) do
allow(provider).to receive(:translate_type).and_return("my_properties")
provider.instance_variable_set(:@new_resource, double(
- :properties => "my_properties", :resource => "my_resource", :timeout => 123
+ properties: "my_properties", resource: "my_resource", timeout: 123
))
end
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index 78534bfb57..48cee78462 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Provider::Execute do
let(:provider) { Chef::Provider::Execute.new(new_resource, run_context) }
let(:current_resource) { Chef::Resource::Ifconfig.new("foo_resource", run_context) }
# You will be the same object, I promise.
- @live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, :name => :execute)
+ @live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, name: :execute)
let(:opts) do
{
diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb
index f840d92dbb..e65d094327 100644
--- a/spec/unit/provider/file/content_spec.rb
+++ b/spec/unit/provider/file/content_spec.rb
@@ -36,7 +36,7 @@ describe Chef::Provider::File::Content do
end
let(:new_resource) do
- double("Chef::Provider::File::Resource (new)", :name => "seattle.txt", :path => resource_path)
+ double("Chef::Provider::File::Resource (new)", name: "seattle.txt", path: resource_path)
end
let(:run_context) do
diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb
index fed9cd5ece..311ef4c55a 100644
--- a/spec/unit/provider/file_spec.rb
+++ b/spec/unit/provider/file_spec.rb
@@ -35,7 +35,7 @@ describe Chef::Provider::File do
let(:node) { double("Chef::Node") }
let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:logger) { double("Mixlib::Log::Child").as_null_object }
- let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) }
+ let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) }
let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
end
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb
index a20c7a838c..fafb83f548 100644
--- a/spec/unit/provider/git_spec.rb
+++ b/spec/unit/provider/git_spec.rb
@@ -58,7 +58,7 @@ describe Chef::Provider::Git do
it "determines the current revision when there is one" do
expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
@stdout = "9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\n"
- expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", { :cwd => "/my/deploy/dir", :returns => [0, 128], :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", { cwd: "/my/deploy/dir", returns: [0, 128], log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.find_current_revision).to eql("9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13")
end
@@ -66,7 +66,7 @@ describe Chef::Provider::Git do
expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
@stderr = "fatal: Not a git repository (or any of the parent directories): .git"
@stdout = ""
- expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", :cwd => "/my/deploy/dir", :returns => [0, 128], :log_tag => "git[web2.0 app]" ).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr))
+ expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", cwd: "/my/deploy/dir", returns: [0, 128], log_tag: "git[web2.0 app]" ).and_return(double("ShellOut result", stdout: "", stderr: @stderr))
expect(@provider.find_current_revision).to be_nil
end
end
@@ -152,7 +152,7 @@ describe Chef::Provider::Git do
@resource.revision "v1.0"
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -161,7 +161,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0^{}\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -170,7 +170,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/releases/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -179,7 +179,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -188,7 +188,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.1\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -198,7 +198,7 @@ describe Chef::Provider::Git do
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" +
"805c22a5e41f5ae3193460cca044ed1435029f53\trefs/pulls/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("805c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -207,7 +207,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -222,21 +222,21 @@ describe Chef::Provider::Git do
it "raises an unresolvable git reference error if the revision can't be resolved to any revision and assertions are run" do
@resource.revision "FAIL, that's the revision I want"
@provider.action = :checkout
- expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", :stdout => "\n"))
+ expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", stdout: "\n"))
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::UnresolvableGitReference)
end
it "does not raise an error if the revision can't be resolved when assertions are not run" do
@resource.revision "FAIL, that's the revision I want"
- expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", :stdout => "\n"))
+ expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", stdout: "\n"))
expect(@provider.target_revision).to eq(nil)
end
it "does not raise an error when the revision is valid and assertions are run." do
@resource.revision "0.8-alpha"
@stdout = "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n"
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
@provider.action = :checkout
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
@provider.define_resource_requirements
@@ -261,7 +261,7 @@ b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{}
ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package
SHAS
@resource.revision ""
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("28af684d8460ba4793eda3e7ac238c864a5d029a")
end
end
@@ -276,15 +276,15 @@ SHAS
let(:expected_cmd) { 'git clone "git://github.com/opscode/chef.git" "/my/deploy/dir"' }
let(:default_options) do
{
- :user => deploy_user,
- :environment => { "GIT_SSH" => wrapper, "HOME" => "/home/deployNinja" },
- :log_tag => "git[web2.0 app]",
+ user: deploy_user,
+ environment: { "GIT_SSH" => wrapper, "HOME" => "/home/deployNinja" },
+ log_tag: "git[web2.0 app]",
}
end
before do
@resource.user deploy_user
@resource.ssh_wrapper wrapper
- allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja"))
+ allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja"))
end
context "without a timeout set" do
it "clones a repo with default git options" do
@@ -296,7 +296,7 @@ SHAS
let (:seconds) { 10 }
before { @resource.timeout(seconds) }
it "clones a repo with amended git options" do
- expect(@provider).to receive(:shell_out!).with(expected_cmd, default_options.merge(:timeout => seconds))
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, default_options.merge(timeout: seconds))
@provider.clone
end
end
@@ -306,9 +306,9 @@ SHAS
end
let(:overrided_options) do
{
- :user => deploy_user,
- :environment => { "GIT_SSH" => wrapper, "HOME" => "/home/masterNinja" },
- :log_tag => "git[web2.0 app]",
+ user: deploy_user,
+ environment: { "GIT_SSH" => wrapper, "HOME" => "/home/masterNinja" },
+ log_tag: "git[web2.0 app]",
}
end
before do
@@ -327,14 +327,14 @@ SHAS
let(:expected_cmd) { 'git clone "git://github.com/opscode/chef.git" "/my/deploy/dir"' }
let(:default_options) do
{
- :user => 123,
- :environment => { "HOME" => "/home/deployNinja" },
- :log_tag => "git[web2.0 app]",
+ user: 123,
+ environment: { "HOME" => "/home/deployNinja" },
+ log_tag: "git[web2.0 app]",
}
end
before do
@resource.user deploy_user
- allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja"))
+ allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja"))
end
context "with a specific home" do
let (:override_home) do
@@ -342,9 +342,9 @@ SHAS
end
let(:overrided_options) do
{
- :user => 123,
- :environment => { "HOME" => "/home/masterNinja" },
- :log_tag => "git[web2.0 app]",
+ user: 123,
+ environment: { "HOME" => "/home/masterNinja" },
+ log_tag: "git[web2.0 app]",
}
end
before do
@@ -360,13 +360,13 @@ SHAS
it "runs a clone command with escaped destination" do
@resource.user "deployNinja"
- allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja"))
+ allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja"))
@resource.destination "/Application Support/with/space"
@resource.ssh_wrapper "do_it_this_way.sh"
expected_cmd = "git clone \"git://github.com/opscode/chef.git\" \"/Application Support/with/space\""
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :user => "deployNinja",
- :log_tag => "git[web2.0 app]",
- :environment => { "HOME" => "/home/deployNinja",
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, user: "deployNinja",
+ log_tag: "git[web2.0 app]",
+ environment: { "HOME" => "/home/deployNinja",
"GIT_SSH" => "do_it_this_way.sh" })
@provider.clone
end
@@ -377,8 +377,8 @@ SHAS
version_response = double("shell_out")
allow(version_response).to receive(:stdout) { "git version 1.7.9" }
expect(@provider).to receive(:shell_out!).with("git --version",
- :log_tag => "git[web2.0 app]").and_return(version_response)
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]")
+ log_tag: "git[web2.0 app]").and_return(version_response)
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]")
@provider.clone
end
@@ -388,33 +388,33 @@ SHAS
version_response = double("shell_out")
allow(version_response).to receive(:stdout) { "git version 1.7.10" }
expect(@provider).to receive(:shell_out!).with("git --version",
- :log_tag => "git[web2.0 app]").and_return(version_response)
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]")
+ log_tag: "git[web2.0 app]").and_return(version_response)
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]")
@provider.clone
end
it "compiles a clone command with a remote other than ``origin''" do
@resource.remote "opscode"
expected_cmd = "git clone -o opscode \"git://github.com/opscode/chef.git\" \"/my/deploy/dir\""
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]")
@provider.clone
end
it "runs a checkout command with default options" do
- expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]").ordered
- expect(@provider).to receive(:shell_out!).with("git checkout deploy", :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]").ordered
+ expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]").ordered
+ expect(@provider).to receive(:shell_out!).with("git checkout deploy", cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]").ordered
@provider.checkout
end
it "runs an enable_submodule command" do
@resource.enable_submodules true
expected_cmd = "git submodule sync"
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
expected_cmd = "git submodule update --init --recursive"
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
@provider.enable_submodules
end
@@ -426,35 +426,35 @@ SHAS
it "runs a sync command with default options" do
expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository)
expected_cmd1 = "git fetch --prune origin"
- expect(@provider).to receive(:shell_out!).with(expected_cmd1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
expected_cmd2 = "git fetch origin --tags"
- expect(@provider).to receive(:shell_out!).with(expected_cmd2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
expected_cmd3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
- expect(@provider).to receive(:shell_out!).with(expected_cmd3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
@provider.fetch_updates
end
it "runs a sync command with the user and group specified in the resource" do
@resource.user("whois")
- allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois"))
+ allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/whois"))
@resource.group("thisis")
expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository)
expected_cmd1 = "git fetch --prune origin"
- expect(@provider).to receive(:shell_out!).with(expected_cmd1, :cwd => "/my/deploy/dir",
- :user => "whois", :group => "thisis",
- :log_tag => "git[web2.0 app]",
- :environment => { "HOME" => "/home/whois" })
+ expect(@provider).to receive(:shell_out!).with(expected_cmd1, cwd: "/my/deploy/dir",
+ user: "whois", group: "thisis",
+ log_tag: "git[web2.0 app]",
+ environment: { "HOME" => "/home/whois" })
expected_cmd2 = "git fetch origin --tags"
- expect(@provider).to receive(:shell_out!).with(expected_cmd2, :cwd => "/my/deploy/dir",
- :user => "whois", :group => "thisis",
- :log_tag => "git[web2.0 app]",
- :environment => { "HOME" => "/home/whois" })
+ expect(@provider).to receive(:shell_out!).with(expected_cmd2, cwd: "/my/deploy/dir",
+ user: "whois", group: "thisis",
+ log_tag: "git[web2.0 app]",
+ environment: { "HOME" => "/home/whois" })
expected_cmd3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
- expect(@provider).to receive(:shell_out!).with(expected_cmd3, :cwd => "/my/deploy/dir",
- :user => "whois", :group => "thisis",
- :log_tag => "git[web2.0 app]",
- :environment => { "HOME" => "/home/whois" })
+ expect(@provider).to receive(:shell_out!).with(expected_cmd3, cwd: "/my/deploy/dir",
+ user: "whois", group: "thisis",
+ log_tag: "git[web2.0 app]",
+ environment: { "HOME" => "/home/whois" })
@provider.fetch_updates
end
@@ -462,11 +462,11 @@ SHAS
@resource.remote "origin"
expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository)
fetch_command1 = "git fetch --prune origin"
- expect(@provider).to receive(:shell_out!).with(fetch_command1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
fetch_command2 = "git fetch origin --tags"
- expect(@provider).to receive(:shell_out!).with(fetch_command2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
fetch_command3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
- expect(@provider).to receive(:shell_out!).with(fetch_command3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
@provider.fetch_updates
end
@@ -474,11 +474,11 @@ SHAS
@resource.remote "opscode"
expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository)
fetch_command1 = "git fetch --prune opscode"
- expect(@provider).to receive(:shell_out!).with(fetch_command1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
fetch_command2 = "git fetch opscode --tags"
- expect(@provider).to receive(:shell_out!).with(fetch_command2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
fetch_command3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
- expect(@provider).to receive(:shell_out!).with(fetch_command3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
@provider.fetch_updates
end
@@ -489,37 +489,37 @@ SHAS
allow(command_response).to receive(:exitstatus) { 1 }
expected_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(expected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ returns: [0, 1, 2]).and_return(command_response)
add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}"
expect(@provider).to receive(:shell_out!).with(add_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
it "runs the config with the user and group specified in the resource" do
@resource.user("whois")
@resource.group("thisis")
- allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois"))
+ allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/whois"))
command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 1 }
expected_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(expected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :user => "whois",
- :group => "thisis",
- :environment => { "HOME" => "/home/whois" },
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ user: "whois",
+ group: "thisis",
+ environment: { "HOME" => "/home/whois" },
+ returns: [0, 1, 2]).and_return(command_response)
add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}"
expect(@provider).to receive(:shell_out!).with(add_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :user => "whois",
- :group => "thisis",
- :environment => { "HOME" => "/home/whois" })
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ user: "whois",
+ group: "thisis",
+ environment: { "HOME" => "/home/whois" })
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
@@ -529,13 +529,13 @@ SHAS
allow(command_response).to receive(:exitstatus) { 1 }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(check_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ returns: [0, 1, 2]).and_return(command_response)
expected_command = "git remote add #{@resource.remote} #{@resource.repository}"
expect(@provider).to receive(:shell_out!).with(expected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
end
@@ -547,13 +547,13 @@ SHAS
allow(command_response).to receive(:stdout) { "some_other_url" }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(check_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ returns: [0, 1, 2]).and_return(command_response)
expected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\""
expect(@provider).to receive(:shell_out!).with(expected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
@@ -563,13 +563,13 @@ SHAS
allow(command_response).to receive(:stdout) { @resource.repository }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(check_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ returns: [0, 1, 2]).and_return(command_response)
unexpected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\""
expect(@provider).not_to receive(:shell_out!).with(unexpected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
@@ -578,13 +578,13 @@ SHAS
allow(command_response).to receive(:exitstatus) { 2 }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(check_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ returns: [0, 1, 2]).and_return(command_response)
expected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\""
expect(@provider).to receive(:shell_out!).with(expected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
end
@@ -705,7 +705,7 @@ SHAS
allow(::File).to receive(:directory?).with("/my/deploy/dir").and_return(true)
allow(@provider).to receive(:sync_command).and_return("huzzah!")
expect(@provider).to receive(:action_checkout)
- expect(@provider).not_to receive(:shell_out!).with("huzzah!", :cwd => "/my/deploy/dir")
+ expect(@provider).not_to receive(:shell_out!).with("huzzah!", cwd: "/my/deploy/dir")
@provider.run_action(:sync)
#@resource.should be_updated
end
@@ -719,8 +719,8 @@ SHAS
describe "calling add_remotes" do
it "adds a new remote for each entry in additional remotes hash" do
- @resource.additional_remotes({ :opscode => "opscode_repo_url",
- :another_repo => "some_other_repo_url" })
+ @resource.additional_remotes({ opscode: "opscode_repo_url",
+ another_repo: "some_other_repo_url" })
allow(STDOUT).to receive(:tty?).and_return(false)
command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 0 }
diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb
index c3e0d4b345..437b8c45ea 100644
--- a/spec/unit/provider/group_spec.rb
+++ b/spec/unit/provider/group_spec.rb
@@ -37,9 +37,9 @@ describe Chef::Provider::User do
@provider.current_resource = @current_resource
@pw_group = double("Struct::Group",
- :name => "wheel",
- :gid => 20,
- :mem => %w{root aj}
+ name: "wheel",
+ gid: 20,
+ mem: %w{root aj}
)
allow(Etc).to receive(:getgrnam).with("wheel").and_return(@pw_group)
end
diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb
index 10dbdc1766..8f1ec8c3ba 100644
--- a/spec/unit/provider/link_spec.rb
+++ b/spec/unit/provider/link_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Resource::Link do
describe "when the target is a symlink" do
before(:each) do
- lstat = double("stats", :ino => 5)
+ lstat = double("stats", ino: 5)
allow(lstat).to receive(:uid).and_return(501)
allow(lstat).to receive(:gid).and_return(501)
allow(lstat).to receive(:mode).and_return(0777)
@@ -146,7 +146,7 @@ describe Chef::Resource::Link do
describe "when the target is a regular old file" do
before do
- stat = double("stats", :ino => 5)
+ stat = double("stats", ino: 5)
allow(stat).to receive(:uid).and_return(501)
allow(stat).to receive(:gid).and_return(501)
allow(stat).to receive(:mode).and_return(0755)
@@ -178,7 +178,7 @@ describe Chef::Resource::Link do
describe "and the source exists" do
before do
- stat = double("stats", :ino => 6)
+ stat = double("stats", ino: 6)
allow(stat).to receive(:uid).and_return(502)
allow(stat).to receive(:gid).and_return(502)
allow(stat).to receive(:mode).and_return(0644)
@@ -205,7 +205,7 @@ describe Chef::Resource::Link do
describe "and is hardlinked to the source" do
before do
- stat = double("stats", :ino => 5)
+ stat = double("stats", ino: 5)
allow(stat).to receive(:uid).and_return(502)
allow(stat).to receive(:gid).and_return(502)
allow(stat).to receive(:mode).and_return(0644)
@@ -254,7 +254,7 @@ describe Chef::Resource::Link do
describe "action_delete" do
before(:each) do
- stat = double("stats", :ino => 5)
+ stat = double("stats", ino: 5)
allow(stat).to receive(:uid).and_return(501)
allow(stat).to receive(:gid).and_return(501)
allow(stat).to receive(:mode).and_return(0755)
@@ -321,7 +321,7 @@ describe Chef::Resource::Link do
end
before(:each) do
- stat = double("stats", :ino => 5)
+ stat = double("stats", ino: 5)
allow(stat).to receive(:uid).and_return(502)
allow(stat).to receive(:gid).and_return(502)
allow(stat).to receive(:mode).and_return(0644)
diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb
index 8ef884e131..17824c4fb8 100644
--- a/spec/unit/provider/mdadm_spec.rb
+++ b/spec/unit/provider/mdadm_spec.rb
@@ -32,20 +32,20 @@ describe Chef::Provider::Mdadm do
describe "when determining the current metadevice status" do
it "should set the current resources mount point to the new resources mount point" do
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:status => 0))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(status: 0))
@provider.load_current_resource
expect(@provider.current_resource.name).to eq("/dev/md1")
expect(@provider.current_resource.raid_device).to eq("/dev/md1")
end
it "determines that the metadevice exists when mdadm exit code is zero" do
- allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 0))
+ allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", returns: [0, 4]).and_return(OpenStruct.new(status: 0))
@provider.load_current_resource
expect(@provider.current_resource.exists).to be_truthy
end
it "determines that the metadevice does not exist when mdadm exit code is 4" do
- allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 4))
+ allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", returns: [0, 4]).and_return(OpenStruct.new(status: 4))
@provider.load_current_resource
expect(@provider.current_resource.exists).to be_falsey
end
diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb
index 615f3c3304..d807409d05 100644
--- a/spec/unit/provider/mount/aix_spec.rb
+++ b/spec/unit/provider/mount/aix_spec.rb
@@ -61,7 +61,7 @@ WRONG
@new_resource.device_type :device
@new_resource.fstype "jfs2"
- @new_resource.supports :remount => false
+ @new_resource.supports remount: false
@provider = Chef::Provider::Mount::Aix.new(@new_resource, @run_context)
@@ -70,12 +70,12 @@ WRONG
end
def stub_mounted(provider, mounted_output)
- response = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => mounted_output, :stderr => "")
+ response = double("Mixlib::ShellOut command", exitstatus: 0, stdout: mounted_output, stderr: "")
expect(provider).to receive(:shell_out!).with("mount").and_return(response)
end
def stub_enabled(provider, enabled_output)
- response = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => enabled_output, :stderr => "")
+ response = double("Mixlib::ShellOut command", exitstatus: 0, stdout: enabled_output, stderr: "")
expect(provider).to receive(:shell_out).with("lsfs -c #{@new_resource.mount_point}").and_return(response)
end
@@ -179,7 +179,7 @@ WRONG
describe "remount_fs" do
it "should remount resource if it is already mounted and it supports remounting" do
- @new_resource.supports({ :remount => true })
+ @new_resource.supports({ remount: true })
stub_mounted_enabled(@provider, @mounted_output, "")
expect(@provider).to receive(:shell_out!).with("mount -o remount #{@new_resource.device} #{@new_resource.mount_point}")
@@ -188,7 +188,7 @@ WRONG
end
it "should remount with new mount options if it is already mounted and it supports remounting" do
- @new_resource.supports({ :remount => true })
+ @new_resource.supports({ remount: true })
@new_resource.options("nodev,rw")
stub_mounted_enabled(@provider, @mounted_output, "")
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index af7916e5bd..18523e3bc6 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Provider::Mount::Mount do
@new_resource.device_type :device
@new_resource.fstype "ext3"
- @new_resource.supports :remount => false
+ @new_resource.supports remount: false
@provider = Chef::Provider::Mount::Mount.new(@new_resource, @run_context)
@@ -42,7 +42,7 @@ describe Chef::Provider::Mount::Mount do
describe "when discovering the current fs state" do
before do
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => ""))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: ""))
allow(::File).to receive(:foreach).with("/etc/fstab")
end
@@ -54,10 +54,10 @@ describe Chef::Provider::Mount::Mount do
end
it "should accept device_type :uuid", :not_supported_on_solaris do
- @status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1)
+ @status = double(stdout: "/dev/sdz1\n", exitstatus: 1)
@new_resource.device_type :uuid
@new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
- @stdout_findfs = double("STDOUT", :first => "/dev/sdz1")
+ @stdout_findfs = double("STDOUT", first: "/dev/sdz1")
expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(@status)
@provider.load_current_resource
@provider.mountable?
@@ -73,7 +73,7 @@ describe Chef::Provider::Mount::Mount do
it "should ignore trailing slash and set mounted to true for network mount (#{type})" do
@new_resource.device fs_spec
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n"))
@provider.load_current_resource
expect(@provider.current_resource.mounted).to be_truthy
end
@@ -94,7 +94,7 @@ describe Chef::Provider::Mount::Mount do
end
it "should raise an error if the mount device (uuid) does not exist", :not_supported_on_solaris do
- status = double(:stdout => "", :exitstatus => 1)
+ status = double(stdout: "", exitstatus: 1)
@new_resource.device_type :uuid
@new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status)
@@ -121,13 +121,13 @@ describe Chef::Provider::Mount::Mount do
end
it "should set mounted true if the mount point is found in the mounts list" do
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdz1 on /tmp/foo type ext3 (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdz1 on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_truthy
end
it "should set mounted false if another mount point beginning with the same path is found in the mounts list" do
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdz1 on /tmp/foobar type ext3 (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdz1 on /tmp/foobar type ext3 (rw)\n"))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_falsey
end
@@ -139,7 +139,7 @@ describe Chef::Provider::Mount::Mount do
allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true)
allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target)
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{target} on /tmp/foo type ext3 (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{target} on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_truthy
end
@@ -153,7 +153,7 @@ describe Chef::Provider::Mount::Mount do
allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true)
allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target)
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{absolute_target} on /tmp/foo type ext3 (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{absolute_target} on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_truthy
end
@@ -162,7 +162,7 @@ describe Chef::Provider::Mount::Mount do
mount = "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n"
mount << "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n"
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: mount))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_truthy
end
@@ -171,13 +171,13 @@ describe Chef::Provider::Mount::Mount do
mount = "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n"
mount << "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n"
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: mount))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_falsey
end
it "mounted should be false if the mount point is not found in the mounts list" do
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdy1 on /tmp/foo type ext3 (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdy1 on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_falsey
end
@@ -307,7 +307,7 @@ describe Chef::Provider::Mount::Mount do
end
it "should mount the filesystem specified by uuid", :not_supported_on_solaris do
- status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1)
+ status = double(stdout: "/dev/sdz1\n", exitstatus: 1)
@new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
@new_resource.device_type :uuid
allow(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status)
@@ -341,14 +341,14 @@ describe Chef::Provider::Mount::Mount do
describe "remount_fs" do
it "should use mount -o remount if remount is supported" do
- @new_resource.supports({ :remount => true })
+ @new_resource.supports({ remount: true })
@current_resource.mounted(true)
expect(@provider).to receive(:shell_out!).with("mount -o remount,defaults #{@new_resource.mount_point}")
@provider.remount_fs
end
it "should use mount -o remount with new mount options if remount is supported" do
- @new_resource.supports({ :remount => true })
+ @new_resource.supports({ remount: true })
options = "rw,noexec,noauto"
@new_resource.options(%w{rw noexec noauto})
@current_resource.mounted(true)
@@ -357,7 +357,7 @@ describe Chef::Provider::Mount::Mount do
end
it "should umount and mount if remount is not supported" do
- @new_resource.supports({ :remount => false })
+ @new_resource.supports({ remount: false })
@current_resource.mounted(true)
expect(@provider).to receive(:umount_fs)
expect(@provider).to receive(:sleep).with(1)
@@ -499,7 +499,7 @@ describe Chef::Provider::Mount::Mount do
context "when the device is described differently", :not_supported_on_solaris do
it "should update the existing line" do
@current_resource.enabled(true)
- status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1)
+ status = double(stdout: "/dev/sdz1\n", exitstatus: 1)
expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status)
filesystems = [%q{/dev/sdy1 /tmp/foo ext3 defaults 1 2},
diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb
index 2ec9feaf3b..e489b9001a 100644
--- a/spec/unit/provider/mount/solaris_spec.rb
+++ b/spec/unit/provider/mount/solaris_spec.rb
@@ -48,7 +48,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
new_resource.fsck_device fsck_device
new_resource.fstype fstype
new_resource.options options
- new_resource.supports :remount => false
+ new_resource.supports remount: false
new_resource
end
@@ -92,7 +92,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
before do
stub_const("Chef::Provider::Mount::Solaris::VFSTAB", vfstab_file.path )
- allow(provider).to receive(:shell_out!).with("mount -v").and_return(OpenStruct.new(:stdout => mount_output))
+ allow(provider).to receive(:shell_out!).with("mount -v").and_return(OpenStruct.new(stdout: mount_output))
allow(File).to receive(:symlink?).with(device).and_return(false)
allow(File).to receive(:exist?).and_call_original # Tempfile.open on ruby 1.8.7 calls File.exist?
allow(File).to receive(:exist?).with(device).and_return(true)
diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb
index fdb44836b5..6d55fb958c 100644
--- a/spec/unit/provider/mount/windows_spec.rb
+++ b/spec/unit/provider/mount/windows_spec.rb
@@ -99,10 +99,10 @@ describe Chef::Provider::Mount::Windows do
end
it "should mount the filesystem if it is not mounted" do
- expect(@vol).to receive(:add).with(:remote => @new_resource.device,
- :username => @new_resource.username,
- :domainname => @new_resource.domain,
- :password => @new_resource.password)
+ expect(@vol).to receive(:add).with(remote: @new_resource.device,
+ username: @new_resource.username,
+ domainname: @new_resource.domain,
+ password: @new_resource.password)
@provider.mount_fs
end
diff --git a/spec/unit/provider/ohai_spec.rb b/spec/unit/provider/ohai_spec.rb
index fad08ba589..518523dca2 100644
--- a/spec/unit/provider/ohai_spec.rb
+++ b/spec/unit/provider/ohai_spec.rb
@@ -29,16 +29,16 @@ describe Chef::Provider::Ohai do
@platform_version = "example-platform"
Chef::Config[:node_name] = @fqdn
mock_ohai = {
- :fqdn => @fqdn,
- :hostname => @hostname,
- :platform => @platform,
- :platform_version => @platform_version,
- :data => {
- :origdata => "somevalue",
+ fqdn: @fqdn,
+ hostname: @hostname,
+ platform: @platform,
+ platform_version: @platform_version,
+ data: {
+ origdata: "somevalue",
},
- :data2 => {
- :origdata => "somevalue",
- :newdata => "somevalue",
+ data2: {
+ origdata: "somevalue",
+ newdata: "somevalue",
},
}
allow(mock_ohai).to receive(:all_plugins).and_return(true)
diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb
index a1dcf3ecd6..dce52fd598 100644
--- a/spec/unit/provider/osx_profile_spec.rb
+++ b/spec/unit/provider/osx_profile_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Provider::OsxProfile do
let(:shell_out_success) do
- double("shell_out", :exitstatus => 0, :error? => false)
+ double("shell_out", exitstatus: 0, error?: false)
end
describe "action_create" do
let(:node) { Chef::Node.new }
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index f15929880d..1047534f98 100644
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Provider::Package::Apt do
allow(@run_context).to receive(:logger).and_return(logger)
@new_resource = Chef::Resource::AptPackage.new("irssi", @run_context)
- @status = double("Status", :exitstatus => 0)
+ @status = double("Status", exitstatus: 0)
@provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context)
@stdin = StringIO.new
@stdout = <<-PKG_STATUS
@@ -43,7 +43,7 @@ irssi:
500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
PKG_STATUS
@stderr = ""
- @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0)
+ @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0)
@timeout = 900
end
@@ -52,8 +52,8 @@ irssi:
it "should create a current resource with the name of the new_resource" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", @new_resource.package_name,
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(@shell_out)
@provider.load_current_resource
@@ -89,20 +89,20 @@ sudo:
policy_out = <<-POLICY_STDOUT
N: Unable to locate package conic-smarms
POLICY_STDOUT
- policy = double(:stdout => policy_out, :exitstatus => 0)
+ policy = double(stdout: policy_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "conic-smarms",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(policy)
showpkg_out = <<-SHOWPKG_STDOUT
N: Unable to locate package conic-smarms
SHOWPKG_STDOUT
- showpkg = double(:stdout => showpkg_out, :exitstatus => 0)
+ showpkg = double(stdout: showpkg_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "showpkg", "conic-smarms",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(showpkg)
@provider.load_current_resource
end
@@ -117,11 +117,11 @@ libmysqlclient15-dev:
Candidate: (none)
Version table:
VPKG_STDOUT
- virtual_package = double(:stdout => virtual_package_out, :exitstatus => 0)
+ virtual_package = double(stdout: virtual_package_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "libmysqlclient15-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(virtual_package)
showpkg_out = <<-SHOWPKG_STDOUT
Package: libmysqlclient15-dev
@@ -141,11 +141,11 @@ libmysqlclient-dev 5.1.41-3ubuntu12.7
libmysqlclient-dev 5.1.41-3ubuntu12.10
libmysqlclient-dev 5.1.41-3ubuntu12
SHOWPKG_STDOUT
- showpkg = double(:stdout => showpkg_out, :exitstatus => 0)
+ showpkg = double(stdout: showpkg_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "showpkg", "libmysqlclient15-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(showpkg)
real_package_out = <<-RPKG_STDOUT
libmysqlclient-dev:
@@ -160,11 +160,11 @@ libmysqlclient-dev:
5.1.41-3ubuntu12 0
500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
RPKG_STDOUT
- real_package = double(:stdout => real_package_out, :exitstatus => 0)
+ real_package = double(stdout: real_package_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "libmysqlclient-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(real_package)
@provider.load_current_resource
end
@@ -177,11 +177,11 @@ mp3-decoder:
Candidate: (none)
Version table:
VPKG_STDOUT
- virtual_package = double(:stdout => virtual_package_out, :exitstatus => 0)
+ virtual_package = double(stdout: virtual_package_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "mp3-decoder",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(virtual_package)
showpkg_out = <<-SHOWPKG_STDOUT
Package: mp3-decoder
@@ -204,11 +204,11 @@ opencubicplayer 1:0.1.17-2
mpg321 0.2.10.6
mpg123 1.12.1-0ubuntu1
SHOWPKG_STDOUT
- showpkg = double(:stdout => showpkg_out, :exitstatus => 0)
+ showpkg = double(stdout: showpkg_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "showpkg", "mp3-decoder",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(showpkg)
expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package)
end
@@ -221,8 +221,8 @@ mpg123 1.12.1-0ubuntu1
@new_resource.provider(nil)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "-o", "APT::Default-Release=lenny-backports", "policy", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(@shell_out)
@provider.load_current_resource
end
@@ -231,8 +231,8 @@ mpg123 1.12.1-0ubuntu1
@new_resource.source "pluto"
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", @new_resource.package_name,
- :env => { "DEBIAN_FRONTEND" => "noninteractive" } ,
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" } ,
+ timeout: @timeout
).and_return(@shell_out)
expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
@@ -260,8 +260,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get install with the package name and version" do
expect(@provider).to receive(:shell_out_compacted!). with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.install_package(["irssi"], ["0.8.12-7"])
end
@@ -269,8 +269,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get install with the package name and version and options if specified" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "--force-yes", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@new_resource.options("--force-yes")
@provider.install_package(["irssi"], ["0.8.12-7"])
@@ -285,8 +285,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "-o", "APT::Default-Release=lenny-backports", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.install_package(["irssi"], ["0.8.12-7"])
@@ -295,8 +295,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get install with the package name and quotes options if specified" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "--force-yes", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confnew", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@new_resource.options('--force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew"')
@provider.install_package(["irssi"], ["0.8.12-7"])
@@ -316,8 +316,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get remove with the package name" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "remove", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.remove_package(["irssi"], ["0.8.12-7"])
end
@@ -325,8 +325,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get remove with the package name and options if specified" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "--force-yes", "remove", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@new_resource.options("--force-yes")
@@ -339,8 +339,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get purge with the package name" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "purge", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.purge_package(["irssi"], ["0.8.12-7"])
end
@@ -348,8 +348,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get purge with the package name and options if specified" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "--force-yes", "purge", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@new_resource.options("--force-yes")
@@ -367,8 +367,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:shell_out_compacted!).with(
"debconf-set-selections", "/tmp/irssi-0.8.12-7.seed",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.preseed_package(file)
@@ -377,8 +377,8 @@ mpg123 1.12.1-0ubuntu1
it "should run debconf-set-selections on the preseed file if it has changed" do
expect(@provider).to receive(:shell_out_compacted!).with(
"debconf-set-selections", "/tmp/irssi-0.8.12-7.seed",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
file = @provider.get_preseed_file("irssi", "0.8.12-7")
@provider.preseed_package(file)
@@ -398,8 +398,8 @@ mpg123 1.12.1-0ubuntu1
it "should run dpkg-reconfigure package" do
expect(@provider).to receive(:shell_out_compacted!).with(
"dpkg-reconfigure", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.reconfig_package("irssi", "0.8.12-7")
end
@@ -409,8 +409,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-mark hold package" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-mark", "hold", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.lock_package("irssi", "0.8.12-7")
end
@@ -430,8 +430,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-mark unhold package" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-mark", "unhold", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.unlock_package("irssi", "0.8.12-7")
end
@@ -452,8 +452,8 @@ mpg123 1.12.1-0ubuntu1
@provider.package_data["libmysqlclient15-dev"][:virtual] = true
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "libmysqlclient15-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.install_package(["libmysqlclient15-dev"], ["not_a_real_version"])
end
@@ -464,8 +464,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:resolve_virtual_package_name).with("libmysqlclient15-dev").and_return("libmysqlclient-dev")
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "remove", "libmysqlclient-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.remove_package(["libmysqlclient15-dev"], ["not_a_real_version"])
end
@@ -476,8 +476,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:resolve_virtual_package_name).with("libmysqlclient15-dev").and_return("libmysqlclient-dev")
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "purge", "libmysqlclient-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.purge_package(["libmysqlclient15-dev"], ["not_a_real_version"])
end
@@ -488,8 +488,8 @@ mpg123 1.12.1-0ubuntu1
# https://github.com/chef/chef/issues/2914
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "libmysqlclient15-dev", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.install_package(["libmysqlclient15-dev", "irssi"], ["not_a_real_version", "0.8.12-7"])
end
@@ -511,8 +511,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:version_compare).and_return(-1)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.run_action(:upgrade)
end
@@ -523,8 +523,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).not_to receive(:version_compare)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.run_action(:upgrade)
end
diff --git a/spec/unit/provider/package/bff_spec.rb b/spec/unit/provider/package/bff_spec.rb
index df407914d3..7606092762 100644
--- a/spec/unit/provider/package/bff_spec.rb
+++ b/spec/unit/provider/package/bff_spec.rb
@@ -38,11 +38,11 @@ describe Chef::Provider::Package::Bff do
@bffinfo = "/usr/lib/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:
/etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:"
- @empty_status = double("Status", :stdout => "", :exitstatus => 0)
+ @empty_status = double("Status", stdout: "", exitstatus: 0)
end
it "should create a current resource with the name of new_resource" do
- status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
+ status = double("Status", stdout: @bffinfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
@provider.load_current_resource
@@ -50,7 +50,7 @@ describe Chef::Provider::Package::Bff do
end
it "should set the current resource bff package name to the new resource bff package name" do
- status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
+ status = double("Status", stdout: @bffinfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
@provider.load_current_resource
@@ -66,7 +66,7 @@ describe Chef::Provider::Package::Bff do
end
it "should get the source package version from lslpp if provided" do
- status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
+ status = double("Status", stdout: @bffinfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
@provider.load_current_resource
@@ -78,7 +78,7 @@ describe Chef::Provider::Package::Bff do
it "should warn if the package is not a fileset" do
info = "samba.base:samba.base.samples:3.3.12.0::COMMITTED:I:Samba for AIX:
/etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:"
- status = double("Status", :stdout => info, :exitstatus => 0)
+ status = double("Status", stdout: info, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
expect(logger).to receive(:warn).once.with(%r{bff package by product name})
@@ -89,7 +89,7 @@ describe Chef::Provider::Package::Bff do
end
it "should return the current version installed if found by lslpp" do
- status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
+ status = double("Status", stdout: @bffinfo, exitstatus: 0)
@stdout = StringIO.new(@bffinfo)
@stdin, @stderr = StringIO.new, StringIO.new
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
@@ -99,7 +99,7 @@ describe Chef::Provider::Package::Bff do
end
it "should raise an exception if the source is not set but we are installing" do
- status = double("Status", :stdout => "", :exitstatus => 1, :format_for_exception => "")
+ status = double("Status", stdout: "", exitstatus: 1, format_for_exception: "")
@new_resource = Chef::Resource::Package.new("samba.base")
@provider = Chef::Provider::Package::Bff.new(@new_resource, @run_context)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
@@ -107,13 +107,13 @@ describe Chef::Provider::Package::Bff do
end
it "should raise an exception if installp/lslpp fails to run" do
- status = double(:stdout => "", :exitstatus => -1, :format_for_exception => "")
+ status = double(stdout: "", exitstatus: -1, format_for_exception: "")
allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package)
end
it "should return a current resource with a nil version if the package is not found" do
- status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
+ status = double("Status", stdout: @bffinfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
@provider.load_current_resource
@@ -123,7 +123,7 @@ describe Chef::Provider::Package::Bff do
it "should raise an exception if the source doesn't provide the requested package" do
wrongbffinfo = "/usr/lib/objrepos:openssl.base:0.9.8.2400::COMMITTED:I:Open Secure Socket Layer:
/etc/objrepos:openssl.base:0.9.8.2400::COMMITTED:I:Open Secure Socket Layer:"
- status = double("Status", :stdout => wrongbffinfo, :exitstatus => 0)
+ status = double("Status", stdout: wrongbffinfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package)
end
@@ -137,13 +137,13 @@ describe Chef::Provider::Package::Bff do
end
it "should lookup the candidate_version if the variable is not already set" do
- status = double(:stdout => "", :exitstatus => 0)
+ status = double(stdout: "", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
@provider.candidate_version
end
it "should throw and exception if the exitstatus is not 0" do
- @status = double(:stdout => "", :exitstatus => 1, :format_for_exception => "")
+ @status = double(stdout: "", exitstatus: 1, format_for_exception: "")
allow(@provider).to receive(:shell_out_compacted).and_return(@status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
end
diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb
index a0a73c445a..40fca821d9 100644
--- a/spec/unit/provider/package/chocolatey_spec.rb
+++ b/spec/unit/provider/package/chocolatey_spec.rb
@@ -45,8 +45,8 @@ ConEmu|15.10.25.0
before do
allow(provider).to receive(:choco_install_path).and_return(choco_install_path)
allow(provider).to receive(:choco_exe).and_return(choco_exe)
- local_list_obj = double(:stdout => local_list_stdout)
- allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -l -r", { :returns => [0], :timeout => timeout }).and_return(local_list_obj)
+ local_list_obj = double(stdout: local_list_stdout)
+ allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -l -r", { returns: [0], timeout: timeout }).and_return(local_list_obj)
end
def allow_remote_list(package_names, args = nil)
@@ -60,7 +60,7 @@ munin-node|1.6.1.20130823
EOF
remote_list_obj = double(stdout: remote_list_stdout)
package_names.each do |pkg|
- allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -r #{pkg}#{args}", { :returns => [0], timeout: timeout }).and_return(remote_list_obj)
+ allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -r #{pkg}#{args}", { returns: [0], timeout: timeout }).and_return(remote_list_obj)
end
end
@@ -182,7 +182,7 @@ munin-node|1.6.1.20130823
it "should install a single package" do
allow_remote_list(["git"])
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -193,7 +193,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"])
new_resource.timeout(timeout)
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -222,7 +222,7 @@ munin-node|1.6.1.20130823
new_resource.package_name("ConEmu")
new_resource.version("15.10.25.1")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -235,7 +235,7 @@ munin-node|1.6.1.20130823
new_resource.package_name(%w{chocolatey ConEmu})
new_resource.version([nil, "15.10.25.1"])
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -245,7 +245,7 @@ munin-node|1.6.1.20130823
new_resource.package_name("conemu")
new_resource.version("15.10.25.1")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -255,8 +255,8 @@ munin-node|1.6.1.20130823
new_resource.package_name(%w{ConEmu git})
new_resource.version(["15.10.25.1", nil])
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -265,7 +265,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git", "munin-node"])
new_resource.package_name(["git", "munin-node"])
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git munin-node", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git munin-node", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -275,7 +275,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"], " -source localpackages")
new_resource.source("localpackages")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -source localpackages git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -source localpackages git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -285,7 +285,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"])
new_resource.options("-force")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -force git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -force git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -319,7 +319,7 @@ munin-node|1.6.1.20130823
it "should install a package that is not installed" do
allow_remote_list(["git"])
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -328,7 +328,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["ConEmu"])
new_resource.package_name("ConEmu")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -337,7 +337,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["conemu"])
new_resource.package_name("conemu")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -346,7 +346,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["chocolatey"])
new_resource.package_name("chocolatey")
provider.load_current_resource
- expect(provider).not_to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y chocolatey", { :returns => [0], :timeout => timeout })
+ expect(provider).not_to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y chocolatey", { returns: [0], timeout: timeout })
provider.run_action(:upgrade)
expect(new_resource).not_to be_updated_by_last_action
end
@@ -355,7 +355,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"])
new_resource.version("2.6.2")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y --version 2.6.2 git", { :returns => [0], :timeout => timeout })
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y --version 2.6.2 git", { returns: [0], timeout: timeout })
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -363,7 +363,7 @@ munin-node|1.6.1.20130823
it "upgrading multiple packages uses a single command" do
allow_remote_list(%w{conemu git})
new_resource.package_name(%w{conemu git})
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -415,7 +415,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["ConEmu"])
new_resource.package_name("ConEmu")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y ConEmu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y ConEmu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -424,7 +424,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["conemu"])
new_resource.package_name("conemu")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -434,7 +434,7 @@ munin-node|1.6.1.20130823
allow_remote_list(%w{git conemu})
new_resource.package_name(%w{git conemu})
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -457,7 +457,7 @@ describe "behavior when Chocolatey is not installed" do
provider.instance_variable_set("@choco_install_path", nil)
# we don't care what this returns, but we have to let it be called.
- allow(provider).to receive(:shell_out_compacted!).and_return(double(:stdout => ""))
+ allow(provider).to receive(:shell_out_compacted!).and_return(double(stdout: ""))
end
let(:error_regex) do
diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb
index c99e91dd46..cf8f5097f0 100644
--- a/spec/unit/provider/package/dpkg_spec.rb
+++ b/spec/unit/provider/package/dpkg_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Provider::Package::Dpkg do
let(:provider) { Chef::Provider::Package::Dpkg.new(new_resource, run_context) }
let(:dpkg_deb_version) { "1.11.4" }
- let(:dpkg_deb_status) { status = double(:stdout => "#{package}\t#{dpkg_deb_version}", :exitstatus => 0) }
+ let(:dpkg_deb_status) { status = double(stdout: "#{package}\t#{dpkg_deb_version}", exitstatus: 0) }
let(:dpkg_s_version) { "1.11.4-1ubuntu1" }
let(:dpkg_s_status) do
stdout = <<-DPKG_S
@@ -47,7 +47,7 @@ Config-Version: #{dpkg_s_version}
Depends: libc6 (>= 2.8~20080505), libssl0.9.8 (>= 0.9.8f-5)
Conflicts: wget-ssl
DPKG_S
- status = double(:stdout => stdout, :exitstatus => 1)
+ status = double(stdout: stdout, exitstatus: 1)
end
before(:each) do
@@ -112,7 +112,7 @@ Conflicts: wget-ssl
describe "gets the source package version from dpkg-deb" do
def check_version(version)
- status = double(:stdout => "wget\t#{version}", :exitstatus => 0)
+ status = double(stdout: "wget\t#{version}", exitstatus: 0)
expect(provider).to receive(:shell_out_compacted!).with("dpkg-deb", "-W", source, timeout: 900).and_return(status)
provider.load_current_resource
expect(provider.current_resource.package_name).to eq(["wget"])
@@ -206,7 +206,7 @@ Section: ruby
end
it "should raise an exception if dpkg-deb -W fails to run" do
- status = double(:stdout => "", :exitstatus => -1)
+ status = double(stdout: "", exitstatus: -1)
expect(provider).to receive(:shell_out_compacted!).with("dpkg-deb", "-W", "/tmp/wget_1.11.4-1ubuntu1_amd64.deb", timeout: 900).and_raise(Mixlib::ShellOut::ShellCommandFailed)
expect { provider.load_current_resource }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
end
diff --git a/spec/unit/provider/package/freebsd/pkg_spec.rb b/spec/unit/provider/package/freebsd/pkg_spec.rb
index 259bd7a4c4..6ad6813503 100644
--- a/spec/unit/provider/package/freebsd/pkg_spec.rb
+++ b/spec/unit/provider/package/freebsd/pkg_spec.rb
@@ -78,21 +78,21 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
end
it "should return the version number when it is installed" do
- pkg_info = OpenStruct.new(:stdout => "zsh-4.3.6_7")
+ pkg_info = OpenStruct.new(stdout: "zsh-4.3.6_7")
expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
allow(@provider).to receive(:package_name).and_return("zsh")
expect(@provider.current_installed_version).to eq("4.3.6_7")
end
it "does not set the current version number when the package is not installed" do
- pkg_info = OpenStruct.new(:stdout => "")
+ pkg_info = OpenStruct.new(stdout: "")
expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
allow(@provider).to receive(:package_name).and_return("zsh")
expect(@provider.current_installed_version).to be_nil
end
it "should return the port path for a valid port name" do
- whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh")
+ whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh")
expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
allow(@provider).to receive(:port_name).and_return("zsh")
expect(@provider.port_path).to eq("/usr/ports/shells/zsh")
@@ -101,7 +101,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
# Not happy with the form of these tests as they are far too closely tied to the implementation and so very fragile.
it "should return the ports candidate version when given a valid port path" do
allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh")
- make_v = OpenStruct.new(:stdout => "4.3.6\n", :exitstatus => 0)
+ make_v = OpenStruct.new(stdout: "4.3.6\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PORTVERSION", { cwd: "/usr/ports/shells/zsh", returns: [0, 1], env: nil, timeout: 900 }).and_return(make_v)
expect(@provider.ports_candidate_version).to eq("4.3.6")
end
@@ -109,7 +109,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
it "should figure out the package name when we have ports" do
allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true)
allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh")
- make_v = OpenStruct.new(:stdout => "zsh-4.3.6_7\n", :exitstatus => 0)
+ make_v = OpenStruct.new(stdout: "zsh-4.3.6_7\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PKGNAME", { cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900 }).and_return(make_v)
#@provider.should_receive(:ports_makefile_variable_value).with("PKGNAME").and_return("zsh-4.3.6_7")
expect(@provider.package_name).to eq("zsh")
@@ -118,7 +118,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
describe Chef::Provider::Package::Freebsd::Pkg, "install_package" do
before(:each) do
- @cmd_result = OpenStruct.new(:status => true)
+ @cmd_result = OpenStruct.new(status: true)
@provider.current_resource = @current_resource
allow(@provider).to receive(:package_name).and_return("zsh")
@@ -141,7 +141,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
end
it "should figure out the port path from the package_name using whereis" do
- whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh")
+ whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh")
expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
expect(@provider.port_path).to eq("/usr/ports/shells/zsh")
end
@@ -174,7 +174,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
allow(@provider).to receive(:package_name).and_return("ruby18-iconv")
allow(@provider).to receive(:latest_link_name).and_return("ruby18-iconv")
- @install_result = OpenStruct.new(:status => true)
+ @install_result = OpenStruct.new(status: true)
end
it "should run pkg_add -r with the package name" do
@@ -185,7 +185,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
describe Chef::Provider::Package::Freebsd::Pkg, "remove_package" do
before(:each) do
- @pkg_delete = OpenStruct.new(:status => true)
+ @pkg_delete = OpenStruct.new(status: true)
@new_resource.version "4.3.6_7"
@current_resource.version "4.3.6_7"
@provider.current_resource = @current_resource
@@ -212,14 +212,14 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
end
it "should return the port path for a valid port name" do
- whereis = OpenStruct.new(:stdout => "bonnie++: /usr/ports/benchmarks/bonnie++")
+ whereis = OpenStruct.new(stdout: "bonnie++: /usr/ports/benchmarks/bonnie++")
expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "bonnie++", env: nil, timeout: 900).and_return(whereis)
allow(@provider).to receive(:port_name).and_return("bonnie++")
expect(@provider.port_path).to eq("/usr/ports/benchmarks/bonnie++")
end
it "should return the version number when it is installed" do
- pkg_info = OpenStruct.new(:stdout => "bonnie++-1.96")
+ pkg_info = OpenStruct.new(stdout: "bonnie++-1.96")
expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "bonnie++*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
allow(@provider).to receive(:package_name).and_return("bonnie++")
expect(@provider.current_installed_version).to eq("1.96")
@@ -252,7 +252,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
allow(@provider).to receive(:package_name).and_return("perl")
allow(@provider).to receive(:latest_link_name).and_return("perl")
- cmd = OpenStruct.new(:status => true)
+ cmd = OpenStruct.new(status: true)
expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "perl", env: nil, timeout: 900).and_return(cmd)
@provider.install_package("perl5.8", "5.8.8_1")
end
@@ -266,7 +266,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
allow(@provider).to receive(:package_name).and_return("mysql-server")
allow(@provider).to receive(:latest_link_name).and_return("mysql50-server")
- cmd = OpenStruct.new(:status => true)
+ cmd = OpenStruct.new(status: true)
expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "mysql50-server", env: nil, timeout: 900).and_return(cmd)
@provider.install_package("mysql50-server", "5.0.45_1")
end
diff --git a/spec/unit/provider/package/freebsd/pkgng_spec.rb b/spec/unit/provider/package/freebsd/pkgng_spec.rb
index 2fdcb87758..a4da5bb235 100644
--- a/spec/unit/provider/package/freebsd/pkgng_spec.rb
+++ b/spec/unit/provider/package/freebsd/pkgng_spec.rb
@@ -63,7 +63,7 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "determining current installed version" do
before(:each) do
allow(@provider).to receive(:supports_pkgng?)
- @pkg_info = OpenStruct.new(:stdout => "zsh-3.1.7\nVersion : 3.1.7\n")
+ @pkg_info = OpenStruct.new(stdout: "zsh-3.1.7\nVersion : 3.1.7\n")
end
it "should query pkg database" do
@@ -74,14 +74,14 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "determining candidate version" do
it "should query repository" do
- pkg_query = OpenStruct.new(:stdout => "5.0.5\n", :exitstatus => 0)
+ pkg_query = OpenStruct.new(stdout: "5.0.5\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with("pkg", "rquery", "%v", "zsh", env: nil, timeout: 900).and_return(pkg_query)
expect(@provider.candidate_version).to eq("5.0.5")
end
it "should query specified repository when given option" do
@provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration.
- pkg_query = OpenStruct.new(:stdout => "5.0.3\n", :exitstatus => 0)
+ pkg_query = OpenStruct.new(stdout: "5.0.3\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with("pkg", "rquery", "-r", "LocalMirror", "%v", "zsh", env: nil, timeout: 900).and_return(pkg_query)
expect(@provider.candidate_version).to eq("5.0.3")
end
@@ -94,7 +94,7 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "installing a binary package" do
before(:each) do
- @install_result = OpenStruct.new(:status => true)
+ @install_result = OpenStruct.new(status: true)
end
it "should handle package source from file" do
@@ -129,7 +129,7 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "removing a binary package" do
before(:each) do
- @install_result = OpenStruct.new(:status => true)
+ @install_result = OpenStruct.new(status: true)
end
it "should call pkg delete" do
diff --git a/spec/unit/provider/package/freebsd/port_spec.rb b/spec/unit/provider/package/freebsd/port_spec.rb
index 26a960dedc..1406235725 100644
--- a/spec/unit/provider/package/freebsd/port_spec.rb
+++ b/spec/unit/provider/package/freebsd/port_spec.rb
@@ -62,7 +62,7 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "determining current installed version" do
before(:each) do
- @pkg_info = OpenStruct.new(:stdout => "zsh-3.1.7\n")
+ @pkg_info = OpenStruct.new(stdout: "zsh-3.1.7\n")
end
it "should check 'pkg_info' if system uses pkg_* tools" do
@@ -73,7 +73,7 @@ describe Chef::Provider::Package::Freebsd::Port do
end
it "should check 'pkg info' if make supports WITH_PKGNG if freebsd version is < 1000017" do
- pkg_enabled = OpenStruct.new(:stdout => "yes\n")
+ pkg_enabled = OpenStruct.new(stdout: "yes\n")
[1000016, 1000000, 901503, 902506, 802511].each do |freebsd_version|
@node.automatic_attrs[:os_version] = freebsd_version
expect(@new_resource).to receive(:shell_out_compacted!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled)
@@ -92,7 +92,7 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "determining candidate version" do
before(:each) do
- @port_version = OpenStruct.new(:stdout => "5.0.5\n", :exitstatus => 0)
+ @port_version = OpenStruct.new(stdout: "5.0.5\n", exitstatus: 0)
end
it "should return candidate version if port exists" do
@@ -121,13 +121,13 @@ describe Chef::Provider::Package::Freebsd::Port do
end
it "should query system for path given just a name" do
- whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh\n")
+ whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh\n")
expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
expect(@provider.port_dir).to eq("/usr/ports/shells/zsh")
end
it "should raise exception if not found" do
- whereis = OpenStruct.new(:stdout => "zsh:\n")
+ whereis = OpenStruct.new(stdout: "zsh:\n")
expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
expect { @provider.port_dir }.to raise_error(Chef::Exceptions::Package, "Could not find port with the name zsh")
end
@@ -135,13 +135,13 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "building a binary package" do
before(:each) do
- @install_result = OpenStruct.new(:status => true)
+ @install_result = OpenStruct.new(status: true)
end
it "should run make install in port directory" do
allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh")
expect(@provider).to receive(:shell_out_compacted!).
- with("make", "-DBATCH", "install", "clean", :timeout => 1800, :cwd => "/usr/ports/shells/zsh", :env => nil).
+ with("make", "-DBATCH", "install", "clean", timeout: 1800, cwd: "/usr/ports/shells/zsh", env: nil).
and_return(@install_result)
@provider.install_package("zsh", "5.0.5")
end
@@ -149,13 +149,13 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "removing a binary package" do
before(:each) do
- @install_result = OpenStruct.new(:status => true)
+ @install_result = OpenStruct.new(status: true)
end
it "should run make deinstall in port directory" do
allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh")
expect(@provider).to receive(:shell_out_compacted!).
- with("make", "deinstall", :timeout => 300, :cwd => "/usr/ports/shells/zsh", :env => nil).
+ with("make", "deinstall", timeout: 300, cwd: "/usr/ports/shells/zsh", env: nil).
and_return(@install_result)
@provider.remove_package("zsh", "5.0.5")
end
diff --git a/spec/unit/provider/package/homebrew_spec.rb b/spec/unit/provider/package/homebrew_spec.rb
index 833fa7bd3e..903aebc93e 100644
--- a/spec/unit/provider/package/homebrew_spec.rb
+++ b/spec/unit/provider/package/homebrew_spec.rb
@@ -173,16 +173,16 @@ describe Chef::Provider::Package::Homebrew do
describe "brew" do
before do
expect(provider).to receive(:find_homebrew_uid).and_return(homebrew_uid)
- expect(Etc).to receive(:getpwuid).with(homebrew_uid).and_return(OpenStruct.new(:name => "name", :dir => "/"))
+ expect(Etc).to receive(:getpwuid).with(homebrew_uid).and_return(OpenStruct.new(name: "name", dir: "/"))
end
it "passes a single to the brew command and return stdout" do
- allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo"))
+ allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "zombo"))
expect(provider.brew).to eql("zombo")
end
it "takes multiple arguments as an array" do
- allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "homestarrunner"))
+ allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "homestarrunner"))
expect(provider.brew("info", "opts", "bananas")).to eql("homestarrunner")
end
@@ -190,7 +190,7 @@ describe Chef::Provider::Package::Homebrew do
let(:new_resource) { Chef::Resource::Package.new("emacs") }
it "does not try to read homebrew_user from Package, which does not have it" do
- allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo"))
+ allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "zombo"))
expect(provider.brew).to eql("zombo")
end
end
diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb
index eac0fd90f3..46f0c72399 100644
--- a/spec/unit/provider/package/ips_spec.rb
+++ b/spec/unit/provider/package/ips_spec.rb
@@ -41,7 +41,7 @@ installed on the system. Try specifying -r to query remotely:
crypto/gnupg
PKG_STATUS
- OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 1)
+ OpenStruct.new(stdout: stdout, stdin: stdin, stderr: stderr, status: @status, exitstatus: 1)
end
def remote_output
@@ -59,7 +59,7 @@ Packaging Date: April 1, 2012 05:55:52 PM
PKG_STATUS
stdin = StringIO.new
stderr = ""
- OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 0)
+ OpenStruct.new(stdout: stdout, stdin: stdin, stderr: stderr, status: @status, exitstatus: 0)
end
context "when loading current resource" do
diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb
index 04e0a9177e..54c5340d72 100644
--- a/spec/unit/provider/package/macports_spec.rb
+++ b/spec/unit/provider/package/macports_spec.rb
@@ -75,13 +75,13 @@ The following ports are currently installed:
openssl @0.9.8k_0 (active)
EOF
- status = double(:stdout => stdout, :exitstatus => 0)
+ status = double(stdout: stdout, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.current_installed_version).to eq("0.9.8k_0")
end
it "should return nil if a package is not currently installed" do
- status = double(:stdout => " \n", :exitstatus => 0)
+ status = double(stdout: " \n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.current_installed_version).to be_nil
end
@@ -89,13 +89,13 @@ EOF
describe "macports_candidate_version" do
it "should return the latest available version of a given package" do
- status = double(:stdout => "version: 4.2.7\n", :exitstatus => 0)
+ status = double(stdout: "version: 4.2.7\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.macports_candidate_version).to eq("4.2.7")
end
it "should return nil if there is no version for a given package" do
- status = double(:stdout => "Error: port fadsfadsfads not found\n", :exitstatus => 0)
+ status = double(stdout: "Error: port fadsfadsfads not found\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.macports_candidate_version).to be_nil
end
diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb
index 07950acf6e..01d6571f65 100644
--- a/spec/unit/provider/package/openbsd_spec.rb
+++ b/spec/unit/provider/package/openbsd_spec.rb
@@ -45,7 +45,7 @@ describe Chef::Provider::Package::Openbsd do
context "when not already installed" do
before do
- allow(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{name}->0", anything()).and_return(instance_double("shellout", :stdout => ""))
+ allow(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{name}->0", anything()).and_return(instance_double("shellout", stdout: ""))
end
context "when there is a single candidate" do
@@ -53,11 +53,11 @@ describe Chef::Provider::Package::Openbsd do
context "when source is not provided" do
it "should run the installation command" do
expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return(
- instance_double("shellout", :stdout => "#{name}-#{version}\n"))
+ instance_double("shellout", stdout: "#{name}-#{version}\n"))
expect(provider).to receive(:shell_out_compacted!).with(
"pkg_add", "-r", "#{name}-#{version}",
- { :env => { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
- ) { OpenStruct.new :status => true }
+ { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
+ ) { OpenStruct.new status: true }
provider.run_action(:install)
end
end
@@ -70,7 +70,7 @@ describe Chef::Provider::Package::Openbsd do
context "if no version is specified" do
it "should raise an exception" do
expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return(
- instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n"))
+ instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n"))
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /multiple matching candidates/)
end
end
@@ -83,13 +83,13 @@ describe Chef::Provider::Package::Openbsd do
context "if no version is specified" do
it "should run the installation command" do
- expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{package_name}->0", anything()).and_return(instance_double("shellout", :stdout => ""))
+ expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{package_name}->0", anything()).and_return(instance_double("shellout", stdout: ""))
expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return(
- instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor}\n"))
+ instance_double("shellout", stdout: "#{name}-#{version}-#{flavor}\n"))
expect(provider).to receive(:shell_out_compacted!).with(
"pkg_add", "-r", "#{name}-#{version}-#{flavor}",
{ env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
- ) { OpenStruct.new :status => true }
+ ) { OpenStruct.new status: true }
provider.run_action(:install)
end
end
@@ -99,13 +99,13 @@ describe Chef::Provider::Package::Openbsd do
context "if a version is specified" do
it "should use the flavor from the version" do
expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", "#{name}-#{version}-#{flavor_b}", anything()).and_return(
- instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n"))
+ instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n"))
new_resource.version("#{version}-#{flavor_b}")
expect(provider).to receive(:shell_out_compacted!).with(
"pkg_add", "-r", "#{name}-#{version}-#{flavor_b}",
{ env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
- ) { OpenStruct.new :status => true }
+ ) { OpenStruct.new status: true }
provider.run_action(:install)
end
end
@@ -124,7 +124,7 @@ describe Chef::Provider::Package::Openbsd do
it "should run the command to delete the installed package" do
expect(@provider).to receive(:shell_out_compacted!).with(
"pkg_delete", @name, env: nil, timeout: 900
- ) { OpenStruct.new :status => true }
+ ) { OpenStruct.new status: true }
@provider.remove_package(@name, nil)
end
end
diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb
index d41df8c24b..9fbba202f5 100644
--- a/spec/unit/provider/package/pacman_spec.rb
+++ b/spec/unit/provider/package/pacman_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Provider::Package::Pacman do
@new_resource = Chef::Resource::Package.new("nano")
@current_resource = Chef::Resource::Package.new("nano")
- @status = double(:stdout => "", :exitstatus => 0)
+ @status = double(stdout: "", exitstatus: 0)
@provider = Chef::Provider::Package::Pacman.new(@new_resource, @run_context)
allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource)
@@ -88,14 +88,14 @@ Install Script : Yes
Description : Pico editor clone with enhancements
PACMAN
- status = double(:stdout => stdout, :exitstatus => 0)
+ status = double(stdout: stdout, exitstatus: 0)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
@provider.load_current_resource
expect(@current_resource.version).to eq("2.2.2-1")
end
it "should set the candidate version if pacman has one" do
- status = double(:stdout => "core nano 2.2.3-1", :exitstatus => 0)
+ status = double(stdout: "core nano 2.2.3-1", exitstatus: 0)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
@provider.load_current_resource
expect(@provider.candidate_version).to eql("2.2.3-1")
@@ -120,7 +120,7 @@ Include = /etc/pacman.d/mirrorlist
Include = /etc/pacman.d/mirrorlist
PACMAN_CONF
- status = double(:stdout => "customrepo nano 1.2.3-4", :exitstatus => 0)
+ status = double(stdout: "customrepo nano 1.2.3-4", exitstatus: 0)
allow(::File).to receive(:exist?).with("/etc/pacman.conf").and_return(true)
allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(@pacman_conf)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
diff --git a/spec/unit/provider/package/paludis_spec.rb b/spec/unit/provider/package/paludis_spec.rb
index 5481a33c0d..a9ae5bf9d3 100644
--- a/spec/unit/provider/package/paludis_spec.rb
+++ b/spec/unit/provider/package/paludis_spec.rb
@@ -42,7 +42,7 @@ user/ntp 0 installed-accounts
net/ntp 4.2.6_p5-r1 installed
PKG_STATUS
@pid = 12345
- @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0)
+ @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0)
end
context "when loading current resource" do
@@ -86,12 +86,12 @@ INSTALLED
context "when installing a package" do
it "should run pkg install with the package name and version" do
- expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 })
@provider.install_package("net/ntp", "4.2.6_p5-r2")
end
it "should run pkg install with the package name and version and options if specified" do
- expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "--preserve-world", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "--preserve-world", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 })
@new_resource.options "--preserve-world"
@provider.install_package("net/ntp", "4.2.6_p5-r2")
end
@@ -101,7 +101,7 @@ INSTALLED
sys-process/lsof 4.87 arbor
sys-process/lsof 4.87 x86_64
PKG_STATUS
- expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=sys-process/lsof-4.87", { :timeout => @new_resource.timeout || 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=sys-process/lsof-4.87", { timeout: @new_resource.timeout || 900 })
@provider.install_package("sys-process/lsof", "4.87")
end
@@ -119,7 +119,7 @@ PKG_STATUS
context "when upgrading a package" do
it "should run pkg install with the package name and version" do
- expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 })
@provider.upgrade_package("net/ntp", "4.2.6_p5-r2")
end
end
diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb
index 7bf8e7f2e8..889053e826 100644
--- a/spec/unit/provider/package/portage_spec.rb
+++ b/spec/unit/provider/package/portage_spec.rb
@@ -113,19 +113,19 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do
end
it "should throw an exception if the exitstatus is not 0" do
- status = double(:stdout => "", :stderr => "", :exitstatus => 1)
+ status = double(stdout: "", stderr: "", exitstatus: 1)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
end
it "should find the candidate_version if a category is specifed and there are no duplicates" do
- status = double(:stdout => "dev-vcs/git-2.16.2", :exitstatus => 0)
+ status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.candidate_version).to eq("2.16.2")
end
it "should find the candidate_version if a category is not specifed and there are no duplicates" do
- status = double(:stdout => "dev-vcs/git-2.16.2", :exitstatus => 0)
+ status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0)
@provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.candidate_version).to eq("2.16.2")
@@ -139,7 +139,7 @@ You specified an unqualified atom that matched multiple packages:
Please use a more specific atom.
EOF
- status = double(:stdout => "", :stderr => stderr_output, :exitstatus => 1)
+ status = double(stdout: "", stderr: stderr_output, exitstatus: 1)
@provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
diff --git a/spec/unit/provider/package/powershell_spec.rb b/spec/unit/provider/package/powershell_spec.rb
index 63f611ac23..c7a16acaa2 100644
--- a/spec/unit/provider/package/powershell_spec.rb
+++ b/spec/unit/provider/package/powershell_spec.rb
@@ -34,63 +34,63 @@ describe Chef::Provider::Package::Powershell do
end
let(:package_xcertificate_installed) do
- double("powershell_out", :stdout => "2.1.0.0\r\n")
+ double("powershell_out", stdout: "2.1.0.0\r\n")
end
let(:package_xcertificate_installed_2_0_0_0) do
- double("powershell_out", :stdout => "2.0.0.0\r\n")
+ double("powershell_out", stdout: "2.0.0.0\r\n")
end
let(:package_xcertificate_available) do
- double("powershell_out", :stdout => "2.1.0.0\r\n")
+ double("powershell_out", stdout: "2.1.0.0\r\n")
end
let(:package_xcertificate_available_2_0_0_0) do
- double("powershell_out", :stdout => "2.0.0.0\r\n")
+ double("powershell_out", stdout: "2.0.0.0\r\n")
end
let(:package_xcertificate_not_installed) do
- double("powershell_out", :stdout => "")
+ double("powershell_out", stdout: "")
end
let(:package_xcertificate_not_available) do
- double("powershell_out", :stdout => "")
+ double("powershell_out", stdout: "")
end
let(:package_xnetworking_installed) do
- double("powershell_out", :stdout => "2.12.0.0\r\n")
+ double("powershell_out", stdout: "2.12.0.0\r\n")
end
let(:package_xnetworking_installed_2_11_0_0) do
- double("powershell_out", :stdout => "2.11.0.0\r\n")
+ double("powershell_out", stdout: "2.11.0.0\r\n")
end
let(:package_xnetworking_available) do
- double("powershell_out", :stdout => "2.12.0.0\r\n")
+ double("powershell_out", stdout: "2.12.0.0\r\n")
end
let(:package_xnetworking_available_2_11_0_0) do
- double("powershell_out", :stdout => "2.11.0.0\r\n")
+ double("powershell_out", stdout: "2.11.0.0\r\n")
end
let(:package_xnetworking_not_installed) do
- double("powershell_out", :stdout => "")
+ double("powershell_out", stdout: "")
end
let(:package_xnetworking_not_available) do
- double("powershell_out", :stdout => "")
+ double("powershell_out", stdout: "")
end
let(:package_7zip_available) do
- double("powershell_out", :stdout => "16.02\r\n")
+ double("powershell_out", stdout: "16.02\r\n")
end
let(:package_7zip_not_installed) do
- double("powershell_out", :stdout => "")
+ double("powershell_out", stdout: "")
end
let(:powershell_installed_version) do
- double("powershell_out", :stdout => "5")
+ double("powershell_out", stdout: "5")
end
let(:generated_command) { "( Get-Package posh-git -Force -ForceBootstrap ).Version" }
@@ -116,14 +116,14 @@ describe Chef::Provider::Package::Powershell do
describe "#candidate_version" do
it "should set the candidate_version to the latest version when not pinning" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
new_resource.package_name(["xNetworking"])
new_resource.version(nil)
expect(provider.candidate_version).to eql(["2.12.0.0"])
end
it "should use the candidate_version from the correct source" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
new_resource.package_name(["xNetworking"])
new_resource.version(nil)
new_resource.source("MyGallery")
@@ -131,60 +131,60 @@ describe Chef::Provider::Package::Powershell do
end
it "should set the candidate_version to the latest version when not pinning and package name is space seperated" do
- allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
new_resource.package_name(["7-Zip 16.02 (x64)"])
new_resource.version(nil)
expect(provider.candidate_version).to eql(["16.02"])
end
it "should set the candidate_version to pinned version if available" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.0.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.0.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0)
new_resource.package_name(["xCertificate"])
new_resource.version(["2.0.0.0"])
expect(provider.candidate_version).to eql(["2.0.0.0"])
end
it "should set the candidate_version to nil if there is no candidate" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
new_resource.package_name(["xCertificate"])
expect(provider.candidate_version).to eql([nil])
end
it "should set the candidate_version correctly when there are two packages to install" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
expect(provider.candidate_version).to eql(["2.1.0.0", "2.12.0.0"])
end
it "should set the candidate_version correctly when only the first is installable" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
expect(provider.candidate_version).to eql(["2.1.0.0", nil])
end
it "should set the candidate_version correctly when only the last is installable" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
expect(provider.candidate_version).to eql([nil, "2.12.0.0"])
end
it "should set the candidate_version correctly when neither are is installable and version is passed as nil array" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
new_resource.package_name(%w{xNetworking xCertificate})
new_resource.version([nil, nil])
expect(provider.candidate_version).to eql([nil, nil])
end
it "should set the candidate_version correctly when neither are is installable and version is not passed" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
new_resource.package_name(%w{xNetworking xCertificate})
new_resource.version(nil)
expect(provider.candidate_version).to eql([nil, nil])
@@ -283,10 +283,10 @@ describe Chef::Provider::Package::Powershell do
provider.load_current_resource
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -296,10 +296,10 @@ describe Chef::Provider::Package::Powershell do
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
new_resource.source("MyGallery")
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -309,10 +309,10 @@ describe Chef::Provider::Package::Powershell do
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
new_resource.skip_publisher_check(true)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { timeout: new_resource.timeout })
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -321,10 +321,10 @@ describe Chef::Provider::Package::Powershell do
provider.load_current_resource
new_resource.package_name(["7-Zip 16.02 (x64)"])
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_not_installed)
+ allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_not_installed)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -RequiredVersion 16.02 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -RequiredVersion 16.02 ).Version", { timeout: new_resource.timeout })
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -336,10 +336,10 @@ describe Chef::Provider::Package::Powershell do
provider.load_current_resource
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -348,8 +348,8 @@ describe Chef::Provider::Package::Powershell do
it "should not install packages that are up-to-date" do
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
expect(provider).not_to receive(:install_package)
@@ -360,8 +360,8 @@ describe Chef::Provider::Package::Powershell do
it "should not install packages that are up-to-date" do
new_resource.package_name(["xNetworking"])
new_resource.version(["2.11.0.0"])
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
expect(provider).not_to receive(:install_package)
@@ -374,13 +374,13 @@ describe Chef::Provider::Package::Powershell do
# new_version.resource[0]
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version([nil, "2.11.0.0"])
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout })
provider.load_current_resource
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
@@ -389,13 +389,13 @@ describe Chef::Provider::Package::Powershell do
it "should split up commands when given two packages, one with a version pin" do
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(["2.1.0.0", nil])
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
provider.load_current_resource
provider.run_action(:install)
@@ -405,13 +405,13 @@ describe Chef::Provider::Package::Powershell do
it "should do multipackage installs when given two packages without constraints" do
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
provider.load_current_resource
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
@@ -421,13 +421,13 @@ describe Chef::Provider::Package::Powershell do
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
new_resource.source("MyGallery")
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout })
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
provider.load_current_resource
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
@@ -439,8 +439,8 @@ describe Chef::Provider::Package::Powershell do
provider.load_current_resource
new_resource.package_name(["xCertificate"])
new_resource.version(["2.1.0.0"])
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
expect(provider).not_to receive(:remove_package)
provider.run_action(:remove)
@@ -451,11 +451,11 @@ describe Chef::Provider::Package::Powershell do
new_resource.package_name(["xCertificate"])
new_resource.version(["2.1.0.0"])
new_resource.source("MyGallery")
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -463,10 +463,10 @@ describe Chef::Provider::Package::Powershell do
it "does nothing when all the packages are already removed" do
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
expect(provider).not_to receive(:remove_package)
@@ -477,11 +477,11 @@ describe Chef::Provider::Package::Powershell do
it "removes a package when version is specified" do
new_resource.package_name(["xCertificate"])
new_resource.version(["2.1.0.0"])
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -489,11 +489,11 @@ describe Chef::Provider::Package::Powershell do
it "removes a package when version is not specified" do
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb
index cb5e987a85..172bfbac84 100644
--- a/spec/unit/provider/package/smartos_spec.rb
+++ b/spec/unit/provider/package/smartos_spec.rb
@@ -28,14 +28,14 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
@new_resource = Chef::Resource::Package.new("varnish")
@current_resource = Chef::Resource::Package.new("varnish")
- @status = double("Status", :exitstatus => 0)
+ @status = double("Status", exitstatus: 0)
@provider = Chef::Provider::Package::SmartOS.new(@new_resource, @run_context)
allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource)
@stdin = StringIO.new
@stdout = "varnish-2.1.5nb2\n"
@stderr = StringIO.new
@pid = 10
- @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0)
+ @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0)
end
describe "when loading current resource" do
@@ -59,7 +59,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
end
it "should set the installed version to nil if it's not installed" do
- out = OpenStruct.new(:stdout => nil)
+ out = OpenStruct.new(stdout: nil)
expect(@provider).to receive(:shell_out_compacted!).and_return(out)
@provider.load_current_resource
expect(@current_resource.version).to eq(nil)
@@ -79,8 +79,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
expect(search).to receive(:each_line).
and_yield("something-varnish-1.1.1 something varnish like\n").
and_yield("varnish-2.3.4 actual varnish\n")
- @shell_out = double("shell_out!", :stdout => search)
- expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out)
+ @shell_out = double("shell_out!", stdout: search)
+ expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", env: nil, returns: [0, 1], timeout: 900).and_return(@shell_out)
expect(@provider.candidate_version).to eq("2.3.4")
end
@@ -89,8 +89,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
expect(search).to receive(:each_line).
and_yield("something-varnish-1.1.1;;something varnish like\n").
and_yield("varnish-2.3.4;;actual varnish\n")
- @shell_out = double("shell_out!", :stdout => search)
- expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out)
+ @shell_out = double("shell_out!", stdout: search)
+ expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", env: nil, returns: [0, 1], timeout: 900).and_return(@shell_out)
expect(@provider.candidate_version).to eq("2.3.4")
end
end
@@ -98,9 +98,9 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
describe "when manipulating a resource" do
it "run pkgin and install the package" do
- out = OpenStruct.new(:stdout => nil)
- expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/sbin/pkg_info", "-E", "varnish*", { :env => nil, :returns => [0, 1], :timeout => 900 }).and_return(@shell_out)
- expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", { :env => nil, :timeout => 900 }).and_return(out)
+ out = OpenStruct.new(stdout: nil)
+ expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/sbin/pkg_info", "-E", "varnish*", { env: nil, returns: [0, 1], timeout: 900 }).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", { env: nil, timeout: 900 }).and_return(out)
@provider.load_current_resource
@provider.install_package("varnish", "2.1.5nb2")
end
diff --git a/spec/unit/provider/package/solaris_spec.rb b/spec/unit/provider/package/solaris_spec.rb
index 57a0288f58..2ebf8fe4be 100644
--- a/spec/unit/provider/package/solaris_spec.rb
+++ b/spec/unit/provider/package/solaris_spec.rb
@@ -46,7 +46,7 @@ INSTDATE: Nov 04 2009 01:02
HOTLINE: Please contact your local service provider
PKGINFO
- @status = double("Status", :stdout => "", :exitstatus => 0)
+ @status = double("Status", stdout: "", exitstatus: 0)
end
it "should create a current resource with the name of new_resource" do
@@ -70,7 +70,7 @@ PKGINFO
end
it "should get the source package version from pkginfo if provided" do
- status = double(:stdout => @pkginfo, :exitstatus => 0)
+ status = double(stdout: @pkginfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "-d", "/tmp/bash.pkg", "SUNWbash", { timeout: 900 }).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "SUNWbash", { timeout: 900 }).and_return(@status)
@provider.load_current_resource
@@ -80,7 +80,7 @@ PKGINFO
end
it "should return the current version installed if found by pkginfo" do
- status = double(:stdout => @pkginfo, :exitstatus => 0)
+ status = double(stdout: @pkginfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "-d", "/tmp/bash.pkg", "SUNWbash", { timeout: 900 }).and_return(@status)
expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "SUNWbash", { timeout: 900 }).and_return(status)
@provider.load_current_resource
@@ -95,7 +95,7 @@ PKGINFO
end
it "should raise an exception if pkginfo fails to run" do
- status = double(:stdout => "", :exitstatus => -1)
+ status = double(stdout: "", exitstatus: -1)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package)
end
@@ -116,14 +116,14 @@ PKGINFO
end
it "should lookup the candidate_version if the variable is not already set" do
- status = double(:stdout => "", :exitstatus => 0)
+ status = double(stdout: "", exitstatus: 0)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider).to receive(:shell_out_compacted)
@provider.candidate_version
end
it "should throw and exception if the exitstatus is not 0" do
- status = double(:stdout => "", :exitstatus => 1)
+ status = double(stdout: "", exitstatus: 1)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
end
diff --git a/spec/unit/provider/package/windows/exe_spec.rb b/spec/unit/provider/package/windows/exe_spec.rb
index f18cbf3dca..f8c4e83fc5 100644
--- a/spec/unit/provider/package/windows/exe_spec.rb
+++ b/spec/unit/provider/package/windows/exe_spec.rb
@@ -126,7 +126,7 @@ describe Chef::Provider::Package::Windows::Exe do
it "removes installed package and quotes uninstall string" do
new_resource.timeout = 300
allow(::File).to receive(:exist?).with("uninst_dir/uninst_file").and_return(true)
- expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir\/uninst_file\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, :timeout => 300, :returns => [0])
+ expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir\/uninst_file\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, timeout: 300, returns: [0])
provider.remove_package
end
end
diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb
index aa528ab90e..0e939610db 100644
--- a/spec/unit/provider/package/windows/msi_spec.rb
+++ b/spec/unit/provider/package/windows/msi_spec.rb
@@ -22,7 +22,7 @@ require "chef/provider/package/windows/msi"
describe Chef::Provider::Package::Windows::MSI do
let(:node) { double("Chef::Node") }
let(:events) { double("Chef::Events").as_null_object } # mock all the methods
- let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
+ let(:run_context) { double("Chef::RunContext", node: node, events: events) }
let(:package_name) { "calculator" }
let(:resource_source) { "calculator.msi" }
let(:resource_version) { nil }
diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb
index aed0ca88be..3030b7f04a 100644
--- a/spec/unit/provider/package/windows_spec.rb
+++ b/spec/unit/provider/package/windows_spec.rb
@@ -50,7 +50,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
before(:each) do
allow(Chef::Util::PathHelper).to receive(:validate_path)
allow(provider).to receive(:package_provider).and_return(double("package_provider",
- :installed_version => "1.0", :package_version => "2.0"))
+ installed_version: "1.0", package_version: "2.0"))
end
it "creates a current resource with the name of the new resource" do
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index 4ba8ac36ac..6795f9e051 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Provider::Package::Zypper do
Chef::Provider::Package::Zypper.new(new_resource, run_context)
end
- let(:status) { double(:stdout => "\n", :exitstatus => 0) }
+ let(:status) { double(stdout: "\n", exitstatus: 0) }
before(:each) do
allow(Chef::Resource::Package).to receive(:new).and_return(current_resource)
@@ -73,7 +73,7 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the installed version if zypper info has one (zypper version < 1.13.0)" do
- status = double(:stdout => "Version: 1.0\nInstalled: Yes\n", :exitstatus => 0)
+ status = double(stdout: "Version: 1.0\nInstalled: Yes\n", exitstatus: 0)
allow(provider).to receive(:shell_out_compacted!).and_return(status)
expect(current_resource).to receive(:version).with(["1.0"]).and_return(true)
@@ -81,7 +81,7 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the installed version if zypper info has one (zypper version >= 1.13.0)" do
- status = double(:stdout => "Version : 1.0 \nInstalled : Yes \n", :exitstatus => 0)
+ status = double(stdout: "Version : 1.0 \nInstalled : Yes \n", exitstatus: 0)
allow(provider).to receive(:shell_out_compacted!).and_return(status)
expect(current_resource).to receive(:version).with(["1.0"]).and_return(true)
@@ -89,7 +89,7 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the installed version if zypper info has one (zypper version >= 1.13.17)" do
- status = double(:stdout => "Version : 1.0\nInstalled : Yes (automatically)\n", :exitstatus => 0)
+ status = double(stdout: "Version : 1.0\nInstalled : Yes (automatically)\n", exitstatus: 0)
allow(provider).to receive(:shell_out_compacted!).and_return(status)
expect(current_resource).to receive(:version).with(["1.0"]).and_return(true)
@@ -97,7 +97,7 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the candidate version if zypper info has one (zypper version < 1.13.0)" do
- status = double(:stdout => "Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)", :exitstatus => 0)
+ status = double(stdout: "Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)", exitstatus: 0)
allow(provider).to receive(:shell_out_compacted!).and_return(status)
provider.load_current_resource
@@ -105,7 +105,7 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the candidate version if zypper info has one (zypper version >= 1.13.0)" do
- status = double(:stdout => "Version : 1.0 \nInstalled : No \nStatus : out-of-date (version 0.9 installed)", :exitstatus => 0)
+ status = double(stdout: "Version : 1.0 \nInstalled : No \nStatus : out-of-date (version 0.9 installed)", exitstatus: 0)
allow(provider).to receive(:shell_out_compacted!).and_return(status)
provider.load_current_resource
diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb
index f4663861c6..79d84e61dc 100644
--- a/spec/unit/provider/powershell_script_spec.rb
+++ b/spec/unit/provider/powershell_script_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Provider::PowershellScript, "action_run" do
node.default["kernel"] = Hash.new
node.default["kernel"][:machine] = :x86_64.to_s
if ! powershell_version.nil?
- node.default[:languages] = { :powershell => { :version => powershell_version } }
+ node.default[:languages] = { powershell: { version: powershell_version } }
end
node
end
diff --git a/spec/unit/provider/registry_key_spec.rb b/spec/unit/provider/registry_key_spec.rb
index 096fe9b9ed..3563af4dc4 100644
--- a/spec/unit/provider/registry_key_spec.rb
+++ b/spec/unit/provider/registry_key_spec.rb
@@ -275,20 +275,20 @@ describe Chef::Provider::RegistryKey do
context "when the key data is safe" do
let(:keyname) { 'HKLM\Software\Opscode\Testing\Safe' }
- let(:testval1) { { :name => "one", :type => :string, :data => "1" } }
- let(:testval1_wrong_type) { { :name => "one", :type => :multi_string, :data => "1" } }
- let(:testval1_wrong_data) { { :name => "one", :type => :string, :data => "2" } }
- let(:testval2) { { :name => "two", :type => :string, :data => "2" } }
+ let(:testval1) { { name: "one", type: :string, data: "1" } }
+ let(:testval1_wrong_type) { { name: "one", type: :multi_string, data: "1" } }
+ let(:testval1_wrong_data) { { name: "one", type: :string, data: "2" } }
+ let(:testval2) { { name: "two", type: :string, data: "2" } }
it_should_behave_like "a registry key"
end
context "when the key data is unsafe" do
let(:keyname) { 'HKLM\Software\Opscode\Testing\Unsafe' }
- let(:testval1) { { :name => "one", :type => :binary, :data => 255.chr * 1 } }
- let(:testval1_wrong_type) { { :name => "one", :type => :string, :data => 255.chr * 1 } }
- let(:testval1_wrong_data) { { :name => "one", :type => :binary, :data => 254.chr * 1 } }
- let(:testval2) { { :name => "two", :type => :binary, :data => 0.chr * 1 } }
+ let(:testval1) { { name: "one", type: :binary, data: 255.chr * 1 } }
+ let(:testval1_wrong_type) { { name: "one", type: :string, data: 255.chr * 1 } }
+ let(:testval1_wrong_data) { { name: "one", type: :binary, data: 254.chr * 1 } }
+ let(:testval2) { { name: "two", type: :binary, data: 0.chr * 1 } }
it_should_behave_like "a registry key"
end
@@ -296,8 +296,8 @@ describe Chef::Provider::RegistryKey do
describe "action_create" do
context "when key exists and type matches" do
let(:keyname) { 'hklm\\software\\opscode\\testing\\dword' }
- let(:dword_passed_as_integer) { { :name => "one", :type => :dword, :data => 12345 } }
- let(:testval1) { { :name => "one", :type => :dword, :data => "12345" } }
+ let(:dword_passed_as_integer) { { name: "one", type: :dword, data: 12345 } }
+ let(:testval1) { { name: "one", type: :dword, data: "12345" } }
before do
expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true)
end
@@ -321,33 +321,33 @@ describe Chef::Provider::RegistryKey, "key_missing?" do
let(:provider) { Chef::Provider::RegistryKey.new(new_resource, run_context) }
let(:all_keys_present_in_all_hash) do
- [ { :name => "input1_value1", :type => :string, :data => "my_value1" },
- { :name => "input1_value2", :type => :string, :data => "my_value2" },
+ [ { name: "input1_value1", type: :string, data: "my_value1" },
+ { name: "input1_value2", type: :string, data: "my_value2" },
]
end
let(:type_key_not_present_in_any_hash) do
- [ { :name => "input2_value1", :data => "my_value1" },
- { :name => "input2_value2", :data => "my_value2" },
+ [ { name: "input2_value1", data: "my_value1" },
+ { name: "input2_value2", data: "my_value2" },
]
end
let(:type_key_not_present_in_some_hash) do
- [ { :name => "input3_value1", :data => "my_value1" },
- { :name => "input3_value2", :type => :string, :data => "my_value2" },
+ [ { name: "input3_value1", data: "my_value1" },
+ { name: "input3_value2", type: :string, data: "my_value2" },
]
end
let(:data_key_not_present_in_any_hash) do
- [ { :name => "input4_value1", :type => :string },
- { :name => "input4_value2", :type => :string },
+ [ { name: "input4_value1", type: :string },
+ { name: "input4_value2", type: :string },
]
end
let(:data_key_not_present_in_some_hash) do
- [ { :name => "input5_value1", :type => :string, :data => "my_value1" },
- { :name => "input5_value2", :type => :string },
+ [ { name: "input5_value1", type: :string, data: "my_value1" },
+ { name: "input5_value2", type: :string },
]
end
let(:only_name_key_present_in_all_hash) do
- [ { :name => "input6_value1" },
- { :name => "input6_value2" },
+ [ { name: "input6_value1" },
+ { name: "input6_value2" },
]
end
diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb
index 307eb98187..1afc95fa48 100644
--- a/spec/unit/provider/remote_file/content_spec.rb
+++ b/spec/unit/provider/remote_file/content_spec.rb
@@ -84,7 +84,7 @@ describe Chef::Provider::RemoteFile::Content do
describe "when the fetcher returns nil for the tempfile" do
before do
- http_fetcher = double("Chef::Provider::RemoteFile::HTTP", :fetch => nil)
+ http_fetcher = double("Chef::Provider::RemoteFile::HTTP", fetch: nil)
expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher)
end
@@ -97,7 +97,7 @@ describe Chef::Provider::RemoteFile::Content do
let(:mtime) { Time.now }
let(:tempfile) { double("Tempfile") }
- let(:http_fetcher) { double("Chef::Provider::RemoteFile::HTTP", :fetch => tempfile) }
+ let(:http_fetcher) { double("Chef::Provider::RemoteFile::HTTP", fetch: tempfile) }
before do
expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher)
@@ -199,7 +199,7 @@ describe Chef::Provider::RemoteFile::Content do
before do
@tempfile = double("Tempfile")
mtime = Time.now
- http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile)
+ http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", fetch: @tempfile)
expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(http_fetcher_works)
end
@@ -236,7 +236,7 @@ describe Chef::Provider::RemoteFile::Content do
expect(URI).not_to receive(:parse).with(new_resource.source[1])
@tempfile = double("Tempfile")
mtime = Time.now
- http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile)
+ http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", fetch: @tempfile)
expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri0, new_resource, current_resource).and_return(http_fetcher_works)
end
diff --git a/spec/unit/provider/remote_file/fetcher_spec.rb b/spec/unit/provider/remote_file/fetcher_spec.rb
index f5b32800f2..b110e2c03a 100644
--- a/spec/unit/provider/remote_file/fetcher_spec.rb
+++ b/spec/unit/provider/remote_file/fetcher_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
end
describe "when passed an http url" do
- let(:uri) { double("uri", :scheme => "http" ) }
+ let(:uri) { double("uri", scheme: "http" ) }
before do
expect(Chef::Provider::RemoteFile::HTTP).to receive(:new).and_return(fetcher_instance)
end
@@ -56,7 +56,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
end
describe "when passed an https url" do
- let(:uri) { double("uri", :scheme => "https" ) }
+ let(:uri) { double("uri", scheme: "https" ) }
before do
expect(Chef::Provider::RemoteFile::HTTP).to receive(:new).and_return(fetcher_instance)
end
@@ -66,7 +66,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
end
describe "when passed an ftp url" do
- let(:uri) { double("uri", :scheme => "ftp" ) }
+ let(:uri) { double("uri", scheme: "ftp" ) }
before do
expect(Chef::Provider::RemoteFile::FTP).to receive(:new).and_return(fetcher_instance)
end
@@ -76,7 +76,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
end
describe "when passed a file url" do
- let(:uri) { double("uri", :scheme => "file" ) }
+ let(:uri) { double("uri", scheme: "file" ) }
before do
expect(Chef::Provider::RemoteFile::LocalFile).to receive(:new).and_return(fetcher_instance)
end
@@ -86,7 +86,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
end
describe "when passed a url we do not recognize" do
- let(:uri) { double("uri", :scheme => "xyzzy" ) }
+ let(:uri) { double("uri", scheme: "xyzzy" ) }
it "throws an ArgumentError exception" do
expect { described_class.for_resource(uri, new_resource, current_resource) }.to raise_error(ArgumentError)
end
diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb
index e1f74bd35a..8ece1a854b 100644
--- a/spec/unit/provider/remote_file/http_spec.rb
+++ b/spec/unit/provider/remote_file/http_spec.rb
@@ -292,7 +292,7 @@ describe Chef::Provider::RemoteFile::HTTP do
context "and the target file is a tarball [CHEF-3140]" do
let(:uri) { URI.parse("http://opscode.com/tarball.tgz") }
- let(:expected_http_opts) { { :disable_gzip => true } }
+ let(:expected_http_opts) { { disable_gzip: true } }
# CHEF-3140
# Some servers return tarballs as content type tar and encoding gzip, which
diff --git a/spec/unit/provider/remote_file/local_file_spec.rb b/spec/unit/provider/remote_file/local_file_spec.rb
index 6f345cadd1..6dad6a57f2 100644
--- a/spec/unit/provider/remote_file/local_file_spec.rb
+++ b/spec/unit/provider/remote_file/local_file_spec.rb
@@ -84,8 +84,8 @@ describe Chef::Provider::RemoteFile::LocalFile do
describe "when fetching the object" do
- let(:tempfile) { double("Tempfile", :path => "/tmp/foo/bar/nyan.png", :close => nil) }
- let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", :tempfile => tempfile) }
+ let(:tempfile) { double("Tempfile", path: "/tmp/foo/bar/nyan.png", close: nil) }
+ let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", tempfile: tempfile) }
before do
current_resource.source("file:///nyan_cat.png")
diff --git a/spec/unit/provider/remote_file/network_file_spec.rb b/spec/unit/provider/remote_file/network_file_spec.rb
index ecb326fc64..1c2bcc5911 100644
--- a/spec/unit/provider/remote_file/network_file_spec.rb
+++ b/spec/unit/provider/remote_file/network_file_spec.rb
@@ -28,9 +28,9 @@ describe Chef::Provider::RemoteFile::NetworkFile do
describe "when fetching the object" do
- let(:tempfile) { double("Tempfile", :path => "/tmp/foo/bar/Foo.tar.gz", :close => nil) }
- let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", :tempfile => tempfile) }
- let(:source_file) { double("::File", :read => nil) }
+ let(:tempfile) { double("Tempfile", path: "/tmp/foo/bar/Foo.tar.gz", close: nil) }
+ let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", tempfile: tempfile) }
+ let(:source_file) { double("::File", read: nil) }
before do
allow(Chef::Platform).to receive(:windows?).and_return(true)
diff --git a/spec/unit/provider/remote_file/sftp_spec.rb b/spec/unit/provider/remote_file/sftp_spec.rb
index ddab1605f0..d8fff87dec 100644
--- a/spec/unit/provider/remote_file/sftp_spec.rb
+++ b/spec/unit/provider/remote_file/sftp_spec.rb
@@ -120,7 +120,7 @@ describe Chef::Provider::RemoteFile::SFTP do
let(:uri) { URI.parse("sftp://conan:cthu1hu@opscode.com:8021/seattle.txt") }
it "should connect on an alternate port when one is provided" do
- expect(Net::SFTP).to receive(:start).with("opscode.com:8021", "conan", :password => "cthu1hu")
+ expect(Net::SFTP).to receive(:start).with("opscode.com:8021", "conan", password: "cthu1hu")
fetcher.fetch
end
diff --git a/spec/unit/provider/remote_file_spec.rb b/spec/unit/provider/remote_file_spec.rb
index 3f91377c60..07b854da6b 100644
--- a/spec/unit/provider/remote_file_spec.rb
+++ b/spec/unit/provider/remote_file_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Provider::RemoteFile do
let(:node) { double("Chef::Node") }
let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:logger) { double("Mixlib::Log::Child").as_null_object }
- let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) }
+ let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) }
let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
end
diff --git a/spec/unit/provider/script_spec.rb b/spec/unit/provider/script_spec.rb
index 651e5130e0..08b19730a7 100644
--- a/spec/unit/provider/script_spec.rb
+++ b/spec/unit/provider/script_spec.rb
@@ -93,7 +93,7 @@ describe Chef::Provider::Script, "action_run" do
end
context "when an alternate user is specified" do
- let(:security_descriptor) { instance_double("Chef::ReservedNames::Win32::Security::SecurityDescriptor", :dacl => []) }
+ let(:security_descriptor) { instance_double("Chef::ReservedNames::Win32::Security::SecurityDescriptor", dacl: []) }
let(:securable_object) { instance_double("Chef::ReservedNames::Win32::Security::SecurableObject", :security_descriptor => security_descriptor, :dacl= => nil) }
it "sets the script file's security descriptor" do
new_resource.user("toor")
diff --git a/spec/unit/provider/service/aix_service_spec.rb b/spec/unit/provider/service/aix_service_spec.rb
index 802ccee2c7..cf6309e82a 100644
--- a/spec/unit/provider/service/aix_service_spec.rb
+++ b/spec/unit/provider/service/aix_service_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Provider::Service::Aix do
describe "load current resource" do
it "should create a current resource with the name of the new resource and determine the status" do
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
expect(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
@@ -47,7 +47,7 @@ describe Chef::Provider::Service::Aix do
describe "determine current status" do
context "when the service is active" do
before do
- @status = double("Status", :exitstatus => 0, :stdout => "chef chef 12345 active\n")
+ @status = double("Status", exitstatus: 0, stdout: "chef chef 12345 active\n")
end
it "current resource is running" do
@@ -61,7 +61,7 @@ describe Chef::Provider::Service::Aix do
context "when the service is inoperative" do
before do
- @status = double("Status", :exitstatus => 0, :stdout => "chef chef inoperative\n")
+ @status = double("Status", exitstatus: 0, stdout: "chef chef inoperative\n")
end
it "current resource is not running" do
@@ -75,7 +75,7 @@ describe Chef::Provider::Service::Aix do
context "when there is no such service" do
before do
- @status = double("Status", :exitstatus => 1, :stdout => "0513-085 The chef Subsystem is not on file.\n")
+ @status = double("Status", exitstatus: 1, stdout: "0513-085 The chef Subsystem is not on file.\n")
end
it "current resource is not running" do
expect(@provider).to receive(:shell_out!).with("lssrc -s chef").and_return(@status)
@@ -90,7 +90,7 @@ describe Chef::Provider::Service::Aix do
describe "is resource group" do
context "when there are multiple subsystems associated with group" do
before do
- @status = double("Status", :exitstatus => 0, :stdout => "chef1 chef 12345 active\nchef2 chef 12334 active\nchef3 chef inoperative")
+ @status = double("Status", exitstatus: 0, stdout: "chef1 chef 12345 active\nchef2 chef 12334 active\nchef3 chef inoperative")
end
it "service is a group" do
@@ -102,7 +102,7 @@ describe Chef::Provider::Service::Aix do
context "when there is a single subsystem in the group" do
before do
- @status = double("Status", :exitstatus => 0, :stdout => "chef1 chef inoperative\n")
+ @status = double("Status", exitstatus: 0, stdout: "chef1 chef inoperative\n")
end
it "service is a group" do
@@ -114,8 +114,8 @@ describe Chef::Provider::Service::Aix do
context "when the service is a subsystem" do
before do
- @group_status = double("Status", :exitstatus => 1, :stdout => "0513-086 The chef Group is not on file.\n")
- @service_status = double("Status", :exitstatus => 0, :stdout => "chef chef inoperative\n")
+ @group_status = double("Status", exitstatus: 1, stdout: "0513-086 The chef Group is not on file.\n")
+ @service_status = double("Status", exitstatus: 0, stdout: "chef chef inoperative\n")
end
it "service is a subsystem" do
diff --git a/spec/unit/provider/service/aixinit_service_spec.rb b/spec/unit/provider/service/aixinit_service_spec.rb
index 09c177903b..725d6e210c 100644
--- a/spec/unit/provider/service/aixinit_service_spec.rb
+++ b/spec/unit/provider/service/aixinit_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::AixInit do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "fuuuu" }
+ @node.automatic_attrs[:command] = { ps: "fuuuu" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb
index 2139e31818..818c2ccb27 100644
--- a/spec/unit/provider/service/arch_service_spec.rb
+++ b/spec/unit/provider/service/arch_service_spec.rb
@@ -26,14 +26,14 @@ require "ostruct"
describe Chef::Provider::Service::Arch, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "ps -ef" }
+ @node.automatic_attrs[:command] = { ps: "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::Service.new("chef")
@new_resource.pattern("chef")
- @new_resource.supports({ :status => false })
+ @new_resource.supports({ status: false })
@provider = Chef::Provider::Service::Arch.new(@new_resource, @run_context)
@@ -43,7 +43,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
describe "when first created" do
it "should set the current resources service name to the new resources service name" do
- allow(@provider).to receive(:shell_out).and_return(OpenStruct.new(:exitstatus => 0, :stdout => ""))
+ allow(@provider).to receive(:shell_out).and_return(OpenStruct.new(exitstatus: 0, stdout: ""))
@provider.load_current_resource
expect(@provider.current_resource.service_name).to eq("chef")
end
@@ -51,22 +51,22 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
describe "when the service supports status" do
before do
- @new_resource.supports({ :status => true })
+ @new_resource.supports({ status: true })
end
it "should run '/etc/rc.d/service_name status'" do
- expect(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0))
+ expect(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 0))
@provider.load_current_resource
end
it "should set running to true if the status command returns 0" do
- allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0))
+ allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 0))
@provider.load_current_resource
expect(@provider.current_resource.running).to be_truthy
end
it "should set running to false if the status command returns anything except 0" do
- allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 1))
+ allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 1))
@provider.load_current_resource
expect(@provider.current_resource.running).to be_falsey
end
@@ -85,21 +85,21 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
end
it "should run the services status command if one has been specified" do
- expect(@provider).to receive(:shell_out).with("/etc/rc.d/chefhasmonkeypants status").and_return(OpenStruct.new(:exitstatus => 0))
+ expect(@provider).to receive(:shell_out).with("/etc/rc.d/chefhasmonkeypants status").and_return(OpenStruct.new(exitstatus: 0))
@provider.load_current_resource
end
end
it "should raise error if the node has a nil ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => nil }
+ @node.automatic_attrs[:command] = { ps: nil }
@provider.define_resource_requirements
@provider.action = :start
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
it "should raise error if the node has an empty ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => "" }
+ @node.automatic_attrs[:command] = { ps: "" }
@provider.define_resource_requirements
@provider.action = :start
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
@@ -122,10 +122,10 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
DEFAULT_PS
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
- @node.automatic_attrs[:command] = { :ps => "ps -ef" }
+ @node.automatic_attrs[:command] = { ps: "ps -ef" }
end
it "determines the service is running when it appears in ps" do
@@ -274,7 +274,7 @@ RUNNING_PS
# end
it "should call 'restart' on the service_name if the resource supports it" do
- @new_resource.supports({ :restart => true })
+ @new_resource.supports({ restart: true })
expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restart", default_env: false)
@provider.restart_service()
end
@@ -309,7 +309,7 @@ RUNNING_PS
# end
it "should call 'reload' on the service if it supports it" do
- @new_resource.supports({ :reload => true })
+ @new_resource.supports({ reload: true })
expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} reload", default_env: false)
@provider.reload_service()
end
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index 25e7c9acc2..173f5e9b61 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Debian do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "fuuuu" }
+ @node.automatic_attrs[:command] = { ps: "fuuuu" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb
index 511962f432..11a02c3421 100644
--- a/spec/unit/provider/service/freebsd_service_spec.rb
+++ b/spec/unit/provider/service/freebsd_service_spec.rb
@@ -27,14 +27,14 @@ end
describe Chef::Provider::Service::Freebsd do
let(:node) do
node = Chef::Node.new
- node.automatic_attrs[:command] = { :ps => "ps -ax" }
+ node.automatic_attrs[:command] = { ps: "ps -ax" }
node
end
let(:new_resource) do
new_resource = Chef::Resource::Service.new("apache22")
new_resource.pattern("httpd")
- new_resource.supports({ :status => false })
+ new_resource.supports({ status: false })
new_resource
end
@@ -99,7 +99,7 @@ describe Chef::Provider::Service::Freebsd do
end
context "when a status command has been specified" do
- let(:status) { double(:stdout => "", :exitstatus => 0) }
+ let(:status) { double(stdout: "", exitstatus: 0) }
before do
new_resource.status_command("/bin/chefhasmonkeypants status")
@@ -112,10 +112,10 @@ describe Chef::Provider::Service::Freebsd do
end
context "when the service supports status" do
- let(:status) { double(:stdout => "", :exitstatus => 0) }
+ let(:status) { double(stdout: "", exitstatus: 0) }
before do
- new_resource.supports({ :status => true })
+ new_resource.supports({ status: true })
end
it "should run '/etc/init.d/service_name status'" do
@@ -144,10 +144,10 @@ describe Chef::Provider::Service::Freebsd do
545 ?? Ss 0:17.53 sendmail: accepting connections (sendmail)
PS_SAMPLE
end
- let(:status) { double(:stdout => stdout, :exitstatus => 0) }
+ let(:status) { double(stdout: stdout, exitstatus: 0) }
before do
- node.automatic_attrs[:command] = { :ps => "ps -ax" }
+ node.automatic_attrs[:command] = { ps: "ps -ax" }
end
it "should shell_out! the node's ps command" do
@@ -191,7 +191,7 @@ PS_SAMPLE
context "when ps is empty string" do
before do
- node.automatic_attrs[:command] = { :ps => "" }
+ node.automatic_attrs[:command] = { ps: "" }
end
it "should set running to nil" do
@@ -369,7 +369,7 @@ EOF
end
before do
- status = double(:stdout => rcvar_stdout, :exitstatus => 0)
+ status = double(stdout: rcvar_stdout, exitstatus: 0)
allow(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} rcvar").and_return(status)
end
@@ -469,7 +469,7 @@ EOF
describe Chef::Provider::Service::Freebsd, "restart_service" do
it "should call 'restart' on the service_name if the resource supports it" do
- new_resource.supports({ :restart => true })
+ new_resource.supports({ restart: true })
expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart", default_env: false)
provider.restart_service()
end
diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb
index a00ca7aadd..6a928d849b 100644
--- a/spec/unit/provider/service/gentoo_service_spec.rb
+++ b/spec/unit/provider/service/gentoo_service_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Provider::Service::Gentoo do
@provider = Chef::Provider::Service::Gentoo.new(@new_resource, @run_context)
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out).and_return(@status)
allow(File).to receive(:exists?).with("/etc/init.d/chef").and_return(true)
allow(File).to receive(:exists?).with("/sbin/rc-update").and_return(true)
diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb
index ff7fae767a..5d403c6898 100644
--- a/spec/unit/provider/service/init_service_spec.rb
+++ b/spec/unit/provider/service/init_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Init, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "ps -ef" }
+ @node.automatic_attrs[:command] = { ps: "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -37,7 +37,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
PS
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
end
@@ -53,7 +53,7 @@ PS
describe "when the service supports status" do
before do
- @new_resource.supports({ :status => true })
+ @new_resource.supports({ status: true })
end
it "should run '/etc/init.d/service_name status'" do
@@ -109,7 +109,7 @@ PS
describe "when the node has not specified a ps command" do
it "should raise an error if the node has a nil ps attribute" do
- @node.automatic_attrs[:command] = { :ps => nil }
+ @node.automatic_attrs[:command] = { ps: nil }
@provider.load_current_resource
@provider.action = :start
@provider.define_resource_requirements
@@ -117,7 +117,7 @@ PS
end
it "should raise an error if the node has an empty ps attribute" do
- @node.automatic_attrs[:command] = { :ps => "" }
+ @node.automatic_attrs[:command] = { ps: "" }
@provider.load_current_resource
@provider.action = :start
@provider.define_resource_requirements
@@ -189,7 +189,7 @@ RUNNING_PS
describe "when restarting a service" do
it "should call 'restart' on the service_name if the resource supports it" do
- @new_resource.supports({ :restart => true })
+ @new_resource.supports({ restart: true })
expect(@provider).to receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} restart", default_env: false)
@provider.restart_service()
end
@@ -210,7 +210,7 @@ RUNNING_PS
describe "when reloading a service" do
it "should call 'reload' on the service if it supports it" do
- @new_resource.supports({ :reload => true })
+ @new_resource.supports({ reload: true })
expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef reload", default_env: false)
@provider.reload_service()
end
diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb
index 3b2b19c432..f2fe19db59 100644
--- a/spec/unit/provider/service/insserv_service_spec.rb
+++ b/spec/unit/provider/service/insserv_service_spec.rb
@@ -23,13 +23,13 @@ describe Chef::Provider::Service::Insserv do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @node.automatic_attrs[:command] = { :ps => "ps -ax" }
+ @node.automatic_attrs[:command] = { ps: "ps -ax" }
@new_resource = Chef::Resource::Service.new("initgrediant")
@current_resource = Chef::Resource::Service.new("initgrediant")
@provider = Chef::Provider::Service::Insserv.new(@new_resource, @run_context)
- @status = double("Process::Status mock", :exitstatus => 0, :stdout => "")
+ @status = double("Process::Status mock", exitstatus: 0, stdout: "")
allow(@provider).to receive(:shell_out!).and_return(@status)
end
diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb
index e70ba7e094..a63e3e1afb 100644
--- a/spec/unit/provider/service/invokercd_service_spec.rb
+++ b/spec/unit/provider/service/invokercd_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Invokercd, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "ps -ef" }
+ @node.automatic_attrs[:command] = { ps: "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -37,7 +37,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
PS
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
end
@@ -53,7 +53,7 @@ PS
describe "when the service supports status" do
before do
- @new_resource.supports({ :status => true })
+ @new_resource.supports({ status: true })
end
it "should run '/usr/sbin/invoke-rc.d service_name status'" do
@@ -95,14 +95,14 @@ PS
describe "when the node has not specified a ps command" do
it "should raise error if the node has a nil ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => nil }
+ @node.automatic_attrs[:command] = { ps: nil }
@provider.action = :start
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
it "should raise error if the node has an empty ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => "" }
+ @node.automatic_attrs[:command] = { ps: "" }
@provider.action = :start
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
@@ -112,7 +112,7 @@ PS
describe "when we have a 'ps' attribute" do
it "should shell_out! the node's ps command" do
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
expect(@provider).to receive(:shell_out!).with(@node[:command][:ps]).and_return(@status)
@provider.load_current_resource
end
@@ -122,14 +122,14 @@ PS
aj 7842 5057 0 21:26 pts/2 00:00:06 chef
aj 7842 5057 0 21:26 pts/2 00:00:06 poos
RUNNING_PS
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
expect(@provider).to receive(:shell_out!).and_return(@status)
@provider.load_current_resource
expect(@current_resource.running).to be_truthy
end
it "should set running to false if the regex doesn't match" do
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
expect(@provider).to receive(:shell_out!).and_return(@status)
@provider.load_current_resource
expect(@current_resource.running).to be_falsey
@@ -176,7 +176,7 @@ RUNNING_PS
describe "when restarting a service" do
it "should call 'restart' on the service_name if the resource supports it" do
- @new_resource.supports({ :restart => true })
+ @new_resource.supports({ restart: true })
expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restart", default_env: false)
@provider.restart_service()
end
@@ -197,7 +197,7 @@ RUNNING_PS
describe "when reloading a service" do
it "should call 'reload' on the service if it supports it" do
- @new_resource.supports({ :reload => true })
+ @new_resource.supports({ reload: true })
expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef reload", default_env: false)
@provider.reload_service()
end
diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb
index 283512108a..5ca06d9ec8 100644
--- a/spec/unit/provider/service/macosx_spec.rb
+++ b/spec/unit/provider/service/macosx_spec.rb
@@ -76,20 +76,20 @@ XML
before do
allow(run_context).to receive(:logger).and_return(logger)
allow(Dir).to receive(:glob).and_return([plist], [])
- @stat = double("File::Stat", { :uid => 501 })
+ @stat = double("File::Stat", { uid: 501 })
allow(File).to receive(:stat).and_return(@stat)
- @getpwuid = double("Etc::Passwd", { :name => "mikedodge04" })
+ @getpwuid = double("Etc::Passwd", { name: "mikedodge04" })
allow(Etc).to receive(:getpwuid).and_return(@getpwuid)
allow(node).to receive(:[]).with("platform_version").and_return(platform_version)
cmd = "launchctl list #{service_label}"
allow(provider).to receive(:shell_out).
with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false).
and_return(double("Status",
- :stdout => launchctl_stdout, :exitstatus => 0))
+ stdout: launchctl_stdout, exitstatus: 0))
allow(File).to receive(:exists?).and_return([true], [])
allow(provider).to receive(:shell_out!).
with(/plutil -convert xml1 -o/, default_env: false).
- and_return(double("Status", :stdout => plutil_stdout))
+ and_return(double("Status", stdout: plutil_stdout))
end
context "#{service_name} that is a #{service_type} running Osx #{platform_version}" do
diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb
index b990532aaf..38283f609d 100644
--- a/spec/unit/provider/service/openbsd_service_spec.rb
+++ b/spec/unit/provider/service/openbsd_service_spec.rb
@@ -31,11 +31,11 @@ end
describe Chef::Provider::Service::Openbsd do
let(:node) do
node = Chef::Node.new
- node.automatic_attrs[:command] = { :ps => "ps -ax" }
+ node.automatic_attrs[:command] = { ps: "ps -ax" }
node
end
- let(:supports) { { :status => false } }
+ let(:supports) { { status: false } }
let(:new_resource) do
new_resource = Chef::Resource::Service.new("sndiod")
@@ -93,7 +93,7 @@ describe Chef::Provider::Service::Openbsd do
end
context "when a status command has been specified" do
- let(:status) { double(:stdout => "", :exitstatus => 0) }
+ let(:status) { double(stdout: "", exitstatus: 0) }
before do
new_resource.status_command("/bin/chefhasmonkeypants status")
@@ -106,9 +106,9 @@ describe Chef::Provider::Service::Openbsd do
end
context "when the service supports status" do
- let(:status) { double(:stdout => "", :exitstatus => 0) }
+ let(:status) { double(stdout: "", exitstatus: 0) }
- let(:supports) { { :status => true } }
+ let(:supports) { { status: true } }
it "should run '/etc/rc.d/service_name status'" do
expect(provider).to receive(:shell_out).with("/etc/rc.d/#{new_resource.service_name} check").and_return(status)
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb
index 40f9bc3a91..b965183d14 100644
--- a/spec/unit/provider/service/redhat_spec.rb
+++ b/spec/unit/provider/service/redhat_spec.rb
@@ -23,17 +23,17 @@ shared_examples_for "define_resource_requirements_common" do
it "should raise an error if /sbin/chkconfig does not exist" do
allow(File).to receive(:exists?).with("/sbin/chkconfig").and_return(false)
allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_raise(Errno::ENOENT)
- allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_raise(Errno::ENOENT)
+ allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_raise(Errno::ENOENT)
@provider.load_current_resource
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
it "should not raise an error if the service exists but is not added to any runlevels" do
- status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "")
+ status = double("Status", exitstatus: 0, stdout: "" , stderr: "")
expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "", :stderr => "service chef supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add chef')")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "", stderr: "service chef supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add chef')")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
@provider.load_current_resource
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.not_to raise_error
@@ -44,7 +44,7 @@ describe "Chef::Provider::Service::Redhat" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "foo" }
+ @node.automatic_attrs[:command] = { ps: "foo" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -65,13 +65,13 @@ describe "Chef::Provider::Service::Redhat" do
describe "load current resource" do
before do
- status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "")
+ status = double("Status", exitstatus: 0, stdout: "" , stderr: "")
allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
end
it "sets supports[:status] to true by default" do
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@provider.supports[:status]).to be true
@@ -80,9 +80,9 @@ describe "Chef::Provider::Service::Redhat" do
it "lets the user override supports[:status] in the new_resource" do
@new_resource.supports( { status: false } )
@new_resource.pattern "myservice"
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
- foo_out = double("ps_command", :exitstatus => 0, :stdout => "a line that matches myservice", :stderr => "")
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
+ foo_out = double("ps_command", exitstatus: 0, stdout: "a line that matches myservice", stderr: "")
expect(@provider).to receive(:shell_out!).with("foo").and_return(foo_out)
expect(@provider.service_missing).to be false
expect(@provider).not_to receive(:shell_out).with("/sbin/service chef status")
@@ -91,16 +91,16 @@ describe "Chef::Provider::Service::Redhat" do
end
it "sets the current enabled status to true if the service is enabled for any run level" do
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be true
end
it "sets the current enabled status to false if the regex does not match" do
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
expect(@provider.load_current_resource).to eql(@current_resource)
expect(@current_resource.enabled).to be false
@@ -108,8 +108,8 @@ describe "Chef::Provider::Service::Redhat" do
it "sets the current enabled status to true if the service is enabled at specified run levels" do
@new_resource.run_levels([1, 2])
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be true
@@ -118,8 +118,8 @@ describe "Chef::Provider::Service::Redhat" do
it "sets the current enabled status to false if the service is enabled at a run level it should not" do
@new_resource.run_levels([1, 2])
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:on 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:on 3:on 4:off 5:off 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be false
@@ -128,8 +128,8 @@ describe "Chef::Provider::Service::Redhat" do
it "sets the current enabled status to false if the service is not enabled at specified run levels" do
@new_resource.run_levels([ 2 ])
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be false
@@ -142,10 +142,10 @@ describe "Chef::Provider::Service::Redhat" do
context "when the service does not exist" do
before do
- status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service")
+ status = double("Status", exitstatus: 1, stdout: "", stderr: "chef: unrecognized service")
expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
- chkconfig = double("Chkconfig", :existatus => 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", existatus: 1, stdout: "", stderr: "error reading information on service chef: No such file or directory")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
@provider.load_current_resource
@provider.define_resource_requirements
end
@@ -194,10 +194,10 @@ describe "Chef::Provider::Service::Redhat" do
it_should_behave_like "define_resource_requirements_common"
it "should not raise an error if the service does not exist" do
- status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service")
+ status = double("Status", exitstatus: 1, stdout: "", stderr: "chef: unrecognized service")
expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
- chkconfig = double("Chkconfig", :existatus => 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", existatus: 1, stdout: "", stderr: "error reading information on service chef: No such file or directory")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
@provider.load_current_resource
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.not_to raise_error
diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb
index 8a03c0552d..e9fe1b0482 100644
--- a/spec/unit/provider/service/simple_service_spec.rb
+++ b/spec/unit/provider/service/simple_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Simple, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "ps -ef" }
+ @node.automatic_attrs[:command] = { ps: "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -36,7 +36,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
aj 8119 6041 0 21:34 pts/3 00:00:03 vi simple_service_spec.rb
NOMOCKINGSTRINGSPLZ
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
end
@@ -51,13 +51,13 @@ NOMOCKINGSTRINGSPLZ
end
it "should raise error if the node has a nil ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => nil }
+ @node.automatic_attrs[:command] = { ps: nil }
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
it "should raise error if the node has an empty ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => "" }
+ @node.automatic_attrs[:command] = { ps: "" }
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
@@ -79,7 +79,7 @@ NOMOCKINGSTRINGSPLZ
aj 7842 5057 0 21:26 pts/2 00:00:06 chef
aj 7842 5057 0 21:26 pts/2 00:00:06 poos
NOMOCKINGSTRINGSPLZ
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
@provider.load_current_resource
expect(@current_resource.running).to be_truthy
diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb
index a5148c236a..7b8bd950d2 100644
--- a/spec/unit/provider/service/solaris_smf_service_spec.rb
+++ b/spec/unit/provider/service/solaris_smf_service_spec.rb
@@ -74,19 +74,19 @@ describe Chef::Provider::Service::Solaris do
].join("\n")
# shell_out! return value for a service that is running
- @enabled_svc_status = double("Status", :exitstatus => 0, :stdout => enabled_svc_stdout, :stdin => "", :stderr => "")
+ @enabled_svc_status = double("Status", exitstatus: 0, stdout: enabled_svc_stdout, stdin: "", stderr: "")
# shell_out! return value for a service that is disabled
- @disabled_svc_status = double("Status", :exitstatus => 0, :stdout => disabled_svc_stdout, :stdin => "", :stderr => "")
+ @disabled_svc_status = double("Status", exitstatus: 0, stdout: disabled_svc_stdout, stdin: "", stderr: "")
# shell_out! return value for a service that is in maintenance mode
- @maintenance_svc_status = double("Status", :exitstatus => 0, :stdout => maintenance_svc_stdout, :stdin => "", :stderr => "")
+ @maintenance_svc_status = double("Status", exitstatus: 0, stdout: maintenance_svc_stdout, stdin: "", stderr: "")
# shell_out! return value for a service that does not exist
- @no_svc_status = double("Status", :exitstatus => 1, :stdout => "", :stdin => "", :stderr => "svcs: Pattern 'chef' doesn't match any instances\n")
+ @no_svc_status = double("Status", exitstatus: 1, stdout: "", stdin: "", stderr: "svcs: Pattern 'chef' doesn't match any instances\n")
# shell_out! return value for a successful execution
- @success = double("clear", :exitstatus => 0, :stdout => "", :stdin => "", :stderr => "")
+ @success = double("clear", exitstatus: 0, stdout: "", stdin: "", stderr: "")
end
it "should raise an error if /bin/svcs and /usr/sbin/svcadm are not executable" do
@@ -116,19 +116,19 @@ describe Chef::Provider::Service::Solaris do
describe "when discovering the current service state" do
it "should create a current resource with the name of the new resource" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
expect(@provider.maintenance).to be_falsey
@provider.load_current_resource
end
it "should return the current resource" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(@provider.load_current_resource).to eql(@current_resource)
end
it "should call '/bin/svcs -l service_name'" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
@provider.load_current_resource
end
@@ -163,7 +163,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm enable -s chef" do
- expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
@provider.load_current_resource
@@ -173,7 +173,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm enable -s chef for start_service" do
- expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
@provider.load_current_resource
@@ -183,7 +183,7 @@ describe Chef::Provider::Service::Solaris do
it "should call svcadm clear chef for start_service when state maintenance" do
# we are in maint mode
- expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@maintenance_svc_status)
+ expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@maintenance_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name).and_return(@success)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
@@ -192,7 +192,7 @@ describe Chef::Provider::Service::Solaris do
expect(@provider.enable_service).to be_truthy
# now we are enabled
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
@provider.load_current_resource
expect(@current_resource.enabled).to be_truthy
@@ -206,7 +206,7 @@ describe Chef::Provider::Service::Solaris do
it "should call svcadm enable -s -r chef" do
@new_resource.options("-r")
- expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", @current_resource.service_name).and_return(@success)
@provider.load_current_resource
@@ -216,7 +216,7 @@ describe Chef::Provider::Service::Solaris do
it "should call svcadm enable -s -r -t chef when passed an array of options" do
@new_resource.options(["-r", "-t"])
- expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", "-t", @current_resource.service_name).and_return(@success)
@provider.load_current_resource
@@ -232,7 +232,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm disable -s chef" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success)
@provider.load_current_resource
expect(@provider.disable_service).to be_truthy
@@ -240,7 +240,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm disable -s chef for stop_service" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success)
@provider.load_current_resource
expect(@provider.disable_service).to be_truthy
@@ -249,7 +249,7 @@ describe Chef::Provider::Service::Solaris do
it "should call svcadm disable chef with options" do
@new_resource.options("-t")
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "-t", "chef").and_return(@success)
@provider.load_current_resource
expect(@provider.disable_service).to be_truthy
@@ -261,7 +261,7 @@ describe Chef::Provider::Service::Solaris do
describe "when reloading the service" do
before(:each) do
@provider.current_resource = @current_resource
- allow(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ allow(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
end
it "should call svcadm refresh chef" do
@@ -274,7 +274,7 @@ describe Chef::Provider::Service::Solaris do
describe "when the service doesn't exist" do
before(:each) do
@provider.current_resource = @current_resource
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@no_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@no_svc_status)
end
it "should be marked not running" do
diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb
index 1082bdfdc4..ccd814a3a9 100644
--- a/spec/unit/provider/service/systemd_service_spec.rb
+++ b/spec/unit/provider/service/systemd_service_spec.rb
@@ -36,11 +36,11 @@ describe Chef::Provider::Service::Systemd do
let(:provider) { Chef::Provider::Service::Systemd.new(new_resource, run_context) }
let(:shell_out_success) do
- double("shell_out", :exitstatus => 0, :error? => false)
+ double("shell_out", exitstatus: 0, error?: false)
end
let(:shell_out_failure) do
- double("shell_out", :exitstatus => 1, :error? => true)
+ double("shell_out", exitstatus: 1, error?: true)
end
let(:current_resource) { Chef::Resource::Service.new(service_name) }
@@ -190,14 +190,14 @@ describe Chef::Provider::Service::Systemd do
context "when a user is specified" do
it "should call '#{systemctl_path} --user start service_name' if no start command is specified" do
current_resource.user("joe")
- expect(provider).to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe", default_env: false }).and_return(shell_out_success)
+ expect(provider).to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, user: "joe", default_env: false }).and_return(shell_out_success)
provider.start_service
end
it "should not call '#{systemctl_path} --user start service_name' if it is already running" do
current_resource.running(true)
current_resource.user("joe")
- expect(provider).not_to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe" })
+ expect(provider).not_to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, user: "joe" })
provider.start_service
end
end
@@ -340,22 +340,22 @@ describe Chef::Provider::Service::Systemd do
end
it "should return true if '#{systemctl_path} --system is-enabled service_name' returns 'masked' and returns anything except 0" do
- expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "masked", :exitstatus => shell_out_failure))
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "masked", exitstatus: shell_out_failure))
expect(provider.is_masked?).to be true
end
it "should return true if '#{systemctl_path} --system is-enabled service_name' outputs 'masked-runtime' and returns anything except 0" do
- expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "masked-runtime", :exitstatus => shell_out_failure))
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "masked-runtime", exitstatus: shell_out_failure))
expect(provider.is_masked?).to be true
end
it "should return false if '#{systemctl_path} --system is-enabled service_name' returns 0" do
- expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "enabled", :exitstatus => shell_out_success))
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "enabled", exitstatus: shell_out_success))
expect(provider.is_masked?).to be false
end
it "should return false if '#{systemctl_path} --system is-enabled service_name' returns anything except 0 and outputs an error'" do
- expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "Failed to get unit file state for #{service_name}: No such file or directory", :exitstatus => shell_out_failure))
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "Failed to get unit file state for #{service_name}: No such file or directory", exitstatus: shell_out_failure))
expect(provider.is_masked?).to be false
end
end
diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb
index a95f9c494e..ae94e49835 100644
--- a/spec/unit/provider/service/upstart_service_spec.rb
+++ b/spec/unit/provider/service/upstart_service_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Provider::Service::Upstart do
let(:shell_out_success) do
- double("shell_out", :exitstatus => 0, :error? => false)
+ double("shell_out", exitstatus: 0, error?: false)
end
before(:each) do
@@ -66,7 +66,7 @@ describe Chef::Provider::Service::Upstart do
describe "load_current_resource" do
before(:each) do
- @node.automatic_attrs[:command] = { :ps => "ps -ax" }
+ @node.automatic_attrs[:command] = { ps: "ps -ax" }
@current_resource = Chef::Resource::Service.new("rsyslog")
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
@@ -167,14 +167,14 @@ describe Chef::Provider::Service::Upstart do
end
it "should set enabled to true when it finds 'starts on'" do
- @lines = double("start on filesystem", :gets => "start on filesystem")
+ @lines = double("start on filesystem", gets: "start on filesystem")
allow(::File).to receive(:open).and_yield(@lines)
expect(@current_resource).to receive(:running).with(false)
@provider.load_current_resource
end
it "should set enabled to false when it finds '#starts on'" do
- @lines = double("start on filesystem", :gets => "#start on filesystem")
+ @lines = double("start on filesystem", gets: "#start on filesystem")
allow(::File).to receive(:open).and_yield(@lines)
expect(@current_resource).to receive(:running).with(false)
@provider.load_current_resource
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb
index 18ea004795..978d180026 100644
--- a/spec/unit/provider/service/windows_spec.rb
+++ b/spec/unit/provider/service/windows_spec.rb
@@ -98,7 +98,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
Win32::Service::DISABLED = 0x00000004
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"))
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name)
.and_return(chef_service_config_info)
@@ -502,8 +502,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "start_service" do
before(:each) do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "running"))
end
it "calls the start command if one is specified" do
@@ -528,7 +528,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "does nothing if the service is running" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
provider.start_service
@@ -537,7 +537,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "raises an error if the service is paused" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "paused"))
+ double("StatusStruct", current_state: "paused"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
expect { provider.start_service }.to raise_error( Chef::Exceptions::Service )
@@ -546,9 +546,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "waits and continues if the service is in start_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "start pending"),
- double("StatusStruct", :current_state => "start pending"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "start pending"),
+ double("StatusStruct", current_state: "start pending"),
+ double("StatusStruct", current_state: "running"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
provider.start_service
@@ -557,7 +557,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "fails if the service is in stop_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stop pending"))
+ double("StatusStruct", current_state: "stop pending"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
expect { provider.start_service }.to raise_error( Chef::Exceptions::Service )
@@ -597,8 +597,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
before(:each) do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"),
- double("StatusStruct", :current_state => "stopped"))
+ double("StatusStruct", current_state: "running"),
+ double("StatusStruct", current_state: "stopped"))
end
it "calls the stop command if one is specified" do
@@ -623,7 +623,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "does nothing if the service is stopped" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stopped"))
+ double("StatusStruct", current_state: "stopped"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
provider.stop_service
@@ -632,7 +632,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "raises an error if the service is paused" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "paused"))
+ double("StatusStruct", current_state: "paused"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service )
@@ -641,9 +641,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "waits and continue if the service is in stop_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stop pending"),
- double("StatusStruct", :current_state => "stop pending"),
- double("StatusStruct", :current_state => "stopped"))
+ double("StatusStruct", current_state: "stop pending"),
+ double("StatusStruct", current_state: "stop pending"),
+ double("StatusStruct", current_state: "stopped"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
provider.stop_service
@@ -652,7 +652,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "fails if the service is in start_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "start pending"))
+ double("StatusStruct", current_state: "start pending"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service )
@@ -661,7 +661,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "passes custom timeout to the stop command if provided" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"))
new_resource.timeout 1
expect(Win32::Service).to receive(:stop).with(new_resource.service_name)
Timeout.timeout(2) do
@@ -683,10 +683,10 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "stops then starts the service if it is running" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"),
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"),
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "running"))
expect(Win32::Service).to receive(:stop).with(new_resource.service_name)
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
provider.restart_service
@@ -695,9 +695,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "just starts the service if it is stopped" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "running"))
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
provider.restart_service
expect(new_resource.updated_by_last_action?).to be_truthy
@@ -716,11 +716,11 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "enable_service" do
before(:each) do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "disabled"))
+ double("ConfigStruct", start_type: "disabled"))
end
it "enables service" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::AUTO_START)
provider.enable_service
expect(new_resource.updated_by_last_action?).to be_truthy
end
@@ -736,14 +736,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "action_enable" do
it "does nothing if the service is enabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "auto start"))
+ double("ConfigStruct", start_type: "auto start"))
expect(provider).not_to receive(:enable_service)
provider.action_enable
end
it "enables the service if it is not set to automatic start" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "disabled"))
+ double("ConfigStruct", start_type: "disabled"))
expect(provider).to receive(:enable_service)
provider.action_enable
end
@@ -752,14 +752,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "action_disable" do
it "does nothing if the service is disabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "disabled"))
+ double("ConfigStruct", start_type: "disabled"))
expect(provider).not_to receive(:disable_service)
provider.action_disable
end
it "disables the service if it is not set to disabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "auto start"))
+ double("ConfigStruct", start_type: "auto start"))
expect(provider).to receive(:disable_service)
provider.action_disable
end
@@ -768,7 +768,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "disable_service" do
before(:each) do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "auto start"))
+ double("ConfigStruct", start_type: "auto start"))
end
it "disables service" do
@@ -810,17 +810,17 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "set_start_type" do
it "when called with :automatic it calls Win32::Service#configure with Win32::Service::AUTO_START" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::AUTO_START)
provider.send(:set_startup_type, :automatic)
end
it "when called with :manual it calls Win32::Service#configure with Win32::Service::DEMAND_START" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DEMAND_START)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::DEMAND_START)
provider.send(:set_startup_type, :manual)
end
it "when called with :disabled it calls Win32::Service#configure with Win32::Service::DISABLED" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DISABLED)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::DISABLED)
provider.send(:set_startup_type, :disabled)
end
diff --git a/spec/unit/provider/service_spec.rb b/spec/unit/provider/service_spec.rb
index c788cb223e..f3e725abb6 100644
--- a/spec/unit/provider/service_spec.rb
+++ b/spec/unit/provider/service_spec.rb
@@ -99,7 +99,7 @@ describe Chef::Provider::Service do
describe "action_restart" do
before do
- @current_resource.supports(:restart => true)
+ @current_resource.supports(restart: true)
end
it "should restart the service if it's supported and set the resource as updated" do
@@ -118,11 +118,11 @@ describe Chef::Provider::Service do
describe "action_reload" do
before do
- @new_resource.supports(:reload => true)
+ @new_resource.supports(reload: true)
end
it "should raise an exception if reload isn't supported" do
- @new_resource.supports(:reload => false)
+ @new_resource.supports(reload: false)
@new_resource.reload_command(false)
expect { @provider.run_action(:reload) }.to raise_error(Chef::Exceptions::UnsupportedAction)
end
diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb
index 55d6dc5d24..8f364aa8c8 100644
--- a/spec/unit/provider/subversion_spec.rb
+++ b/spec/unit/provider/subversion_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Provider::Subversion do
it "converts resource attributes to options for shell_out" do
expect(@provider.run_options).to eq({})
@resource.user "deployninja"
- expect(@provider.run_options).to eq({ :user => "deployninja" })
+ expect(@provider.run_options).to eq({ user: "deployninja" })
end
context "determining the revision of the currently deployed code" do
@@ -73,18 +73,18 @@ describe Chef::Provider::Subversion do
"Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision
"Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n"
expect(::File).to receive(:exist?).at_least(1).times.with("/my/deploy/dir/.svn").and_return(true)
- expected_command = ["svn info", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
+ expected_command = ["svn info", { cwd: "/my/deploy/dir", returns: [0, 1] }]
expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ and_return(double("ShellOut result", stdout: example_svn_info, stderr: ""))
expect(@provider.find_current_revision).to eql("11410")
end
it "gives nil as the current revision if the deploy dir isn't a SVN working copy" do
example_svn_info = "svn: '/tmp/deploydir' is not a working copy\n"
expect(::File).to receive(:exist?).with("/my/deploy/dir/.svn").and_return(true)
- expected_command = ["svn info", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
+ expected_command = ["svn info", { cwd: "/my/deploy/dir", returns: [0, 1] }]
expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ and_return(double("ShellOut result", stdout: example_svn_info, stderr: ""))
expect(@provider.find_current_revision).to be_nil
end
@@ -128,18 +128,18 @@ describe Chef::Provider::Subversion do
"Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision
"Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n"
@resource.revision "HEAD"
- expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
+ expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { cwd: "/my/deploy/dir", returns: [0, 1] }]
expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ and_return(double("ShellOut result", stdout: example_svn_info, stderr: ""))
expect(@provider.revision_int).to eql("11410")
end
it "returns a helpful message if data from `svn info` can't be parsed" do
example_svn_info = "some random text from an error message\n"
@resource.revision "HEAD"
- expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
+ expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { cwd: "/my/deploy/dir", returns: [0, 1] }]
expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ and_return(double("ShellOut result", stdout: example_svn_info, stderr: ""))
expect { @provider.revision_int }.to raise_error(RuntimeError, "Could not parse `svn info` data: some random text from an error message\n")
end
diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb
index 5e57cbb840..8c42c41420 100644
--- a/spec/unit/provider/systemd_unit_spec.rb
+++ b/spec/unit/provider/systemd_unit_spec.rb
@@ -50,27 +50,27 @@ describe Chef::Provider::SystemdUnit do
let(:user_cmd_opts) do
{
- :user => "joe",
- :environment => {
+ user: "joe",
+ environment: {
"DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/1000/bus",
},
}
end
let(:shell_out_success) do
- double("shell_out", :exitstatus => 0, :error? => false)
+ double("shell_out", exitstatus: 0, error?: false)
end
let(:shell_out_failure) do
- double("shell_out", :exitstatus => 1, :error? => true)
+ double("shell_out", exitstatus: 1, error?: true)
end
let(:shell_out_masked) do
- double("shell_out", :exit_status => 0, :error? => false, :stdout => "masked")
+ double("shell_out", exit_status: 0, error?: false, stdout: "masked")
end
let(:shell_out_static) do
- double("shell_out", :exit_status => 0, :error? => false, :stdout => "static")
+ double("shell_out", exit_status: 0, error?: false, stdout: "static")
end
before(:each) do
diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb
index 8f30d8f868..fb5d127d57 100644
--- a/spec/unit/provider/template/content_spec.rb
+++ b/spec/unit/provider/template/content_spec.rb
@@ -30,20 +30,20 @@ describe Chef::Provider::Template::Content do
let(:new_resource) do
double("Chef::Resource::Template (new)",
- :cookbook_name => "openldap",
- :recipe_name => "default",
- :source_line => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
- :source_line_file => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb",
- :source_line_number => "2",
- :source => "openldap_stuff.conf.erb",
- :name => "openldap_stuff.conf",
- :path => resource_path,
- :local => false,
- :cookbook => nil,
- :variables => {},
- :inline_helper_blocks => {},
- :inline_helper_modules => [],
- :helper_modules => [])
+ cookbook_name: "openldap",
+ recipe_name: "default",
+ source_line: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
+ source_line_file: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb",
+ source_line_number: "2",
+ source: "openldap_stuff.conf.erb",
+ name: "openldap_stuff.conf",
+ path: resource_path,
+ local: false,
+ cookbook: nil,
+ variables: {},
+ inline_helper_blocks: {},
+ inline_helper_modules: [],
+ helper_modules: [])
end
let(:rendered_file_locations) do
@@ -58,7 +58,7 @@ describe Chef::Provider::Template::Content do
cl.load_cookbooks
cookbook_collection = Chef::CookbookCollection.new(cl)
node = Chef::Node.new
- double("Chef::Resource::RunContext", :node => node, :cookbook_collection => cookbook_collection)
+ double("Chef::Resource::RunContext", node: node, cookbook_collection: cookbook_collection)
end
let(:content) do
@@ -130,20 +130,20 @@ describe Chef::Provider::Template::Content do
describe "when using location helpers" do
let(:new_resource) do
double("Chef::Resource::Template (new)",
- :cookbook_name => "openldap",
- :recipe_name => "default",
- :source_line => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
- :source_line_file => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb",
- :source_line_number => "2",
- :source => "helpers.erb",
- :name => "helpers.erb",
- :path => CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb",
- :local => false,
- :cookbook => nil,
- :variables => {},
- :inline_helper_blocks => {},
- :inline_helper_modules => [],
- :helper_modules => [])
+ cookbook_name: "openldap",
+ recipe_name: "default",
+ source_line: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
+ source_line_file: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb",
+ source_line_number: "2",
+ source: "helpers.erb",
+ name: "helpers.erb",
+ path: CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb",
+ local: false,
+ cookbook: nil,
+ variables: {},
+ inline_helper_blocks: {},
+ inline_helper_modules: [],
+ helper_modules: [])
end
it "creates the template with the rendered content" do
diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb
index 9f69772bc8..a65846ecb2 100644
--- a/spec/unit/provider/template_spec.rb
+++ b/spec/unit/provider/template_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Provider::Template do
let(:node) { double("Chef::Node") }
let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:logger) { double("Mixlib::Log::Child").as_null_object }
- let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) }
+ let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) }
let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
end
@@ -50,7 +50,7 @@ describe Chef::Provider::Template do
end
let(:content) do
- content = double("Chef::Provider::File::Content::Template", :template_location => "/foo/bar/baz")
+ content = double("Chef::Provider::File::Content::Template", template_location: "/foo/bar/baz")
allow(File).to receive(:exists?).with("/foo/bar/baz").and_return(true)
content
end
diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb
index 8cc69f88af..7c6948bf84 100644
--- a/spec/unit/provider/user/pw_spec.rb
+++ b/spec/unit/provider/user/pw_spec.rb
@@ -202,7 +202,7 @@ describe Chef::Provider::User::Pw do
end
it "should run pw usermod with the username and the option -H 0" do
- expect(@provider).to receive(:shell_out_compacted!).with( "pw usermod adam -H 0", { :input => "abracadabra" }).and_return(@status)
+ expect(@provider).to receive(:shell_out_compacted!).with( "pw usermod adam -H 0", { input: "abracadabra" }).and_return(@status)
@provider.modify_password
end
diff --git a/spec/unit/provider/windows_task_spec.rb b/spec/unit/provider/windows_task_spec.rb
index 66bd6854b6..39f39b37fe 100644
--- a/spec/unit/provider/windows_task_spec.rb
+++ b/spec/unit/provider/windows_task_spec.rb
@@ -70,20 +70,20 @@ describe Chef::Provider::WindowsTask, :windows_only do
new_resource.frequency_modifier 15
new_resource.random_delay 60
result = {
- :start_year => 2017,
- :start_month => 12,
- :start_day => 2,
- :start_hour => 17,
- :start_minute => 30,
- :end_month => 0,
- :end_day => 0,
- :end_year => 0,
- :trigger_type => 1,
- :type => { :once => nil },
- :random_minutes_interval => 60,
- :minutes_interval => 15,
- :run_on_last_day_of_month => false,
- :run_on_last_week_of_month => false
+ start_year: 2017,
+ start_month: 12,
+ start_day: 2,
+ start_hour: 17,
+ start_minute: 30,
+ end_month: 0,
+ end_day: 0,
+ end_year: 0,
+ trigger_type: 1,
+ type: { once: nil },
+ random_minutes_interval: 60,
+ minutes_interval: 15,
+ run_on_last_day_of_month: false,
+ run_on_last_week_of_month: false
}
expect(provider.send(:trigger)).to eq(result)
@@ -145,7 +145,7 @@ describe Chef::Provider::WindowsTask, :windows_only do
new_resource.frequency_modifier 2
result = provider.send(:type)
expect(result).to include(:once)
- expect(result).to eq({ :once => nil })
+ expect(result).to eq({ once: nil })
end
it "returns type hash when frequency :daily" do