aboutsummaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorJosh Cooper <josh@puppet.com>2018-07-09 19:50:03 -0700
committerJosh Cooper <josh@puppet.com>2018-07-09 19:50:03 -0700
commit59f4a9e49d397556a60f060faffdc14b734856da (patch)
tree8b630a7d02fc4e6e207fc3d84b9d78c1f6637191 /spec/lib
parent34e83e11a5fc344195217d9cd159d022b5d89ec1 (diff)
downloadpuppet-hosts_core-59f4a9e49d397556a60f060faffdc14b734856da.tar.gz
puppet-hosts_core-59f4a9e49d397556a60f060faffdc14b734856da.tar.bz2
Automatic validation updates
Updated rubocop violations using `pdk validate -a`.
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/puppet_spec/files.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/spec/lib/puppet_spec/files.rb b/spec/lib/puppet_spec/files.rb
index b34daed..ebbe1a9 100644
--- a/spec/lib/puppet_spec/files.rb
+++ b/spec/lib/puppet_spec/files.rb
@@ -7,10 +7,10 @@ require 'pathname'
module PuppetSpec::Files
def self.cleanup
$global_tempfiles ||= []
- while path = $global_tempfiles.pop do
+ while path = $global_tempfiles.pop
begin
Dir.unstub(:entries)
- FileUtils.rm_rf path, :secure => true
+ FileUtils.rm_rf path, secure: true
rescue Errno::ENOENT
# nothing to do
end
@@ -48,7 +48,7 @@ module PuppetSpec::Files
text = contents[:posix]
end
File.open(file, 'wb') { |f| f.write(text) }
- Puppet::FileSystem.chmod(0755, file)
+ Puppet::FileSystem.chmod(0o755, file)
file
end
@@ -62,12 +62,12 @@ module PuppetSpec::Files
# Copied from ruby 2.4 source
def make_tmpname((prefix, suffix), n)
- prefix = (String.try_convert(prefix) or
- raise ArgumentError, "unexpected prefix: #{prefix.inspect}")
- suffix &&= (String.try_convert(suffix) or
- raise ArgumentError, "unexpected suffix: #{suffix.inspect}")
- t = Time.now.strftime("%Y%m%d")
- path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}".dup
+ prefix = (String.try_convert(prefix) ||
+ raise(ArgumentError, "unexpected prefix: #{prefix.inspect}"))
+ suffix &&= (String.try_convert(suffix) ||
+ raise(ArgumentError, "unexpected suffix: #{suffix.inspect}"))
+ t = Time.now.strftime('%Y%m%d')
+ path = "#{prefix}#{t}-#{$PROCESS_ID}-#{rand(0x100000000).to_s(36)}".dup
path << "-#{n}" if n
path << suffix if suffix
path
@@ -78,13 +78,13 @@ module PuppetSpec::Files
end
def dir_contained_in(dir, contents_hash)
- contents_hash.each do |k,v|
+ contents_hash.each do |k, v|
if v.is_a?(Hash)
- Dir.mkdir(tmp = File.join(dir,k))
+ Dir.mkdir(tmp = File.join(dir, k))
dir_contained_in(tmp, v)
else
file = File.join(dir, k)
- File.open(file, 'wb') {|f| f.write(v) }
+ File.open(file, 'wb') { |f| f.write(v) }
end
end
dir
@@ -97,11 +97,11 @@ module PuppetSpec::Files
end
def expect_file_mode(file, mode)
- actual_mode = "%o" % Puppet::FileSystem.stat(file).mode
+ actual_mode = '%o' % Puppet::FileSystem.stat(file).mode
target_mode = if Puppet.features.microsoft_windows?
- mode
- else
- "10" + "%04i" % mode.to_i
+ mode
+ else
+ '10' + '%04i' % mode.to_i
end
expect(actual_mode).to eq(target_mode)
end