summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-09-08 16:35:34 -0700
committerTim Smith <tsmith84@gmail.com>2020-09-08 16:35:34 -0700
commitb88d9aaa844f2c98d1e49099d9e23e0497667e02 (patch)
treeed850b436da9a0d796141e63f28e9c12d0fe0870
parent313afa345a0d19019218807a16bf6fdd6447a87b (diff)
downloadchef-b88d9aaa844f2c98d1e49099d9e23e0497667e02.tar.gz
Use include? to example strings when we don't need a regexstrings
There's no need for match? with regex here. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/user/dscl.rb2
-rw-r--r--spec/support/platform_helpers.rb17
2 files changed, 9 insertions, 10 deletions
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 7b86fa5269..7c4ed98aa8 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -587,7 +587,7 @@ in 'password', with the associated 'salt' and 'iterations'.")
result = shell_out("dscl", ".", "-#{args[0]}", args[1..-1])
return "" if ( args.first =~ /^delete/ ) && ( result.exitstatus != 0 )
raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") unless result.exitstatus == 0
- raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") if /No such key: /.match?(result.stdout)
+ raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") if result.stdout.include?("No such key: ")
result.stdout
end
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index d4bd0701d8..51a9299497 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -26,11 +26,11 @@ class DependencyProc < Proc
end
def ruby_64bit?
- !!(RbConfig::CONFIG["host_cpu"] =~ /x86_64/)
+ RbConfig::CONFIG["host_cpu"].include?("x86_64")
end
def ruby_32bit?
- !!(RbConfig::CONFIG["host_cpu"] =~ /i686/)
+ RbConfig::CONFIG["host_cpu"].include?("i686")
end
def windows?
@@ -117,19 +117,19 @@ def unix?
end
def linux?
- RUBY_PLATFORM.match?(/linux/)
+ RUBY_PLATFORM.include?("linux")
end
def macos?
- RUBY_PLATFORM.match?(/darwin/)
+ RUBY_PLATFORM.include?("darwin")
end
def solaris?
- RUBY_PLATFORM.match?(/solaris/)
+ RUBY_PLATFORM.include?("solaris")
end
def freebsd?
- RUBY_PLATFORM.match?(/freebsd/)
+ RUBY_PLATFORM.include?("freebsd")
end
def intel_64bit?
@@ -165,7 +165,7 @@ def debian_family?
end
def aix?
- RUBY_PLATFORM.match?(/aix/)
+ RUBY_PLATFORM.include?("aix")
end
def wpar?
@@ -199,8 +199,7 @@ def selinux_enabled?
end
def suse?
- ::File.exist?("/etc/SuSE-release") ||
- ( ::File.exist?("/etc/os-release") && /sles|suse/.match?(File.read("/etc/os-release")) )
+ !!(ohai[:platform_family] == "suse")
end
def root?