summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlamont-granquist <lamont@scriptkiddie.org>2014-09-09 12:56:05 -0700
committerlamont-granquist <lamont@scriptkiddie.org>2014-09-09 12:56:05 -0700
commit7e5c08a2ef1df3ea190ef83ebfd7d4769476324d (patch)
tree2ee96d35c6e74e9e689da25c6d733cee0a9f08f3
parent9eb2a7260226103793b5519a4295480b3cf512c6 (diff)
parenta463b6df7ed3003447644ca99ea52f7ef0b404ea (diff)
downloadchef-7e5c08a2ef1df3ea190ef83ebfd7d4769476324d.tar.gz
Merge pull request #1977 from opscode/lcg/unicode
Unicode fixes for Chef 12
-rw-r--r--Gemfile3
-rw-r--r--chef.gemspec2
-rw-r--r--lib/chef/application.rb6
-rw-r--r--lib/chef/config.rb45
-rw-r--r--lib/chef/mixin/shell_out.rb46
-rw-r--r--lib/chef/provider/package/aix.rb16
-rw-r--r--lib/chef/provider/package/ips.rb20
-rw-r--r--lib/chef/provider/package/macports.rb16
-rw-r--r--lib/chef/provider/package/pacman.rb8
-rw-r--r--lib/chef/provider/package/portage.rb8
-rw-r--r--lib/chef/provider/package/rpm.rb16
-rw-r--r--lib/chef/provider/package/solaris.rb16
-rw-r--r--lib/chef/provider/service/debian.rb20
-rw-r--r--lib/chef/provider/service/freebsd.rb6
-rw-r--r--lib/chef/provider/service/gentoo.rb4
-rw-r--r--lib/chef/provider/service/init.rb8
-rw-r--r--lib/chef/provider/service/insserv.rb6
-rw-r--r--lib/chef/provider/service/macosx.rb4
-rw-r--r--lib/chef/provider/service/simple.rb8
-rw-r--r--lib/chef/provider/service/solaris.rb2
-rw-r--r--lib/chef/provider/service/systemd.rb18
-rw-r--r--lib/chef/provider/service/upstart.rb12
-rw-r--r--lib/chef/provider/subversion.rb12
-rw-r--r--spec/functional/mixin/shell_out_spec.rb4
-rw-r--r--spec/functional/resource/deploy_revision_spec.rb4
-rw-r--r--spec/unit/mixin/shell_out_spec.rb198
-rw-r--r--spec/unit/provider/package/aix_spec.rb22
-rw-r--r--spec/unit/provider/package/ips_spec.rb29
-rw-r--r--spec/unit/provider/package/macports_spec.rb24
-rw-r--r--spec/unit/provider/package/pacman_spec.rb16
-rw-r--r--spec/unit/provider/package/portage_spec.rb20
-rw-r--r--spec/unit/provider/package/rpm_spec.rb29
-rw-r--r--spec/unit/provider/package/solaris_spec.rb21
-rw-r--r--spec/unit/provider/service/arch_service_spec.rb22
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb2
-rw-r--r--spec/unit/provider/service/freebsd_service_spec.rb12
-rw-r--r--spec/unit/provider/service/gentoo_service_spec.rb4
-rw-r--r--spec/unit/provider/service/init_service_spec.rb20
-rw-r--r--spec/unit/provider/service/insserv_service_spec.rb7
-rw-r--r--spec/unit/provider/service/invokercd_service_spec.rb17
-rw-r--r--spec/unit/provider/service/macosx_spec.rb10
-rw-r--r--spec/unit/provider/service/simple_service_spec.rb8
-rw-r--r--spec/unit/provider/service/solaris_smf_service_spec.rb4
-rw-r--r--spec/unit/provider/service/systemd_service_spec.rb40
-rw-r--r--spec/unit/provider/service/upstart_service_spec.rb32
-rw-r--r--spec/unit/provider/subversion_spec.rb11
46 files changed, 433 insertions, 425 deletions
diff --git a/Gemfile b/Gemfile
index 1418235ebc..3701211e4f 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,6 +3,9 @@ gemspec :name => "chef"
gem "activesupport", "< 4.0.0", :group => :compat_testing, :platform => "ruby"
+gem "mixlib-shellout", github: "opscode/mixlib-shellout", branch: "master"
+gem "ohai", github: "opscode/ohai", branch: "master"
+
group(:docgen) do
gem "yard"
end
diff --git a/chef.gemspec b/chef.gemspec
index 89b4ac2665..075748a232 100644
--- a/chef.gemspec
+++ b/chef.gemspec
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.add_dependency "mixlib-cli", "~> 1.4"
s.add_dependency "mixlib-log", "~> 1.3"
s.add_dependency "mixlib-authentication", "~> 1.3"
- s.add_dependency "mixlib-shellout", "~> 1.4"
+ s.add_dependency "mixlib-shellout", ">= 2.0.0.rc.0", "< 3.0"
s.add_dependency "ohai", "~> 7.2"
s.add_dependency "ffi-yajl", "~> 1.0", ">= 1.0.2"
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index 5b1d53d741..0430d4acfa 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -46,6 +46,7 @@ class Chef::Application
configure_chef
configure_logging
configure_proxy_environment_variables
+ configure_encoding
end
# Get this party started
@@ -175,6 +176,11 @@ class Chef::Application
configure_no_proxy
end
+ # Sets the default external encoding to UTF-8 (users can change this, but they shouldn't)
+ def configure_encoding
+ Encoding.default_external = Chef::Config[:ruby_encoding]
+ end
+
# Called prior to starting the application, by the run method
def setup_application
raise Chef::Exceptions::Application, "#{self.to_s}: you must override setup_application"
diff --git a/lib/chef/config.rb b/lib/chef/config.rb
index 4e71645dcc..1963a95aab 100644
--- a/lib/chef/config.rb
+++ b/lib/chef/config.rb
@@ -587,6 +587,51 @@ class Chef
default :normal_attribute_whitelist, nil
default :override_attribute_whitelist, nil
+ # Chef requires an English-language UTF-8 locale to function properly. We attempt
+ # to use the 'locale -a' command and search through a list of preferences until we
+ # find one that we can use. On Ubuntu systems we should find 'C.UTF-8' and be
+ # able to use that even if there is no English locale on the server, but Mac, Solaris,
+ # AIX, etc do not have that locale. We then try to find an English locale and fall
+ # back to 'C' if we do not. The choice of fallback is pick-your-poison. If we try
+ # to do the work to return a non-US UTF-8 locale then we fail inside of providers when
+ # things like 'svn info' return Japanese and we can't parse them. OTOH, if we pick 'C' then
+ # we will blow up on UTF-8 characters. Between the warn we throw and the Encoding
+ # exception that ruby will throw it is more obvious what is broken if we drop UTF-8 by
+ # default rather than drop English.
+ #
+ # If there is no 'locale -a' then we return 'en_US.UTF-8' since that is the most commonly
+ # available English UTF-8 locale. However, all modern POSIXen should support 'locale -a'.
+ default :internal_locale do
+ begin
+ locales = `locale -a`.split
+ case
+ when locales.include?('C.UTF-8')
+ 'C.UTF-8'
+ when locales.include?('en_US.UTF-8')
+ 'en_US.UTF-8'
+ when locales.include?('en.UTF-8')
+ 'en.UTF-8'
+ when guesses = locales.select { |l| l =~ /^en_.*UTF-8$'/ }
+ guesses.first
+ else
+ Chef::Log.warn "Please install an English UTF-8 locale for Chef to use, falling back to C locale and disabling UTF-8 support."
+ 'C'
+ end
+ rescue
+ Chef::Log.warn "No usable locale -a command found, assuming you have en_US.UTF-8 installed."
+ 'en_US.UTF-8'
+ end
+ end
+
+ # Force UTF-8 Encoding, for when we fire up in the 'C' locale or other strange locales (e.g.
+ # japanese windows encodings). If we do not do this, then knife upload will fail when a cookbook's
+ # README.md has UTF-8 characters that do not encode in whatever surrounding encoding we have been
+ # passed. Effectively, the Chef Ecosystem is globally UTF-8 by default. Anyone who wants to be
+ # able to upload Shift_JIS or ISO-8859-1 files needs to mark *those* files explicitly with
+ # magic tags to make ruby correctly identify the encoding being used. Changing this default will
+ # break Chef community cookbooks and is very highly discouraged.
+ default :ruby_encoding, Encoding::UTF_8
+
# If installed via an omnibus installer, this gives the path to the
# "embedded" directory which contains all of the software packaged with
# omnibus. This is used to locate the cacert.pem file on windows.
diff --git a/lib/chef/mixin/shell_out.rb b/lib/chef/mixin/shell_out.rb
index 881c94b862..82772b584a 100644
--- a/lib/chef/mixin/shell_out.rb
+++ b/lib/chef/mixin/shell_out.rb
@@ -30,32 +30,39 @@ class Chef
# Generally speaking, 'extend Chef::Mixin::ShellOut' in your recipes and include 'Chef::Mixin::ShellOut' in your LWRPs
# You can also call Mixlib::Shellout.new directly, but you lose all of the above functionality
+ # we use 'en_US.UTF-8' by default because we parse localized strings in English as an API and
+ # generally must support UTF-8 unicode.
def shell_out(*command_args)
- cmd = Mixlib::ShellOut.new(*run_command_compatible_options(command_args))
- cmd.live_stream ||= io_for_live_stream
- cmd.run_command
- cmd
+ args = command_args.dup
+ if args.last.is_a?(Hash)
+ options = args.pop.dup
+ env_key = options.has_key?(:env) ? :env : :environment
+ options[env_key] ||= {}
+ options[env_key] = options[env_key].dup
+ options[env_key]['LC_ALL'] ||= Chef::Config[:internal_locale] unless options[env_key].has_key?('LC_ALL')
+ args << options
+ else
+ args << { :environment => { 'LC_ALL' => Chef::Config[:internal_locale] } }
+ end
+
+ shell_out_command(*args)
end
+ # call shell_out (using en_US.UTF-8) and raise errors
def shell_out!(*command_args)
- cmd= shell_out(*command_args)
+ cmd = shell_out(*command_args)
cmd.error!
cmd
end
- # environment['LC_ALL'] should be nil or what the user specified
def shell_out_with_systems_locale(*command_args)
- args = command_args.dup
- if args.last.is_a?(Hash)
- options = args.last
- env_key = options.has_key?(:env) ? :env : :environment
- options[env_key] ||= {}
- options[env_key]['LC_ALL'] ||= nil
- else
- args << { :environment => { 'LC_ALL' => nil } }
- end
+ shell_out_command(*command_args)
+ end
- shell_out(*args)
+ def shell_out_with_systems_locale!(*command_args)
+ cmd = shell_out_with_systems_locale(*command_args)
+ cmd.error!
+ cmd
end
DEPRECATED_OPTIONS =
@@ -82,6 +89,13 @@ class Chef
private
+ def shell_out_command(*command_args)
+ cmd = Mixlib::ShellOut.new(*run_command_compatible_options(command_args))
+ cmd.live_stream ||= io_for_live_stream
+ cmd.run_command
+ cmd
+ end
+
def deprecate_option(old_option, new_option)
Chef::Log.logger.warn "DEPRECATION: Chef::Mixin::ShellOut option :#{old_option} is deprecated. Use :#{new_option}"
end
diff --git a/lib/chef/provider/package/aix.rb b/lib/chef/provider/package/aix.rb
index 9fb87d6ea0..da3e6d1684 100644
--- a/lib/chef/provider/package/aix.rb
+++ b/lib/chef/provider/package/aix.rb
@@ -112,14 +112,10 @@ class Chef
def install_package(name, version)
Chef::Log.debug("#{@new_resource} package install options: #{@new_resource.options}")
if @new_resource.options.nil?
- run_command_with_systems_locale(
- :command => "installp -aYF -d #{@new_resource.source} #{@new_resource.package_name}"
- )
+ shell_out!( "installp -aYF -d #{@new_resource.source} #{@new_resource.package_name}" )
Chef::Log.debug("#{@new_resource} installed version #{@new_resource.version} from: #{@new_resource.source}")
else
- run_command_with_systems_locale(
- :command => "installp -aYF #{expand_options(@new_resource.options)} -d #{@new_resource.source} #{@new_resource.package_name}"
- )
+ shell_out!( "installp -aYF #{expand_options(@new_resource.options)} -d #{@new_resource.source} #{@new_resource.package_name}" )
Chef::Log.debug("#{@new_resource} installed version #{@new_resource.version} from: #{@new_resource.source}")
end
end
@@ -128,14 +124,10 @@ class Chef
def remove_package(name, version)
if @new_resource.options.nil?
- run_command_with_systems_locale(
- :command => "installp -u #{name}"
- )
+ shell_out!( "installp -u #{name}" )
Chef::Log.debug("#{@new_resource} removed version #{@new_resource.version}")
else
- run_command_with_systems_locale(
- :command => "installp -u #{expand_options(@new_resource.options)} #{name}"
- )
+ shell_out!( "installp -u #{expand_options(@new_resource.options)} #{name}" )
Chef::Log.debug("#{@new_resource} removed version #{@new_resource.version}")
end
end
diff --git a/lib/chef/provider/package/ips.rb b/lib/chef/provider/package/ips.rb
index 92b41b3627..4090507303 100644
--- a/lib/chef/provider/package/ips.rb
+++ b/lib/chef/provider/package/ips.rb
@@ -65,15 +65,13 @@ class Chef
def install_package(name, version)
package_name = "#{name}@#{version}"
normal_command = "pkg#{expand_options(@new_resource.options)} install -q #{package_name}"
- if @new_resource.respond_to?(:accept_license) and @new_resource.accept_license
- command = normal_command.gsub('-q', '-q --accept')
- else
- command = normal_command
- end
- begin
- run_command_with_systems_locale(:command => command)
- rescue
- end
+ command =
+ if @new_resource.respond_to?(:accept_license) and @new_resource.accept_license
+ normal_command.gsub('-q', '-q --accept')
+ else
+ normal_command
+ end
+ shell_out(command)
end
def upgrade_package(name, version)
@@ -82,9 +80,7 @@ class Chef
def remove_package(name, version)
package_name = "#{name}@#{version}"
- run_command_with_systems_locale(
- :command => "pkg#{expand_options(@new_resource.options)} uninstall -q #{package_name}"
- )
+ shell_out!( "pkg#{expand_options(@new_resource.options)} uninstall -q #{package_name}" )
end
end
end
diff --git a/lib/chef/provider/package/macports.rb b/lib/chef/provider/package/macports.rb
index 6ef303ee4f..05247e6d31 100644
--- a/lib/chef/provider/package/macports.rb
+++ b/lib/chef/provider/package/macports.rb
@@ -45,27 +45,21 @@ class Chef
unless @current_resource.version == version
command = "port#{expand_options(@new_resource.options)} install #{name}"
command << " @#{version}" if version and !version.empty?
- run_command_with_systems_locale(
- :command => command
- )
+ shell_out!(command)
end
end
def purge_package(name, version)
command = "port#{expand_options(@new_resource.options)} uninstall #{name}"
command << " @#{version}" if version and !version.empty?
- run_command_with_systems_locale(
- :command => command
- )
+ shell_out!(command)
end
def remove_package(name, version)
command = "port#{expand_options(@new_resource.options)} deactivate #{name}"
command << " @#{version}" if version and !version.empty?
- run_command_with_systems_locale(
- :command => command
- )
+ shell_out!(command)
end
def upgrade_package(name, version)
@@ -78,9 +72,7 @@ class Chef
# that hasn't been installed.
install_package(name, version)
elsif current_version != version
- run_command_with_systems_locale(
- :command => "port#{expand_options(@new_resource.options)} upgrade #{name} @#{version}"
- )
+ shell_out!( "port#{expand_options(@new_resource.options)} upgrade #{name} @#{version}" )
end
end
diff --git a/lib/chef/provider/package/pacman.rb b/lib/chef/provider/package/pacman.rb
index 2e8bb7850b..1014ebcaa5 100644
--- a/lib/chef/provider/package/pacman.rb
+++ b/lib/chef/provider/package/pacman.rb
@@ -86,9 +86,7 @@ class Chef
end
def install_package(name, version)
- run_command_with_systems_locale(
- :command => "pacman --sync --noconfirm --noprogressbar#{expand_options(@new_resource.options)} #{name}"
- )
+ shell_out!( "pacman --sync --noconfirm --noprogressbar#{expand_options(@new_resource.options)} #{name}" )
end
def upgrade_package(name, version)
@@ -96,9 +94,7 @@ class Chef
end
def remove_package(name, version)
- run_command_with_systems_locale(
- :command => "pacman --remove --noconfirm --noprogressbar#{expand_options(@new_resource.options)} #{name}"
- )
+ shell_out!( "pacman --remove --noconfirm --noprogressbar#{expand_options(@new_resource.options)} #{name}" )
end
def purge_package(name, version)
diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb
index 6a3587558a..7e0eebd0d9 100644
--- a/lib/chef/provider/package/portage.rb
+++ b/lib/chef/provider/package/portage.rb
@@ -110,9 +110,7 @@ class Chef
pkg = "~#{name}-#{$1}"
end
- run_command_with_systems_locale(
- :command => "emerge -g --color n --nospinner --quiet#{expand_options(@new_resource.options)} #{pkg}"
- )
+ shell_out!( "emerge -g --color n --nospinner --quiet#{expand_options(@new_resource.options)} #{pkg}" )
end
def upgrade_package(name, version)
@@ -126,9 +124,7 @@ class Chef
pkg = "#{@new_resource.package_name}"
end
- run_command_with_systems_locale(
- :command => "emerge --unmerge --color n --nospinner --quiet#{expand_options(@new_resource.options)} #{pkg}"
- )
+ shell_out!( "emerge --unmerge --color n --nospinner --quiet#{expand_options(@new_resource.options)} #{pkg}" )
end
def purge_package(name, version)
diff --git a/lib/chef/provider/package/rpm.rb b/lib/chef/provider/package/rpm.rb
index bbb561bd15..c0a6444252 100644
--- a/lib/chef/provider/package/rpm.rb
+++ b/lib/chef/provider/package/rpm.rb
@@ -90,13 +90,9 @@ class Chef
def install_package(name, version)
unless @current_resource.version
- run_command_with_systems_locale(
- :command => "rpm #{@new_resource.options} -i #{@new_resource.source}"
- )
+ shell_out!( "rpm #{@new_resource.options} -i #{@new_resource.source}" )
else
- run_command_with_systems_locale(
- :command => "rpm #{@new_resource.options} -U #{@new_resource.source}"
- )
+ shell_out!( "rpm #{@new_resource.options} -U #{@new_resource.source}" )
end
end
@@ -104,13 +100,9 @@ class Chef
def remove_package(name, version)
if version
- run_command_with_systems_locale(
- :command => "rpm #{@new_resource.options} -e #{name}-#{version}"
- )
+ shell_out!( "rpm #{@new_resource.options} -e #{name}-#{version}" )
else
- run_command_with_systems_locale(
- :command => "rpm #{@new_resource.options} -e #{name}"
- )
+ shell_out!( "rpm #{@new_resource.options} -e #{name}" )
end
end
diff --git a/lib/chef/provider/package/solaris.rb b/lib/chef/provider/package/solaris.rb
index 0f45b61e18..19f844b66a 100644
--- a/lib/chef/provider/package/solaris.rb
+++ b/lib/chef/provider/package/solaris.rb
@@ -112,9 +112,7 @@ class Chef
else
command = "pkgadd -n -d #{@new_resource.source} all"
end
- run_command_with_systems_locale(
- :command => command
- )
+ shell_out!(command)
Chef::Log.debug("#{@new_resource} installed version #{@new_resource.version} from: #{@new_resource.source}")
else
if ::File.directory?(@new_resource.source) # CHEF-4469
@@ -122,23 +120,17 @@ class Chef
else
command = "pkgadd -n#{expand_options(@new_resource.options)} -d #{@new_resource.source} all"
end
- run_command_with_systems_locale(
- :command => command
- )
+ shell_out!(command)
Chef::Log.debug("#{@new_resource} installed version #{@new_resource.version} from: #{@new_resource.source}")
end
end
def remove_package(name, version)
if @new_resource.options.nil?
- run_command_with_systems_locale(
- :command => "pkgrm -n #{name}"
- )
+ shell_out!( "pkgrm -n #{name}" )
Chef::Log.debug("#{@new_resource} removed version #{@new_resource.version}")
else
- run_command_with_systems_locale(
- :command => "pkgrm -n#{expand_options(@new_resource.options)} #{name}"
- )
+ shell_out!( "pkgrm -n#{expand_options(@new_resource.options)} #{name}" )
Chef::Log.debug("#{@new_resource} removed version #{@new_resource.version}")
end
end
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
index 06fe7fc480..1ebef90349 100644
--- a/lib/chef/provider/service/debian.rb
+++ b/lib/chef/provider/service/debian.rb
@@ -130,15 +130,15 @@ class Chef
def enable_service
if @new_resource.priority.is_a? Integer
- run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
- run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} defaults #{@new_resource.priority} #{100 - @new_resource.priority}")
+ shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
+ shell_out!("/usr/sbin/update-rc.d #{@new_resource.service_name} defaults #{@new_resource.priority} #{100 - @new_resource.priority}")
elsif @new_resource.priority.is_a? Hash
# we call the same command regardless of we're enabling or disabling
# users passing a Hash are responsible for setting their own start priorities
set_priority
else # No priority, go with update-rc.d defaults
- run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
- run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} defaults")
+ shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
+ shell_out!("/usr/sbin/update-rc.d #{@new_resource.service_name} defaults")
end
end
@@ -146,16 +146,16 @@ class Chef
def disable_service
if @new_resource.priority.is_a? Integer
# Stop processes in reverse order of start using '100 - start_priority'
- run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
- run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} stop #{100 - @new_resource.priority} 2 3 4 5 .")
+ shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
+ shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} stop #{100 - @new_resource.priority} 2 3 4 5 .")
elsif @new_resource.priority.is_a? Hash
# we call the same command regardless of we're enabling or disabling
# users passing a Hash are responsible for setting their own stop priorities
set_priority
else
# no priority, using '100 - 20 (update-rc.d default)' to stop in reverse order of start
- run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
- run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} stop 80 2 3 4 5 .")
+ shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
+ shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} stop 80 2 3 4 5 .")
end
end
@@ -166,8 +166,8 @@ class Chef
priority = o[1]
args += "#{action} #{priority} #{level} . "
end
- run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
- run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} #{args}")
+ shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
+ shell_out!("/usr/sbin/update-rc.d #{@new_resource.service_name} #{args}")
end
end
end
diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb
index 7b69957cc6..08d58232e1 100644
--- a/lib/chef/provider/service/freebsd.rb
+++ b/lib/chef/provider/service/freebsd.rb
@@ -78,7 +78,7 @@ class Chef
if new_resource.start_command
super
else
- shell_out!("#{init_command} faststart")
+ shell_out_with_systems_locale!("#{init_command} faststart")
end
end
@@ -86,7 +86,7 @@ class Chef
if new_resource.stop_command
super
else
- shell_out!("#{init_command} faststop")
+ shell_out_with_systems_locale!("#{init_command} faststop")
end
end
@@ -94,7 +94,7 @@ class Chef
if new_resource.restart_command
super
elsif new_resource.supports[:restart]
- shell_out!("#{init_command} fastrestart")
+ shell_out_with_systems_locale!("#{init_command} fastrestart")
else
stop_service
sleep 1
diff --git a/lib/chef/provider/service/gentoo.rb b/lib/chef/provider/service/gentoo.rb
index 1559c7893f..a68abfebc9 100644
--- a/lib/chef/provider/service/gentoo.rb
+++ b/lib/chef/provider/service/gentoo.rb
@@ -58,10 +58,10 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
end
def enable_service()
- run_command(:command => "/sbin/rc-update add #{@new_resource.service_name} default")
+ shell_out!("/sbin/rc-update add #{@new_resource.service_name} default")
end
def disable_service()
- run_command(:command => "/sbin/rc-update del #{@new_resource.service_name} default")
+ shell_out!("/sbin/rc-update del #{@new_resource.service_name} default")
end
end
diff --git a/lib/chef/provider/service/init.rb b/lib/chef/provider/service/init.rb
index 23d9dde80a..5d8bb5bb38 100644
--- a/lib/chef/provider/service/init.rb
+++ b/lib/chef/provider/service/init.rb
@@ -50,7 +50,7 @@ class Chef
if @new_resource.start_command
super
else
- shell_out!("#{default_init_command} start")
+ shell_out_with_systems_locale!("#{default_init_command} start")
end
end
@@ -58,7 +58,7 @@ class Chef
if @new_resource.stop_command
super
else
- shell_out!("#{default_init_command} stop")
+ shell_out_with_systems_locale!("#{default_init_command} stop")
end
end
@@ -66,7 +66,7 @@ class Chef
if @new_resource.restart_command
super
elsif @new_resource.supports[:restart]
- shell_out!("#{default_init_command} restart")
+ shell_out_with_systems_locale!("#{default_init_command} restart")
else
stop_service
sleep 1
@@ -78,7 +78,7 @@ class Chef
if @new_resource.reload_command
super
elsif @new_resource.supports[:reload]
- shell_out!("#{default_init_command} reload")
+ shell_out_with_systems_locale!("#{default_init_command} reload")
end
end
end
diff --git a/lib/chef/provider/service/insserv.rb b/lib/chef/provider/service/insserv.rb
index 35767ee7b9..f4c85dd9d3 100644
--- a/lib/chef/provider/service/insserv.rb
+++ b/lib/chef/provider/service/insserv.rb
@@ -37,12 +37,12 @@ class Chef
end
def enable_service()
- run_command(:command => "/sbin/insserv -r -f #{@new_resource.service_name}")
- run_command(:command => "/sbin/insserv -d -f #{@new_resource.service_name}")
+ shell_out!("/sbin/insserv -r -f #{@new_resource.service_name}")
+ shell_out!("/sbin/insserv -d -f #{@new_resource.service_name}")
end
def disable_service()
- run_command(:command => "/sbin/insserv -r -f #{@new_resource.service_name}")
+ shell_out!("/sbin/insserv -r -f #{@new_resource.service_name}")
end
end
end
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb
index 36930ee4ac..cf5e554559 100644
--- a/lib/chef/provider/service/macosx.rb
+++ b/lib/chef/provider/service/macosx.rb
@@ -83,7 +83,7 @@ class Chef
if @new_resource.start_command
super
else
- shell_out!("launchctl load -w '#{@plist}'", :user => @owner_uid, :group => @owner_gid)
+ shell_out_with_systems_locale!("launchctl load -w '#{@plist}'", :user => @owner_uid, :group => @owner_gid)
end
end
end
@@ -95,7 +95,7 @@ class Chef
if @new_resource.stop_command
super
else
- shell_out!("launchctl unload '#{@plist}'", :user => @owner_uid, :group => @owner_gid)
+ shell_out_with_systems_locale!("launchctl unload '#{@plist}'", :user => @owner_uid, :group => @owner_gid)
end
end
end
diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb
index 0eb983a0bf..bd51d15f84 100644
--- a/lib/chef/provider/service/simple.rb
+++ b/lib/chef/provider/service/simple.rb
@@ -85,16 +85,16 @@ class Chef
end
def start_service
- shell_out!(@new_resource.start_command)
+ shell_out_with_systems_locale!(@new_resource.start_command)
end
def stop_service
- shell_out!(@new_resource.stop_command)
+ shell_out_with_systems_locale!(@new_resource.stop_command)
end
def restart_service
if @new_resource.restart_command
- shell_out!(@new_resource.restart_command)
+ shell_out_with_systems_locale!(@new_resource.restart_command)
else
stop_service
sleep 1
@@ -103,7 +103,7 @@ class Chef
end
def reload_service
- shell_out!(@new_resource.reload_command)
+ shell_out_with_systems_locale!(@new_resource.reload_command)
end
protected
diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb
index 0c47a3462b..f0584dcf6d 100644
--- a/lib/chef/provider/service/solaris.rb
+++ b/lib/chef/provider/service/solaris.rb
@@ -56,7 +56,7 @@ class Chef
alias_method :start_service, :enable_service
def reload_service
- shell_out!("#{default_init_command} refresh #{@new_resource.service_name}")
+ shell_out_with_systems_locale!("#{default_init_command} refresh #{@new_resource.service_name}")
end
def restart_service
diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb
index 6231603d03..31feee65d4 100644
--- a/lib/chef/provider/service/systemd.rb
+++ b/lib/chef/provider/service/systemd.rb
@@ -28,7 +28,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
if @new_resource.status_command
Chef::Log.debug("#{@new_resource} you have specified a status command, running..")
- unless shell_out_with_systems_locale(@new_resource.status_command).error?
+ unless shell_out(@new_resource.status_command).error?
@current_resource.running(true)
else
@status_check_success = false
@@ -61,7 +61,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
if @new_resource.start_command
super
else
- shell_out_with_systems_locale("/bin/systemctl start #{@new_resource.service_name}")
+ shell_out_with_systems_locale!("/bin/systemctl start #{@new_resource.service_name}")
end
end
end
@@ -73,7 +73,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
if @new_resource.stop_command
super
else
- shell_out_with_systems_locale("/bin/systemctl stop #{@new_resource.service_name}")
+ shell_out_with_systems_locale!("/bin/systemctl stop #{@new_resource.service_name}")
end
end
end
@@ -82,7 +82,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
if @new_resource.restart_command
super
else
- shell_out_with_systems_locale("/bin/systemctl restart #{@new_resource.service_name}")
+ shell_out_with_systems_locale!("/bin/systemctl restart #{@new_resource.service_name}")
end
end
@@ -91,7 +91,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
super
else
if @current_resource.running
- shell_out_with_systems_locale("/bin/systemctl reload #{@new_resource.service_name}")
+ shell_out_with_systems_locale!("/bin/systemctl reload #{@new_resource.service_name}")
else
start_service
end
@@ -99,18 +99,18 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
end
def enable_service
- shell_out_with_systems_locale("/bin/systemctl enable #{@new_resource.service_name}")
+ shell_out!("/bin/systemctl enable #{@new_resource.service_name}")
end
def disable_service
- shell_out_with_systems_locale("/bin/systemctl disable #{@new_resource.service_name}")
+ shell_out!("/bin/systemctl disable #{@new_resource.service_name}")
end
def is_active?
- shell_out_with_systems_locale("/bin/systemctl is-active #{@new_resource.service_name} --quiet").exitstatus == 0
+ shell_out("/bin/systemctl is-active #{@new_resource.service_name} --quiet").exitstatus == 0
end
def is_enabled?
- shell_out_with_systems_locale("/bin/systemctl is-enabled #{@new_resource.service_name} --quiet").exitstatus == 0
+ shell_out("/bin/systemctl is-enabled #{@new_resource.service_name} --quiet").exitstatus == 0
end
end
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index c81a8a50dc..670bf9e5f8 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -97,10 +97,10 @@ class Chef
Chef::Log.debug("#{@new_resource} you have specified a status command, running..")
begin
- if run_command_with_systems_locale(:command => @new_resource.status_command) == 0
+ if shell_out!(@new_resource.status_command) == 0
@current_resource.running true
end
- rescue Chef::Exceptions::Exec
+ rescue
@command_success = false
@current_resource.running false
nil
@@ -153,7 +153,7 @@ class Chef
if @new_resource.start_command
super
else
- run_command_with_systems_locale(:command => "/sbin/start #{@job}")
+ shell_out_with_systems_locale!("/sbin/start #{@job}")
end
end
end
@@ -167,7 +167,7 @@ class Chef
if @new_resource.stop_command
super
else
- run_command_with_systems_locale(:command => "/sbin/stop #{@job}")
+ shell_out_with_systems_locale!("/sbin/stop #{@job}")
end
end
end
@@ -179,7 +179,7 @@ class Chef
# Older versions of upstart would fail on restart if the service was currently stopped, check for that. LP:430883
else
if @current_resource.running
- run_command_with_systems_locale(:command => "/sbin/restart #{@job}")
+ shell_out_with_systems_locale!("/sbin/restart #{@job}")
else
start_service
end
@@ -191,7 +191,7 @@ class Chef
super
else
# upstart >= 0.6.3-4 supports reload (HUP)
- run_command_with_systems_locale(:command => "/sbin/reload #{@job}")
+ shell_out_with_systems_locale!("/sbin/reload #{@job}")
end
end
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index 81ed639c53..6cf31c8ec8 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -60,7 +60,7 @@ class Chef
def action_checkout
if target_dir_non_existent_or_empty?
converge_by("perform checkout of #{@new_resource.repository} into #{@new_resource.destination}") do
- run_command(run_options(:command => checkout_command))
+ shell_out!(run_options(command: checkout_command))
end
else
Chef::Log.debug "#{@new_resource} checkout destination #{@new_resource.destination} already exists or is a non-empty directory - nothing to do"
@@ -77,7 +77,7 @@ class Chef
def action_force_export
converge_by("export #{@new_resource.repository} into #{@new_resource.destination}") do
- run_command(run_options(:command => export_command))
+ shell_out!(run_options(command: export_command))
end
end
@@ -88,7 +88,7 @@ class Chef
Chef::Log.debug "#{@new_resource} current revision: #{current_rev} target revision: #{revision_int}"
unless current_revision_matches_target_revision?
converge_by("sync #{@new_resource.destination} from #{@new_resource.repository}") do
- run_command(run_options(:command => sync_command))
+ shell_out!(run_options(command: sync_command))
Chef::Log.info "#{@new_resource} updated to revision: #{revision_int}"
end
end
@@ -100,14 +100,14 @@ class Chef
def sync_command
c = scm :update, @new_resource.svn_arguments, verbose, authentication, "-r#{revision_int}", @new_resource.destination
Chef::Log.debug "#{@new_resource} updated working copy #{@new_resource.destination} to revision #{@new_resource.revision}"
- c
+ c
end
def checkout_command
c = scm :checkout, @new_resource.svn_arguments, verbose, authentication,
"-r#{revision_int}", @new_resource.repository, @new_resource.destination
Chef::Log.info "#{@new_resource} checked out #{@new_resource.repository} at revision #{@new_resource.revision} to #{@new_resource.destination}"
- c
+ c
end
def export_command
@@ -116,7 +116,7 @@ class Chef
"-r#{revision_int}" << @new_resource.repository << @new_resource.destination
c = scm :export, *args
Chef::Log.info "#{@new_resource} exported #{@new_resource.repository} at revision #{@new_resource.revision} to #{@new_resource.destination}"
- c
+ c
end
# If the specified revision isn't an integer ("HEAD" for example), look
diff --git a/spec/functional/mixin/shell_out_spec.rb b/spec/functional/mixin/shell_out_spec.rb
index 92492fcf6f..35e5b30eae 100644
--- a/spec/functional/mixin/shell_out_spec.rb
+++ b/spec/functional/mixin/shell_out_spec.rb
@@ -29,7 +29,7 @@ describe Chef::Mixin::ShellOut do
shell_out_with_systems_locale('echo $LC_ALL')
end
- cmd.stdout.chomp.should match_environment_variable('LC_ALL')
+ expect(cmd.stdout.chomp).to match_environment_variable('LC_ALL')
end
end
@@ -41,7 +41,7 @@ describe Chef::Mixin::ShellOut do
shell_out_with_systems_locale('echo $LC_ALL', :environment => {'LC_ALL' => 'POSIX'})
end
- cmd.stdout.chomp.should eq 'POSIX'
+ expect(cmd.stdout.chomp).to eq 'POSIX'
end
end
end
diff --git a/spec/functional/resource/deploy_revision_spec.rb b/spec/functional/resource/deploy_revision_spec.rb
index 9ff1391e35..eae422ac1d 100644
--- a/spec/functional/resource/deploy_revision_spec.rb
+++ b/spec/functional/resource/deploy_revision_spec.rb
@@ -59,7 +59,6 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
let(:event_dispatch) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, event_dispatch) }
-
# These tests use git's bundle feature, which is a way to export an entire
# git repo (or subset of commits) as a single file.
#
@@ -799,7 +798,6 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
deploy_to_latest_with_callback_tracking.run_action(:deploy)
end
-
let(:deploy_that_fails) do
resource = deploy_to_latest_rev.dup
errant_callback = lambda {|x| raise Exception, "I am a failed deploy" }
@@ -882,5 +880,3 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
end
end
-
-
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index 1f85ec6bf1..744492a1a9 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -32,7 +32,7 @@ describe Chef::Mixin::ShellOut do
let(:output) { StringIO.new }
let!(:capture_log_output) { Chef::Log.logger = Logger.new(output) }
- let(:assume_deprecation_log_level) { Chef::Log.stub(:level).and_return(:warn) }
+ let(:assume_deprecation_log_level) { allow(Chef::Log).to receive(:level).and_return(:warn) }
context 'without options' do
let(:command_args) { [ cmd ] }
@@ -55,9 +55,9 @@ describe Chef::Mixin::ShellOut do
it 'should emit a deprecation warning' do
assume_deprecation_log_level and capture_log_output
subject
- output.string.should match /DEPRECATION:/
- output.string.should match Regexp.escape(old_option.to_s)
- output.string.should match Regexp.escape(new_option.to_s)
+ expect(output.string).to match /DEPRECATION:/
+ expect(output.string).to match Regexp.escape(old_option.to_s)
+ expect(output.string).to match Regexp.escape(new_option.to_s)
end
end
@@ -106,7 +106,7 @@ describe Chef::Mixin::ShellOut do
end
end
- describe "#shell_out_with_systems_locale" do
+ context "when testing individual methods" do
before(:each) do
@original_env = ENV.to_hash
ENV.clear
@@ -120,82 +120,152 @@ describe Chef::Mixin::ShellOut do
let(:shell_out) { Chef::Mixin::ShellOut }
let(:cmd) { "echo '#{rand(1000)}'" }
- describe "when the last argument is a Hash" do
- describe "and environment is an option" do
- it "should not change environment['LC_ALL'] when set to nil" do
- options = { :environment => { 'LC_ALL' => nil } }
- shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
- shell_out.shell_out_with_systems_locale(cmd, options)
+ 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['LC_ALL'] when set to nil" do
+ options = { :environment => { 'LC_ALL' => nil } }
+ expect(shell_out).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ shell_out.shell_out(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).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ shell_out.shell_out(cmd, options)
+ end
+
+ it "should set environment['LC_ALL'] to 'en_US.UTF-8' when 'LC_ALL' not present" do
+ options = { :environment => { 'HOME' => '/Users/morty' } }
+ expect(shell_out).to receive(:shell_out_command).with(cmd, {
+ :environment => { 'HOME' => '/Users/morty', 'LC_ALL' => 'en_US.UTF-8' },
+ }).and_return(true)
+ shell_out.shell_out(cmd, options)
+ end
+
+ it "should not mutate the options hash when it adds LC_ALL" do
+ options = { :environment => { 'HOME' => '/Users/morty' } }
+ expect(shell_out).to receive(:shell_out_command).with(cmd, {
+ :environment => { 'HOME' => '/Users/morty', 'LC_ALL' => 'en_US.UTF-8' },
+ }).and_return(true)
+ shell_out.shell_out(cmd, options)
+ expect(options[:environment].has_key?('LC_ALL')).to be false
+ end
end
- it "should not change environment['LC_ALL'] when set to non-nil" do
- options = { :environment => { 'LC_ALL' => 'en_US.UTF-8' } }
- shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
- shell_out.shell_out_with_systems_locale(cmd, options)
+ 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).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ shell_out.shell_out(cmd, options)
+ end
+
+ it "should not change env when set to non-nil" do
+ options = { :env => { 'LC_ALL' => 'de_DE.UTF-8'}}
+ expect(shell_out).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ shell_out.shell_out(cmd, options)
+ end
+
+ it "should set env['LC_ALL'] to 'en_US.UTF-8' when 'LC_ALL' not present" do
+ options = { :env => { 'HOME' => '/Users/morty' } }
+ expect(shell_out).to receive(:shell_out_command).with(cmd, {
+ :env => { 'HOME' => '/Users/morty', 'LC_ALL' => 'en_US.UTF-8' },
+ }).and_return(true)
+ shell_out.shell_out(cmd, options)
+ end
+
+ it "should not mutate the options hash when it adds LC_ALL" do
+ options = { :env => { 'HOME' => '/Users/morty' } }
+ expect(shell_out).to receive(:shell_out_command).with(cmd, {
+ :env => { 'HOME' => '/Users/morty', 'LC_ALL' => 'en_US.UTF-8' },
+ }).and_return(true)
+ shell_out.shell_out(cmd, options)
+ expect(options[:env].has_key?('LC_ALL')).to be false
+ end
end
- it "should set environment['LC_ALL'] to nil when 'LC_ALL' not present" do
- options = { :environment => { 'HOME' => '/Users/morty' } }
- shell_out.should_receive(:shell_out).with(
- cmd,
- { :environment => {
- 'HOME' => '/Users/morty',
- 'LC_ALL' => nil }
- }
- ).and_return(true)
- shell_out.shell_out_with_systems_locale(cmd, options)
+ describe "and no env/environment option is present" do
+ it "should add environment option and set environment['LC_ALL'] to 'en_US.UTF_8'" do
+ options = { :user => 'morty' }
+ expect(shell_out).to receive(:shell_out_command).with(cmd, {
+ :user => 'morty', :environment => { 'LC_ALL' => 'en_US.UTF-8' },
+ }).and_return(true)
+ shell_out.shell_out(cmd, options)
+ end
end
end
- describe "and env is an option" do
- it "should not change env when set to nil" do
- options = { :env => { 'LC_ALL' => nil } }
- shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
- shell_out.shell_out_with_systems_locale(cmd, options)
+ describe "when the last argument is not a Hash" do
+ it "should add environment options and set environment['LC_ALL'] to 'en_US.UTF-8'" do
+ expect(shell_out).to receive(:shell_out_command).with(cmd, {
+ :environment => { 'LC_ALL' => 'en_US.UTF-8' },
+ }).and_return(true)
+ shell_out.shell_out(cmd)
end
+ end
+
+ end
- it "should not change env when set to non-nil" do
- options = { :env => { 'LC_ALL' => 'en_US.UTF-8'}}
- shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
- shell_out.shell_out_with_systems_locale(cmd, options)
+ describe "#shell_out_with_systems_locale" do
+
+ describe "when the last argument is a Hash" do
+ describe "and environment is an option" do
+ it "should not change environment['LC_ALL'] when set to nil" do
+ options = { :environment => { 'LC_ALL' => nil } }
+ expect(shell_out).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ shell_out.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).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ shell_out.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).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ shell_out.shell_out_with_systems_locale(cmd, options)
+ end
end
- it "should set env['LC_ALL'] to nil when 'LC_ALL' not present" do
- options = { :env => { 'HOME' => '/Users/morty' } }
- shell_out.should_receive(:shell_out).with(
- cmd,
- { :env => {
- 'HOME' => '/Users/morty',
- 'LC_ALL' => nil }
- }
- ).and_return(true)
- shell_out.shell_out_with_systems_locale(cmd, options)
+ 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).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ shell_out.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).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ shell_out.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).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ shell_out.shell_out_with_systems_locale(cmd, options)
+ end
end
- end
- describe "and no env/environment option is present" do
- it "should add environment option and set environment['LC_ALL'] to nil" do
- options = { :user => 'morty' }
- shell_out.should_receive(:shell_out).with(
- cmd,
- { :environment => { 'LC_ALL' => nil },
- :user => 'morty'
- }
- ).and_return(true)
- shell_out.shell_out_with_systems_locale(cmd, options)
+ 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).to receive(:shell_out_command).with(cmd, options).and_return(true)
+ shell_out.shell_out_with_systems_locale(cmd, options)
+ end
end
end
- end
- describe "when the last argument is not a Hash" do
- it "should add environment options and set environment['LC_ALL'] to nil" do
- shell_out.should_receive(:shell_out).with(
- cmd,
- { :environment => { 'LC_ALL' => nil } }
- ).and_return(true)
- shell_out.shell_out_with_systems_locale(cmd)
+ 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).to receive(:shell_out_command).with(cmd).and_return(true)
+ shell_out.shell_out_with_systems_locale(cmd)
+ end
end
end
- end
+ end
end
diff --git a/spec/unit/provider/package/aix_spec.rb b/spec/unit/provider/package/aix_spec.rb
index 35f85b628f..5d6e23302f 100644
--- a/spec/unit/provider/package/aix_spec.rb
+++ b/spec/unit/provider/package/aix_spec.rb
@@ -59,7 +59,6 @@ describe Chef::Provider::Package::Aix do
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Package)
end
-
it "should get the source package version from lslpp if provided" do
@stdout = StringIO.new(@bffinfo)
@stdin, @stderr = StringIO.new, StringIO.new
@@ -125,9 +124,7 @@ describe Chef::Provider::Package::Aix do
describe "install and upgrade" do
it "should run installp -aYF -d with the package source to install" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "installp -aYF -d /tmp/samba.base samba.base"
- })
+ @provider.should_receive(:shell_out!).with("installp -aYF -d /tmp/samba.base samba.base")
@provider.install_package("samba.base", "3.3.12.0")
end
@@ -135,37 +132,28 @@ describe Chef::Provider::Package::Aix do
@new_resource = Chef::Resource::Package.new("/tmp/samba.base")
@provider = Chef::Provider::Package::Aix.new(@new_resource, @run_context)
@new_resource.source.should == "/tmp/samba.base"
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "installp -aYF -d /tmp/samba.base /tmp/samba.base"
- })
+ @provider.should_receive(:shell_out!).with("installp -aYF -d /tmp/samba.base /tmp/samba.base")
@provider.install_package("/tmp/samba.base", "3.3.12.0")
end
it "should run installp with -eLogfile option." do
@new_resource.stub(:options).and_return("-e/tmp/installp.log")
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "installp -aYF -e/tmp/installp.log -d /tmp/samba.base samba.base"
- })
+ @provider.should_receive(:shell_out!).with("installp -aYF -e/tmp/installp.log -d /tmp/samba.base samba.base")
@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
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "installp -u samba.base"
- })
+ @provider.should_receive(:shell_out!).with("installp -u samba.base")
@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.stub(:options).and_return("-e/tmp/installp.log")
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "installp -u -e/tmp/installp.log samba.base"
- })
+ @provider.should_receive(:shell_out!).with("installp -u -e/tmp/installp.log samba.base")
@provider.remove_package("samba.base", "3.3.12.0")
end
end
end
-
diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb
index c5941c2a91..07bca7f6d5 100644
--- a/spec/unit/provider/package/ips_spec.rb
+++ b/spec/unit/provider/package/ips_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Provider::Package::Ips do
pkg: info: no packages matching the following patterns you specified are
installed on the system. Try specifying -r to query remotely:
- crypto/gnupg
+ crypto/gnupg
PKG_STATUS
return OpenStruct.new(:stdout => stdout,:stdin => stdin,:stderr => stderr,:status => @status,:exitstatus => 1)
end
@@ -59,7 +59,7 @@ Packaging Date: April 1, 2012 05:55:52 PM
FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z
PKG_STATUS
stdin = StringIO.new
- stderr = ''
+ stderr = ''
return OpenStruct.new(:stdout => stdout,:stdin => stdin,:stderr => stderr,:status => @status,:exitstatus => 0)
end
@@ -123,17 +123,12 @@ INSTALLED
context "when installing a package" do
it "should run pkg install with the package name and version" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pkg install -q crypto/gnupg@2.0.17"
- })
+ @provider.should_receive(:shell_out).with("pkg install -q crypto/gnupg@2.0.17")
@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
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pkg --no-refresh install -q crypto/gnupg@2.0.17"
- })
+ @provider.should_receive(:shell_out).with("pkg --no-refresh install -q crypto/gnupg@2.0.17")
@new_resource.stub(:options).and_return("--no-refresh")
@provider.install_package("crypto/gnupg", "2.0.17")
end
@@ -206,9 +201,7 @@ REMOTE
end
it "should run pkg install with the --accept flag" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pkg install -q --accept crypto/gnupg@2.0.17"
- })
+ @provider.should_receive(:shell_out).with("pkg install -q --accept crypto/gnupg@2.0.17")
@provider.install_package("crypto/gnupg", "2.0.17")
end
end
@@ -216,25 +209,19 @@ REMOTE
context "when upgrading a package" do
it "should run pkg install with the package name and version" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pkg install -q crypto/gnupg@2.0.17"
- })
+ @provider.should_receive(:shell_out).with("pkg install -q crypto/gnupg@2.0.17")
@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
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pkg uninstall -q crypto/gnupg@2.0.17"
- })
+ @provider.should_receive(:shell_out!).with("pkg uninstall -q crypto/gnupg@2.0.17")
@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
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pkg --no-refresh uninstall -q crypto/gnupg@2.0.17"
- })
+ @provider.should_receive(:shell_out!).with("pkg --no-refresh uninstall -q crypto/gnupg@2.0.17")
@new_resource.stub(:options).and_return("--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 9ebf23860d..535a5d2459 100644
--- a/spec/unit/provider/package/macports_spec.rb
+++ b/spec/unit/provider/package/macports_spec.rb
@@ -105,7 +105,7 @@ EOF
it "should run the port install command with the correct version" do
@current_resource.should_receive(:version).and_return("4.1.6")
@provider.current_resource = @current_resource
- @provider.should_receive(:run_command_with_systems_locale).with(:command => "port install zsh @4.2.7")
+ @provider.should_receive(:shell_out!).with("port install zsh @4.2.7")
@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
@current_resource.should_receive(:version).and_return("4.2.7")
@provider.current_resource = @current_resource
- @provider.should_not_receive(:run_command_with_systems_locale)
+ @provider.should_not_receive(:shell_out!)
@provider.install_package("zsh", "4.2.7")
end
@@ -122,7 +122,7 @@ EOF
@current_resource.should_receive(:version).and_return("4.1.6")
@provider.current_resource = @current_resource
@new_resource.stub(:options).and_return("-f")
- @provider.should_receive(:run_command_with_systems_locale).with(:command => "port -f install zsh @4.2.7")
+ @provider.should_receive(:shell_out!).with("port -f install zsh @4.2.7")
@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
- @provider.should_receive(:run_command_with_systems_locale).with(:command => "port uninstall zsh @4.2.7")
+ @provider.should_receive(:shell_out!).with("port uninstall zsh @4.2.7")
@provider.purge_package("zsh", "4.2.7")
end
it "should purge the currently active version if no explicit version is passed in" do
- @provider.should_receive(:run_command_with_systems_locale).with(:command => "port uninstall zsh")
+ @provider.should_receive(:shell_out!).with("port uninstall zsh")
@provider.purge_package("zsh", nil)
end
it "should add options to the port command when specified" do
@new_resource.stub(:options).and_return("-f")
- @provider.should_receive(:run_command_with_systems_locale).with(:command => "port -f uninstall zsh @4.2.7")
+ @provider.should_receive(:shell_out!).with("port -f uninstall zsh @4.2.7")
@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
- @provider.should_receive(:run_command_with_systems_locale).with(:command => "port deactivate zsh @4.2.7")
+ @provider.should_receive(:shell_out!).with("port deactivate zsh @4.2.7")
@provider.remove_package("zsh", "4.2.7")
end
it "should remove the currently active version if no explicit version is passed in" do
- @provider.should_receive(:run_command_with_systems_locale).with(:command => "port deactivate zsh")
+ @provider.should_receive(:shell_out!).with("port deactivate zsh")
@provider.remove_package("zsh", nil)
end
it "should add options to the port command when specified" do
@new_resource.stub(:options).and_return("-f")
- @provider.should_receive(:run_command_with_systems_locale).with(:command => "port -f deactivate zsh @4.2.7")
+ @provider.should_receive(:shell_out!).with("port -f deactivate zsh @4.2.7")
@provider.remove_package("zsh", "4.2.7")
end
end
@@ -169,7 +169,7 @@ EOF
@current_resource.should_receive(:version).at_least(:once).and_return("4.1.6")
@provider.current_resource = @current_resource
- @provider.should_receive(:run_command_with_systems_locale).with(:command => "port upgrade zsh @4.2.7")
+ @provider.should_receive(:shell_out!).with("port upgrade zsh @4.2.7")
@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
@current_resource.should_receive(:version).at_least(:once).and_return("4.2.7")
@provider.current_resource = @current_resource
- @provider.should_not_receive(:run_command_with_systems_locale)
+ @provider.should_not_receive(:shell_out!)
@provider.upgrade_package("zsh", "4.2.7")
end
@@ -195,7 +195,7 @@ EOF
@current_resource.should_receive(:version).at_least(:once).and_return("4.1.6")
@provider.current_resource = @current_resource
- @provider.should_receive(:run_command_with_systems_locale).with(:command => "port -f upgrade zsh @4.2.7")
+ @provider.should_receive(:shell_out!).with("port -f upgrade zsh @4.2.7")
@provider.upgrade_package("zsh", "4.2.7")
end
diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb
index 528f7097e8..0c1c487980 100644
--- a/spec/unit/provider/package/pacman_spec.rb
+++ b/spec/unit/provider/package/pacman_spec.rb
@@ -155,16 +155,12 @@ PACMAN_CONF
describe Chef::Provider::Package::Pacman, "install_package" do
it "should run pacman install with the package name and version" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pacman --sync --noconfirm --noprogressbar nano"
- })
+ @provider.should_receive(:shell_out!).with("pacman --sync --noconfirm --noprogressbar nano")
@provider.install_package("nano", "1.0")
end
it "should run pacman install with the package name and version and options if specified" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pacman --sync --noconfirm --noprogressbar --debug nano"
- })
+ @provider.should_receive(:shell_out!).with("pacman --sync --noconfirm --noprogressbar --debug nano")
@new_resource.stub(:options).and_return("--debug")
@provider.install_package("nano", "1.0")
@@ -180,16 +176,12 @@ PACMAN_CONF
describe Chef::Provider::Package::Pacman, "remove_package" do
it "should run pacman remove with the package name" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pacman --remove --noconfirm --noprogressbar nano"
- })
+ @provider.should_receive(:shell_out!).with("pacman --remove --noconfirm --noprogressbar nano")
@provider.remove_package("nano", "1.0")
end
it "should run pacman remove with the package name and options if specified" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pacman --remove --noconfirm --noprogressbar --debug nano"
- })
+ @provider.should_receive(:shell_out!).with("pacman --remove --noconfirm --noprogressbar --debug nano")
@new_resource.stub(:options).and_return("--debug")
@provider.remove_package("nano", "1.0")
diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb
index 6f22952da2..570f123168 100644
--- a/spec/unit/provider/package/portage_spec.rb
+++ b/spec/unit/provider/package/portage_spec.rb
@@ -278,23 +278,17 @@ EOF
describe Chef::Provider::Package::Portage, "install_package" do
it "should install a normally versioned package using portage" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "emerge -g --color n --nospinner --quiet =dev-util/git-1.0.0"
- })
+ @provider.should_receive(:shell_out!).with("emerge -g --color n --nospinner --quiet =dev-util/git-1.0.0")
@provider.install_package("dev-util/git", "1.0.0")
end
it "should install a tilde versioned package using portage" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "emerge -g --color n --nospinner --quiet ~dev-util/git-1.0.0"
- })
+ @provider.should_receive(:shell_out!).with("emerge -g --color n --nospinner --quiet ~dev-util/git-1.0.0")
@provider.install_package("dev-util/git", "~1.0.0")
end
it "should add options to the emerge command when specified" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "emerge -g --color n --nospinner --quiet --oneshot =dev-util/git-1.0.0"
- })
+ @provider.should_receive(:shell_out!).with("emerge -g --color n --nospinner --quiet --oneshot =dev-util/git-1.0.0")
@new_resource.stub(:options).and_return("--oneshot")
@provider.install_package("dev-util/git", "1.0.0")
@@ -303,16 +297,12 @@ EOF
describe Chef::Provider::Package::Portage, "remove_package" do
it "should un-emerge the package with no version specified" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "emerge --unmerge --color n --nospinner --quiet dev-util/git"
- })
+ @provider.should_receive(:shell_out!).with("emerge --unmerge --color n --nospinner --quiet dev-util/git")
@provider.remove_package("dev-util/git", nil)
end
it "should un-emerge the package with a version specified" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "emerge --unmerge --color n --nospinner --quiet =dev-util/git-1.0.0"
- })
+ @provider.should_receive(:shell_out!).with("emerge --unmerge --color n --nospinner --quiet =dev-util/git-1.0.0")
@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 6e46cf5e98..9a96d829b8 100644
--- a/spec/unit/provider/package/rpm_spec.rb
+++ b/spec/unit/provider/package/rpm_spec.rb
@@ -102,25 +102,19 @@ describe Chef::Provider::Package::Rpm do
describe "when installing or upgrading" do
it "should run rpm -i with the package source to install" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
- })
+ @provider.should_receive(:shell_out!).with("rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
@provider.install_package("ImageMagick-c++", "6.5.4.7-7.el6_5")
end
it "should run rpm -U with the package source to upgrade" do
@current_resource.version("21.4-19.el5")
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
- })
+ @provider.should_receive(:shell_out!).with("rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
@provider.upgrade_package("ImageMagick-c++", "6.5.4.7-7.el6_5")
end
it "should install package if missing and set to upgrade" do
@current_resource.version("ImageMagick-c++")
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
- })
+ @provider.should_receive(:shell_out!).with("rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
@provider.upgrade_package("ImageMagick-c++", "6.5.4.7-7.el6_5")
end
@@ -130,9 +124,7 @@ describe Chef::Provider::Package::Rpm do
@new_resource.source.should == "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
@current_resource = Chef::Resource::Package.new("ImageMagick-c++")
@provider.current_resource = @current_resource
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
- })
+ @provider.should_receive(:shell_out!).with("rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
@provider.install_package("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", "6.5.4.7-7.el6_5")
end
@@ -143,30 +135,23 @@ describe Chef::Provider::Package::Rpm do
@current_resource = Chef::Resource::Package.new("ImageMagick-c++")
@current_resource.version("21.4-19.el5")
@provider.current_resource = @current_resource
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
- })
+ @provider.should_receive(:shell_out!).with("rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
@provider.upgrade_package("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", "6.5.4.7-7.el6_5")
end
it "installs with custom options specified in the resource" do
@provider.candidate_version = '11'
@new_resource.options("--dbpath /var/lib/rpm")
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "rpm --dbpath /var/lib/rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
- })
+ @provider.should_receive(:shell_out!).with("rpm --dbpath /var/lib/rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
@provider.install_package(@new_resource.name, @provider.candidate_version)
end
end
describe "when removing the package" do
it "should run rpm -e to remove the package" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "rpm -e ImageMagick-c++-6.5.4.7-7.el6_5"
- })
+ @provider.should_receive(:shell_out!).with("rpm -e ImageMagick-c++-6.5.4.7-7.el6_5")
@provider.remove_package("ImageMagick-c++", "6.5.4.7-7.el6_5")
end
end
end
end
-
diff --git a/spec/unit/provider/package/solaris_spec.rb b/spec/unit/provider/package/solaris_spec.rb
index 086e327cce..d83ccbdf06 100644
--- a/spec/unit/provider/package/solaris_spec.rb
+++ b/spec/unit/provider/package/solaris_spec.rb
@@ -69,7 +69,6 @@ PKGINFO
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Package)
end
-
it "should get the source package version from pkginfo if provided" do
@stdout = StringIO.new(@pkginfo)
@stdin, @stderr = StringIO.new, StringIO.new
@@ -136,9 +135,7 @@ PKGINFO
describe "install and upgrade" do
it "should run pkgadd -n -d with the package source to install" do
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pkgadd -n -d /tmp/bash.pkg all"
- })
+ @provider.should_receive(:shell_out!).with("pkgadd -n -d /tmp/bash.pkg all")
@provider.install_package("SUNWbash", "11.10.0,REV=2005.01.08.05.16")
end
@@ -146,34 +143,26 @@ PKGINFO
@new_resource = Chef::Resource::Package.new("/tmp/bash.pkg")
@provider = Chef::Provider::Package::Solaris.new(@new_resource, @run_context)
@new_resource.source.should == "/tmp/bash.pkg"
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pkgadd -n -d /tmp/bash.pkg all"
- })
+ @provider.should_receive(:shell_out!).with("pkgadd -n -d /tmp/bash.pkg all")
@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.stub(:options).and_return("-a /tmp/myadmin")
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pkgadd -n -a /tmp/myadmin -d /tmp/bash.pkg all"
- })
+ @provider.should_receive(:shell_out!).with("pkgadd -n -a /tmp/myadmin -d /tmp/bash.pkg all")
@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
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pkgrm -n SUNWbash"
- })
+ @provider.should_receive(:shell_out!).with("pkgrm -n SUNWbash")
@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.stub(:options).and_return("-a /tmp/myadmin")
- @provider.should_receive(:run_command_with_systems_locale).with({
- :command => "pkgrm -n -a /tmp/myadmin SUNWbash"
- })
+ @provider.should_receive(:shell_out!).with("pkgrm -n -a /tmp/myadmin SUNWbash")
@provider.remove_package("SUNWbash", "11.10.0,REV=2005.01.08.05.16")
end
diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb
index b267915e44..38ed74cdee 100644
--- a/spec/unit/provider/service/arch_service_spec.rb
+++ b/spec/unit/provider/service/arch_service_spec.rb
@@ -20,7 +20,6 @@
require 'spec_helper'
require 'ostruct'
-
# most of this code has been ripped from init_service_spec.rb
# and is only slightly modified to match "arch" needs.
@@ -36,7 +35,6 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
@new_resource.pattern("chef")
@new_resource.supports({:status => false})
-
@provider = Chef::Provider::Service::Arch.new(@new_resource, @run_context)
::File.stub(:exists?).with("/etc/rc.conf").and_return(true)
@@ -51,7 +49,6 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
end
end
-
describe "when the service supports status" do
before do
@new_resource.supports({:status => true})
@@ -82,7 +79,6 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
end
-
describe "when a status command has been specified" do
before do
@new_resource.status_command("/etc/rc.d/chefhasmonkeypants status")
@@ -109,7 +105,6 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
end
-
it "should fail if file /etc/rc.conf does not exist" do
::File.stub(:exists?).with("/etc/rc.conf").and_return(false)
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Service)
@@ -211,7 +206,6 @@ RUNNING_PS
end
end
-
describe Chef::Provider::Service::Arch, "start_service" do
# before(:each) do
# @new_resource = double("Chef::Resource::Service",
@@ -228,12 +222,12 @@ RUNNING_PS
it "should call the start command if one is specified" do
@new_resource.stub(:start_command).and_return("/etc/rc.d/chef startyousillysally")
- @provider.should_receive(:shell_out!).with("/etc/rc.d/chef startyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/chef startyousillysally")
@provider.start_service()
end
it "should call '/etc/rc.d/service_name start' if no start command is specified" do
- @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} start")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} start")
@provider.start_service()
end
end
@@ -254,12 +248,12 @@ RUNNING_PS
it "should call the stop command if one is specified" do
@new_resource.stub(:stop_command).and_return("/etc/rc.d/chef itoldyoutostop")
- @provider.should_receive(:shell_out!).with("/etc/rc.d/chef itoldyoutostop")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/chef itoldyoutostop")
@provider.stop_service()
end
it "should call '/etc/rc.d/service_name stop' if no stop command is specified" do
- @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} stop")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} stop")
@provider.stop_service()
end
end
@@ -281,13 +275,13 @@ RUNNING_PS
it "should call 'restart' on the service_name if the resource supports it" do
@new_resource.stub(:supports).and_return({:restart => true})
- @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restart")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} restart")
@provider.restart_service()
end
it "should call the restart_command if one has been specified" do
@new_resource.stub(:restart_command).and_return("/etc/rc.d/chef restartinafire")
- @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restartinafire")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} restartinafire")
@provider.restart_service()
end
@@ -316,13 +310,13 @@ RUNNING_PS
it "should call 'reload' on the service if it supports it" do
@new_resource.stub(:supports).and_return({:reload => true})
- @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} reload")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} reload")
@provider.reload_service()
end
it "should should run the user specified reload command if one is specified and the service doesn't support reload" do
@new_resource.stub(:reload_command).and_return("/etc/rc.d/chef lollerpants")
- @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} lollerpants")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} lollerpants")
@provider.reload_service()
end
end
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index 567eb6744a..3e60857cbf 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -301,7 +301,7 @@ insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop
def expect_commands(provider, commands)
commands.each do |command|
- provider.should_receive(:run_command).with({:command => command})
+ provider.should_receive(:shell_out!).with(command)
end
end
diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb
index 6e58e82b97..eb55fac820 100644
--- a/spec/unit/provider/service/freebsd_service_spec.rb
+++ b/spec/unit/provider/service/freebsd_service_spec.rb
@@ -452,12 +452,12 @@ EOF
describe Chef::Provider::Service::Freebsd, "start_service" do
it "should call the start command if one is specified" do
new_resource.start_command("/etc/rc.d/chef startyousillysally")
- expect(provider).to receive(:shell_out!).with("/etc/rc.d/chef startyousillysally")
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/chef startyousillysally")
provider.start_service()
end
it "should call '/usr/local/etc/rc.d/service_name faststart' if no start command is specified" do
- expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststart")
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststart")
provider.start_service()
end
end
@@ -465,12 +465,12 @@ EOF
describe Chef::Provider::Service::Freebsd, "stop_service" do
it "should call the stop command if one is specified" do
new_resource.stop_command("/etc/init.d/chef itoldyoutostop")
- expect(provider).to receive(:shell_out!).with("/etc/init.d/chef itoldyoutostop")
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef itoldyoutostop")
provider.stop_service()
end
it "should call '/usr/local/etc/rc.d/service_name faststop' if no stop command is specified" do
- expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststop")
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststop")
provider.stop_service()
end
end
@@ -478,13 +478,13 @@ EOF
describe Chef::Provider::Service::Freebsd, "restart_service" do
it "should call 'restart' on the service_name if the resource supports it" do
new_resource.supports({:restart => true})
- expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart")
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart")
provider.restart_service()
end
it "should call the restart_command if one has been specified" do
new_resource.restart_command("/etc/init.d/chef restartinafire")
- expect(provider).to receive(:shell_out!).with("/etc/init.d/chef restartinafire")
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef restartinafire")
provider.restart_service()
end
diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb
index 95dc04108d..022a73cc9a 100644
--- a/spec/unit/provider/service/gentoo_service_spec.rb
+++ b/spec/unit/provider/service/gentoo_service_spec.rb
@@ -128,14 +128,14 @@ describe Chef::Provider::Service::Gentoo do
describe Chef::Provider::Service::Gentoo, "enable_service" do
it "should call rc-update add *service* default" do
- @provider.should_receive(:run_command).with({:command => "/sbin/rc-update add chef default"})
+ @provider.should_receive(:shell_out!).with("/sbin/rc-update add chef default")
@provider.enable_service()
end
end
describe Chef::Provider::Service::Gentoo, "disable_service" do
it "should call rc-update del *service* default" do
- @provider.should_receive(:run_command).with({:command => "/sbin/rc-update del chef default"})
+ @provider.should_receive(:shell_out!).with("/sbin/rc-update del chef default")
@provider.disable_service()
end
end
diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb
index ad887c84a5..b523f6d3a9 100644
--- a/spec/unit/provider/service/init_service_spec.rb
+++ b/spec/unit/provider/service/init_service_spec.rb
@@ -100,7 +100,7 @@ PS
end
it "should use the init_command if one has been specified" do
- @provider.should_receive(:shell_out!).with("/opt/chef-server/service/erchef start")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/opt/chef-server/service/erchef start")
@provider.start_service
end
@@ -126,7 +126,6 @@ PS
end
-
describe "when we have a 'ps' attribute" do
it "should shell_out! the node's ps command" do
@provider.should_receive(:shell_out!).and_return(@status)
@@ -165,12 +164,12 @@ RUNNING_PS
describe "when starting the service" do
it "should call the start command if one is specified" do
@new_resource.start_command("/etc/init.d/chef startyousillysally")
- @provider.should_receive(:shell_out!).with("/etc/init.d/chef startyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef startyousillysally")
@provider.start_service()
end
it "should call '/etc/init.d/service_name start' if no start command is specified" do
- @provider.should_receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} start")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/#{@new_resource.service_name} start")
@provider.start_service()
end
end
@@ -178,12 +177,12 @@ RUNNING_PS
describe Chef::Provider::Service::Init, "stop_service" do
it "should call the stop command if one is specified" do
@new_resource.stop_command("/etc/init.d/chef itoldyoutostop")
- @provider.should_receive(:shell_out!).with("/etc/init.d/chef itoldyoutostop")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef itoldyoutostop")
@provider.stop_service()
end
it "should call '/etc/init.d/service_name stop' if no stop command is specified" do
- @provider.should_receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} stop")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/#{@new_resource.service_name} stop")
@provider.stop_service()
end
end
@@ -191,13 +190,13 @@ RUNNING_PS
describe "when restarting a service" do
it "should call 'restart' on the service_name if the resource supports it" do
@new_resource.supports({:restart => true})
- @provider.should_receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} restart")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/#{@new_resource.service_name} restart")
@provider.restart_service()
end
it "should call the restart_command if one has been specified" do
@new_resource.restart_command("/etc/init.d/chef restartinafire")
- @provider.should_receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} restartinafire")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/#{@new_resource.service_name} restartinafire")
@provider.restart_service()
end
@@ -212,13 +211,13 @@ RUNNING_PS
describe "when reloading a service" do
it "should call 'reload' on the service if it supports it" do
@new_resource.supports({:reload => true})
- @provider.should_receive(:shell_out!).with("/etc/init.d/chef reload")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef reload")
@provider.reload_service()
end
it "should should run the user specified reload command if one is specified and the service doesn't support reload" do
@new_resource.reload_command("/etc/init.d/chef lollerpants")
- @provider.should_receive(:shell_out!).with("/etc/init.d/chef lollerpants")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef lollerpants")
@provider.reload_service()
end
end
@@ -226,6 +225,7 @@ RUNNING_PS
describe "when a custom command has been specified" do
before do
@new_resource.start_command("/etc/init.d/chef startyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef startyousillysally")
end
it "should still pass all why run assertions" do
diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb
index 04e63458a0..9ed03b519f 100644
--- a/spec/unit/provider/service/insserv_service_spec.rb
+++ b/spec/unit/provider/service/insserv_service_spec.rb
@@ -60,17 +60,16 @@ describe Chef::Provider::Service::Insserv do
describe "enable_service" do
it "should call insserv and create the default links" do
- @provider.should_receive(:run_command).with({:command=>"/sbin/insserv -r -f #{@new_resource.service_name}"})
- @provider.should_receive(:run_command).with({:command=>"/sbin/insserv -d -f #{@new_resource.service_name}"})
+ @provider.should_receive(:shell_out!).with("/sbin/insserv -r -f #{@new_resource.service_name}")
+ @provider.should_receive(:shell_out!).with("/sbin/insserv -d -f #{@new_resource.service_name}")
@provider.enable_service
end
end
describe "disable_service" do
it "should call insserv and remove the links" do
- @provider.should_receive(:run_command).with({:command=>"/sbin/insserv -r -f #{@new_resource.service_name}"})
+ @provider.should_receive(:shell_out!).with("/sbin/insserv -r -f #{@new_resource.service_name}")
@provider.disable_service
end
end
end
-
diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb
index b638b08b72..d8a9851837 100644
--- a/spec/unit/provider/service/invokercd_service_spec.rb
+++ b/spec/unit/provider/service/invokercd_service_spec.rb
@@ -110,7 +110,6 @@ PS
end
-
describe "when we have a 'ps' attribute" do
it "should shell_out! the node's ps command" do
@status = double("Status", :exitstatus => 0, :stdout => @stdout)
@@ -152,12 +151,12 @@ RUNNING_PS
describe "when starting the service" do
it "should call the start command if one is specified" do
@new_resource.start_command("/usr/sbin/invoke-rc.d chef startyousillysally")
- @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef startyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d chef startyousillysally")
@provider.start_service()
end
it "should call '/usr/sbin/invoke-rc.d service_name start' if no start command is specified" do
- @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} start")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} start")
@provider.start_service()
end
end
@@ -165,12 +164,12 @@ RUNNING_PS
describe Chef::Provider::Service::Invokercd, "stop_service" do
it "should call the stop command if one is specified" do
@new_resource.stop_command("/usr/sbin/invoke-rc.d chef itoldyoutostop")
- @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef itoldyoutostop")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d chef itoldyoutostop")
@provider.stop_service()
end
it "should call '/usr/sbin/invoke-rc.d service_name stop' if no stop command is specified" do
- @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} stop")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} stop")
@provider.stop_service()
end
end
@@ -178,13 +177,13 @@ RUNNING_PS
describe "when restarting a service" do
it "should call 'restart' on the service_name if the resource supports it" do
@new_resource.supports({:restart => true})
- @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restart")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restart")
@provider.restart_service()
end
it "should call the restart_command if one has been specified" do
@new_resource.restart_command("/usr/sbin/invoke-rc.d chef restartinafire")
- @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restartinafire")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restartinafire")
@provider.restart_service()
end
@@ -199,13 +198,13 @@ RUNNING_PS
describe "when reloading a service" do
it "should call 'reload' on the service if it supports it" do
@new_resource.supports({:reload => true})
- @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef reload")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d chef reload")
@provider.reload_service()
end
it "should should run the user specified reload command if one is specified and the service doesn't support reload" do
@new_resource.reload_command("/usr/sbin/invoke-rc.d chef lollerpants")
- @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef lollerpants")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d chef lollerpants")
@provider.reload_service()
end
end
diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb
index 1202d80873..c5df1e0637 100644
--- a/spec/unit/provider/service/macosx_spec.rb
+++ b/spec/unit/provider/service/macosx_spec.rb
@@ -226,7 +226,7 @@ SVC_LIST
it "calls the start command if one is specified and service is not running" do
new_resource.stub(:start_command).and_return("cowsay dirty")
- provider.should_receive(:shell_out!).with("cowsay dirty")
+ provider.should_receive(:shell_out_with_systems_locale!).with("cowsay dirty")
provider.start_service
end
@@ -238,7 +238,7 @@ SVC_LIST
end
it "starts service via launchctl if service found" do
- provider.should_receive(:shell_out!).
+ provider.should_receive(:shell_out_with_systems_locale!).
with("launchctl load -w '/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist'",
:group => 1001, :user => 101).
and_return(0)
@@ -258,7 +258,7 @@ SVC_LIST
it "calls the stop command if one is specified and service is running" do
new_resource.stub(:stop_command).and_return("kill -9 123")
- provider.should_receive(:shell_out!).with("kill -9 123")
+ provider.should_receive(:shell_out_with_systems_locale!).with("kill -9 123")
provider.stop_service
end
@@ -270,7 +270,7 @@ SVC_LIST
end
it "stops the service via launchctl if service found" do
- provider.should_receive(:shell_out!).
+ provider.should_receive(:shell_out_with_systems_locale!).
with("launchctl unload '/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist'",
:group => 1001, :user => 101).
and_return(0)
@@ -291,7 +291,7 @@ SVC_LIST
it "issues a command if given" do
new_resource.stub(:restart_command).and_return("reload that thing")
- provider.should_receive(:shell_out!).with("reload that thing")
+ provider.should_receive(:shell_out_with_systems_locale!).with("reload that thing")
provider.restart_service
end
diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb
index 61fb30fe13..11ebf74725 100644
--- a/spec/unit/provider/service/simple_service_spec.rb
+++ b/spec/unit/provider/service/simple_service_spec.rb
@@ -107,7 +107,7 @@ NOMOCKINGSTRINGSPLZ
describe "when starting the service" do
it "should call the start command if one is specified" do
@new_resource.stub(:start_command).and_return("#{@new_resource.start_command}")
- @provider.should_receive(:shell_out!).with("#{@new_resource.start_command}")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("#{@new_resource.start_command}")
@provider.start_service()
end
@@ -121,7 +121,7 @@ NOMOCKINGSTRINGSPLZ
describe "when stopping a service" do
it "should call the stop command if one is specified" do
@new_resource.stop_command("/etc/init.d/themadness stop")
- @provider.should_receive(:shell_out!).with("/etc/init.d/themadness stop")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/themadness stop")
@provider.stop_service()
end
@@ -135,7 +135,7 @@ NOMOCKINGSTRINGSPLZ
describe Chef::Provider::Service::Simple, "restart_service" do
it "should call the restart command if one has been specified" do
@new_resource.restart_command("/etc/init.d/foo restart")
- @provider.should_receive(:shell_out!).with("/etc/init.d/foo restart")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/foo restart")
@provider.restart_service()
end
@@ -162,7 +162,7 @@ NOMOCKINGSTRINGSPLZ
it "should should run the user specified reload command if one is specified" do
@new_resource.reload_command("kill -9 1")
- @provider.should_receive(:shell_out!).with("kill -9 1")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("kill -9 1")
@provider.reload_service()
end
end
diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb
index 978f149258..8df22efa7e 100644
--- a/spec/unit/provider/service/solaris_smf_service_spec.rb
+++ b/spec/unit/provider/service/solaris_smf_service_spec.rb
@@ -59,7 +59,6 @@ describe Chef::Provider::Service::Solaris do
@provider.load_current_resource
end
-
it "should return the current resource" do
@provider.stub(:shell_out!).with("/bin/svcs -l chef").and_return(@status)
@provider.load_current_resource.should eql(@current_resource)
@@ -131,7 +130,6 @@ describe Chef::Provider::Service::Solaris do
end
end
-
describe "when disabling the service" do
before(:each) do
@provider.current_resource = @current_resource
@@ -159,7 +157,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm refresh chef" do
- @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm refresh chef").and_return(@status)
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/svcadm refresh chef").and_return(@status)
@provider.reload_service
end
diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb
index 2aa7b539f2..7358f63b5e 100644
--- a/spec/unit/provider/service/systemd_service_spec.rb
+++ b/spec/unit/provider/service/systemd_service_spec.rb
@@ -74,25 +74,25 @@ describe Chef::Provider::Service::Systemd do
end
it "should run the services status command if one has been specified" do
- @provider.stub(:shell_out_with_systems_locale).and_return(@shell_out_success)
+ @provider.stub(:shell_out).and_return(@shell_out_success)
@current_resource.should_receive(:running).with(true)
@provider.load_current_resource
end
it "should run the services status command if one has been specified and properly set status check state" do
- @provider.stub(:shell_out_with_systems_locale).with("/bin/chefhasmonkeypants status").and_return(@shell_out_success)
+ @provider.stub(:shell_out).with("/bin/chefhasmonkeypants status").and_return(@shell_out_success)
@provider.load_current_resource
@provider.instance_variable_get("@status_check_success").should be_true
end
it "should set running to false if a status command fails" do
- @provider.stub(:shell_out_with_systems_locale).and_return(@shell_out_failure)
+ @provider.stub(:shell_out).and_return(@shell_out_failure)
@current_resource.should_receive(:running).with(false)
@provider.load_current_resource
end
it "should update state to indicate status check failed when a status command fails" do
- @provider.stub(:shell_out_with_systems_locale).and_return(@shell_out_failure)
+ @provider.stub(:shell_out).and_return(@shell_out_failure)
@provider.load_current_resource
@provider.instance_variable_get("@status_check_success").should be_false
end
@@ -129,31 +129,31 @@ describe Chef::Provider::Service::Systemd do
it "should call the start command if one is specified" do
@new_resource.stub(:start_command).and_return("/sbin/rsyslog startyousillysally")
- @provider.should_receive(:shell_out!).with("/sbin/rsyslog startyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog startyousillysally")
@provider.start_service
end
it "should call '/bin/systemctl start service_name' if no start command is specified" do
- @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl start #{@new_resource.service_name}").and_return(@shell_out_success)
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/bin/systemctl start #{@new_resource.service_name}").and_return(@shell_out_success)
@provider.start_service
end
it "should not call '/bin/systemctl start service_name' if it is already running" do
@current_resource.stub(:running).and_return(true)
- @provider.should_not_receive(:shell_out_with_systems_locale).with("/bin/systemctl start #{@new_resource.service_name}")
+ @provider.should_not_receive(:shell_out_with_systems_locale!).with("/bin/systemctl start #{@new_resource.service_name}")
@provider.start_service
end
it "should call the restart command if one is specified" do
@current_resource.stub(:running).and_return(true)
@new_resource.stub(:restart_command).and_return("/sbin/rsyslog restartyousillysally")
- @provider.should_receive(:shell_out!).with("/sbin/rsyslog restartyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog restartyousillysally")
@provider.restart_service
end
it "should call '/bin/systemctl restart service_name' if no restart command is specified" do
@current_resource.stub(:running).and_return(true)
- @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl restart #{@new_resource.service_name}").and_return(@shell_out_success)
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/bin/systemctl restart #{@new_resource.service_name}").and_return(@shell_out_success)
@provider.restart_service
end
@@ -162,7 +162,7 @@ describe Chef::Provider::Service::Systemd do
it "should call the reload command" do
@current_resource.stub(:running).and_return(true)
@new_resource.stub(:reload_command).and_return("/sbin/rsyslog reloadyousillysally")
- @provider.should_receive(:shell_out!).with("/sbin/rsyslog reloadyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog reloadyousillysally")
@provider.reload_service
end
end
@@ -170,7 +170,7 @@ describe Chef::Provider::Service::Systemd do
context "when a reload command is not specified" do
it "should call '/bin/systemctl reload service_name' if the service is running" do
@current_resource.stub(:running).and_return(true)
- @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl reload #{@new_resource.service_name}").and_return(@shell_out_success)
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/bin/systemctl reload #{@new_resource.service_name}").and_return(@shell_out_success)
@provider.reload_service
end
@@ -185,19 +185,19 @@ describe Chef::Provider::Service::Systemd do
it "should call the stop command if one is specified" do
@current_resource.stub(:running).and_return(true)
@new_resource.stub(:stop_command).and_return("/sbin/rsyslog stopyousillysally")
- @provider.should_receive(:shell_out!).with("/sbin/rsyslog stopyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog stopyousillysally")
@provider.stop_service
end
it "should call '/bin/systemctl stop service_name' if no stop command is specified" do
@current_resource.stub(:running).and_return(true)
- @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl stop #{@new_resource.service_name}").and_return(@shell_out_success)
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/bin/systemctl stop #{@new_resource.service_name}").and_return(@shell_out_success)
@provider.stop_service
end
it "should not call '/bin/systemctl stop service_name' if it is already stopped" do
@current_resource.stub(:running).and_return(false)
- @provider.should_not_receive(:shell_out_with_systems_locale).with("/bin/systemctl stop #{@new_resource.service_name}")
+ @provider.should_not_receive(:shell_out_with_systems_locale!).with("/bin/systemctl stop #{@new_resource.service_name}")
@provider.stop_service
end
end
@@ -210,12 +210,12 @@ describe Chef::Provider::Service::Systemd do
end
it "should call '/bin/systemctl enable service_name' to enable the service" do
- @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl enable #{@new_resource.service_name}").and_return(@shell_out_success)
+ @provider.should_receive(:shell_out!).with("/bin/systemctl enable #{@new_resource.service_name}").and_return(@shell_out_success)
@provider.enable_service
end
it "should call '/bin/systemctl disable service_name' to disable the service" do
- @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl disable #{@new_resource.service_name}").and_return(@shell_out_success)
+ @provider.should_receive(:shell_out!).with("/bin/systemctl disable #{@new_resource.service_name}").and_return(@shell_out_success)
@provider.disable_service
end
end
@@ -227,12 +227,12 @@ describe Chef::Provider::Service::Systemd do
end
it "should return true if '/bin/systemctl is-active service_name' returns 0" do
- @provider.should_receive(:shell_out_with_systems_locale).with('/bin/systemctl is-active rsyslog.service --quiet').and_return(@shell_out_success)
+ @provider.should_receive(:shell_out).with('/bin/systemctl is-active rsyslog.service --quiet').and_return(@shell_out_success)
@provider.is_active?.should be_true
end
it "should return false if '/bin/systemctl is-active service_name' returns anything except 0" do
- @provider.should_receive(:shell_out_with_systems_locale).with('/bin/systemctl is-active rsyslog.service --quiet').and_return(@shell_out_failure)
+ @provider.should_receive(:shell_out).with('/bin/systemctl is-active rsyslog.service --quiet').and_return(@shell_out_failure)
@provider.is_active?.should be_false
end
end
@@ -244,12 +244,12 @@ describe Chef::Provider::Service::Systemd do
end
it "should return true if '/bin/systemctl is-enabled service_name' returns 0" do
- @provider.should_receive(:shell_out_with_systems_locale).with('/bin/systemctl is-enabled rsyslog.service --quiet').and_return(@shell_out_success)
+ @provider.should_receive(:shell_out).with('/bin/systemctl is-enabled rsyslog.service --quiet').and_return(@shell_out_success)
@provider.is_enabled?.should be_true
end
it "should return false if '/bin/systemctl is-enabled service_name' returns anything except 0" do
- @provider.should_receive(:shell_out_with_systems_locale).with('/bin/systemctl is-enabled rsyslog.service --quiet').and_return(@shell_out_failure)
+ @provider.should_receive(:shell_out).with('/bin/systemctl is-enabled rsyslog.service --quiet').and_return(@shell_out_failure)
@provider.is_enabled?.should be_false
end
end
diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb
index efe4e0481f..499a794ff4 100644
--- a/spec/unit/provider/service/upstart_service_spec.rb
+++ b/spec/unit/provider/service/upstart_service_spec.rb
@@ -161,7 +161,6 @@ describe Chef::Provider::Service::Upstart do
@provider.load_current_resource
end
-
it "should track state when the upstart configuration file fails to load" do
File.should_receive(:exists?).and_return false
@provider.load_current_resource
@@ -174,19 +173,19 @@ describe Chef::Provider::Service::Upstart do
end
it "should run the services status command if one has been specified" do
- @provider.stub(:run_command_with_systems_locale).with({:command => "/bin/chefhasmonkeypants status"}).and_return(0)
+ @provider.stub(:shell_out!).with("/bin/chefhasmonkeypants status").and_return(0)
@current_resource.should_receive(:running).with(true)
@provider.load_current_resource
end
it "should track state when the user-provided status command fails" do
- @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_raise(Chef::Exceptions::Exec)
+ @provider.stub(:shell_out!).and_raise(Errno::ENOENT)
@provider.load_current_resource
@provider.instance_variable_get("@command_success").should == false
end
it "should set running to false if it catches a Chef::Exceptions::Exec when using a status command" do
- @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_raise(Chef::Exceptions::Exec)
+ @provider.stub(:shell_out!).and_raise(Errno::ENOENT)
@current_resource.should_receive(:running).with(false)
@provider.load_current_resource
end
@@ -202,7 +201,6 @@ describe Chef::Provider::Service::Upstart do
@provider.load_current_resource.should eql(@current_resource)
end
-
end
describe "enable and disable service" do
@@ -243,18 +241,18 @@ describe Chef::Provider::Service::Upstart do
it "should call the start command if one is specified" do
@new_resource.stub(:start_command).and_return("/sbin/rsyslog startyousillysally")
- @provider.should_receive(:shell_out!).with("/sbin/rsyslog startyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog startyousillysally")
@provider.start_service()
end
it "should call '/sbin/start service_name' if no start command is specified" do
- @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/start #{@new_resource.service_name}"}).and_return(0)
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(0)
@provider.start_service()
end
it "should not call '/sbin/start service_name' if it is already running" do
@current_resource.stub(:running).and_return(true)
- @provider.should_not_receive(:run_command_with_systems_locale).with({:command => "/sbin/start #{@new_resource.service_name}"})
+ @provider.should_not_receive(:shell_out_with_systems_locale!)
@provider.start_service()
end
@@ -263,58 +261,58 @@ describe Chef::Provider::Service::Upstart do
@new_resource.parameters({ "OSD_ID" => "2" })
@provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
- @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/start rsyslog OSD_ID=2"}).and_return(0)
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/start rsyslog OSD_ID=2").and_return(0)
@provider.start_service()
end
it "should call the restart command if one is specified" do
@current_resource.stub(:running).and_return(true)
@new_resource.stub(:restart_command).and_return("/sbin/rsyslog restartyousillysally")
- @provider.should_receive(:shell_out!).with("/sbin/rsyslog restartyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog restartyousillysally")
@provider.restart_service()
end
it "should call '/sbin/restart service_name' if no restart command is specified" do
@current_resource.stub(:running).and_return(true)
- @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/restart #{@new_resource.service_name}"}).and_return(0)
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/restart #{@new_resource.service_name}").and_return(0)
@provider.restart_service()
end
it "should call '/sbin/start service_name' if restart_service is called for a stopped service" do
@current_resource.stub(:running).and_return(false)
- @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/start #{@new_resource.service_name}"}).and_return(0)
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(0)
@provider.restart_service()
end
it "should call the reload command if one is specified" do
@current_resource.stub(:running).and_return(true)
@new_resource.stub(:reload_command).and_return("/sbin/rsyslog reloadyousillysally")
- @provider.should_receive(:shell_out!).with("/sbin/rsyslog reloadyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog reloadyousillysally")
@provider.reload_service()
end
it "should call '/sbin/reload service_name' if no reload command is specified" do
@current_resource.stub(:running).and_return(true)
- @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/reload #{@new_resource.service_name}"}).and_return(0)
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/reload #{@new_resource.service_name}").and_return(0)
@provider.reload_service()
end
it "should call the stop command if one is specified" do
@current_resource.stub(:running).and_return(true)
@new_resource.stub(:stop_command).and_return("/sbin/rsyslog stopyousillysally")
- @provider.should_receive(:shell_out!).with("/sbin/rsyslog stopyousillysally")
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog stopyousillysally")
@provider.stop_service()
end
it "should call '/sbin/stop service_name' if no stop command is specified" do
@current_resource.stub(:running).and_return(true)
- @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/stop #{@new_resource.service_name}"}).and_return(0)
+ @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}").and_return(0)
@provider.stop_service()
end
it "should not call '/sbin/stop service_name' if it is already stopped" do
@current_resource.stub(:running).and_return(false)
- @provider.should_not_receive(:run_command_with_systems_locale).with({:command => "/sbin/stop #{@new_resource.service_name}"})
+ @provider.should_not_receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}")
@provider.stop_service()
end
end
diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb
index f37a42d235..5d9d1cec1e 100644
--- a/spec/unit/provider/subversion_spec.rb
+++ b/spec/unit/provider/subversion_spec.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require 'spec_helper'
describe Chef::Provider::Subversion do
@@ -199,7 +198,7 @@ describe Chef::Provider::Subversion do
it "runs an export with the --force option" do
::File.stub(:directory?).with("/my/deploy").and_return(true)
expected_cmd = "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
- @provider.should_receive(:run_command).with(:command => expected_cmd)
+ @provider.should_receive(:shell_out!).with(command: expected_cmd)
@provider.run_action(:force_export)
@resource.should be_updated
end
@@ -207,7 +206,7 @@ describe Chef::Provider::Subversion do
it "runs the checkout command for action_checkout" do
::File.stub(:directory?).with("/my/deploy").and_return(true)
expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
- @provider.should_receive(:run_command).with(:command => expected_cmd)
+ @provider.should_receive(:shell_out!).with(command: expected_cmd)
@provider.run_action(:checkout)
@resource.should be_updated
end
@@ -231,7 +230,7 @@ describe Chef::Provider::Subversion do
@resource.user "whois"
@resource.group "thisis"
expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
- @provider.should_receive(:run_command).with(:command => expected_cmd, :user => "whois", :group => "thisis")
+ @provider.should_receive(:shell_out!).with(command: expected_cmd, user: "whois", group: "thisis")
@provider.run_action(:checkout)
@resource.should be_updated
end
@@ -256,7 +255,7 @@ describe Chef::Provider::Subversion do
@provider.stub(:find_current_revision).and_return("11410")
@provider.stub(:current_revision_matches_target_revision?).and_return(false)
expected_cmd = "svn update -q -r12345 /my/deploy/dir"
- @provider.should_receive(:run_command).with(:command => expected_cmd)
+ @provider.should_receive(:shell_out!).with(command: expected_cmd)
@provider.run_action(:sync)
@resource.should be_updated
end
@@ -273,7 +272,7 @@ describe Chef::Provider::Subversion do
it "runs the export_command on action_export" do
::File.stub(:directory?).with("/my/deploy").and_return(true)
expected_cmd = "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
- @provider.should_receive(:run_command).with(:command => expected_cmd)
+ @provider.should_receive(:shell_out!).with(command: expected_cmd)
@provider.run_action(:export)
@resource.should be_updated
end