summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/support/shared/unit/provider/useradd_based_user_provider.rb22
-rw-r--r--spec/unit/lwrp_spec.rb2
-rw-r--r--spec/unit/mixin/shell_out_spec.rb238
-rw-r--r--spec/unit/provider/group/dscl_spec.rb4
-rw-r--r--spec/unit/provider/group/gpasswd_spec.rb14
-rw-r--r--spec/unit/provider/group/groupadd_spec.rb14
-rw-r--r--spec/unit/provider/group/groupmod_spec.rb26
-rw-r--r--spec/unit/provider/group/pw_spec.rb8
-rw-r--r--spec/unit/provider/group/suse_spec.rb4
-rw-r--r--spec/unit/provider/group/usermod_spec.rb8
-rw-r--r--spec/unit/provider/ifconfig/aix_spec.rb14
-rw-r--r--spec/unit/provider/ifconfig_spec.rb26
-rw-r--r--spec/unit/provider/package/apt_spec.rb76
-rw-r--r--spec/unit/provider/package/bff_spec.rb48
-rw-r--r--spec/unit/provider/package/chocolatey_spec.rb44
-rw-r--r--spec/unit/provider/package/dpkg_spec.rb16
-rw-r--r--spec/unit/provider/package/freebsd/pkg_spec.rb26
-rw-r--r--spec/unit/provider/package/freebsd/pkgng_spec.rb18
-rw-r--r--spec/unit/provider/package/freebsd/port_spec.rb18
-rw-r--r--spec/unit/provider/package/ips_spec.rb48
-rw-r--r--spec/unit/provider/package/macports_spec.rb32
-rw-r--r--spec/unit/provider/package/msu_spec.rb4
-rw-r--r--spec/unit/provider/package/openbsd_spec.rb20
-rw-r--r--spec/unit/provider/package/pacman_spec.rb24
-rw-r--r--spec/unit/provider/package/paludis_spec.rb22
-rw-r--r--spec/unit/provider/package/portage_spec.rb20
-rw-r--r--spec/unit/provider/package/rpm_spec.rb34
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb38
-rw-r--r--spec/unit/provider/package/smartos_spec.rb18
-rw-r--r--spec/unit/provider/package/solaris_spec.rb40
-rw-r--r--spec/unit/provider/package/zypper_spec.rb76
-rw-r--r--spec/unit/provider/package_spec.rb2
-rw-r--r--spec/unit/provider/user/aix_spec.rb10
-rw-r--r--spec/unit/provider/user/dscl_spec.rb24
-rw-r--r--spec/unit/provider/user/pw_spec.rb24
-rw-r--r--spec/unit/provider/user/solaris_spec.rb12
-rw-r--r--spec/unit/resource/powershell_package_source_spec.rb219
-rw-r--r--spec/unit/util/selinux_spec.rb8
38 files changed, 759 insertions, 542 deletions
diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
index e123e8e0e2..caa76e4ad6 100644
--- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb
+++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
@@ -160,7 +160,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
"-d", "/Users/mud",
"-m",
"adam" ])
- expect(provider).to receive(:shell_out!).with(*command).and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with(*command).and_return(true)
provider.create_user
end
@@ -181,7 +181,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
"-u", "1000",
"-r", "-m",
"adam" ])
- expect(provider).to receive(:shell_out!).with(*command).and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with(*command).and_return(true)
provider.create_user
end
@@ -204,7 +204,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
"-d", "/Users/mud",
"-m",
"adam" ]
- expect(provider).to receive(:shell_out!).with(*command).and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with(*command).and_return(true)
provider.manage_user
end
@@ -215,7 +215,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
"-d", "/Users/mud",
"-m",
"adam" ]
- expect(provider).to receive(:shell_out!).with(*command).and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with(*command).and_return(true)
provider.manage_user
end
@@ -224,7 +224,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
command = ["usermod",
"-g", "23",
"adam" ]
- expect(provider).to receive(:shell_out!).with(*command).and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with(*command).and_return(true)
provider.manage_user
end
end
@@ -232,24 +232,24 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
describe "when removing a user" do
it "should run userdel with the new resources user name" do
- expect(provider).to receive(:shell_out!).with("userdel", @new_resource.username).and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with("userdel", @new_resource.username).and_return(true)
provider.remove_user
end
it "should run userdel with the new resources user name and -r if manage_home is true" do
@new_resource.manage_home true
- expect(provider).to receive(:shell_out!).with("userdel", "-r", @new_resource.username).and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with("userdel", "-r", @new_resource.username).and_return(true)
provider.remove_user
end
it "should run userdel with the new resources user name if non_unique is true" do
- expect(provider).to receive(:shell_out!).with("userdel", @new_resource.username).and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with("userdel", @new_resource.username).and_return(true)
provider.remove_user
end
it "should run userdel with the new resources user name and -f if force is true" do
@new_resource.force(true)
- expect(provider).to receive(:shell_out!).with("userdel", "-f", @new_resource.username).and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with("userdel", "-f", @new_resource.username).and_return(true)
provider.remove_user
end
end
@@ -335,14 +335,14 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
describe "when locking the user" do
it "should run usermod -L with the new resources username" do
- expect(provider).to receive(:shell_out!).with("usermod", "-L", @new_resource.username)
+ expect(provider).to receive(:shell_out_compacted!).with("usermod", "-L", @new_resource.username)
provider.lock_user
end
end
describe "when unlocking the user" do
it "should run usermod -L with the new resources username" do
- expect(provider).to receive(:shell_out!).with("usermod", "-U", @new_resource.username)
+ expect(provider).to receive(:shell_out_compacted!).with("usermod", "-U", @new_resource.username)
provider.unlock_user
end
end
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index 4423ccf64e..b42ac3af1e 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Christopher Walters (<cw@chef.io>)
-# Copyright:: Copyright 2009-2017, Chef Software Inc.
+# Copyright:: Copyright 2009-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index 66dfbd3491..df35960cc9 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -48,128 +48,130 @@ describe Chef::Mixin::ShellOut do
ENV.update(@original_env)
end
+ let(:retobj) { instance_double(Mixlib::ShellOut, "error!" => false) }
let(:cmd) { "echo '#{rand(1000)}'" }
- describe "#shell_out" do
-
- describe "when the last argument is a Hash" do
- describe "and environment is an option" do
- it "should not change environment language settings when they are set to nil" do
- options = { :environment => { "LC_ALL" => nil, "LANGUAGE" => nil, "LANG" => nil, env_path => nil } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
- shell_out_obj.shell_out(cmd, options)
+ [ :shell_out, :shell_out_compact, :shell_out_compact_timeout, :shell_out!, :shell_out_compact!, :shell_out_compact_timeout! ].each do |method|
+ describe "##{method}" do
+
+ describe "when the last argument is a Hash" do
+ describe "and environment is an option" do
+ it "should not change environment language settings when they are set to nil" do
+ options = { :environment => { "LC_ALL" => nil, "LANGUAGE" => nil, "LANG" => nil, env_path => nil } }
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
+ shell_out_obj.send(method, cmd, options)
+ end
+
+ it "should not change environment language settings when they are set to non-nil" do
+ options = { :environment => { "LC_ALL" => "en_US.UTF-8", "LANGUAGE" => "en_US.UTF-8", "LANG" => "en_US.UTF-8", env_path => "foo:bar:baz" } }
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
+ shell_out_obj.send(method, cmd, options)
+ end
+
+ it "should set environment language settings to the configured internal locale when they are not present" do
+ options = { :environment => { "HOME" => "/Users/morty" } }
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
+ :environment => {
+ "HOME" => "/Users/morty",
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
+ env_path => sanitized_path,
+ },
+ }).and_return(retobj)
+ shell_out_obj.send(method, cmd, options)
+ end
+
+ it "should not mutate the options hash when it adds language settings" do
+ options = { :environment => { "HOME" => "/Users/morty" } }
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
+ :environment => {
+ "HOME" => "/Users/morty",
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
+ env_path => sanitized_path,
+ },
+ }).and_return(retobj)
+ shell_out_obj.send(method, cmd, options)
+ expect(options[:environment].has_key?("LC_ALL")).to be false
+ end
end
- it "should not change environment language settings when they are set to non-nil" do
- options = { :environment => { "LC_ALL" => "en_US.UTF-8", "LANGUAGE" => "en_US.UTF-8", "LANG" => "en_US.UTF-8", env_path => "foo:bar:baz" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
- shell_out_obj.shell_out(cmd, options)
+ describe "and env is an option" do
+ it "should not change env when langauge options are set to nil" do
+ options = { :env => { "LC_ALL" => nil, "LANG" => nil, "LANGUAGE" => nil, env_path => nil } }
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
+ shell_out_obj.send(method, cmd, options)
+ end
+
+ it "should not change env when language options are set to non-nil" do
+ options = { :env => { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8", env_path => "foo:bar:baz" } }
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
+ shell_out_obj.send(method, cmd, options)
+ end
+
+ it "should set environment language settings to the configured internal locale when they are not present" do
+ options = { :env => { "HOME" => "/Users/morty" } }
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
+ :env => {
+ "HOME" => "/Users/morty",
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
+ env_path => sanitized_path,
+ },
+ }).and_return(retobj)
+ shell_out_obj.send(method, cmd, options)
+ end
+
+ it "should not mutate the options hash when it adds language settings" do
+ options = { :env => { "HOME" => "/Users/morty" } }
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
+ :env => {
+ "HOME" => "/Users/morty",
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
+ env_path => sanitized_path,
+ },
+ }).and_return(retobj)
+ shell_out_obj.send(method, cmd, options)
+ expect(options[:env].has_key?("LC_ALL")).to be false
+ end
end
- it "should set environment language settings to the configured internal locale when they are not present" do
- options = { :environment => { "HOME" => "/Users/morty" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
- :environment => {
- "HOME" => "/Users/morty",
- "LC_ALL" => Chef::Config[:internal_locale],
- "LANG" => Chef::Config[:internal_locale],
- "LANGUAGE" => Chef::Config[:internal_locale],
- env_path => sanitized_path,
- },
- }).and_return(true)
- shell_out_obj.shell_out(cmd, options)
- end
-
- it "should not mutate the options hash when it adds language settings" do
- options = { :environment => { "HOME" => "/Users/morty" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
- :environment => {
- "HOME" => "/Users/morty",
- "LC_ALL" => Chef::Config[:internal_locale],
- "LANG" => Chef::Config[:internal_locale],
- "LANGUAGE" => Chef::Config[:internal_locale],
- env_path => sanitized_path,
- },
- }).and_return(true)
- shell_out_obj.shell_out(cmd, options)
- expect(options[:environment].has_key?("LC_ALL")).to be false
- end
- end
-
- describe "and env is an option" do
- it "should not change env when langauge options are set to nil" do
- options = { :env => { "LC_ALL" => nil, "LANG" => nil, "LANGUAGE" => nil, env_path => nil } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
- shell_out_obj.shell_out(cmd, options)
- end
-
- it "should not change env when language options are set to non-nil" do
- options = { :env => { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8", env_path => "foo:bar:baz" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
- shell_out_obj.shell_out(cmd, options)
- end
-
- it "should set environment language settings to the configured internal locale when they are not present" do
- options = { :env => { "HOME" => "/Users/morty" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
- :env => {
- "HOME" => "/Users/morty",
- "LC_ALL" => Chef::Config[:internal_locale],
- "LANG" => Chef::Config[:internal_locale],
- "LANGUAGE" => Chef::Config[:internal_locale],
- env_path => sanitized_path,
- },
- }).and_return(true)
- shell_out_obj.shell_out(cmd, options)
- end
-
- it "should not mutate the options hash when it adds language settings" do
- options = { :env => { "HOME" => "/Users/morty" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
- :env => {
- "HOME" => "/Users/morty",
- "LC_ALL" => Chef::Config[:internal_locale],
- "LANG" => Chef::Config[:internal_locale],
- "LANGUAGE" => Chef::Config[:internal_locale],
- env_path => sanitized_path,
- },
- }).and_return(true)
- shell_out_obj.shell_out(cmd, options)
- expect(options[:env].has_key?("LC_ALL")).to be false
- end
- end
-
- describe "and no env/environment option is present" do
- it "should set environment language settings to the configured internal locale" do
- options = { :user => "morty" }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
- :user => "morty",
- :environment => {
- "LC_ALL" => Chef::Config[:internal_locale],
- "LANG" => Chef::Config[:internal_locale],
- "LANGUAGE" => Chef::Config[:internal_locale],
- env_path => sanitized_path,
- },
- }).and_return(true)
- shell_out_obj.shell_out(cmd, options)
+ describe "and no env/environment option is present" do
+ it "should set environment language settings to the configured internal locale" do
+ options = { :user => "morty" }
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
+ :user => "morty",
+ :environment => {
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
+ env_path => sanitized_path,
+ },
+ }).and_return(retobj)
+ shell_out_obj.send(method, cmd, options)
+ end
end
end
end
describe "when the last argument is not a Hash" do
it "should set environment language settings to the configured internal locale" do
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
:environment => {
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
"LANGUAGE" => Chef::Config[:internal_locale],
env_path => sanitized_path,
},
- }).and_return(true)
- shell_out_obj.shell_out(cmd)
+ }).and_return(retobj)
+ shell_out_obj.send(method, cmd)
end
end
-
end
describe "#shell_out_with_systems_locale" do
@@ -178,19 +180,19 @@ describe Chef::Mixin::ShellOut do
describe "and environment is an option" do
it "should not change environment['LC_ALL'] when set to nil" do
options = { :environment => { "LC_ALL" => nil } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
it "should not change environment['LC_ALL'] when set to non-nil" do
options = { :environment => { "LC_ALL" => "en_US.UTF-8" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
it "should no longer set environment['LC_ALL'] to nil when 'LC_ALL' not present" do
options = { :environment => { "HOME" => "/Users/morty" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
end
@@ -198,19 +200,19 @@ describe Chef::Mixin::ShellOut do
describe "and env is an option" do
it "should not change env when set to nil" do
options = { :env => { "LC_ALL" => nil } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
it "should not change env when set to non-nil" do
options = { :env => { "LC_ALL" => "en_US.UTF-8" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
it "should no longer set env['LC_ALL'] to nil when 'LC_ALL' not present" do
options = { :env => { "HOME" => "/Users/morty" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
end
@@ -218,7 +220,7 @@ describe Chef::Mixin::ShellOut do
describe "and no env/environment option is present" do
it "should no longer add environment option and set environment['LC_ALL'] to nil" do
options = { :user => "morty" }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
end
@@ -226,7 +228,7 @@ describe Chef::Mixin::ShellOut do
describe "when the last argument is not a Hash" do
it "should no longer add environment options and set environment['LC_ALL'] to nil" do
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {}).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd)
end
end
@@ -238,19 +240,19 @@ describe Chef::Mixin::ShellOut do
describe "and environment is an option" do
it "should not change environment['LC_ALL'] when set to nil" do
options = { :environment => { "LC_ALL" => nil } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
it "should not change environment['LC_ALL'] when set to non-nil" do
options = { :environment => { "LC_ALL" => "en_US.UTF-8" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
it "should no longer set environment['LC_ALL'] to nil when 'LC_ALL' not present" do
options = { :environment => { "HOME" => "/Users/morty" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
end
@@ -258,19 +260,19 @@ describe Chef::Mixin::ShellOut do
describe "and env is an option" do
it "should not change env when set to nil" do
options = { :env => { "LC_ALL" => nil } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
it "should not change env when set to non-nil" do
options = { :env => { "LC_ALL" => "en_US.UTF-8" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
it "should no longer set env['LC_ALL'] to nil when 'LC_ALL' not present" do
options = { :env => { "HOME" => "/Users/morty" } }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
end
@@ -278,7 +280,7 @@ describe Chef::Mixin::ShellOut do
describe "and no env/environment option is present" do
it "should no longer add environment option and set environment['LC_ALL'] to nil" do
options = { :user => "morty" }
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
end
@@ -286,7 +288,7 @@ describe Chef::Mixin::ShellOut do
describe "when the last argument is not a Hash" do
it "should no longer add environment options and set environment['LC_ALL'] to nil" do
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {}).and_return(true)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd).and_return(true)
shell_out_obj.shell_out(cmd, default_env: false)
end
end
diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb
index 6e40e41579..b6748fd5f8 100644
--- a/spec/unit/provider/group/dscl_spec.rb
+++ b/spec/unit/provider/group/dscl_spec.rb
@@ -32,11 +32,11 @@ describe Chef::Provider::Group::Dscl do
@provider.current_resource = @current_resource
@status = double(stdout: "\n", stderr: "", exitstatus: 0)
- allow(@provider).to receive(:shell_out).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@status)
end
it "should run shell_out with the supplied array of arguments appended to the dscl command" do
- expect(@provider).to receive(:shell_out).with("dscl", ".", "-cmd", "/Path", "arg1", "arg2")
+ expect(@provider).to receive(:shell_out_compacted).with("dscl", ".", "-cmd", "/Path", "arg1", "arg2")
@provider.dscl("cmd", "/Path", "arg1", "arg2")
end
diff --git a/spec/unit/provider/group/gpasswd_spec.rb b/spec/unit/provider/group/gpasswd_spec.rb
index 287951a1a9..506c7b642a 100644
--- a/spec/unit/provider/group/gpasswd_spec.rb
+++ b/spec/unit/provider/group/gpasswd_spec.rb
@@ -69,7 +69,7 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
it "logs a message and sets group's members to 'none'" do
expect(logger).to receive(:trace).with("group[wheel] setting group members to: none")
- expect(@provider).to receive(:shell_out!).with("gpasswd", "-M", "", "wheel")
+ expect(@provider).to receive(:shell_out_compacted!).with("gpasswd", "-M", "", "wheel")
@provider.modify_group_members
end
end
@@ -81,7 +81,7 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
end
it "does not modify group membership" do
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
@provider.modify_group_members
end
end
@@ -89,12 +89,12 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
describe "when the resource specifies group members" do
it "should log an appropriate debug message" do
expect(logger).to receive(:trace).with("group[wheel] setting group members to: lobster, rage, fist")
- allow(@provider).to receive(:shell_out!)
+ allow(@provider).to receive(:shell_out_compacted!)
@provider.modify_group_members
end
it "should run gpasswd with the members joined by ',' followed by the target group" do
- expect(@provider).to receive(:shell_out!).with("gpasswd", "-M", "lobster,rage,fist", "wheel")
+ expect(@provider).to receive(:shell_out_compacted!).with("gpasswd", "-M", "lobster,rage,fist", "wheel")
@provider.modify_group_members
end
@@ -107,9 +107,9 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
it "should run gpasswd individually for each user when the append option is set" do
@new_resource.append(true)
- expect(@provider).to receive(:shell_out!).with("gpasswd", "-a", "lobster", "wheel")
- expect(@provider).to receive(:shell_out!).with("gpasswd", "-a", "rage", "wheel")
- expect(@provider).to receive(:shell_out!).with("gpasswd", "-a", "fist", "wheel")
+ expect(@provider).to receive(:shell_out_compacted!).with("gpasswd", "-a", "lobster", "wheel")
+ expect(@provider).to receive(:shell_out_compacted!).with("gpasswd", "-a", "rage", "wheel")
+ expect(@provider).to receive(:shell_out_compacted!).with("gpasswd", "-a", "fist", "wheel")
@provider.modify_group_members
end
end
diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb
index ded1bc76f1..1aae4fc7f1 100644
--- a/spec/unit/provider/group/groupadd_spec.rb
+++ b/spec/unit/provider/group/groupadd_spec.rb
@@ -108,14 +108,14 @@ describe Chef::Provider::Group::Groupadd do
describe "#create_group" do
before do
- allow(provider).to receive(:shell_out!).and_return(true)
+ allow(provider).to receive(:shell_out_compacted!).and_return(true)
allow(provider).to receive(:set_options).and_return("monkey")
allow(provider).to receive(:groupadd_options).and_return([])
allow(provider).to receive(:modify_group_members).and_return(true)
end
it "should run groupadd with the return of set_options" do
- expect(provider).to receive(:shell_out!).with("groupadd", "monkey").and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with("groupadd", "monkey").and_return(true)
provider.create_group
end
@@ -127,13 +127,13 @@ describe Chef::Provider::Group::Groupadd do
describe "#manage_group" do
before do
- allow(provider).to receive(:shell_out!).and_return(true)
+ allow(provider).to receive(:shell_out_compacted!).and_return(true)
allow(provider).to receive(:set_options).and_return("monkey")
end
it "should run groupmod with the return of set_options" do
allow(provider).to receive(:modify_group_members).and_return(true)
- expect(provider).to receive(:shell_out!).with("groupmod", "monkey").and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with("groupmod", "monkey").and_return(true)
provider.manage_group
end
@@ -145,12 +145,12 @@ describe Chef::Provider::Group::Groupadd do
describe "#remove_group" do
before do
- allow(provider).to receive(:shell_out!).and_return(true)
+ allow(provider).to receive(:shell_out_compacted!).and_return(true)
allow(provider).to receive(:set_options).and_return("monkey")
end
it "should run groupdel with the new resources group name" do
- expect(provider).to receive(:shell_out!).with("groupdel", "aj").and_return(true)
+ expect(provider).to receive(:shell_out_compacted!).with("groupdel", "aj").and_return(true)
provider.remove_group
end
end
@@ -163,7 +163,7 @@ describe Chef::Provider::Group::Groupadd do
describe "#load_current_resource" do
before do
- allow(provider).to receive(:shell_out!).and_return(true)
+ allow(provider).to receive(:shell_out_compacted!).and_return(true)
allow(provider).to receive(:set_options).and_return("monkey")
end
diff --git a/spec/unit/provider/group/groupmod_spec.rb b/spec/unit/provider/group/groupmod_spec.rb
index 3f36a5b8a6..60965f2d47 100644
--- a/spec/unit/provider/group/groupmod_spec.rb
+++ b/spec/unit/provider/group/groupmod_spec.rb
@@ -65,9 +65,9 @@ describe Chef::Provider::Group::Groupmod do
it "logs a message and sets group's members to 'none', then removes existing group members" do
expect(logger).to receive(:trace).with("group[wheel] setting group members to: none")
- expect(@provider).to receive(:shell_out!).with("group", "mod", "-n", "wheel_bak", "wheel")
- expect(@provider).to receive(:shell_out!).with("group", "add", "-g", "123", "-o", "wheel")
- expect(@provider).to receive(:shell_out!).with("group", "del", "wheel_bak")
+ expect(@provider).to receive(:shell_out_compacted!).with("group", "mod", "-n", "wheel_bak", "wheel")
+ expect(@provider).to receive(:shell_out_compacted!).with("group", "add", "-g", "123", "-o", "wheel")
+ expect(@provider).to receive(:shell_out_compacted!).with("group", "del", "wheel_bak")
@provider.manage_group
end
end
@@ -80,7 +80,7 @@ describe Chef::Provider::Group::Groupmod do
it "logs a message and does not modify group membership" do
expect(logger).to receive(:trace).with("group[wheel] not changing group members, the group has no members to add")
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
@provider.manage_group
end
end
@@ -93,10 +93,10 @@ describe Chef::Provider::Group::Groupmod do
it "updates group membership correctly" do
allow(logger).to receive(:trace)
- expect(@provider).to receive(:shell_out!).with("group", "mod", "-n", "wheel_bak", "wheel")
- expect(@provider).to receive(:shell_out!).with("user", "mod", "-G", "wheel", "lobster")
- expect(@provider).to receive(:shell_out!).with("group", "add", "-g", "123", "-o", "wheel")
- expect(@provider).to receive(:shell_out!).with("group", "del", "wheel_bak")
+ expect(@provider).to receive(:shell_out_compacted!).with("group", "mod", "-n", "wheel_bak", "wheel")
+ expect(@provider).to receive(:shell_out_compacted!).with("user", "mod", "-G", "wheel", "lobster")
+ expect(@provider).to receive(:shell_out_compacted!).with("group", "add", "-g", "123", "-o", "wheel")
+ expect(@provider).to receive(:shell_out_compacted!).with("group", "del", "wheel_bak")
@provider.manage_group
end
end
@@ -111,10 +111,10 @@ describe Chef::Provider::Group::Groupmod do
end
it "should run a group add command and some user mod commands" do
- expect(@provider).to receive(:shell_out!).with("group", "add", "-g", "123", "wheel")
- expect(@provider).to receive(:shell_out!).with("user", "mod", "-G", "wheel", "lobster")
- expect(@provider).to receive(:shell_out!).with("user", "mod", "-G", "wheel", "rage")
- expect(@provider).to receive(:shell_out!).with("user", "mod", "-G", "wheel", "fist")
+ expect(@provider).to receive(:shell_out_compacted!).with("group", "add", "-g", "123", "wheel")
+ expect(@provider).to receive(:shell_out_compacted!).with("user", "mod", "-G", "wheel", "lobster")
+ expect(@provider).to receive(:shell_out_compacted!).with("user", "mod", "-G", "wheel", "rage")
+ expect(@provider).to receive(:shell_out_compacted!).with("user", "mod", "-G", "wheel", "fist")
@provider.create_group
end
end
@@ -128,7 +128,7 @@ describe Chef::Provider::Group::Groupmod do
end
it "should run a group del command" do
- expect(@provider).to receive(:shell_out!).with("group", "del", "wheel")
+ expect(@provider).to receive(:shell_out_compacted!).with("group", "del", "wheel")
@provider.remove_group
end
end
diff --git a/spec/unit/provider/group/pw_spec.rb b/spec/unit/provider/group/pw_spec.rb
index 736ba0671b..fc42a64566 100644
--- a/spec/unit/provider/group/pw_spec.rb
+++ b/spec/unit/provider/group/pw_spec.rb
@@ -52,7 +52,7 @@ describe Chef::Provider::Group::Pw do
describe "when creating a group" do
it "should run pw groupadd with the return of set_options and set_members_option" do
@new_resource.gid(23)
- expect(@provider).to receive(:shell_out!).with("pw", "groupadd", "wheel", "-g", "23", "-M", "root,aj").and_return(true)
+ expect(@provider).to receive(:shell_out_compacted!).with("pw", "groupadd", "wheel", "-g", "23", "-M", "root,aj").and_return(true)
@provider.create_group
end
end
@@ -62,8 +62,8 @@ describe Chef::Provider::Group::Pw do
it "should run pw groupmod with the return of set_options" do
@new_resource.gid(42)
@new_resource.members(["someone"])
- expect(@provider).to receive(:shell_out!).with("pw", "groupmod", "wheel", "-g", "42", "-m", "someone").and_return(true)
- expect(@provider).to receive(:shell_out!).with("pw", "groupmod", "wheel", "-g", "42", "-d", "root,aj").and_return(true)
+ expect(@provider).to receive(:shell_out_compacted!).with("pw", "groupmod", "wheel", "-g", "42", "-m", "someone").and_return(true)
+ expect(@provider).to receive(:shell_out_compacted!).with("pw", "groupmod", "wheel", "-g", "42", "-d", "root,aj").and_return(true)
@provider.manage_group
end
@@ -71,7 +71,7 @@ describe Chef::Provider::Group::Pw do
describe "when removing the group" do
it "should run pw groupdel with the new resources group name" do
- expect(@provider).to receive(:shell_out!).with("pw", "groupdel", "wheel").and_return(true)
+ expect(@provider).to receive(:shell_out_compacted!).with("pw", "groupdel", "wheel").and_return(true)
@provider.remove_group
end
end
diff --git a/spec/unit/provider/group/suse_spec.rb b/spec/unit/provider/group/suse_spec.rb
index e61d865b6d..29d8f4c58c 100644
--- a/spec/unit/provider/group/suse_spec.rb
+++ b/spec/unit/provider/group/suse_spec.rb
@@ -76,14 +76,14 @@ describe Chef::Provider::Group::Suse do
describe "#add_member" do
it "should call out to groupmod to add user" do
- expect(provider).to receive(:shell_out!).with("groupmod", "-A", "new_user", "new_group")
+ expect(provider).to receive(:shell_out_compacted!).with("groupmod", "-A", "new_user", "new_group")
provider.add_member("new_user")
end
end
describe "#remove_member" do
it "should call out to groupmod to remove user" do
- expect(provider).to receive(:shell_out!).with("groupmod", "-R", "new_user", "new_group")
+ expect(provider).to receive(:shell_out_compacted!).with("groupmod", "-R", "new_user", "new_group")
provider.remove_member("new_user")
end
end
diff --git a/spec/unit/provider/group/usermod_spec.rb b/spec/unit/provider/group/usermod_spec.rb
index da2c20b7da..e34949f839 100644
--- a/spec/unit/provider/group/usermod_spec.rb
+++ b/spec/unit/provider/group/usermod_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Provider::Group::Usermod do
end
it "should log an appropriate message" do
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
@provider.modify_group_members
end
end
@@ -85,9 +85,9 @@ describe Chef::Provider::Group::Usermod do
@provider.current_resource = current_resource
@node.automatic_attrs[:platform] = platform
@new_resource.append(true)
- expect(@provider).to receive(:shell_out!).with("usermod", *flags, "wheel", "all")
- expect(@provider).to receive(:shell_out!).with("usermod", *flags, "wheel", "your")
- expect(@provider).to receive(:shell_out!).with("usermod", *flags, "wheel", "base")
+ expect(@provider).to receive(:shell_out_compacted!).with("usermod", *flags, "wheel", "all")
+ expect(@provider).to receive(:shell_out_compacted!).with("usermod", *flags, "wheel", "your")
+ expect(@provider).to receive(:shell_out_compacted!).with("usermod", *flags, "wheel", "base")
@provider.modify_group_members
end
end
diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb
index 7f316c952b..3eb4228c51 100644
--- a/spec/unit/provider/ifconfig/aix_spec.rb
+++ b/spec/unit/provider/ifconfig/aix_spec.rb
@@ -49,7 +49,7 @@ IFCONFIG
describe "#load_current_resource" do
before do
@status = double(stdout: @ifconfig_output, exitstatus: 0)
- allow(@provider).to receive(:shell_out).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@status)
@new_resource.device "en0"
end
@@ -72,7 +72,7 @@ IFCONFIG
@provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
command = "chdev -l #{@new_resource.device} -a netaddr=#{@new_resource.name}"
- expect(@provider).to receive(:shell_out!).with(*command.split(" "))
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
@provider.run_action(:add)
expect(@new_resource).to be_updated
@@ -98,7 +98,7 @@ IFCONFIG
@provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
command = "ifconfig #{@new_resource.device} #{@new_resource.name}"
- expect(@provider).to receive(:shell_out!).with(*command.split(" "))
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
@provider.run_action(:enable)
expect(@new_resource).to be_updated
@@ -114,7 +114,7 @@ IFCONFIG
@provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
@provider.run_action(:disable)
expect(@new_resource).not_to be_updated
@@ -133,7 +133,7 @@ IFCONFIG
it "should disable an interface if it exists" do
command = "ifconfig #{@new_resource.device} down"
- expect(@provider).to receive(:shell_out!).with(*command.split(" "))
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
@provider.run_action(:disable)
expect(@new_resource).to be_updated
@@ -151,7 +151,7 @@ IFCONFIG
@provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
@provider.run_action(:delete)
expect(@new_resource).not_to be_updated
@@ -170,7 +170,7 @@ IFCONFIG
it "should delete an interface if it exists" do
command = "chdev -l #{@new_resource.device} -a state=down"
- expect(@provider).to receive(:shell_out!).with(*command.split(" "))
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
@provider.run_action(:delete)
expect(@new_resource).to be_updated
diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb
index 3732d75cc9..748b4d897e 100644
--- a/spec/unit/provider/ifconfig_spec.rb
+++ b/spec/unit/provider/ifconfig_spec.rb
@@ -48,9 +48,9 @@ EOS
before do
ifconfig = double(stdout: "", exitstatus: 1)
- allow(@provider).to receive(:shell_out).and_return(ifconfig)
+ allow(@provider).to receive(:shell_out_compacted).and_return(ifconfig)
ifconfig_version = double(stdout: "", stderr: net_tools_version, exitstatus: 4)
- allow(@provider).to receive(:shell_out).with("ifconfig --version").and_return(ifconfig_version)
+ allow(@provider).to receive(:shell_out_compacted).with("ifconfig --version").and_return(ifconfig_version)
@provider.load_current_resource
end
it "should track state of ifconfig failure" do
@@ -67,7 +67,7 @@ EOS
allow(@provider).to receive(:load_current_resource)
@current_resource.inet_addr nil
command = "ifconfig eth0 10.0.0.1 netmask 255.255.254.0 metric 1 mtu 1500"
- expect(@provider).to receive(:shell_out!).with(*command.split(" "))
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
expect(@provider).to receive(:generate_config)
@provider.run_action(:add)
@@ -78,7 +78,7 @@ EOS
allow(@provider).to receive(:load_current_resource)
@new_resource.target "172.16.32.2"
command = "ifconfig eth0 172.16.32.2 netmask 255.255.254.0 metric 1 mtu 1500"
- expect(@provider).to receive(:shell_out!).with(*command.split(" "))
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
@provider.run_action(:add)
expect(@new_resource).to be_updated
@@ -86,7 +86,7 @@ EOS
it "should not add an interface if it already exists" do
allow(@provider).to receive(:load_current_resource)
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
@current_resource.inet_addr "10.0.0.1"
expect(@provider).to receive(:generate_config)
@@ -105,7 +105,7 @@ EOS
allow(@provider).to receive(:load_current_resource)
@current_resource.inet_addr nil
command = "ifconfig eth0 10.0.0.1 netmask 255.255.254.0 metric 1 mtu 1500"
- expect(@provider).to receive(:shell_out!).with(*command.split(" "))
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
expect(@provider).not_to receive(:generate_config)
@provider.run_action(:enable)
@@ -116,7 +116,7 @@ EOS
allow(@provider).to receive(:load_current_resource)
@new_resource.target "172.16.32.2"
command = "ifconfig eth0 172.16.32.2 netmask 255.255.254.0 metric 1 mtu 1500"
- expect(@provider).to receive(:shell_out!).with(*command.split(" "))
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
@provider.run_action(:enable)
expect(@new_resource).to be_updated
@@ -139,7 +139,7 @@ EOS
allow(@provider).to receive(:load_current_resource)
@current_resource.device "eth0"
command = "ifconfig #{@new_resource.device} down"
- expect(@provider).to receive(:shell_out!).with(*command.split(" "))
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
expect(@provider).to receive(:delete_config)
@provider.run_action(:delete)
@@ -148,7 +148,7 @@ EOS
it "should not delete interface if it does not exist" do
allow(@provider).to receive(:load_current_resource)
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
expect(@provider).to receive(:delete_config)
@provider.run_action(:delete)
@@ -162,7 +162,7 @@ EOS
allow(@provider).to receive(:load_current_resource)
@current_resource.device "eth0"
command = "ifconfig #{@new_resource.device} down"
- expect(@provider).to receive(:shell_out!).with(*command.split(" "))
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
expect(@provider).not_to receive(:delete_config)
@provider.run_action(:disable)
@@ -171,7 +171,7 @@ EOS
it "should not delete interface if it does not exist" do
allow(@provider).to receive(:load_current_resource)
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
expect(@provider).not_to receive(:delete_config)
@provider.run_action(:disable)
@@ -185,7 +185,7 @@ EOS
allow(@provider).to receive(:load_current_resource)
@current_resource.device "eth0"
command = "ifconfig #{@new_resource.device} down"
- expect(@provider).to receive(:shell_out!).with(*command.split(" "))
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
expect(@provider).to receive(:delete_config)
@provider.run_action(:delete)
@@ -196,7 +196,7 @@ EOS
# This is so that our fake values do not get overwritten
allow(@provider).to receive(:load_current_resource)
# This is so that nothing actually runs
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
expect(@provider).to receive(:delete_config)
@provider.run_action(:delete)
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index e132bc3d21..f15929880d 100644
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -50,7 +50,7 @@ irssi:
describe "when loading current resource" do
it "should create a current resource with the name of the new_resource" do
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", @new_resource.package_name,
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -77,7 +77,7 @@ sudo:
1.7.2p1-1ubuntu5 0
500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
INSTALLED
- expect(@provider).to receive(:shell_out!).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
@provider.load_current_resource
expect(@provider.current_resource.version).to eq(["1.7.2p1-1ubuntu5.3"])
expect(@provider.candidate_version).to eql(["1.7.2p1-1ubuntu5.3"])
@@ -90,7 +90,7 @@ sudo:
N: Unable to locate package conic-smarms
POLICY_STDOUT
policy = double(:stdout => policy_out, :exitstatus => 0)
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "conic-smarms",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -99,7 +99,7 @@ N: Unable to locate package conic-smarms
N: Unable to locate package conic-smarms
SHOWPKG_STDOUT
showpkg = double(:stdout => showpkg_out, :exitstatus => 0)
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "showpkg", "conic-smarms",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -118,7 +118,7 @@ libmysqlclient15-dev:
Version table:
VPKG_STDOUT
virtual_package = double(:stdout => virtual_package_out, :exitstatus => 0)
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "libmysqlclient15-dev",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -142,7 +142,7 @@ libmysqlclient-dev 5.1.41-3ubuntu12.10
libmysqlclient-dev 5.1.41-3ubuntu12
SHOWPKG_STDOUT
showpkg = double(:stdout => showpkg_out, :exitstatus => 0)
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "showpkg", "libmysqlclient15-dev",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -161,7 +161,7 @@ libmysqlclient-dev:
500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
RPKG_STDOUT
real_package = double(:stdout => real_package_out, :exitstatus => 0)
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "libmysqlclient-dev",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -178,7 +178,7 @@ mp3-decoder:
Version table:
VPKG_STDOUT
virtual_package = double(:stdout => virtual_package_out, :exitstatus => 0)
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "mp3-decoder",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -205,7 +205,7 @@ mpg321 0.2.10.6
mpg123 1.12.1-0ubuntu1
SHOWPKG_STDOUT
showpkg = double(:stdout => showpkg_out, :exitstatus => 0)
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "showpkg", "mp3-decoder",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -219,7 +219,7 @@ mpg123 1.12.1-0ubuntu1
@new_resource.default_release("lenny-backports")
@new_resource.provider(nil)
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "-o", "APT::Default-Release=lenny-backports", "policy", "irssi",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -229,7 +229,7 @@ mpg123 1.12.1-0ubuntu1
it "raises an exception if a source is specified (CHEF-5113)" do
@new_resource.source "pluto"
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", @new_resource.package_name,
:env => { "DEBIAN_FRONTEND" => "noninteractive" } ,
:timeout => @timeout
@@ -258,7 +258,7 @@ mpg123 1.12.1-0ubuntu1
describe "install_package" do
it "should run apt-get install with the package name and version" do
- expect(@provider).to receive(:shell_out!). with(
+ 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
@@ -267,7 +267,7 @@ mpg123 1.12.1-0ubuntu1
end
it "should run apt-get install with the package name and version and options if specified" do
- expect(@provider).to receive(:shell_out!).with(
+ 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
@@ -283,7 +283,7 @@ mpg123 1.12.1-0ubuntu1
@new_resource.provider = nil
@provider.new_resource = @new_resource
- expect(@provider).to receive(:shell_out!).with(
+ 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
@@ -293,7 +293,7 @@ mpg123 1.12.1-0ubuntu1
end
it "should run apt-get install with the package name and quotes options if specified" do
- expect(@provider).to receive(:shell_out!).with(
+ 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
@@ -314,7 +314,7 @@ mpg123 1.12.1-0ubuntu1
describe Chef::Resource::AptPackage, "remove_package" do
it "should run apt-get remove with the package name" do
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "remove", "irssi",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -323,7 +323,7 @@ mpg123 1.12.1-0ubuntu1
end
it "should run apt-get remove with the package name and options if specified" do
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "--force-yes", "remove", "irssi",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -337,7 +337,7 @@ mpg123 1.12.1-0ubuntu1
describe "when purging a package" do
it "should run apt-get purge with the package name" do
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "purge", "irssi",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -346,7 +346,7 @@ mpg123 1.12.1-0ubuntu1
end
it "should run apt-get purge with the package name and options if specified" do
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "--force-yes", "purge", "irssi",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -365,7 +365,7 @@ mpg123 1.12.1-0ubuntu1
it "should get the full path to the preseed response file" do
file = "/tmp/irssi-0.8.12-7.seed"
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"debconf-set-selections", "/tmp/irssi-0.8.12-7.seed",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -375,7 +375,7 @@ mpg123 1.12.1-0ubuntu1
end
it "should run debconf-set-selections on the preseed file if it has changed" do
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"debconf-set-selections", "/tmp/irssi-0.8.12-7.seed",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -389,14 +389,14 @@ mpg123 1.12.1-0ubuntu1
@current_resource.version "0.8.11"
@new_resource.response_file "/tmp/file"
allow(@provider).to receive(:get_preseed_file).and_return(false)
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
@provider.run_action(:reconfig)
end
end
describe "when reconfiguring a package" do
it "should run dpkg-reconfigure package" do
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"dpkg-reconfigure", "irssi",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -407,7 +407,7 @@ mpg123 1.12.1-0ubuntu1
describe "when locking a package" do
it "should run apt-mark hold package" do
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-mark", "hold", "irssi",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -415,8 +415,8 @@ mpg123 1.12.1-0ubuntu1
@provider.lock_package("irssi", "0.8.12-7")
end
it "should not lock if the package is already locked" do
- allow(@provider).to receive(:shell_out_compact!).with(
- "apt-mark", "showhold"
+ allow(@provider).to receive(:shell_out_compacted!).with(
+ "apt-mark", "showhold", timeout: 900
).and_return(instance_double(
Mixlib::ShellOut, stdout: "irssi")
)
@@ -428,7 +428,7 @@ mpg123 1.12.1-0ubuntu1
describe "when unlocking a package" do
it "should run apt-mark unhold package" do
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-mark", "unhold", "irssi",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -436,8 +436,8 @@ mpg123 1.12.1-0ubuntu1
@provider.unlock_package("irssi", "0.8.12-7")
end
it "should not unlock if the package is already unlocked" do
- allow(@provider).to receive(:shell_out_compact!).with(
- "apt-mark", "showhold"
+ allow(@provider).to receive(:shell_out_compacted!).with(
+ "apt-mark", "showhold", timeout: 900
).and_return(instance_double(
Mixlib::ShellOut, stdout: "")
)
@@ -450,7 +450,7 @@ mpg123 1.12.1-0ubuntu1
describe "when installing a virtual package" do
it "should install the package without specifying a version" do
@provider.package_data["libmysqlclient15-dev"][:virtual] = true
- expect(@provider).to receive(:shell_out!).with(
+ 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
@@ -462,7 +462,7 @@ mpg123 1.12.1-0ubuntu1
describe "when removing a virtual package" do
it "should remove the resolved name instead of the virtual package name" do
expect(@provider).to receive(:resolve_virtual_package_name).with("libmysqlclient15-dev").and_return("libmysqlclient-dev")
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "remove", "libmysqlclient-dev",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -474,7 +474,7 @@ mpg123 1.12.1-0ubuntu1
describe "when purging a virtual package" do
it "should purge the resolved name instead of the virtual package name" do
expect(@provider).to receive(:resolve_virtual_package_name).with("libmysqlclient15-dev").and_return("libmysqlclient-dev")
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "purge", "libmysqlclient-dev",
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
:timeout => @timeout
@@ -486,7 +486,7 @@ mpg123 1.12.1-0ubuntu1
describe "when installing multiple packages" do
it "can install a virtual package followed by a non-virtual package" do
# https://github.com/chef/chef/issues/2914
- expect(@provider).to receive(:shell_out!).with(
+ 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
@@ -499,8 +499,8 @@ mpg123 1.12.1-0ubuntu1
it "should run dpkg to compare versions if an existing version is installed" do
allow(@provider).to receive(:get_current_versions).and_return("1.4.0")
allow(@new_resource).to receive(:allow_downgrade).and_return(false)
- expect(@provider).to receive(:shell_out_compact).with(
- "dpkg", "--compare-versions", "1.4.0", "gt", "0.8.12-7"
+ expect(@provider).to receive(:shell_out_compacted).with(
+ "dpkg", "--compare-versions", "1.4.0", "gt", "0.8.12-7", timeout: 900
).and_return(double(error?: false))
@provider.run_action(:upgrade)
end
@@ -509,7 +509,7 @@ mpg123 1.12.1-0ubuntu1
allow(@provider).to receive(:get_current_versions).and_return("0.4.0")
allow(@new_resource).to receive(:allow_downgrade).and_return(false)
expect(@provider).to receive(:version_compare).and_return(-1)
- expect(@provider).to receive(:shell_out!).with(
+ 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
@@ -521,7 +521,7 @@ mpg123 1.12.1-0ubuntu1
allow(@provider).to receive(:get_current_versions).and_return(nil)
allow(@new_resource).to receive(:allow_downgrade).and_return(false)
expect(@provider).not_to receive(:version_compare)
- expect(@provider).to receive(:shell_out!).with(
+ 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
diff --git a/spec/unit/provider/package/bff_spec.rb b/spec/unit/provider/package/bff_spec.rb
index abe1d4155c..df407914d3 100644
--- a/spec/unit/provider/package/bff_spec.rb
+++ b/spec/unit/provider/package/bff_spec.rb
@@ -43,22 +43,22 @@ describe Chef::Provider::Package::Bff do
it "should create a current resource with the name of new_resource" do
status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
- expect(@provider).to receive(:shell_out).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
- expect(@provider).to receive(:shell_out).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
+ 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
expect(@provider.current_resource.name).to eq("samba.base")
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)
- expect(@provider).to receive(:shell_out).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
- expect(@provider).to receive(:shell_out).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
+ 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
expect(@provider.current_resource.package_name).to eq("samba.base")
end
it "should raise an exception if a source is supplied but not found" do
- allow(@provider).to receive(:shell_out).and_return(@empty_status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@empty_status)
allow(::File).to receive(:exist?).with(@new_resource.source).and_return(false)
@provider.load_current_resource
@provider.define_resource_requirements
@@ -67,8 +67,8 @@ describe Chef::Provider::Package::Bff do
it "should get the source package version from lslpp if provided" do
status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
- expect(@provider).to receive(:shell_out).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
- expect(@provider).to receive(:shell_out).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
+ 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
expect(@provider.current_resource.package_name).to eq("samba.base")
@@ -79,8 +79,8 @@ describe Chef::Provider::Package::Bff 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)
- expect(@provider).to receive(:shell_out).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
- expect(@provider).to receive(:shell_out).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
+ 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})
@provider.load_current_resource
@@ -92,8 +92,8 @@ describe Chef::Provider::Package::Bff do
status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
@stdout = StringIO.new(@bffinfo)
@stdin, @stderr = StringIO.new, StringIO.new
- expect(@provider).to receive(:shell_out).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
- expect(@provider).to receive(:shell_out).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(status)
+ 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(status)
@provider.load_current_resource
expect(@provider.current_resource.version).to eq("3.3.12.0")
end
@@ -102,20 +102,20 @@ describe Chef::Provider::Package::Bff do
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).and_return(status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
it "should raise an exception if installp/lslpp fails to run" do
status = double(:stdout => "", :exitstatus => -1, :format_for_exception => "")
- allow(@provider).to receive(:shell_out).and_return(status)
+ 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)
- expect(@provider).to receive(:shell_out).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
- expect(@provider).to receive(:shell_out).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
+ 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
expect(@provider.current_resource.version).to be_nil
end
@@ -124,7 +124,7 @@ describe Chef::Provider::Package::Bff 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)
- expect(@provider).to receive(:shell_out).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
+ 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
end
@@ -132,19 +132,19 @@ describe Chef::Provider::Package::Bff do
describe "candidate_version" do
it "should return the candidate_version variable if already setup" do
@provider.candidate_version = "3.3.12.0"
- expect(@provider).not_to receive(:shell_out)
+ expect(@provider).not_to receive(:shell_out_compacted)
@provider.candidate_version
end
it "should lookup the candidate_version if the variable is not already set" do
status = double(:stdout => "", :exitstatus => 0)
- expect(@provider).to receive(:shell_out).and_return(status)
+ 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 => "")
- allow(@provider).to receive(:shell_out).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
end
@@ -152,7 +152,7 @@ describe Chef::Provider::Package::Bff do
describe "install and upgrade" do
it "should run installp -aYF -d with the package source to install" do
- expect(@provider).to receive(:shell_out!).with("installp", "-aYF", "-d", "/tmp/samba.base", "samba.base", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("installp", "-aYF", "-d", "/tmp/samba.base", "samba.base", timeout: 900)
@provider.install_package("samba.base", "3.3.12.0")
end
@@ -160,26 +160,26 @@ describe Chef::Provider::Package::Bff do
@new_resource = Chef::Resource::Package.new("/tmp/samba.base")
@provider = Chef::Provider::Package::Bff.new(@new_resource, @run_context)
expect(@new_resource.source).to eq("/tmp/samba.base")
- expect(@provider).to receive(:shell_out!).with("installp", "-aYF", "-d", "/tmp/samba.base", "/tmp/samba.base", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("installp", "-aYF", "-d", "/tmp/samba.base", "/tmp/samba.base", timeout: 900)
@provider.install_package("/tmp/samba.base", "3.3.12.0")
end
it "should run installp with -eLogfile option." do
@new_resource.options("-e/tmp/installp.log")
- expect(@provider).to receive(:shell_out!).with("installp", "-aYF", "-e/tmp/installp.log", "-d", "/tmp/samba.base", "samba.base", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("installp", "-aYF", "-e/tmp/installp.log", "-d", "/tmp/samba.base", "samba.base", timeout: 900)
@provider.install_package("samba.base", "3.3.12.0")
end
end
describe "remove" do
it "should run installp -u samba.base to remove the package" do
- expect(@provider).to receive(:shell_out!).with("installp", "-u", "samba.base", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("installp", "-u", "samba.base", timeout: 900)
@provider.remove_package("samba.base", "3.3.12.0")
end
it "should run installp -u -e/tmp/installp.log with options -e/tmp/installp.log" do
@new_resource.options("-e/tmp/installp.log")
- expect(@provider).to receive(:shell_out!).with("installp", "-u", "-e/tmp/installp.log", "samba.base", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("installp", "-u", "-e/tmp/installp.log", "samba.base", timeout: 900)
@provider.remove_package("samba.base", "3.3.12.0")
end
diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb
index ff9dc3ca6b..a0a73c445a 100644
--- a/spec/unit/provider/package/chocolatey_spec.rb
+++ b/spec/unit/provider/package/chocolatey_spec.rb
@@ -46,7 +46,7 @@ ConEmu|15.10.25.0
allow(provider).to receive(:choco_install_path).and_return(choco_install_path)
allow(provider).to receive(:choco_exe).and_return(choco_exe)
local_list_obj = double(:stdout => local_list_stdout)
- allow(provider).to receive(:shell_out!).with("#{choco_exe} list -l -r", { :returns => [0], :timeout => timeout }).and_return(local_list_obj)
+ 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!).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!).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!).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!).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!).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!).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!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
- expect(provider).to receive(:shell_out!).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!).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!).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!).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!).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!).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!).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!).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!).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!).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!).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!).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!).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!).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 7c7c9c605e..c99e91dd46 100644
--- a/spec/unit/provider/package/dpkg_spec.rb
+++ b/spec/unit/provider/package/dpkg_spec.rb
@@ -51,8 +51,8 @@ Conflicts: wget-ssl
end
before(:each) do
- allow(provider).to receive(:shell_out!).with("dpkg-deb", "-W", source, timeout: 900).and_return(dpkg_deb_status)
- allow(provider).to receive(:shell_out!).with("dpkg", "-s", package, timeout: 900, returns: [0, 1]).and_return(double(stdout: "", exitstatus: 1))
+ allow(provider).to receive(:shell_out_compacted!).with("dpkg-deb", "-W", source, timeout: 900).and_return(dpkg_deb_status)
+ allow(provider).to receive(:shell_out_compacted!).with("dpkg", "-s", package, timeout: 900, returns: [0, 1]).and_return(double(stdout: "", exitstatus: 1))
allow(::File).to receive(:exist?).with(source).and_return(true)
end
@@ -113,7 +113,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)
- expect(provider).to receive(:shell_out!).with("dpkg-deb", "-W", source, timeout: 900).and_return(status)
+ 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"])
expect(provider.candidate_version).to eq([version])
@@ -165,7 +165,7 @@ Conflicts: wget-ssl
end
it "should return the current version installed if found by dpkg" do
- allow(provider).to receive(:shell_out!).with("dpkg", "-s", package, timeout: 900, returns: [0, 1]).and_return(dpkg_s_status)
+ allow(provider).to receive(:shell_out_compacted!).with("dpkg", "-s", package, timeout: 900, returns: [0, 1]).and_return(dpkg_s_status)
provider.load_current_resource
expect(provider.current_resource.version).to eq(["1.11.4-1ubuntu1"])
end
@@ -178,7 +178,7 @@ Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
EOF
)
- expect(provider).to receive(:shell_out!).with("dpkg", "-s", package, returns: [0, 1], timeout: 900).and_return(dpkg_s_status)
+ expect(provider).to receive(:shell_out_compacted!).with("dpkg", "-s", package, returns: [0, 1], timeout: 900).and_return(dpkg_s_status)
provider.load_current_resource
expect(provider.current_resource.version).to eq([nil])
end
@@ -192,7 +192,7 @@ Priority: extra
Section: ruby
EOF
)
- expect(provider).to receive(:shell_out!).with("dpkg", "-s", package, returns: [0, 1], timeout: 900).and_return(dpkg_s_status)
+ expect(provider).to receive(:shell_out_compacted!).with("dpkg", "-s", package, returns: [0, 1], timeout: 900).and_return(dpkg_s_status)
provider.load_current_resource
expect(provider.current_resource.version).to eq([nil])
end
@@ -201,13 +201,13 @@ Section: ruby
dpkg_s_status = double(
exitstatus: 3, stderr: "i am very, very angry with you. i'm very, very cross. go to your room.", stdout: ""
)
- expect(provider).to receive(:shell_out!).with("dpkg", "-s", package, returns: [0, 1], timeout: 900).and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ expect(provider).to receive(:shell_out_compacted!).with("dpkg", "-s", package, returns: [0, 1], timeout: 900).and_raise(Mixlib::ShellOut::ShellCommandFailed)
expect { provider.load_current_resource }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
end
it "should raise an exception if dpkg-deb -W fails to run" do
status = double(:stdout => "", :exitstatus => -1)
- expect(provider).to receive(:shell_out_compact!).with("dpkg-deb", "-W", "/tmp/wget_1.11.4-1ubuntu1_amd64.deb").and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ 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
end
diff --git a/spec/unit/provider/package/freebsd/pkg_spec.rb b/spec/unit/provider/package/freebsd/pkg_spec.rb
index 4b3a94aa33..259bd7a4c4 100644
--- a/spec/unit/provider/package/freebsd/pkg_spec.rb
+++ b/spec/unit/provider/package/freebsd/pkg_spec.rb
@@ -79,21 +79,21 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
it "should return the version number when it is installed" do
pkg_info = OpenStruct.new(:stdout => "zsh-4.3.6_7")
- expect(@provider).to receive(:shell_out!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
+ expect(@provider).to receive(:shell_out_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 => "")
- expect(@provider).to receive(:shell_out!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
+ expect(@provider).to receive(:shell_out_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")
- expect(@provider).to receive(:shell_out!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
+ 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")
end
@@ -102,7 +102,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
it "should return the ports candidate version when given a valid port path" do
allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh")
make_v = OpenStruct.new(:stdout => "4.3.6\n", :exitstatus => 0)
- expect(@provider).to receive(:shell_out!).with("make", "-V", "PORTVERSION", { cwd: "/usr/ports/shells/zsh", returns: [0, 1], env: nil, timeout: 900 }).and_return(make_v)
+ expect(@provider).to receive(:shell_out_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
@@ -110,7 +110,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true)
allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh")
make_v = OpenStruct.new(:stdout => "zsh-4.3.6_7\n", :exitstatus => 0)
- expect(@provider).to receive(:shell_out!).with("make", "-V", "PKGNAME", { cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900 }).and_return(make_v)
+ expect(@provider).to receive(:shell_out_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")
end
@@ -127,7 +127,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
end
it "should run pkg_add -r with the package name" do
- expect(@provider).to receive(:shell_out!).with("pkg_add", "-r", "zsh", env: nil, timeout: 900).and_return(@cmd_result)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "zsh", env: nil, timeout: 900).and_return(@cmd_result)
@provider.install_package("zsh", "4.3.6_7")
end
end
@@ -142,7 +142,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
it "should figure out the port path from the package_name using whereis" do
whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh")
- expect(@provider).to receive(:shell_out!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
+ 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
@@ -178,7 +178,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
end
it "should run pkg_add -r with the package name" do
- expect(@provider).to receive(:shell_out!).with("pkg_add", "-r", "ruby18-iconv", env: nil, timeout: 900).and_return(@install_result)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "ruby18-iconv", env: nil, timeout: 900).and_return(@install_result)
@provider.install_package("ruby-iconv", "1.0")
end
end
@@ -193,7 +193,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
end
it "should run pkg_delete with the package name and version" do
- expect(@provider).to receive(:shell_out!).with("pkg_delete", "zsh-4.3.6_7", env: nil, timeout: 900).and_return(@pkg_delete)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg_delete", "zsh-4.3.6_7", env: nil, timeout: 900).and_return(@pkg_delete)
@provider.remove_package("zsh", "4.3.6_7")
end
end
@@ -213,14 +213,14 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
it "should return the port path for a valid port name" do
whereis = OpenStruct.new(:stdout => "bonnie++: /usr/ports/benchmarks/bonnie++")
- expect(@provider).to receive(:shell_out!).with("whereis", "-s", "bonnie++", env: nil, timeout: 900).and_return(whereis)
+ 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")
- expect(@provider).to receive(:shell_out!).with("pkg_info", "-E", "bonnie++*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
+ expect(@provider).to receive(:shell_out_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")
end
@@ -253,7 +253,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
allow(@provider).to receive(:latest_link_name).and_return("perl")
cmd = OpenStruct.new(:status => true)
- expect(@provider).to receive(:shell_out!).with("pkg_add", "-r", "perl", env: nil, timeout: 900).and_return(cmd)
+ 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
@@ -267,7 +267,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
allow(@provider).to receive(:latest_link_name).and_return("mysql50-server")
cmd = OpenStruct.new(:status => true)
- expect(@provider).to receive(:shell_out!).with("pkg_add", "-r", "mysql50-server", env: nil, timeout: 900).and_return(cmd)
+ 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
end
diff --git a/spec/unit/provider/package/freebsd/pkgng_spec.rb b/spec/unit/provider/package/freebsd/pkgng_spec.rb
index 098052a057..2fdcb87758 100644
--- a/spec/unit/provider/package/freebsd/pkgng_spec.rb
+++ b/spec/unit/provider/package/freebsd/pkgng_spec.rb
@@ -67,7 +67,7 @@ describe Chef::Provider::Package::Freebsd::Port do
end
it "should query pkg database" do
- expect(@provider).to receive(:shell_out!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
expect(@provider.current_installed_version).to eq("3.1.7")
end
end
@@ -75,14 +75,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)
- expect(@provider).to receive(:shell_out!).with("pkg", "rquery", "%v", "zsh", env: nil, timeout: 900).and_return(pkg_query)
+ 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)
- expect(@provider).to receive(:shell_out!).with("pkg", "rquery", "-r", "LocalMirror", "%v", "zsh", env: nil, timeout: 900).and_return(pkg_query)
+ 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
@@ -99,7 +99,7 @@ describe Chef::Provider::Package::Freebsd::Port do
it "should handle package source from file" do
@provider.new_resource.source("/nas/pkg/repo/zsh-5.0.1.txz")
- expect(@provider).to receive(:shell_out!).
+ expect(@provider).to receive(:shell_out_compacted!).
with("pkg", "add", "/nas/pkg/repo/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900).
and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
@@ -107,21 +107,21 @@ describe Chef::Provider::Package::Freebsd::Port do
it "should handle package source over ftp or http" do
@provider.new_resource.source("http://repo.example.com/zsh-5.0.1.txz")
- expect(@provider).to receive(:shell_out!).
+ expect(@provider).to receive(:shell_out_compacted!).
with("pkg", "add", "http://repo.example.com/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900).
and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
end
it "should handle a package name" do
- expect(@provider).to receive(:shell_out!).
+ expect(@provider).to receive(:shell_out_compacted!).
with("pkg", "install", "-y", "zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
end
it "should handle a package name with a specified repo" do
@provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration.
- expect(@provider).to receive(:shell_out!).
+ expect(@provider).to receive(:shell_out_compacted!).
with("pkg", "install", "-y", "-r", "LocalMirror", "zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
end
@@ -133,14 +133,14 @@ describe Chef::Provider::Package::Freebsd::Port do
end
it "should call pkg delete" do
- expect(@provider).to receive(:shell_out!).
+ expect(@provider).to receive(:shell_out_compacted!).
with("pkg", "delete", "-y", "zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result)
@provider.remove_package("zsh", "5.0.1")
end
it "should not include repo option in pkg delete" do
@provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration.
- expect(@provider).to receive(:shell_out!).
+ expect(@provider).to receive(:shell_out_compacted!).
with("pkg", "delete", "-y", "zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result)
@provider.remove_package("zsh", "5.0.1")
end
diff --git a/spec/unit/provider/package/freebsd/port_spec.rb b/spec/unit/provider/package/freebsd/port_spec.rb
index 5c87483fa6..26a960dedc 100644
--- a/spec/unit/provider/package/freebsd/port_spec.rb
+++ b/spec/unit/provider/package/freebsd/port_spec.rb
@@ -68,7 +68,7 @@ describe Chef::Provider::Package::Freebsd::Port do
it "should check 'pkg_info' if system uses pkg_* tools" do
allow(@new_resource).to receive(:supports_pkgng?)
expect(@new_resource).to receive(:supports_pkgng?).and_return(false)
- expect(@provider).to receive(:shell_out!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(@pkg_info)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(@pkg_info)
expect(@provider.current_installed_version).to eq("3.1.7")
end
@@ -76,8 +76,8 @@ describe Chef::Provider::Package::Freebsd::Port do
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!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled)
- expect(@provider).to receive(:shell_out!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
+ expect(@new_resource).to receive(:shell_out_compacted!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
expect(@provider.current_installed_version).to eq("3.1.7")
end
end
@@ -85,7 +85,7 @@ describe Chef::Provider::Package::Freebsd::Port do
it "should check 'pkg info' if the freebsd version is greater than or equal to 1000017" do
freebsd_version = 1000017
@node.automatic_attrs[:os_version] = freebsd_version
- expect(@provider).to receive(:shell_out!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
expect(@provider.current_installed_version).to eq("3.1.7")
end
end
@@ -98,7 +98,7 @@ describe Chef::Provider::Package::Freebsd::Port do
it "should return candidate version if port exists" do
allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true)
allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh")
- expect(@provider).to receive(:shell_out!).with("make", "-V", "PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900).
+ expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900).
and_return(@port_version)
expect(@provider.candidate_version).to eq("5.0.5")
end
@@ -122,13 +122,13 @@ describe Chef::Provider::Package::Freebsd::Port do
it "should query system for path given just a name" do
whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh\n")
- expect(@provider).to receive(:shell_out!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
+ 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")
- expect(@provider).to receive(:shell_out!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
+ 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
end
@@ -140,7 +140,7 @@ describe Chef::Provider::Package::Freebsd::Port do
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!).
+ expect(@provider).to receive(:shell_out_compacted!).
with("make", "-DBATCH", "install", "clean", :timeout => 1800, :cwd => "/usr/ports/shells/zsh", :env => nil).
and_return(@install_result)
@provider.install_package("zsh", "5.0.5")
@@ -154,7 +154,7 @@ describe Chef::Provider::Package::Freebsd::Port do
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!).
+ expect(@provider).to receive(:shell_out_compacted!).
with("make", "deinstall", :timeout => 300, :cwd => "/usr/ports/shells/zsh", :env => nil).
and_return(@install_result)
@provider.remove_package("zsh", "5.0.5")
diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb
index 45111601fa..eac0fd90f3 100644
--- a/spec/unit/provider/package/ips_spec.rb
+++ b/spec/unit/provider/package/ips_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Bryan McLellan <btm@chef.io>
-# Copyright:: Copyright 2012-2017, Chef Software Inc.
+# Copyright:: Copyright 2012-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -64,28 +64,28 @@ PKG_STATUS
context "when loading current resource" do
it "should create a current resource with the name of the new_resource" do
- expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
- expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
+ expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
expect(Chef::Resource::IpsPackage).to receive(:new).and_return(@current_resource)
@provider.load_current_resource
end
it "should set the current resources package name to the new resources package name" do
- expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
- expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
+ expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
@provider.load_current_resource
expect(@current_resource.package_name).to eq(@new_resource.package_name)
end
it "should run pkg info with the package name" do
- expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
- expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
+ expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
@provider.load_current_resource
end
it "should set the installed version to nil on the current resource if package state is not installed" do
- expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
- expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
+ expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
@provider.load_current_resource
expect(@current_resource.version).to be_nil
end
@@ -107,33 +107,33 @@ Packaging Date: October 19, 2011 09:14:50 AM
Size: 8.07 MB
FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z
INSTALLED
- expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local)
- expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
+ expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
@provider.load_current_resource
expect(@current_resource.version).to eq("2.0.17")
end
it "should return the current resource" do
- expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
- expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
+ expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
expect(@provider.load_current_resource).to eql(@current_resource)
end
end
context "when installing a package" do
it "should run pkg install with the package name and version" do
- expect(@provider).to receive(:shell_out!).with("pkg", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900)
@provider.install_package("crypto/gnupg", "2.0.17")
end
it "should run pkg install with the package name and version and options if specified" do
- expect(@provider).to receive(:shell_out!).with("pkg", "--no-refresh", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "--no-refresh", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900)
@new_resource.options "--no-refresh"
@provider.install_package("crypto/gnupg", "2.0.17")
end
it "raises an error if package fails to install" do
- expect(@provider).to receive(:shell_out!).with("pkg", "--no-refresh", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900).and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "--no-refresh", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900).and_raise(Mixlib::ShellOut::ShellCommandFailed)
@new_resource.options("--no-refresh")
expect { @provider.install_package("crypto/gnupg", "2.0.17") }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
end
@@ -152,8 +152,8 @@ Packaging Date: April 1, 2012 05:55:52 PM
Size: 2.57 MB
FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z
PKG_STATUS
- expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
- expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote)
+ expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote)
@provider.load_current_resource
expect(@current_resource.version).to be_nil
expect(@provider.candidate_version).to eql("1.8.4.1")
@@ -193,8 +193,8 @@ Packaging Date: October 19, 2011 09:14:50 AM
FMRI: pkg://solaris/crypto/gnupg@2.0.18,5.11-0.175.0.0.0.2.537:20111019T091450Z
REMOTE
- expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local)
- expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote)
+ expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote)
expect(@provider).to receive(:install_package).exactly(0).times
@provider.run_action(:install)
end
@@ -205,7 +205,7 @@ REMOTE
end
it "should run pkg install with the --accept flag" do
- expect(@provider).to receive(:shell_out).with("pkg", "install", "-q", "--accept", "crypto/gnupg@2.0.17", timeout: 900).and_return(local_output)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "install", "-q", "--accept", "crypto/gnupg@2.0.17", timeout: 900).and_return(local_output)
@provider.install_package("crypto/gnupg", "2.0.17")
end
end
@@ -213,19 +213,19 @@ REMOTE
context "when upgrading a package" do
it "should run pkg install with the package name and version" do
- expect(@provider).to receive(:shell_out).with("pkg", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900).and_return(local_output)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900).and_return(local_output)
@provider.upgrade_package("crypto/gnupg", "2.0.17")
end
end
context "when uninstalling a package" do
it "should run pkg uninstall with the package name and version" do
- expect(@provider).to receive(:shell_out!).with("pkg", "uninstall", "-q", "crypto/gnupg@2.0.17", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "uninstall", "-q", "crypto/gnupg@2.0.17", timeout: 900)
@provider.remove_package("crypto/gnupg", "2.0.17")
end
it "should run pkg uninstall with the package name and version and options if specified" do
- expect(@provider).to receive(:shell_out!).with("pkg", "--no-refresh", "uninstall", "-q", "crypto/gnupg@2.0.17", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "--no-refresh", "uninstall", "-q", "crypto/gnupg@2.0.17", timeout: 900)
@new_resource.options "--no-refresh"
@provider.remove_package("crypto/gnupg", "2.0.17")
end
diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb
index 4961f4c467..04e0a9177e 100644
--- a/spec/unit/provider/package/macports_spec.rb
+++ b/spec/unit/provider/package/macports_spec.rb
@@ -76,13 +76,13 @@ The following ports are currently installed:
EOF
status = double(:stdout => stdout, :exitstatus => 0)
- expect(@provider).to receive(:shell_out).and_return(status)
+ 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)
- expect(@provider).to receive(:shell_out).and_return(status)
+ expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.current_installed_version).to be_nil
end
end
@@ -90,13 +90,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)
- expect(@provider).to receive(:shell_out).and_return(status)
+ 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)
- expect(@provider).to receive(:shell_out).and_return(status)
+ expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.macports_candidate_version).to be_nil
end
end
@@ -105,7 +105,7 @@ EOF
it "should run the port install command with the correct version" do
expect(@current_resource).to receive(:version).and_return("4.1.6")
@provider.current_resource = @current_resource
- expect(@provider).to receive(:shell_out!).with("port", "install", "zsh", "@4.2.7", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("port", "install", "zsh", "@4.2.7", timeout: 900)
@provider.install_package("zsh", "4.2.7")
end
@@ -113,7 +113,7 @@ EOF
it "should not do anything if a package already exists with the same version" do
expect(@current_resource).to receive(:version).and_return("4.2.7")
@provider.current_resource = @current_resource
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
@provider.install_package("zsh", "4.2.7")
end
@@ -122,7 +122,7 @@ EOF
expect(@current_resource).to receive(:version).and_return("4.1.6")
@provider.current_resource = @current_resource
@new_resource.options("-f")
- expect(@provider).to receive(:shell_out!).with("port", "-f", "install", "zsh", "@4.2.7", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("port", "-f", "install", "zsh", "@4.2.7", timeout: 900)
@provider.install_package("zsh", "4.2.7")
end
@@ -130,36 +130,36 @@ EOF
describe "purge_package" do
it "should run the port uninstall command with the correct version" do
- expect(@provider).to receive(:shell_out!).with("port", "uninstall", "zsh", "@4.2.7", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("port", "uninstall", "zsh", "@4.2.7", timeout: 900)
@provider.purge_package("zsh", "4.2.7")
end
it "should purge the currently active version if no explicit version is passed in" do
- expect(@provider).to receive(:shell_out!).with("port", "uninstall", "zsh", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("port", "uninstall", "zsh", timeout: 900)
@provider.purge_package("zsh", nil)
end
it "should add options to the port command when specified" do
@new_resource.options("-f")
- expect(@provider).to receive(:shell_out!).with("port", "-f", "uninstall", "zsh", "@4.2.7", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("port", "-f", "uninstall", "zsh", "@4.2.7", timeout: 900)
@provider.purge_package("zsh", "4.2.7")
end
end
describe "remove_package" do
it "should run the port deactivate command with the correct version" do
- expect(@provider).to receive(:shell_out!).with("port", "deactivate", "zsh", "@4.2.7", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("port", "deactivate", "zsh", "@4.2.7", timeout: 900)
@provider.remove_package("zsh", "4.2.7")
end
it "should remove the currently active version if no explicit version is passed in" do
- expect(@provider).to receive(:shell_out!).with("port", "deactivate", "zsh", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("port", "deactivate", "zsh", timeout: 900)
@provider.remove_package("zsh", nil)
end
it "should add options to the port command when specified" do
@new_resource.options("-f")
- expect(@provider).to receive(:shell_out!).with("port", "-f", "deactivate", "zsh", "@4.2.7", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("port", "-f", "deactivate", "zsh", "@4.2.7", timeout: 900)
@provider.remove_package("zsh", "4.2.7")
end
end
@@ -169,7 +169,7 @@ EOF
expect(@current_resource).to receive(:version).at_least(:once).and_return("4.1.6")
@provider.current_resource = @current_resource
- expect(@provider).to receive(:shell_out!).with("port", "upgrade", "zsh", "@4.2.7", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("port", "upgrade", "zsh", "@4.2.7", timeout: 900)
@provider.upgrade_package("zsh", "4.2.7")
end
@@ -177,7 +177,7 @@ EOF
it "should not run the port upgrade command if the version is already installed" do
expect(@current_resource).to receive(:version).at_least(:once).and_return("4.2.7")
@provider.current_resource = @current_resource
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
@provider.upgrade_package("zsh", "4.2.7")
end
@@ -195,7 +195,7 @@ EOF
expect(@current_resource).to receive(:version).at_least(:once).and_return("4.1.6")
@provider.current_resource = @current_resource
- expect(@provider).to receive(:shell_out!).with("port", "-f", "upgrade", "zsh", "@4.2.7", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("port", "-f", "upgrade", "zsh", "@4.2.7", timeout: 900)
@provider.upgrade_package("zsh", "4.2.7")
end
diff --git a/spec/unit/provider/package/msu_spec.rb b/spec/unit/provider/package/msu_spec.rb
index b9091d757a..de805fcb39 100644
--- a/spec/unit/provider/package/msu_spec.rb
+++ b/spec/unit/provider/package/msu_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Nimisha Sharad (<nimisha.sharad@msystechnologies.com>)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -243,7 +243,7 @@ The operation completed successfully.
describe "#extract_msu_contents" do
it "extracts the msu contents by using mixlib shellout" do
- expect(provider).to receive(:shell_out_with_timeout!).with("#{ENV['SYSTEMROOT']}\\system32\\expand.exe -f:* msu_file destination")
+ expect(provider).to receive(:shell_out!).with("#{ENV['SYSTEMROOT']}\\system32\\expand.exe -f:* msu_file destination")
provider.extract_msu_contents("msu_file", "destination")
end
end
diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb
index 20eb85dfcf..07950acf6e 100644
--- a/spec/unit/provider/package/openbsd_spec.rb
+++ b/spec/unit/provider/package/openbsd_spec.rb
@@ -45,16 +45,16 @@ describe Chef::Provider::Package::Openbsd do
context "when not already installed" do
before do
- allow(provider).to receive(:shell_out!).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
context "when source is not provided" do
it "should run the installation command" do
- expect(provider).to receive(:shell_out!).with("pkg_info", "-I", name, anything()).and_return(
+ expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return(
instance_double("shellout", :stdout => "#{name}-#{version}\n"))
- expect(provider).to receive(:shell_out!).with(
+ 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 }
@@ -69,7 +69,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!).with("pkg_info", "-I", name, anything()).and_return(
+ 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"))
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /multiple matching candidates/)
end
@@ -83,10 +83,10 @@ 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!).with("pkg_info", "-e", "#{package_name}->0", anything()).and_return(instance_double("shellout", :stdout => ""))
- expect(provider).to receive(:shell_out!).with("pkg_info", "-I", name, anything()).and_return(
+ 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"))
- expect(provider).to receive(:shell_out!).with(
+ 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 }
@@ -98,11 +98,11 @@ 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!).with("pkg_info", "-I", "#{name}-#{version}-#{flavor_b}", anything()).and_return(
+ 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"))
new_resource.version("#{version}-#{flavor_b}")
- expect(provider).to receive(:shell_out!).with(
+ 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 }
@@ -122,7 +122,7 @@ describe Chef::Provider::Package::Openbsd do
@provider.current_resource = @current_resource
end
it "should run the command to delete the installed package" do
- expect(@provider).to receive(:shell_out!).with(
+ expect(@provider).to receive(:shell_out_compacted!).with(
"pkg_delete", @name, env: nil, timeout: 900
) { OpenStruct.new :status => true }
@provider.remove_package(@name, nil)
diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb
index ceae73dbd1..d41df8c24b 100644
--- a/spec/unit/provider/package/pacman_spec.rb
+++ b/spec/unit/provider/package/pacman_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Provider::Package::Pacman do
@provider = Chef::Provider::Package::Pacman.new(@new_resource, @run_context)
allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource)
- allow(@provider).to receive(:shell_out).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@status)
@stdin = StringIO.new
@stdout = StringIO.new(<<-ERR)
error: package "nano" not found
@@ -51,17 +51,17 @@ ERR
end
it "should run pacman query with the package name" do
- expect(@provider).to receive(:shell_out).with("pacman", "-Qi", @new_resource.package_name, { timeout: 900 }).and_return(@status)
+ expect(@provider).to receive(:shell_out_compacted).with("pacman", "-Qi", @new_resource.package_name, { timeout: 900 }).and_return(@status)
@provider.load_current_resource
end
it "should read stdout on pacman" do
- allow(@provider).to receive(:shell_out).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@status)
@provider.load_current_resource
end
it "should set the installed version to nil on the current resource if pacman installed version not exists" do
- allow(@provider).to receive(:shell_out).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@status)
@provider.load_current_resource
end
@@ -89,14 +89,14 @@ Description : Pico editor clone with enhancements
PACMAN
status = double(:stdout => stdout, :exitstatus => 0)
- allow(@provider).to receive(:shell_out).and_return(status)
+ 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)
- allow(@provider).to receive(:shell_out).and_return(status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(status)
@provider.load_current_resource
expect(@provider.candidate_version).to eql("2.2.3-1")
end
@@ -123,7 +123,7 @@ PACMAN_CONF
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).and_return(status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(status)
@provider.load_current_resource
expect(@provider.candidate_version).to eql("1.2.3-4")
@@ -140,7 +140,7 @@ PACMAN_CONF
end
it "should raise an exception if pacman does not return a candidate version" do
- allow(@provider).to receive(:shell_out).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
end
@@ -151,12 +151,12 @@ PACMAN_CONF
describe Chef::Provider::Package::Pacman, "install_package" do
it "should run pacman install with the package name and version" do
- expect(@provider).to receive(:shell_out!).with("pacman", "--sync", "--noconfirm", "--noprogressbar", "nano", { timeout: 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("pacman", "--sync", "--noconfirm", "--noprogressbar", "nano", { timeout: 900 })
@provider.install_package("nano", "1.0")
end
it "should run pacman install with the package name and version and options if specified" do
- expect(@provider).to receive(:shell_out!).with("pacman", "--sync", "--noconfirm", "--noprogressbar", "--debug", "nano", { timeout: 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("pacman", "--sync", "--noconfirm", "--noprogressbar", "--debug", "nano", { timeout: 900 })
@new_resource.options("--debug")
@provider.install_package("nano", "1.0")
@@ -172,12 +172,12 @@ PACMAN_CONF
describe Chef::Provider::Package::Pacman, "remove_package" do
it "should run pacman remove with the package name" do
- expect(@provider).to receive(:shell_out!).with("pacman", "--remove", "--noconfirm", "--noprogressbar", "nano", { timeout: 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("pacman", "--remove", "--noconfirm", "--noprogressbar", "nano", { timeout: 900 })
@provider.remove_package("nano", "1.0")
end
it "should run pacman remove with the package name and options if specified" do
- expect(@provider).to receive(:shell_out!).with("pacman", "--remove", "--noconfirm", "--noprogressbar", "--debug", "nano", { timeout: 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("pacman", "--remove", "--noconfirm", "--noprogressbar", "--debug", "nano", { timeout: 900 })
@new_resource.options("--debug")
@provider.remove_package("nano", "1.0")
diff --git a/spec/unit/provider/package/paludis_spec.rb b/spec/unit/provider/package/paludis_spec.rb
index fe3f5f61d7..5481a33c0d 100644
--- a/spec/unit/provider/package/paludis_spec.rb
+++ b/spec/unit/provider/package/paludis_spec.rb
@@ -47,19 +47,19 @@ PKG_STATUS
context "when loading current resource" do
it "should create a current resource with the name of the new_resource" do
- expect(@provider).to receive(:shell_out!).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
expect(Chef::Resource::Package).to receive(:new).and_return(@current_resource)
@provider.load_current_resource
end
it "should set the current resources package name to the new resources package name" do
- expect(@provider).to receive(:shell_out!).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
expect(@current_resource).to receive(:package_name).with(@new_resource.package_name)
@provider.load_current_resource
end
it "should run pkg info with the package name" do
- expect(@provider).to receive(:shell_out!).with("cave", "-L", "warning", "print-ids", "-M", "none", "-m", @new_resource.package_name, "-f", "%c/%p %v %r\n", timeout: 900).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "print-ids", "-M", "none", "-m", @new_resource.package_name, "-f", "%c/%p %v %r\n", timeout: 900).and_return(@shell_out)
@provider.load_current_resource
end
@@ -72,26 +72,26 @@ user/ntp 0 accounts
user/ntp 0 installed-accounts
net/ntp 4.2.6_p5-r1 installed
INSTALLED
- expect(@provider).to receive(:shell_out!).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
@provider.load_current_resource
expect(@current_resource.version).to eq("4.2.6_p5-r1")
expect(@provider.candidate_version).to eql("4.2.6_p5-r2")
end
it "should return the current resource" do
- expect(@provider).to receive(:shell_out!).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
expect(@provider.load_current_resource).to eql(@current_resource)
end
end
context "when installing a package" do
it "should run pkg install with the package name and version" do
- expect(@provider).to receive(:shell_out!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 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!).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!).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
@@ -110,7 +110,7 @@ PKG_STATUS
sys-process/lsof 4.87 arbor
sys-process/lsof 4.87 x86_64
PKG_STATUS
- expect(@provider).to receive(:shell_out!).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
@provider.load_current_resource
expect(@current_resource.version).to be_nil
expect(@provider.candidate_version).to eql("4.87")
@@ -119,14 +119,14 @@ PKG_STATUS
context "when upgrading a package" do
it "should run pkg install with the package name and version" do
- expect(@provider).to receive(:shell_out!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 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
context "when uninstalling a package" do
it "should run pkg uninstall with the package name and version" do
- expect(@provider).to receive(:shell_out!).with("cave", "-L", "warning", "uninstall", "-x", "=net/ntp-4.2.6_p5-r2", timeout: 900)
+ expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "uninstall", "-x", "=net/ntp-4.2.6_p5-r2", timeout: 900)
@provider.remove_package("net/ntp", "4.2.6_p5-r2")
end
diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb
index 5e971ba7e8..7bf8e7f2e8 100644
--- a/spec/unit/provider/package/portage_spec.rb
+++ b/spec/unit/provider/package/portage_spec.rb
@@ -108,26 +108,26 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do
describe Chef::Provider::Package::Portage, "candidate_version" do
it "should return the candidate_version variable if already set" do
@provider.candidate_version = "1.0.0"
- expect(@provider).not_to receive(:shell_out)
+ expect(@provider).not_to receive(:shell_out_compacted)
@provider.candidate_version
end
it "should throw an exception if the exitstatus is not 0" do
status = double(:stdout => "", :stderr => "", :exitstatus => 1)
- allow(@provider).to receive(:shell_out).and_return(status)
+ 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)
- expect(@provider).to receive(:shell_out).and_return(status)
+ 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)
@provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context)
- expect(@provider).to receive(:shell_out).and_return(status)
+ expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.candidate_version).to eq("2.16.2")
end
@@ -141,24 +141,24 @@ Please use a more specific atom.
EOF
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).and_return(status)
+ expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
end
end
describe Chef::Provider::Package::Portage, "install_package" do
it "should install a normally versioned package using portage" do
- expect(@provider).to receive(:shell_out!).with("emerge", "-g", "--color", "n", "--nospinner", "--quiet", "=dev-util/git-1.0.0", timeout: 3600)
+ expect(@provider).to receive(:shell_out_compacted!).with("emerge", "-g", "--color", "n", "--nospinner", "--quiet", "=dev-util/git-1.0.0", timeout: 3600)
@provider.install_package("dev-util/git", "1.0.0")
end
it "should install a tilde versioned package using portage" do
- expect(@provider).to receive(:shell_out!).with("emerge", "-g", "--color", "n", "--nospinner", "--quiet", "~dev-util/git-1.0.0", timeout: 3600)
+ expect(@provider).to receive(:shell_out_compacted!).with("emerge", "-g", "--color", "n", "--nospinner", "--quiet", "~dev-util/git-1.0.0", timeout: 3600)
@provider.install_package("dev-util/git", "~1.0.0")
end
it "should add options to the emerge command when specified" do
- expect(@provider).to receive(:shell_out!).with("emerge", "-g", "--color", "n", "--nospinner", "--quiet", "--oneshot", "=dev-util/git-1.0.0", timeout: 3600)
+ expect(@provider).to receive(:shell_out_compacted!).with("emerge", "-g", "--color", "n", "--nospinner", "--quiet", "--oneshot", "=dev-util/git-1.0.0", timeout: 3600)
@new_resource.options "--oneshot"
@provider.install_package("dev-util/git", "1.0.0")
end
@@ -166,12 +166,12 @@ EOF
describe Chef::Provider::Package::Portage, "remove_package" do
it "should un-emerge the package with no version specified" do
- expect(@provider).to receive(:shell_out!).with("emerge", "--unmerge", "--color", "n", "--nospinner", "--quiet", "dev-util/git", timeout: 3600)
+ expect(@provider).to receive(:shell_out_compacted!).with("emerge", "--unmerge", "--color", "n", "--nospinner", "--quiet", "dev-util/git", timeout: 3600)
@provider.remove_package("dev-util/git", nil)
end
it "should un-emerge the package with a version specified" do
- expect(@provider).to receive(:shell_out!).with("emerge", "--unmerge", "--color", "n", "--nospinner", "--quiet", "=dev-util/git-1.0.0", timeout: 3600)
+ expect(@provider).to receive(:shell_out_compacted!).with("emerge", "--unmerge", "--color", "n", "--nospinner", "--quiet", "=dev-util/git-1.0.0", timeout: 3600)
@provider.remove_package("dev-util/git", "1.0.0")
end
end
diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb
index 3730878026..91d4ca69b4 100644
--- a/spec/unit/provider/package/rpm_spec.rb
+++ b/spec/unit/provider/package/rpm_spec.rb
@@ -44,8 +44,8 @@ describe Chef::Provider::Package::Rpm do
allow(::File).to receive(:exist?).with("PLEASE STUB File.exists? EXACTLY").and_return(true)
# Ensure all shell out usage is stubbed with exact arguments
- allow(provider).to receive(:shell_out!).with("PLEASE STUB YOUR SHELLOUT CALLS").and_return(nil)
- allow(provider).to receive(:shell_out).with("PLEASE STUB YOUR SHELLOUT CALLS").and_return(nil)
+ allow(provider).to receive(:shell_out_compacted!).with("PLEASE STUB YOUR SHELLOUT CALLS").and_return(nil)
+ allow(provider).to receive(:shell_out_compacted).with("PLEASE STUB YOUR SHELLOUT CALLS").and_return(nil)
end
describe "when the package source is not valid" do
@@ -85,11 +85,11 @@ describe Chef::Provider::Package::Rpm do
describe "when the package source is valid" do
before do
- expect(provider).to receive(:shell_out!).
+ expect(provider).to receive(:shell_out_compacted!).
with("rpm", "-qp", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_source, timeout: 900).
and_return(rpm_qp_status)
- expect(provider).to receive(:shell_out).
+ expect(provider).to receive(:shell_out_compacted).
with("rpm", "-q", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_name, timeout: 900).
and_return(rpm_q_status)
end
@@ -151,7 +151,7 @@ describe Chef::Provider::Package::Rpm do
context "when at the desired version already" do
it "does nothing when the correct version is installed" do
- expect(provider).to_not receive(:shell_out!).with("rpm", "-i", "/tmp/imagemagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to_not receive(:shell_out_compacted!).with("rpm", "-i", "/tmp/imagemagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_install
end
@@ -162,7 +162,7 @@ describe Chef::Provider::Package::Rpm do
let(:rpm_q_stdout) { "imagemagick-c++ 0.5.4.7-7.el6_5" }
it "runs rpm -u with the package source to upgrade" do
- expect(provider).to receive(:shell_out!).with("rpm", "-U", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("rpm", "-U", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_install
end
end
@@ -178,7 +178,7 @@ describe Chef::Provider::Package::Rpm do
let(:rpm_q_stdout) { "imagemagick-c++ 21.4-19.el6_5" }
it "should run rpm -u --oldpackage with the package source to downgrade" do
- expect(provider).to receive(:shell_out!).with("rpm", "-U", "--oldpackage", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("rpm", "-U", "--oldpackage", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_install
end
@@ -192,7 +192,7 @@ describe Chef::Provider::Package::Rpm do
context "when at the desired version already" do
it "does nothing when the correct version is installed" do
- expect(provider).to_not receive(:shell_out!).with("rpm", "-i", "/tmp/imagemagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to_not receive(:shell_out_compacted!).with("rpm", "-i", "/tmp/imagemagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_upgrade
end
@@ -203,7 +203,7 @@ describe Chef::Provider::Package::Rpm do
let(:rpm_q_stdout) { "imagemagick-c++ 0.5.4.7-7.el6_5" }
it "runs rpm -u with the package source to upgrade" do
- expect(provider).to receive(:shell_out!).with("rpm", "-U", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("rpm", "-U", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_upgrade
end
end
@@ -219,7 +219,7 @@ describe Chef::Provider::Package::Rpm do
let(:rpm_q_stdout) { "imagemagick-c++ 21.4-19.el6_5" }
it "should run rpm -u --oldpackage with the package source to downgrade" do
- expect(provider).to receive(:shell_out!).with("rpm", "-U", "--oldpackage", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("rpm", "-U", "--oldpackage", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_upgrade
end
@@ -231,7 +231,7 @@ describe Chef::Provider::Package::Rpm do
let(:action) { :remove }
it "should remove the package" do
- expect(provider).to receive(:shell_out!).with("rpm", "-e", "ImageMagick-c++-6.5.4.7-7.el6_5", timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("rpm", "-e", "ImageMagick-c++-6.5.4.7-7.el6_5", timeout: 900)
provider.action_remove
end
end
@@ -357,7 +357,7 @@ describe Chef::Provider::Package::Rpm do
describe "action install" do
it "installs the package" do
- expect(provider).to receive(:shell_out!).with("rpm", "-i", package_source, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("rpm", "-i", package_source, timeout: 900)
provider.action_install
end
@@ -365,7 +365,7 @@ describe Chef::Provider::Package::Rpm do
context "when custom resource options are given" do
it "installs with custom options specified in the resource" do
new_resource.options("--dbpath /var/lib/rpm")
- expect(provider).to receive(:shell_out!).with("rpm", "--dbpath", "/var/lib/rpm", "-i", package_source, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("rpm", "--dbpath", "/var/lib/rpm", "-i", package_source, timeout: 900)
provider.action_install
end
end
@@ -376,7 +376,7 @@ describe Chef::Provider::Package::Rpm do
let(:action) { :upgrade }
it "installs the package" do
- expect(provider).to receive(:shell_out!).with("rpm", "-i", package_source, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("rpm", "-i", package_source, timeout: 900)
provider.action_upgrade
end
@@ -387,7 +387,7 @@ describe Chef::Provider::Package::Rpm do
let(:action) { :remove }
it "should do nothing" do
- expect(provider).to_not receive(:shell_out!).with("rpm", "-e", "ImageMagick-c++-6.5.4.7-7.el6_5", timeout: 900)
+ expect(provider).to_not receive(:shell_out_compacted!).with("rpm", "-e", "ImageMagick-c++-6.5.4.7-7.el6_5", timeout: 900)
provider.action_remove
end
end
@@ -413,7 +413,7 @@ describe Chef::Provider::Package::Rpm do
it "should install from a path when the package is a path and the source is nil" do
expect(new_resource.source).to eq("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
provider.current_resource = current_resource
- expect(provider).to receive(:shell_out!).with("rpm", "-i", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("rpm", "-i", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.install_package("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", "6.5.4.7-7.el6_5")
end
@@ -421,7 +421,7 @@ describe Chef::Provider::Package::Rpm do
expect(new_resource.source).to eq("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
current_resource.version("21.4-19.el5")
provider.current_resource = current_resource
- expect(provider).to receive(:shell_out!).with("rpm", "-U", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("rpm", "-U", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.upgrade_package("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", "6.5.4.7-7.el6_5")
end
end
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index 28bd371539..3b1a13e49c 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -190,21 +190,21 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
it "determines the gem paths from shelling out to gem env" do
gem_env_output = ["/path/to/gems", "/another/path/to/gems"].join(File::PATH_SEPARATOR)
shell_out_result = OpenStruct.new(stdout: gem_env_output)
- expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env gempath").and_return(shell_out_result)
+ expect(@gem_env).to receive(:shell_out_compacted!).with("/usr/weird/bin/gem env gempath").and_return(shell_out_result)
expect(@gem_env.gem_paths).to eq(["/path/to/gems", "/another/path/to/gems"])
end
it "caches the gempaths by gem_binary" do
gem_env_output = ["/path/to/gems", "/another/path/to/gems"].join(File::PATH_SEPARATOR)
shell_out_result = OpenStruct.new(stdout: gem_env_output)
- expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env gempath").and_return(shell_out_result)
+ expect(@gem_env).to receive(:shell_out_compacted!).with("/usr/weird/bin/gem env gempath").and_return(shell_out_result)
expected = ["/path/to/gems", "/another/path/to/gems"]
expect(@gem_env.gem_paths).to eq(["/path/to/gems", "/another/path/to/gems"])
expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache["/usr/weird/bin/gem"]).to eq(expected)
end
it "uses the cached result for gem paths when available" do
- expect(@gem_env).not_to receive(:shell_out!)
+ expect(@gem_env).not_to receive(:shell_out_compacted!)
expected = ["/path/to/gems", "/another/path/to/gems"]
Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache["/usr/weird/bin/gem"] = expected
expect(@gem_env.gem_paths).to eq(["/path/to/gems", "/another/path/to/gems"])
@@ -280,7 +280,7 @@ RubyGems Environment:
- https://rubygems.org/
- http://gems.github.com/
JRUBY_GEM_ENV
- expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env").and_return(double("jruby_gem_env", stdout: gem_env_out))
+ expect(@gem_env).to receive(:shell_out_compacted!).with("/usr/weird/bin/gem env").and_return(double("jruby_gem_env", stdout: gem_env_out))
expected = ["ruby", Gem::Platform.new("universal-java-1.6")]
expect(@gem_env.gem_platforms).to eq(expected)
# it should also cache the result
@@ -288,7 +288,7 @@ RubyGems Environment:
end
it "uses the cached result for gem platforms if available" do
- expect(@gem_env).not_to receive(:shell_out!)
+ expect(@gem_env).not_to receive(:shell_out_compacted!)
expected = ["ruby", Gem::Platform.new("universal-java-1.6")]
Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"] = expected
expect(@gem_env.gem_platforms).to eq(expected)
@@ -322,7 +322,7 @@ RubyGems Environment:
- https://rubygems.org/
- http://gems.github.com/
RBX_GEM_ENV
- expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env").and_return(double("rbx_gem_env", stdout: gem_env_out))
+ expect(@gem_env).to receive(:shell_out_compacted!).with("/usr/weird/bin/gem env").and_return(double("rbx_gem_env", stdout: gem_env_out))
expect(@gem_env.gem_platforms).to eq(Gem.platforms)
expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"]).to eq(Gem.platforms)
end
@@ -684,7 +684,7 @@ describe Chef::Provider::Package::Rubygems do
it "installs the gem by shelling out when options are provided as a String" do
expected = "gem install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=https://www.rubygems.org #{options}"
- expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -697,7 +697,7 @@ describe Chef::Provider::Package::Rubygems do
Chef::Config[:rubygems_url] = "https://mirror1"
expect(provider.gem_env).to receive(:candidate_version_from_remote).with(gem_dep, Chef::Config[:rubygems_url]).and_return(version)
expected = "#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=https://mirror1"
- expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -709,7 +709,7 @@ describe Chef::Provider::Package::Rubygems do
it "installs the gem with rubygems.org as an added source" do
expected = "#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=#{source} --source=https://www.rubygems.org"
- expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -720,7 +720,7 @@ describe Chef::Provider::Package::Rubygems do
it "ignores the Chef::Config setting" do
Chef::Config[:rubygems_url] = "https://ignored"
expected = "#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=#{source}"
- expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -733,7 +733,7 @@ describe Chef::Provider::Package::Rubygems do
it "installs the gem with an array as an added source" do
expected = "#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=https://mirror1 --source=https://mirror2 --source=https://www.rubygems.org"
- expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -744,7 +744,7 @@ describe Chef::Provider::Package::Rubygems do
it "ignores the Chef::Config setting" do
Chef::Config[:rubygems_url] = "https://ignored"
expected = "#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=https://mirror1 --source=https://mirror2"
- expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -758,7 +758,7 @@ describe Chef::Provider::Package::Rubygems do
it "installs the gem" do
new_resource.clear_sources(true)
expected = "#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --clear-sources --source=#{source} --source=https://www.rubygems.org"
- expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -770,7 +770,7 @@ describe Chef::Provider::Package::Rubygems do
it "installs the gem by shelling out when options are provided but no version is given" do
expected = "gem install rspec-core -q --no-rdoc --no-ri -v \"#{candidate_version}\" --source=https://www.rubygems.org #{options}"
- expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -833,7 +833,7 @@ describe Chef::Provider::Package::Rubygems do
let(:gem_binary) { "/usr/weird/bin/gem" }
it "installs the gem by shelling out to gem install" do
- expect(provider).to receive(:shell_out!).with("#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=https://www.rubygems.org", env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=https://www.rubygems.org", env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -843,7 +843,7 @@ describe Chef::Provider::Package::Rubygems do
let(:target_version) { ">= 0" }
it "installs the gem by shelling out to gem install" do
- expect(provider).to receive(:shell_out!).with("#{gem_binary} install #{source} -q --no-rdoc --no-ri -v \"#{target_version}\"", env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("#{gem_binary} install #{source} -q --no-rdoc --no-ri -v \"#{target_version}\"", env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -855,7 +855,7 @@ describe Chef::Provider::Package::Rubygems do
it "installs the gem from file by shelling out to gem install when the package is a path and the source is nil" do
expect(new_resource.source).to eq(gem_name)
- expect(provider).to receive(:shell_out!).with("#{gem_binary} install #{gem_name} -q --no-rdoc --no-ri -v \"#{target_version}\"", env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("#{gem_binary} install #{gem_name} -q --no-rdoc --no-ri -v \"#{target_version}\"", env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -902,7 +902,7 @@ describe Chef::Provider::Package::Rubygems do
let(:options) { "-i /alt/install/location" }
it "uninstalls via the gem command" do
- expect(provider).to receive(:shell_out!).with("gem uninstall rspec -q -x -I -a #{options}", env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("gem uninstall rspec -q -x -I -a #{options}", env: nil, timeout: 900)
provider.action_remove
end
end
@@ -921,7 +921,7 @@ describe Chef::Provider::Package::Rubygems do
let(:gem_binary) { "/usr/weird/bin/gem" }
it "uninstalls via the gem command" do
- expect(provider).to receive(:shell_out!).with("#{gem_binary} uninstall rspec -q -x -I -a", env: nil, timeout: 900)
+ expect(provider).to receive(:shell_out_compacted!).with("#{gem_binary} uninstall rspec -q -x -I -a", env: nil, timeout: 900)
provider.action_remove
end
end
diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb
index 51bffa17b6..cb5e987a85 100644
--- a/spec/unit/provider/package/smartos_spec.rb
+++ b/spec/unit/provider/package/smartos_spec.rb
@@ -41,26 +41,26 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
describe "when loading current resource" do
it "should create a current resource with the name of the new_resource" do
- expect(@provider).to receive(:shell_out!).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
expect(Chef::Resource::Package).to receive(:new).and_return(@current_resource)
@provider.load_current_resource
end
it "should set the current resource package name" do
- expect(@provider).to receive(:shell_out!).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
expect(@current_resource).to receive(:package_name).with(@new_resource.package_name)
@provider.load_current_resource
end
it "should set the installed version if it is installed" do
- expect(@provider).to receive(:shell_out!).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
@provider.load_current_resource
expect(@current_resource.version).to eq("2.1.5nb2")
end
it "should set the installed version to nil if it's not installed" do
out = OpenStruct.new(:stdout => nil)
- expect(@provider).to receive(:shell_out!).and_return(out)
+ expect(@provider).to receive(:shell_out_compacted!).and_return(out)
@provider.load_current_resource
expect(@current_resource.version).to eq(nil)
end
@@ -70,7 +70,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
describe "candidate_version" do
it "should return the candidate_version variable if already setup" do
@provider.candidate_version = "2.1.1"
- expect(@provider).not_to receive(:shell_out!)
+ expect(@provider).not_to receive(:shell_out_compacted!)
@provider.candidate_version
end
@@ -80,7 +80,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
and_yield("something-varnish-1.1.1 something varnish like\n").
and_yield("varnish-2.3.4 actual varnish\n")
@shell_out = double("shell_out!", :stdout => search)
- expect(@provider).to receive(:shell_out!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_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
@@ -90,7 +90,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
and_yield("something-varnish-1.1.1;;something varnish like\n").
and_yield("varnish-2.3.4;;actual varnish\n")
@shell_out = double("shell_out!", :stdout => search)
- expect(@provider).to receive(:shell_out!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_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
@@ -99,8 +99,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
it "run pkgin and install the package" do
out = OpenStruct.new(:stdout => nil)
- expect(@provider).to receive(:shell_out!).with("/opt/local/sbin/pkg_info", "-E", "varnish*", { :env => nil, :returns => [0, 1], :timeout => 900 }).and_return(@shell_out)
- expect(@provider).to receive(:shell_out!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", { :env => nil, :timeout => 900 }).and_return(out)
+ expect(@provider).to receive(:shell_out_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 2fba2e3a08..57a0288f58 100644
--- a/spec/unit/provider/package/solaris_spec.rb
+++ b/spec/unit/provider/package/solaris_spec.rb
@@ -50,19 +50,19 @@ PKGINFO
end
it "should create a current resource with the name of new_resource" do
- allow(@provider).to receive(:shell_out).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@status)
@provider.load_current_resource
expect(@provider.current_resource.name).to eq("SUNWbash")
end
it "should set the current reource package name to the new resource package name" do
- allow(@provider).to receive(:shell_out).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@status)
@provider.load_current_resource
expect(@provider.current_resource.package_name).to eq("SUNWbash")
end
it "should raise an exception if a source is supplied but not found" do
- allow(@provider).to receive(:shell_out).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@status)
allow(::File).to receive(:exist?).and_return(false)
@provider.load_current_resource
@provider.define_resource_requirements
@@ -71,8 +71,8 @@ PKGINFO
it "should get the source package version from pkginfo if provided" do
status = double(:stdout => @pkginfo, :exitstatus => 0)
- expect(@provider).to receive(:shell_out).with("pkginfo", "-l", "-d", "/tmp/bash.pkg", "SUNWbash", { timeout: 900 }).and_return(status)
- expect(@provider).to receive(:shell_out).with("pkginfo", "-l", "SUNWbash", { timeout: 900 }).and_return(@status)
+ 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
expect(@provider.current_resource.package_name).to eq("SUNWbash")
@@ -81,8 +81,8 @@ PKGINFO
it "should return the current version installed if found by pkginfo" do
status = double(:stdout => @pkginfo, :exitstatus => 0)
- expect(@provider).to receive(:shell_out).with("pkginfo", "-l", "-d", "/tmp/bash.pkg", "SUNWbash", { timeout: 900 }).and_return(@status)
- expect(@provider).to receive(:shell_out).with("pkginfo", "-l", "SUNWbash", { timeout: 900 }).and_return(status)
+ 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
expect(@provider.current_resource.version).to eq("11.10.0,REV=2005.01.08.05.16")
end
@@ -90,19 +90,19 @@ PKGINFO
it "should raise an exception if the source is not set but we are installing" do
@new_resource = Chef::Resource::Package.new("SUNWbash")
@provider = Chef::Provider::Package::Solaris.new(@new_resource, @run_context)
- allow(@provider).to receive(:shell_out).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(@status)
expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
it "should raise an exception if pkginfo fails to run" do
status = double(:stdout => "", :exitstatus => -1)
- allow(@provider).to receive(:shell_out).and_return(status)
+ 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
- expect(@provider).to receive(:shell_out).with("pkginfo", "-l", "-d", "/tmp/bash.pkg", "SUNWbash", { timeout: 900 }).and_return(@status)
- expect(@provider).to receive(:shell_out).with("pkginfo", "-l", "SUNWbash", { timeout: 900 }).and_return(@status)
+ 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
expect(@provider.current_resource.version).to be_nil
end
@@ -111,20 +111,20 @@ PKGINFO
describe "candidate_version" do
it "should return the candidate_version variable if already setup" do
@provider.candidate_version = "11.10.0,REV=2005.01.08.05.16"
- expect(@provider).not_to receive(:shell_out)
+ expect(@provider).not_to receive(:shell_out_compacted)
@provider.candidate_version
end
it "should lookup the candidate_version if the variable is not already set" do
status = double(:stdout => "", :exitstatus => 0)
- allow(@provider).to receive(:shell_out).and_return(status)
- expect(@provider).to receive(:shell_out)
+ 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)
- allow(@provider).to receive(:shell_out).and_return(status)
+ allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
end
@@ -132,7 +132,7 @@ PKGINFO
describe "install and upgrade" do
it "should run pkgadd -n -d with the package source to install" do
- expect(@provider).to receive(:shell_out!).with("pkgadd", "-n", "-d", "/tmp/bash.pkg", "all", { timeout: 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("pkgadd", "-n", "-d", "/tmp/bash.pkg", "all", { timeout: 900 })
@provider.install_package("SUNWbash", "11.10.0,REV=2005.01.08.05.16")
end
@@ -140,26 +140,26 @@ PKGINFO
@new_resource = Chef::Resource::Package.new("/tmp/bash.pkg")
@provider = Chef::Provider::Package::Solaris.new(@new_resource, @run_context)
expect(@new_resource.source).to eq("/tmp/bash.pkg")
- expect(@provider).to receive(:shell_out!).with("pkgadd", "-n", "-d", "/tmp/bash.pkg", "all", { timeout: 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("pkgadd", "-n", "-d", "/tmp/bash.pkg", "all", { timeout: 900 })
@provider.install_package("/tmp/bash.pkg", "11.10.0,REV=2005.01.08.05.16")
end
it "should run pkgadd -n -a /tmp/myadmin -d with the package options -a /tmp/myadmin" do
@new_resource.options "-a /tmp/myadmin"
- expect(@provider).to receive(:shell_out!).with("pkgadd", "-n", "-a", "/tmp/myadmin", "-d", "/tmp/bash.pkg", "all", { timeout: 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("pkgadd", "-n", "-a", "/tmp/myadmin", "-d", "/tmp/bash.pkg", "all", { timeout: 900 })
@provider.install_package("SUNWbash", "11.10.0,REV=2005.01.08.05.16")
end
end
describe "remove" do
it "should run pkgrm -n to remove the package" do
- expect(@provider).to receive(:shell_out!).with("pkgrm", "-n", "SUNWbash", { timeout: 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("pkgrm", "-n", "SUNWbash", { timeout: 900 })
@provider.remove_package("SUNWbash", "11.10.0,REV=2005.01.08.05.16")
end
it "should run pkgrm -n -a /tmp/myadmin with options -a /tmp/myadmin" do
@new_resource.options "-a /tmp/myadmin"
- expect(@provider).to receive(:shell_out!).with("pkgrm", "-n", "-a", "/tmp/myadmin", "SUNWbash", { timeout: 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("pkgrm", "-n", "-a", "/tmp/myadmin", "SUNWbash", { timeout: 900 })
@provider.remove_package("SUNWbash", "11.10.0,REV=2005.01.08.05.16")
end
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index 756ba3a480..4ba8ac36ac 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,18 +34,18 @@ describe Chef::Provider::Package::Zypper do
before(:each) do
allow(Chef::Resource::Package).to receive(:new).and_return(current_resource)
- allow(provider).to receive(:shell_out!).and_return(status)
+ allow(provider).to receive(:shell_out_compacted!).and_return(status)
allow(provider).to receive(:`).and_return("2.0")
end
def shell_out_expectation(*command, **options)
options[:timeout] ||= 900
- expect(provider).to receive(:shell_out).with(*command, **options)
+ expect(provider).to receive(:shell_out_compacted).with(*command, **options)
end
def shell_out_expectation!(*command, **options)
options[:timeout] ||= 900
- expect(provider).to receive(:shell_out!).with(*command, **options)
+ expect(provider).to receive(:shell_out_compacted!).with(*command, **options)
end
describe "when loading the current package state" do
@@ -67,7 +67,7 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the installed version to nil on the current resource if zypper info installed version is (none)" do
- allow(provider).to receive(:shell_out).and_return(status)
+ allow(provider).to receive(:shell_out_compacted).and_return(status)
expect(current_resource).to receive(:version).with([nil]).and_return(true)
provider.load_current_resource
end
@@ -75,7 +75,7 @@ describe Chef::Provider::Package::Zypper do
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)
- allow(provider).to receive(:shell_out!).and_return(status)
+ allow(provider).to receive(:shell_out_compacted!).and_return(status)
expect(current_resource).to receive(:version).with(["1.0"]).and_return(true)
provider.load_current_resource
end
@@ -83,7 +83,7 @@ describe Chef::Provider::Package::Zypper do
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)
- allow(provider).to receive(:shell_out!).and_return(status)
+ allow(provider).to receive(:shell_out_compacted!).and_return(status)
expect(current_resource).to receive(:version).with(["1.0"]).and_return(true)
provider.load_current_resource
end
@@ -91,7 +91,7 @@ describe Chef::Provider::Package::Zypper do
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)
- allow(provider).to receive(:shell_out!).and_return(status)
+ allow(provider).to receive(:shell_out_compacted!).and_return(status)
expect(current_resource).to receive(:version).with(["1.0"]).and_return(true)
provider.load_current_resource
end
@@ -99,7 +99,7 @@ describe Chef::Provider::Package::Zypper do
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)
- allow(provider).to receive(:shell_out!).and_return(status)
+ allow(provider).to receive(:shell_out_compacted!).and_return(status)
provider.load_current_resource
expect(provider.candidate_version).to eql(["1.0"])
end
@@ -107,7 +107,7 @@ describe Chef::Provider::Package::Zypper do
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)
- allow(provider).to receive(:shell_out!).and_return(status)
+ allow(provider).to receive(:shell_out_compacted!).and_return(status)
provider.load_current_resource
expect(provider.candidate_version).to eql(["1.0"])
end
@@ -269,35 +269,33 @@ describe Chef::Provider::Package::Zypper do
describe "action_lock" do
it "should lock if the package is not already locked" do
- prov = provider
- allow(prov).to receive(:shell_out_compact!).with(
- "zypper", "--non-interactive", "info", new_resource.package_name
+ expect(provider).to receive(:shell_out_compacted!).with(
+ "zypper", "--non-interactive", "info", new_resource.package_name, timeout: 900
).and_return(status)
- allow(prov).to receive(:shell_out_compact!).with(
- "zypper", "locks"
+ expect(provider).to receive(:shell_out_compacted!).with(
+ "zypper", "locks", timeout: 900
).and_return(instance_double(
Mixlib::ShellOut, stdout: "1 | somethingelse | package | (any)"
))
- expect(prov).to receive(:lock_package).with(["cups"], [nil])
+ expect(provider).to receive(:lock_package).with(["cups"], [nil])
- prov.load_current_resource
- prov.action_lock
+ provider.load_current_resource
+ provider.action_lock
end
it "should not lock if the package is already locked" do
- prov = provider
- allow(prov).to receive(:shell_out_compact!).with(
- "zypper", "--non-interactive", "info", new_resource.package_name
+ expect(provider).to receive(:shell_out_compacted!).with(
+ "zypper", "--non-interactive", "info", new_resource.package_name, timeout: 900
).and_return(status)
- allow(prov).to receive(:shell_out_compact!).with(
- "zypper", "locks"
+ expect(provider).to receive(:shell_out_compacted!).with(
+ "zypper", "locks", timeout: 900
).and_return(instance_double(
Mixlib::ShellOut, stdout: "1 | cups | package | (any)"
))
- expect(prov).to_not receive(:lock_package)
+ expect(provider).to_not receive(:lock_package)
- prov.load_current_resource
- prov.action_lock
+ provider.load_current_resource
+ provider.action_lock
end
end
@@ -326,33 +324,31 @@ describe Chef::Provider::Package::Zypper do
describe "action_unlock" do
it "should unlock if the package is not already unlocked" do
- prov = provider
- allow(prov).to receive(:shell_out_compact!).with(
- "zypper", "--non-interactive", "info", new_resource.package_name
+ allow(provider).to receive(:shell_out_compacted!).with(
+ "zypper", "--non-interactive", "info", new_resource.package_name, timeout: 900
).and_return(status)
- allow(prov).to receive(:shell_out_compact!).with(
- "zypper", "locks"
+ allow(provider).to receive(:shell_out_compacted!).with(
+ "zypper", "locks", timeout: 900
).and_return(instance_double(
Mixlib::ShellOut, stdout: "1 | cups | package | (any)"
))
- expect(prov).to receive(:unlock_package).with(["cups"], [nil])
+ expect(provider).to receive(:unlock_package).with(["cups"], [nil])
- prov.load_current_resource
+ provider.load_current_resource
provider.action_unlock
end
it "should not unlock if the package is already unlocked" do
- prov = provider
- allow(prov).to receive(:shell_out_compact!).with(
- "zypper", "--non-interactive", "info", new_resource.package_name
+ allow(provider).to receive(:shell_out_compacted!).with(
+ "zypper", "--non-interactive", "info", new_resource.package_name, timeout: 900
).and_return(status)
- allow(prov).to receive(:shell_out_compact!).with(
- "zypper", "locks"
+ allow(provider).to receive(:shell_out_compacted!).with(
+ "zypper", "locks", timeout: 900
).and_return(instance_double(
Mixlib::ShellOut, stdout: "1 | somethingelse | package | (any)"
))
- expect(prov).to_not receive(:unlock_package)
+ expect(provider).to_not receive(:unlock_package)
- prov.load_current_resource
+ provider.load_current_resource
provider.action_unlock
end
end
diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb
index da74c932a8..2eb7cf63e1 100644
--- a/spec/unit/provider/package_spec.rb
+++ b/spec/unit/provider/package_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/spec/unit/provider/user/aix_spec.rb b/spec/unit/provider/user/aix_spec.rb
index c70fdd9a57..aa62edd878 100644
--- a/spec/unit/provider/user/aix_spec.rb
+++ b/spec/unit/provider/user/aix_spec.rb
@@ -52,7 +52,7 @@ describe Chef::Provider::User::Aix do
end
it "should call chpasswd correctly" do
- expect(provider).to receive(:shell_out!).with("echo 'adam:Ostagazuzulum' | chpasswd -e").and_return true
+ expect(provider).to receive(:shell_out_compacted!).with("echo 'adam:Ostagazuzulum' | chpasswd -e").and_return true
provider.manage_user
end
end
@@ -61,7 +61,7 @@ describe Chef::Provider::User::Aix do
context "with a system user" do
before { new_resource.system(true) }
it "should add the user to the system group" do
- expect(provider).to receive(:shell_out!).with("useradd", "-g", "system", "adam")
+ expect(provider).to receive(:shell_out_compacted!).with("useradd", "-g", "system", "adam")
provider.create_user
end
end
@@ -74,13 +74,13 @@ describe Chef::Provider::User::Aix do
end
it "should create the home directory" do
- allow(provider).to receive(:shell_out!).with("usermod", "-d", "/home/adam", "adam")
+ allow(provider).to receive(:shell_out_compacted!).with("usermod", "-d", "/home/adam", "adam")
expect(FileUtils).to receive(:mkdir_p).and_return(true)
provider.manage_user
end
it "should move an existing home dir" do
- allow(provider).to receive(:shell_out!).with("usermod", "-d", "/mnt/home/adam", "adam")
+ allow(provider).to receive(:shell_out_compacted!).with("usermod", "-d", "/mnt/home/adam", "adam")
new_resource.home("/mnt/home/adam")
allow(File).to receive(:directory?).with("/home/adam").and_return(true)
expect(FileUtils).to receive(:mv).with("/home/adam", "/mnt/home/adam")
@@ -89,7 +89,7 @@ describe Chef::Provider::User::Aix do
it "should not pass -m" do
allow(FileUtils).to receive(:mkdir_p).and_return(true)
- expect(provider).to receive(:shell_out!).with("usermod", "-d", "/home/adam", "adam")
+ expect(provider).to receive(:shell_out_compacted!).with("usermod", "-d", "/home/adam", "adam")
provider.manage_user
end
end
diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb
index 1019a9ae0f..928cf020e8 100644
--- a/spec/unit/provider/user/dscl_spec.rb
+++ b/spec/unit/provider/user/dscl_spec.rb
@@ -116,31 +116,31 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
describe "when shelling out to dscl" do
it "should run dscl with the supplied cmd /Path args" do
shell_return = shellcmdresult.new("stdout", "err", 0)
- expect(provider).to receive(:shell_out).with("dscl", ".", "-cmd", "/Path", "args").and_return(shell_return)
+ expect(provider).to receive(:shell_out_compacted).with("dscl", ".", "-cmd", "/Path", "args").and_return(shell_return)
expect(provider.run_dscl("cmd", "/Path", "args")).to eq("stdout")
end
it "returns an empty string from delete commands" do
shell_return = shellcmdresult.new("out", "err", 23)
- expect(provider).to receive(:shell_out).with("dscl", ".", "-delete", "/Path", "args").and_return(shell_return)
+ expect(provider).to receive(:shell_out_compacted).with("dscl", ".", "-delete", "/Path", "args").and_return(shell_return)
expect(provider.run_dscl("delete", "/Path", "args")).to eq("")
end
it "should raise an exception for any other command" do
shell_return = shellcmdresult.new("out", "err", 23)
- expect(provider).to receive(:shell_out).with("dscl", ".", "-cmd", "/Path", "arguments").and_return(shell_return)
+ expect(provider).to receive(:shell_out_compacted).with("dscl", ".", "-cmd", "/Path", "arguments").and_return(shell_return)
expect { provider.run_dscl("cmd", "/Path", "arguments") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
end
it "raises an exception when dscl reports 'no such key'" do
shell_return = shellcmdresult.new("No such key: ", "err", 23)
- expect(provider).to receive(:shell_out).with("dscl", ".", "-cmd", "/Path", "args").and_return(shell_return)
+ expect(provider).to receive(:shell_out_compacted).with("dscl", ".", "-cmd", "/Path", "args").and_return(shell_return)
expect { provider.run_dscl("cmd", "/Path", "args") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
end
it "raises an exception when dscl reports 'eDSRecordNotFound'" do
shell_return = shellcmdresult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", "err", -14136)
- expect(provider).to receive(:shell_out).with("dscl", ".", "-cmd", "/Path", "args").and_return(shell_return)
+ expect(provider).to receive(:shell_out_compacted).with("dscl", ".", "-cmd", "/Path", "args").and_return(shell_return)
expect { provider.run_dscl("cmd", "/Path", "args") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
end
end
@@ -284,7 +284,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
end
it "should run createhomedir to create the user's new home folder" do
- expect(provider).to receive(:shell_out!).with("/usr/sbin/createhomedir", "-c", "-u", "toor")
+ expect(provider).to receive(:shell_out_compacted!).with("/usr/sbin/createhomedir", "-c", "-u", "toor")
provider.ditto_home
end
@@ -399,8 +399,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
let(:user_plist_file) { nil }
before do
- expect(provider).to receive(:shell_out).with("dscacheutil", "-flushcache")
- expect(provider).to receive(:shell_out).with("plutil", "-convert", "xml1", "-o", "-", "/var/db/dslocal/nodes/Default/users/toor.plist") do
+ expect(provider).to receive(:shell_out_compacted).with("dscacheutil", "-flushcache")
+ expect(provider).to receive(:shell_out_compacted).with("plutil", "-convert", "xml1", "-o", "-", "/var/db/dslocal/nodes/Default/users/toor.plist") do
if user_plist_file.nil?
shellcmdresult.new("Can not find the file", "Sorry!!", 1)
else
@@ -743,7 +743,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
expect(provider).to receive(:prepare_password_shadow_info).and_return({})
mock_shellout = double("Mock::Shellout")
allow(mock_shellout).to receive(:run_command)
- expect(provider).to receive(:shell_out).and_return(mock_shellout)
+ expect(provider).to receive(:shell_out_compacted).and_return(mock_shellout)
expect(provider).to receive(:read_user_info)
expect(provider).to receive(:dscl_set)
expect(provider).to receive(:sleep).with(3)
@@ -812,7 +812,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
it "should raise an exception when the group does not exist" do
shell_return = shellcmdresult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", "err", -14136)
- expect(provider).to receive(:shell_out).with("dscl", ".", "-read", "/Groups/newgroup", "PrimaryGroupID").and_return(shell_return)
+ expect(provider).to receive(:shell_out_compacted).with("dscl", ".", "-read", "/Groups/newgroup", "PrimaryGroupID").and_return(shell_return)
expect { provider.dscl_set_gid }.to raise_error(Chef::Exceptions::GroupIDNotFound)
end
end
@@ -867,8 +867,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
describe "when the user exists" do
before do
- expect(provider).to receive(:shell_out).with("dscacheutil", "-flushcache")
- expect(provider).to receive(:shell_out).with("plutil", "-convert", "xml1", "-o", "-", "/var/db/dslocal/nodes/Default/users/toor.plist") do
+ expect(provider).to receive(:shell_out_compacted).with("dscacheutil", "-flushcache")
+ expect(provider).to receive(:shell_out_compacted).with("plutil", "-convert", "xml1", "-o", "-", "/var/db/dslocal/nodes/Default/users/toor.plist") do
shellcmdresult.new(File.read(File.join(CHEF_SPEC_DATA, "mac_users/10.9.plist.xml")), "", 0)
end
provider.load_current_resource
diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb
index 079fd44ef5..8cc69f88af 100644
--- a/spec/unit/provider/user/pw_spec.rb
+++ b/spec/unit/provider/user/pw_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Stephen Haynes (<sh@nomitor.com>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -81,12 +81,12 @@ describe Chef::Provider::User::Pw do
describe "create_user" do
before(:each) do
- allow(@provider).to receive(:shell_out!).and_return(true)
+ allow(@provider).to receive(:shell_out_compacted!).and_return(true)
allow(@provider).to receive(:modify_password).and_return(true)
end
it "should run pw useradd with the return of set_options" do
- expect(@provider).to receive(:shell_out!).with("pw", "useradd", "adam", "-m").and_return(true)
+ expect(@provider).to receive(:shell_out_compacted!).with( "pw", "useradd", "adam", "-m").and_return(true)
@provider.create_user
end
@@ -98,12 +98,12 @@ describe Chef::Provider::User::Pw do
describe "manage_user" do
before(:each) do
- allow(@provider).to receive(:shell_out!).and_return(true)
+ allow(@provider).to receive(:shell_out_compacted!).and_return(true)
allow(@provider).to receive(:modify_password).and_return(true)
end
it "should run pw usermod with the return of set_options" do
- expect(@provider).to receive(:shell_out!).with("pw", "usermod", "adam", "-m").and_return(true)
+ expect(@provider).to receive(:shell_out_compacted!).with( "pw", "usermod", "adam", "-m").and_return(true)
@provider.manage_user
end
@@ -116,12 +116,12 @@ describe Chef::Provider::User::Pw do
describe "remove_user" do
it "should run pw userdel with the new resources user name" do
@new_resource.manage_home false
- expect(@provider).to receive(:shell_out!).with("pw", "userdel", @new_resource.username).and_return(true)
+ expect(@provider).to receive(:shell_out_compacted!).with( "pw", "userdel", @new_resource.username).and_return(true)
@provider.remove_user
end
it "should run pw userdel with the new resources user name and -r if manage_home is true" do
- expect(@provider).to receive(:shell_out!).with("pw", "userdel", @new_resource.username, "-r").and_return(true)
+ expect(@provider).to receive(:shell_out_compacted!).with( "pw", "userdel", @new_resource.username, "-r").and_return(true)
@provider.remove_user
end
end
@@ -140,14 +140,14 @@ describe Chef::Provider::User::Pw do
describe "when locking the user" do
it "should run pw lock with the new resources username" do
- expect(@provider).to receive(:shell_out!).with("pw", "lock", @new_resource.username)
+ expect(@provider).to receive(:shell_out_compacted!).with( "pw", "lock", @new_resource.username)
@provider.lock_user
end
end
describe "when unlocking the user" do
it "should run pw unlock with the new resources username" do
- expect(@provider).to receive(:shell_out!).with("pw", "unlock", @new_resource.username)
+ expect(@provider).to receive(:shell_out_compacted!).with( "pw", "unlock", @new_resource.username)
@provider.unlock_user
end
end
@@ -155,7 +155,7 @@ describe Chef::Provider::User::Pw do
describe "when modifying the password" do
before(:each) do
@status = double("Status", exitstatus: 0)
- allow(@provider).to receive(:shell_out!).and_return(@status)
+ allow(@provider).to receive(:shell_out_compacted!).and_return(@status)
end
describe "and the new password has not been specified" do
@@ -202,12 +202,12 @@ 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!).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
it "should raise an exception if pw usermod fails" do
- expect(@provider).to receive(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ expect(@provider).to receive(:shell_out_compacted!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
expect { @provider.modify_password }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
end
diff --git a/spec/unit/provider/user/solaris_spec.rb b/spec/unit/provider/user/solaris_spec.rb
index ecc85677e7..b39e065f48 100644
--- a/spec/unit/provider/user/solaris_spec.rb
+++ b/spec/unit/provider/user/solaris_spec.rb
@@ -58,7 +58,7 @@ describe Chef::Provider::User::Solaris do
it "should use its own shadow file writer to set the password" do
expect(provider).to receive(:write_shadow_file)
- allow(provider).to receive(:shell_out!).and_return(true)
+ allow(provider).to receive(:shell_out_compacted!).and_return(true)
provider.manage_user
end
@@ -69,7 +69,7 @@ describe Chef::Provider::User::Solaris do
password_file.puts "adam:existingpassword:15441::::::"
password_file.close
stub_const("Chef::Provider::User::Solaris::PASSWORD_FILE", password_file.path)
- allow(provider).to receive(:shell_out!).and_return(true)
+ allow(provider).to receive(:shell_out_compacted!).and_return(true)
# may not be able to write to /etc for tests...
temp_file = Tempfile.new("shadow")
allow(Tempfile).to receive(:new).with("shadow", "/etc").and_return(temp_file)
@@ -84,7 +84,7 @@ describe Chef::Provider::User::Solaris do
context "with a system user" do
before { new_resource.system(true) }
it "should not pass -r" do
- expect(provider).to receive(:shell_out!).with("useradd", "adam")
+ expect(provider).to receive(:shell_out_compacted!).with( "useradd", "adam")
provider.create_user
end
end
@@ -92,7 +92,7 @@ describe Chef::Provider::User::Solaris do
context "with manage_home" do
before { new_resource.manage_home(true) }
it "should not pass -r" do
- expect(provider).to receive(:shell_out!).with("useradd", "-m", "adam")
+ expect(provider).to receive(:shell_out_compacted!).with( "useradd", "-m", "adam")
provider.create_user
end
end
@@ -162,7 +162,7 @@ describe Chef::Provider::User::Solaris do
describe "when locking the user" do
it "should run passwd -l with the new resources username" do
shell_return = shellcmdresult.new("", "", 0)
- expect(provider).to receive(:shell_out!).with("passwd", "-l", "adam").and_return(shell_return)
+ expect(provider).to receive(:shell_out_compacted!).with("passwd", "-l", "adam").and_return(shell_return)
provider.lock_user
end
end
@@ -170,7 +170,7 @@ describe Chef::Provider::User::Solaris do
describe "when unlocking the user" do
it "should run passwd -u with the new resources username" do
shell_return = shellcmdresult.new("", "", 0)
- expect(provider).to receive(:shell_out!).with("passwd", "-u", "adam").and_return(shell_return)
+ expect(provider).to receive(:shell_out_compacted!).with("passwd", "-u", "adam").and_return(shell_return)
provider.unlock_user
end
end
diff --git a/spec/unit/resource/powershell_package_source_spec.rb b/spec/unit/resource/powershell_package_source_spec.rb
new file mode 100644
index 0000000000..d8cb8a09a0
--- /dev/null
+++ b/spec/unit/resource/powershell_package_source_spec.rb
@@ -0,0 +1,219 @@
+# Author:: Tor Magnus Rakvåg (tm@intility.no)
+# Copyright:: 2018, Intility AS
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "spec_helper"
+
+describe Chef::Resource::PowershellPackageSource do
+ let(:resource) { Chef::Resource::PowershellPackageSource.new("MyGallery") }
+ let(:provider) { resource.provider_for_action(:enable) }
+
+ it "has a resource name of :powershell_package_source" do
+ expect(resource.resource_name).to eql(:powershell_package_source)
+ end
+
+ it "the name_property is 'name'" do
+ expect(resource.source_name).to eql("MyGallery")
+ end
+
+ it "the default action is :register" do
+ expect(resource.action).to eql([:register])
+ end
+
+ it "supports :register and :unregister actions" do
+ expect { resource.action :register }.not_to raise_error
+ expect { resource.action :unregister }.not_to raise_error
+ end
+
+ it "the url property accepts strings" do
+ resource.url("https://mygallery.company.co/api/v2/")
+ expect(resource.url).to eql("https://mygallery.company.co/api/v2/")
+ end
+
+ it "the trusted property accepts true and false" do
+ resource.trusted(false)
+ expect(resource.trusted).to eql(false)
+ resource.trusted(true)
+ expect(resource.trusted).to eql(true)
+ end
+
+ it "trusted defaults to false" do
+ expect(resource.trusted).to eql(false)
+ end
+
+ it "provider_name accepts 'Programs', 'msi', 'NuGet', 'msu', 'PowerShellGet', 'psl', 'chocolatey'" do
+ expect { resource.provider_name("Programs") }.not_to raise_error
+ expect { resource.provider_name("msi") }.not_to raise_error
+ expect { resource.provider_name("NuGet") }.not_to raise_error
+ expect { resource.provider_name("msu") }.not_to raise_error
+ expect { resource.provider_name("PowerShellGet") }.not_to raise_error
+ expect { resource.provider_name("psl") }.not_to raise_error
+ expect { resource.provider_name("chocolatey") }.not_to raise_error
+ end
+
+ it "the publish_location property accepts strings" do
+ resource.publish_location("https://mygallery.company.co/api/v2/package")
+ expect(resource.publish_location).to eql("https://mygallery.company.co/api/v2/package")
+ end
+
+ it "the script_source_location property accepts strings" do
+ resource.publish_location("https://mygallery.company.co/api/v2/scripts")
+ expect(resource.publish_location).to eql("https://mygallery.company.co/api/v2/scripts")
+ end
+
+ it "the script_publish_location property accepts strings" do
+ resource.publish_location("https://mygallery.company.co/api/v2/scripts")
+ expect(resource.publish_location).to eql("https://mygallery.company.co/api/v2/scripts")
+ end
+
+ describe "#build_ps_repository_command" do
+ before do
+ resource.source_name("MyGallery")
+ resource.url("https://mygallery.company.co/api/v2/")
+ end
+
+ context "#register" do
+ it "builds a minimal command" do
+ expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted'")
+ end
+
+ it "builds a command with trusted set to true" do
+ resource.trusted(true)
+ expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Trusted'")
+ end
+
+ it "builds a command with a publish location" do
+ resource.publish_location("https://mygallery.company.co/api/v2/package")
+ expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -PublishLocation 'https://mygallery.company.co/api/v2/package'")
+ end
+
+ it "builds a command with a script source location" do
+ resource.script_source_location("https://mygallery.company.co/api/v2/scripts")
+ expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -ScriptSourceLocation 'https://mygallery.company.co/api/v2/scripts'")
+ end
+
+ it "builds a command with a script publish location" do
+ resource.script_publish_location("https://mygallery.company.co/api/v2/scripts/package")
+ expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -ScriptPublishLocation 'https://mygallery.company.co/api/v2/scripts/package'")
+ end
+ end
+
+ context "#set" do
+ it "builds a minimal command" do
+ expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted'")
+ end
+
+ it "builds a command to change the url" do
+ resource.url("https://othergallery.company.co/api/v2/")
+ expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://othergallery.company.co/api/v2/' -InstallationPolicy 'Untrusted'")
+ end
+
+ it "builds a command with trusted set to true" do
+ resource.trusted(true)
+ expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Trusted'")
+ end
+
+ it "builds a command with a publish location" do
+ resource.publish_location("https://mygallery.company.co/api/v2/package")
+ expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -PublishLocation 'https://mygallery.company.co/api/v2/package'")
+ end
+
+ it "builds a command with a script source location" do
+ resource.script_source_location("https://mygallery.company.co/api/v2/scripts")
+ expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -ScriptSourceLocation 'https://mygallery.company.co/api/v2/scripts'")
+ end
+
+ it "builds a command with a script publish location" do
+ resource.script_publish_location("https://mygallery.company.co/api/v2/scripts/package")
+ expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -ScriptPublishLocation 'https://mygallery.company.co/api/v2/scripts/package'")
+ end
+ end
+ end
+
+ describe "#build_package_source_command" do
+ before do
+ resource.source_name("NuGet")
+ resource.url("http://nuget.org/api/v2/")
+ end
+
+ context "#register" do
+ it "builds a minimal command" do
+ expect(provider.build_package_source_command("Register", resource)).to eql("Register-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -Trusted:$false -ProviderName 'NuGet'")
+ end
+
+ it "builds a command with trusted set to true" do
+ resource.trusted(true)
+ expect(provider.build_package_source_command("Register", resource)).to eql("Register-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -Trusted:$true -ProviderName 'NuGet'")
+ end
+
+ it "builds a command with a different provider" do
+ resource.source_name("choco")
+ resource.url("https://chocolatey.org/api/v2/")
+ resource.provider_name("chocolatey")
+ expect(provider.build_package_source_command("Register", resource)).to eql("Register-PackageSource -Name 'choco' -Location 'https://chocolatey.org/api/v2/' -Trusted:$false -ProviderName 'chocolatey'")
+ end
+ end
+
+ context "#set" do
+ it "builds a minimal command" do
+ expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -Trusted:$false -ProviderName 'NuGet'")
+ end
+
+ it "builds a command to change the url" do
+ resource.url("https://nuget.company.co/api/v2/")
+ expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'NuGet' -Location 'https://nuget.company.co/api/v2/' -Trusted:$false -ProviderName 'NuGet'")
+ end
+
+ it "builds a command with trusted set to true" do
+ resource.trusted(true)
+ expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -Trusted:$true -ProviderName 'NuGet'")
+ end
+
+ it "builds a command with a different provider" do
+ resource.source_name("choco")
+ resource.url("https://chocolatey.org/api/v2/")
+ resource.provider_name("chocolatey")
+ expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'choco' -Location 'https://chocolatey.org/api/v2/' -Trusted:$false -ProviderName 'chocolatey'")
+ end
+ end
+ end
+
+ describe "#psrepository_cmdlet_appropriate?" do
+ it "returns true if the provider_name is 'PowerShellGet'" do
+ resource.provider_name("PowerShellGet")
+ expect(provider.psrepository_cmdlet_appropriate?).to eql(true)
+ end
+
+ it "returns false if the provider_name is something else" do
+ resource.provider_name("NuGet")
+ expect(provider.psrepository_cmdlet_appropriate?).to eql(false)
+ end
+ end
+
+ describe "#package_source_exists?" do
+ it "returns true if it exists" do
+ allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", :stdout => "MyGallery\r\n"))
+ resource.source_name("MyGallery")
+ expect(provider.package_source_exists?).to eql(true)
+ end
+
+ it "returns false if it doesn't exist" do
+ allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", :stdout => ""))
+ resource.source_name("MyGallery")
+ expect(provider.package_source_exists?).to eql(false)
+ end
+ end
+end
diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb
index 5081281cf4..8da6492fae 100644
--- a/spec/unit/util/selinux_spec.rb
+++ b/spec/unit/util/selinux_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Serdar Sutay (<serdar@chef.io>)
-# Copyright:: Copyright 2013-2017, Chef Software Inc.
+# Copyright:: Copyright 2013-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -124,21 +124,21 @@ describe Chef::Util::Selinux do
end
it "should call restorecon non-recursive by default" do
- expect(@test_instance).to receive(:shell_out_compact!).twice.with(@restorecon_enabled_path, [ "-R", path ])
+ expect(@test_instance).to receive(:shell_out_compacted!).with(@restorecon_enabled_path, "-R", path).twice
@test_instance.restore_security_context(path)
expect(File).not_to receive(:executable?)
@test_instance.restore_security_context(path)
end
it "should call restorecon recursive when recursive is set" do
- expect(@test_instance).to receive(:shell_out_compact!).twice.with(@restorecon_enabled_path, [ "-R", "-r", path ])
+ expect(@test_instance).to receive(:shell_out_compacted!).with(@restorecon_enabled_path, "-R", "-r", path).twice
@test_instance.restore_security_context(path, true)
expect(File).not_to receive(:executable?)
@test_instance.restore_security_context(path, true)
end
it "should call restorecon non-recursive when recursive is not set" do
- expect(@test_instance).to receive(:shell_out_compact!).twice.with(@restorecon_enabled_path, [ "-R", path ])
+ expect(@test_instance).to receive(:shell_out_compacted!).with(@restorecon_enabled_path, "-R", path).twice
@test_instance.restore_security_context(path)
expect(File).not_to receive(:executable?)
@test_instance.restore_security_context(path)