summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-09-08 19:01:12 -0700
committerGitHub <noreply@github.com>2020-09-08 19:01:12 -0700
commit80b2115913042a65ceceff72cd5ab3faa7bdc7f4 (patch)
tree489685eaf96b2465b1992b04e2469efcaa28696e
parent8cac887c99a5f5c24ea02d52c70fd951c7b3a09a (diff)
parentb88d9aaa844f2c98d1e49099d9e23e0497667e02 (diff)
downloadchef-80b2115913042a65ceceff72cd5ab3faa7bdc7f4.tar.gz
Merge pull request #10396 from chef/strings
Use include? to example strings when we don't need a regex
-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 80853d43da..2a7300c017 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?