summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/snippets.rb4
-rwxr-xr-xtest/language/transportable.rb4
-rwxr-xr-xtest/lib/puppettest.rb24
-rw-r--r--test/lib/puppettest/certificates.rb4
-rw-r--r--test/lib/puppettest/exetest.rb8
-rw-r--r--test/lib/puppettest/fakes.rb8
-rw-r--r--test/lib/puppettest/filetesting.rb20
-rw-r--r--test/lib/puppettest/parsertesting.rb24
-rw-r--r--test/lib/puppettest/railstesting.rb8
-rw-r--r--test/lib/puppettest/runnable_test.rb4
-rw-r--r--test/lib/puppettest/support/assertions.rb8
-rw-r--r--test/lib/puppettest/support/helpers.rb8
-rwxr-xr-xtest/lib/puppettest/support/resources.rb4
-rw-r--r--test/lib/puppettest/support/utils.rb16
-rw-r--r--test/lib/puppettest/testcase.rb4
-rw-r--r--test/lib/rake/puppet_test_loader.rb4
-rwxr-xr-xtest/network/handler/fileserver.rb4
-rwxr-xr-xtest/other/puppet.rb4
-rwxr-xr-xtest/other/transactions.rb8
-rwxr-xr-xtest/puppet/defaults.rb4
-rwxr-xr-xtest/ral/providers/cron/crontab.rb20
-rwxr-xr-xtest/ral/providers/group.rb4
-rwxr-xr-xtest/ral/providers/package.rb8
-rwxr-xr-xtest/ral/providers/provider.rb4
-rwxr-xr-xtest/ral/providers/user.rb8
-rwxr-xr-xtest/ral/providers/user/useradd.rb12
-rwxr-xr-xtest/ral/type/cron.rb4
-rwxr-xr-xtest/ral/type/exec.rb4
-rwxr-xr-xtest/ral/type/filesources.rb4
-rwxr-xr-xtest/ral/type/resources.rb8
-rwxr-xr-xtest/ral/type/sshkey.rb4
-rwxr-xr-xtest/ral/type/zone.rb4
-rwxr-xr-xtest/util/fileparsing.rb4
33 files changed, 65 insertions, 195 deletions
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index cd8015db7..c42d67397 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -178,9 +178,7 @@ class TestSnippets < Test::Unit::TestCase
%w{a b c d}.each { |letter|
path = "/tmp/create#{letter}test"
assert_file(path)
- if %w{a b}.include?(letter)
- assert_mode_equal(0755, path)
- end
+ assert_mode_equal(0755, path) if %w{a b}.include?(letter)
}
end
diff --git a/test/language/transportable.rb b/test/language/transportable.rb
index 4607c3947..37c67d6f8 100755
--- a/test/language/transportable.rb
+++ b/test/language/transportable.rb
@@ -50,9 +50,7 @@ class TestTransportable < Test::Unit::TestCase
# Make sure our 'delve' command is working
def test_delve
top = mk_transtree do |object, depth, width|
- if width % 2 == 1
- object.file = :funtest
- end
+ object.file = :funtest if width % 2 == 1
end
objects = []
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 9bcbff9c1..38bb04298 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -113,9 +113,7 @@ module PuppetTest
end
def exampledir(*args)
- unless defined?(@@exampledir)
- @@exampledir = File.join(basedir, "examples")
- end
+ @@exampledir = File.join(basedir, "examples") unless defined?(@@exampledir)
if args.empty?
return @@exampledir
@@ -134,9 +132,7 @@ module PuppetTest
def libsetup
curlibs = ENV["RUBYLIB"].split(":")
$LOAD_PATH.reject do |dir| dir =~ /^\/usr/ end.each do |dir|
- unless curlibs.include?(dir)
- curlibs << dir
- end
+ curlibs << dir unless curlibs.include?(dir)
end
ENV["RUBYLIB"] = curlibs.join(":")
@@ -169,9 +165,7 @@ module PuppetTest
end
def setup
- unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin")
- ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin"
- end
+ ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin" unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin")
@memoryatstart = Puppet::Util.memory
if defined?(@@testcount)
@@testcount += 1
@@ -198,9 +192,7 @@ module PuppetTest
Puppet[:confdir] = @configpath
Puppet[:vardir] = @configpath
- unless File.exists?(@configpath)
- Dir.mkdir(@configpath)
- end
+ Dir.mkdir(@configpath) unless File.exists?(@configpath)
@@tmpfiles << @configpath << tmpdir()
@@tmppids = []
@@ -212,9 +204,7 @@ module PuppetTest
# If we're running under rake, then disable debugging and such.
#if rake? or ! Puppet[:debug]
#if defined?($puppet_debug) or ! rake?
- if textmate?
- Puppet[:color] = false
- end
+ Puppet[:color] = false if textmate?
Puppet::Util::Log.newdestination(@logs)
if defined? $console
Puppet.info @method_name
@@ -319,9 +309,7 @@ module PuppetTest
@memoryatend = Puppet::Util.memory
diff = @memoryatend - @memoryatstart
- if diff > 1000
- Puppet.info "#{self.class}##{@method_name} memory growth (#{@memoryatstart} to #{@memoryatend}): #{diff}"
- end
+ Puppet.info "#{self.class}##{@method_name} memory growth (#{@memoryatstart} to #{@memoryatend}): #{diff}" if diff > 1000
# reset all of the logs
Puppet::Util::Log.close_all
diff --git a/test/lib/puppettest/certificates.rb b/test/lib/puppettest/certificates.rb
index 4f643b2d5..198ec96c4 100644
--- a/test/lib/puppettest/certificates.rb
+++ b/test/lib/puppettest/certificates.rb
@@ -8,9 +8,7 @@ module PuppetTest::Certificates
def mkPassFile()
keyfile = File.join(@dir, "tmpkeyfile")
@@tmpfiles << keyfile
- unless FileTest.exists?(@dir)
- system("mkdir -p #{@dir}")
- end
+ system("mkdir -p #{@dir}") unless FileTest.exists?(@dir)
File.open(keyfile, "w", 0600) { |f|
f.print "as;dklj23rlkjzdflij23wr"
}
diff --git a/test/lib/puppettest/exetest.rb b/test/lib/puppettest/exetest.rb
index c07615245..78f391ddd 100644
--- a/test/lib/puppettest/exetest.rb
+++ b/test/lib/puppettest/exetest.rb
@@ -18,12 +18,8 @@ module PuppetTest::ExeTest
end
def setbindir
- unless ENV["PATH"].split(":").include?(bindir)
- ENV["PATH"] = [bindir, ENV["PATH"]].join(":")
- end
- unless ENV["PATH"].split(":").include?(sbindir)
- ENV["PATH"] = [sbindir, ENV["PATH"]].join(":")
- end
+ ENV["PATH"] = [bindir, ENV["PATH"]].join(":") unless ENV["PATH"].split(":").include?(bindir)
+ ENV["PATH"] = [sbindir, ENV["PATH"]].join(":") unless ENV["PATH"].split(":").include?(sbindir)
end
def setlibdir
diff --git a/test/lib/puppettest/fakes.rb b/test/lib/puppettest/fakes.rb
index c0e0bd899..2db045ab5 100644
--- a/test/lib/puppettest/fakes.rb
+++ b/test/lib/puppettest/fakes.rb
@@ -35,9 +35,7 @@ module PuppetTest
def []=(param, value)
param = symbolize(param)
- unless @realresource.valid_parameter?(param)
- raise Puppet::DevError, "Invalid attribute #{param} for #{@realresource.name}"
- end
+ raise Puppet::DevError, "Invalid attribute #{param} for #{@realresource.name}" unless @realresource.valid_parameter?(param)
if @realresource.attrtype(param) == :property
@should[param] = value
else
@@ -157,9 +155,7 @@ module PuppetTest
def store(hash)
hash.each do |n, v|
method = n.to_s + "="
- if respond_to? method
- send(method, v)
- end
+ send(method, v) if respond_to? method
end
end
end
diff --git a/test/lib/puppettest/filetesting.rb b/test/lib/puppettest/filetesting.rb
index 3c869f5cf..2ecfce58f 100644
--- a/test/lib/puppettest/filetesting.rb
+++ b/test/lib/puppettest/filetesting.rb
@@ -22,9 +22,7 @@ module PuppetTest::FileTesting
ret = []
num.times { |index|
item = list[rand(list.length)]
- if set.include?(item)
- redo
- end
+ redo if set.include?(item)
ret.push item
}
@@ -32,17 +30,11 @@ module PuppetTest::FileTesting
end
def mkranddirsandfiles(dirs = nil,files = nil,depth = 3)
- if depth < 0
- return
- end
+ return if depth < 0
- unless dirs
- dirs = %w{This Is A Set Of Directories}
- end
+ dirs = %w{This Is A Set Of Directories} unless dirs
- unless files
- files = %w{and this is a set of files}
- end
+ files = %w{and this is a set of files} unless files
tfiles = randlist(files)
tdirs = randlist(dirs)
@@ -128,9 +120,7 @@ module PuppetTest::FileTesting
path = File.join(dir,file)
stat = File.stat(dir)
if checked < 10 and (i % 3) == 2
- unless yield path
- next
- end
+ next unless yield path
checked += 1
end
}
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb
index 2211d17be..a23bd5601 100644
--- a/test/lib/puppettest/parsertesting.rb
+++ b/test/lib/puppettest/parsertesting.rb
@@ -21,9 +21,7 @@ module PuppetTest::ParserTesting
end
def initialize(val = nil)
- if val
- @evaluate = val
- end
+ @evaluate = val if val
end
def reset
@@ -66,9 +64,7 @@ module PuppetTest::ParserTesting
compiler ||= mkcompiler
compiler.topscope.source = (parser.find_hostclass("", "") || parser.newclass(""))
- unless compiler.topscope.source
- raise "Could not find source for scope"
- end
+ raise "Could not find source for scope" unless compiler.topscope.source
# Make the 'main' stuff
compiler.send(:evaluate_main)
compiler.topscope
@@ -97,9 +93,7 @@ module PuppetTest::ParserTesting
end
def resourcedef(type, title, params)
- unless title.is_a?(AST)
- title = stringobj(title)
- end
+ title = stringobj(title) unless title.is_a?(AST)
assert_nothing_raised("Could not create #{type} #{title}") {
return AST::Resource.new(
@@ -221,9 +215,7 @@ module PuppetTest::ParserTesting
def resourceparam(param, value)
# Allow them to pass non-strings in
- if value.is_a?(String)
- value = stringobj(value)
- end
+ value = stringobj(value) if value.is_a?(String)
assert_nothing_raised("Could not create param #{param}") {
return AST::ResourceParam.new(
@@ -249,9 +241,7 @@ module PuppetTest::ParserTesting
end
def varobj(name, value)
- unless value.is_a? AST
- value = stringobj(value)
- end
+ value = stringobj(value) unless value.is_a? AST
assert_nothing_raised("Could not create #{name} code") {
return AST::VarDef.new(
@@ -403,9 +393,7 @@ module PuppetTest::ParserTesting
obj["mode"] = "644"
# Yield, if they want
- if block_given?
- yield(obj, i, j)
- end
+ yield(obj, i, j) if block_given?
resources << obj
end
diff --git a/test/lib/puppettest/railstesting.rb b/test/lib/puppettest/railstesting.rb
index 3af593762..2240c739a 100644
--- a/test/lib/puppettest/railstesting.rb
+++ b/test/lib/puppettest/railstesting.rb
@@ -8,9 +8,7 @@ module PuppetTest::RailsTesting
# If we don't clean up the connection list, then the rails
# lib will still think it's connected.
- if Puppet.features.rails?
- ActiveRecord::Base.clear_active_connections!
- end
+ ActiveRecord::Base.clear_active_connections! if Puppet.features.rails?
end
def railsinit
@@ -18,9 +16,7 @@ module PuppetTest::RailsTesting
end
def railsteardown
- if Puppet[:dbadapter] != "sqlite3"
- Puppet::Rails.teardown
- end
+ Puppet::Rails.teardown if Puppet[:dbadapter] != "sqlite3"
end
def railsresource(type = "file", title = "/tmp/testing", params = {})
diff --git a/test/lib/puppettest/runnable_test.rb b/test/lib/puppettest/runnable_test.rb
index 6fcd9c6dc..ac2fb7b2e 100644
--- a/test/lib/puppettest/runnable_test.rb
+++ b/test/lib/puppettest/runnable_test.rb
@@ -23,9 +23,7 @@ module PuppetTest
# is used directly by Rspec and is not intended for develper use.
#
def runnable?
- if superclass.respond_to?(:runnable?) and not superclass.runnable?
- return false
- end
+ return false if superclass.respond_to?(:runnable?) and not superclass.runnable?
confines.each do |message, is_runnable|
is_runnable = is_runnable.call if is_runnable.respond_to?(:call)
diff --git a/test/lib/puppettest/support/assertions.rb b/test/lib/puppettest/support/assertions.rb
index 528c7b8db..b918e28f6 100644
--- a/test/lib/puppettest/support/assertions.rb
+++ b/test/lib/puppettest/support/assertions.rb
@@ -42,12 +42,8 @@ module PuppetTest
comp = nil
msg = nil
- unless events.is_a? Array
- raise Puppet::DevError, "Incorrect call of assert_events"
- end
- if resources[-1].is_a? String
- msg = resources.pop
- end
+ raise Puppet::DevError, "Incorrect call of assert_events" unless events.is_a? Array
+ msg = resources.pop if resources[-1].is_a? String
config = resources2catalog(*resources)
transaction = Puppet::Transaction.new(config)
diff --git a/test/lib/puppettest/support/helpers.rb b/test/lib/puppettest/support/helpers.rb
index 5b1872dfb..4a3a53095 100644
--- a/test/lib/puppettest/support/helpers.rb
+++ b/test/lib/puppettest/support/helpers.rb
@@ -5,17 +5,13 @@ module PuppetTest
# UID of nobody.
def nonrootuser
Etc.passwd { |user|
- if user.uid != Puppet::Util::SUIDManager.uid and user.uid > 0 and user.uid < 255
- return user
- end
+ return user if user.uid != Puppet::Util::SUIDManager.uid and user.uid > 0 and user.uid < 255
}
end
def nonrootgroup
Etc.group { |group|
- if group.gid != Puppet::Util::SUIDManager.gid and group.gid > 0 and group.gid < 255
- return group
- end
+ return group if group.gid != Puppet::Util::SUIDManager.gid and group.gid > 0 and group.gid < 255
}
end
end
diff --git a/test/lib/puppettest/support/resources.rb b/test/lib/puppettest/support/resources.rb
index 865995507..6b771dda8 100755
--- a/test/lib/puppettest/support/resources.rb
+++ b/test/lib/puppettest/support/resources.rb
@@ -15,9 +15,7 @@ module PuppetTest::Support::Resources
def treenode(config, name, *resources)
comp = tree_container name
resources.each do |resource|
- if resource.is_a?(String)
- resource = tree_resource(resource)
- end
+ resource = tree_resource(resource) if resource.is_a?(String)
config.add_edge(comp, resource)
config.add_resource resource unless config.resource(resource.ref)
end
diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb
index 06ce3ad4a..61ab6e754 100644
--- a/test/lib/puppettest/support/utils.rb
+++ b/test/lib/puppettest/support/utils.rb
@@ -26,9 +26,7 @@ module PuppetTest::Support::Utils
def resources2catalog(*resources)
if resources[0].is_a?(Puppet::Resource::Catalog)
config = resources.shift
- unless resources.empty?
- resources.each { |r| config.add_resource r }
- end
+ resources.each { |r| config.add_resource r } unless resources.empty?
elsif resources[0].is_a?(Puppet::Type.type(:component))
raise ArgumentError, "resource2config() no longer accpts components"
comp = resources.shift
@@ -55,18 +53,14 @@ module PuppetTest::Support::Utils
else
puts id
end
- unless defined?(@me)
- raise "Could not retrieve user name; 'id' did not work"
- end
+ raise "Could not retrieve user name; 'id' did not work" unless defined?(@me)
end
# Define a variable that contains a group I'm in.
def set_mygroup
# retrieve the user name
group = %x{groups}.chomp.split(/ /)[0]
- unless group
- raise "Could not find group to set in @mygroup"
- end
+ raise "Could not find group to set in @mygroup" unless group
@mygroup = group
end
@@ -93,9 +87,7 @@ module PuppetTest::Support::Utils
ary = [PuppetTest.basedir, "test"]
ary += name.split("/")
file = File.join(ary)
- unless FileTest.exists?(file)
- raise Puppet::DevError, "No fakedata file #{file}"
- end
+ raise Puppet::DevError, "No fakedata file #{file}" unless FileTest.exists?(file)
return file
end
diff --git a/test/lib/puppettest/testcase.rb b/test/lib/puppettest/testcase.rb
index 3521589bf..de088a468 100644
--- a/test/lib/puppettest/testcase.rb
+++ b/test/lib/puppettest/testcase.rb
@@ -20,9 +20,7 @@ class PuppetTest::TestCase < Test::Unit::TestCase
elsif self.runnable?
return super
else
- if defined? $console
- puts "Skipping #{name}: #{@messages.join(", ")}"
- end
+ puts "Skipping #{name}: #{@messages.join(", ")}" if defined? $console
suite = Test::Unit::TestSuite.new(name)
return suite
end
diff --git a/test/lib/rake/puppet_test_loader.rb b/test/lib/rake/puppet_test_loader.rb
index be3319ccc..17d29591f 100644
--- a/test/lib/rake/puppet_test_loader.rb
+++ b/test/lib/rake/puppet_test_loader.rb
@@ -10,7 +10,5 @@ args.each { |f| require f unless f =~ /^-/ }
runner = Test::Unit::AutoRunner.new(false)
runner.process_args
-unless runner.run
- exit 14
-end
+exit 14 unless runner.run
diff --git a/test/network/handler/fileserver.rb b/test/network/handler/fileserver.rb
index 3f93a74e0..32951bcce 100755
--- a/test/network/handler/fileserver.rb
+++ b/test/network/handler/fileserver.rb
@@ -12,9 +12,7 @@ class TestFileServer < Test::Unit::TestCase
mount = nil
name = "yaytest"
base = path || tempfile()
- unless FileTest.exists?(base)
- Dir.mkdir(base)
- end
+ Dir.mkdir(base) unless FileTest.exists?(base)
# Create a test file
File.open(File.join(base, "file"), "w") { |f| f.puts "bazoo" }
assert_nothing_raised {
diff --git a/test/other/puppet.rb b/test/other/puppet.rb
index 4acee3ee5..1f81bb781 100755
--- a/test/other/puppet.rb
+++ b/test/other/puppet.rb
@@ -58,9 +58,7 @@ class TestPuppetModule < Test::Unit::TestCase
oldlibs = $LOAD_PATH.dup
cleanup do
$LOAD_PATH.each do |dir|
- unless oldlibs.include?(dir)
- $LOAD_PATH.delete(dir)
- end
+ $LOAD_PATH.delete(dir) unless oldlibs.include?(dir)
end
end
one = tempfile()
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index e49e96a7f..fa4fa4f61 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -46,9 +46,7 @@ class TestTransactions < Test::Unit::TestCase
$finished << self.name
end
end
- if block
- type.class_eval(&block)
- end
+ type.class_eval(&block) if block
cleanup do
Puppet::Type.rmtype(:generator)
end
@@ -70,9 +68,7 @@ class TestTransactions < Test::Unit::TestCase
end
end
- if block
- type.class_eval(&block)
- end
+ type.class_eval(&block) if block
return type
end
diff --git a/test/puppet/defaults.rb b/test/puppet/defaults.rb
index 1620dfd82..2338e03ee 100755
--- a/test/puppet/defaults.rb
+++ b/test/puppet/defaults.rb
@@ -48,9 +48,7 @@ class TestPuppetDefaults < Test::Unit::TestCase
[@@dirs,@@files].flatten.each { |param|
value = Puppet[param]
- unless value !~ notval
- assert_nothing_raised { raise "#{param} is incorrectly set to #{value}" }
- end
+ assert_nothing_raised { raise "#{param} is incorrectly set to #{value}" } unless value !~ notval
}
end
diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb
index 46678dc7d..3dfac96e6 100755
--- a/test/ral/providers/cron/crontab.rb
+++ b/test/ral/providers/cron/crontab.rb
@@ -23,9 +23,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
# a full cron job. These tests assume individual record types will always be correctly
# parsed, so all they
def sample_crons
- unless defined?(@sample_crons)
- @sample_crons = YAML.load(File.read(File.join(@crondir, "crontab_collections.yaml")))
- end
+ @sample_crons = YAML.load(File.read(File.join(@crondir, "crontab_collections.yaml"))) unless defined?(@sample_crons)
@sample_crons
end
@@ -33,9 +31,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
# mapping between records and lines. We have plenty of redundancy here because
# we use these records to build up our complex, multi-line cron jobs below.
def sample_records
- unless defined?(@sample_records)
- @sample_records = YAML.load(File.read(File.join(@crondir, "crontab_sample_records.yaml")))
- end
+ @sample_records = YAML.load(File.read(File.join(@crondir, "crontab_sample_records.yaml"))) unless defined?(@sample_records)
@sample_records
end
@@ -62,25 +58,19 @@ class TestCronParsedProvider < Test::Unit::TestCase
assert_equal(value, cron.send(param), "#{param} was not equal in #{msg}")
end
%w{command environment minute hour month monthday weekday}.each do |var|
- unless options.include?(var.intern)
- assert_equal(:absent, cron.send(var), "#{var} was not parsed absent in #{msg}")
- end
+ assert_equal(:absent, cron.send(var), "#{var} was not parsed absent in #{msg}") unless options.include?(var.intern)
end
end
# Make sure a cron record matches. This only works for crontab records.
def assert_record_equal(msg, record, options)
- unless options.include?(:record_type)
- raise ArgumentError, "You must pass the required record type"
- end
+ raise ArgumentError, "You must pass the required record type" unless options.include?(:record_type)
assert_instance_of(Hash, record, "not an instance of a hash in #{msg}")
options.each do |param, value|
assert_equal(value, record[param], "#{param} was not equal in #{msg}")
end
FIELDS[record[:record_type]].each do |var|
- unless options.include?(var)
- assert_equal(:absent, record[var], "#{var} was not parsed absent in #{msg}")
- end
+ assert_equal(:absent, record[var], "#{var} was not parsed absent in #{msg}") unless options.include?(var)
end
end
diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb
index 067affd68..d6783bf7f 100755
--- a/test/ral/providers/group.rb
+++ b/test/ral/providers/group.rb
@@ -22,9 +22,7 @@ class TestGroupProvider < Test::Unit::TestCase
def teardown
super
@@tmpgroups.each { |group|
- unless missing?(group)
- remove(group)
- end
+ remove(group) unless missing?(group)
}
end
diff --git a/test/ral/providers/package.rb b/test/ral/providers/package.rb
index 600770f13..03b81477d 100755
--- a/test/ral/providers/package.rb
+++ b/test/ral/providers/package.rb
@@ -17,9 +17,7 @@ class TestPackageProvider < Test::Unit::TestCase
def self.load_test_packages
require 'yaml'
file = File.join(PuppetTest.datadir(), "providers", "package", "testpackages.yaml")
- unless FileTest.exists?(file)
- raise "Could not find file #{file}"
- end
+ raise "Could not find file #{file}" unless FileTest.exists?(file)
array = YAML::load(File.read(file)).collect { |hash|
# Stupid ruby 1.8.1. YAML is sometimes broken such that
# symbols end up being strings with the : in them.
@@ -163,9 +161,7 @@ class TestPackageProvider < Test::Unit::TestCase
end
end
else
- if cleancmd
- system(cleancmd)
- end
+ system(cleancmd) if cleancmd
end
end
diff --git a/test/ral/providers/provider.rb b/test/ral/providers/provider.rb
index f716bc1cf..081020638 100755
--- a/test/ral/providers/provider.rb
+++ b/test/ral/providers/provider.rb
@@ -11,9 +11,7 @@ class TestProvider < Test::Unit::TestCase
def echo
echo = Puppet::Util.binary("echo")
- unless echo
- raise "Could not find 'echo' binary; cannot complete test"
- end
+ raise "Could not find 'echo' binary; cannot complete test" unless echo
return echo
end
diff --git a/test/ral/providers/user.rb b/test/ral/providers/user.rb
index 81b3afd3e..e4ec3c125 100755
--- a/test/ral/providers/user.rb
+++ b/test/ral/providers/user.rb
@@ -24,9 +24,7 @@ class TestUserProvider < Test::Unit::TestCase
def teardown
@@tmpusers.each { |user|
- unless missing?(user)
- remove(user)
- end
+ remove(user) unless missing?(user)
}
super
end
@@ -376,9 +374,7 @@ class TestUserProvider < Test::Unit::TestCase
Etc.setgrent
max = 0
while group = Etc.getgrent
- if group.gid > max and group.gid < 5000
- max = group.gid
- end
+ max = group.gid if group.gid > max and group.gid < 5000
end
groups = []
diff --git a/test/ral/providers/user/useradd.rb b/test/ral/providers/user/useradd.rb
index 2e98d7f5d..52d933f89 100755
--- a/test/ral/providers/user/useradd.rb
+++ b/test/ral/providers/user/useradd.rb
@@ -64,9 +64,7 @@ class UserAddProviderTest < PuppetTest::TestCase
end
options = {}
- while params.length > 0
- options[params.shift] = params.shift
- end
+ options[params.shift] = params.shift while params.length > 0
@vals[:groups] = @vals[:groups].join(",")
@@ -118,9 +116,7 @@ class UserAddProviderTest < PuppetTest::TestCase
@user.provider.expects(:execute).with do |params|
assert_equal(params[0], @provider.command(:add), "useradd was not called")
- if %w{Fedora RedHat}.include?(Facter.value(:operatingsystem))
- assert(params.include?("-M"), "Did not add -M on Red Hat")
- end
+ assert(params.include?("-M"), "Did not add -M on Red Hat") if %w{Fedora RedHat}.include?(Facter.value(:operatingsystem))
assert(! params.include?("-m"), "Added -m when managehome was disabled")
true
@@ -171,9 +167,7 @@ class UserAddProviderTest < PuppetTest::TestCase
end
def test_manages_password
- unless @provider.feature?(:manages_passwords)
- return
- end
+ return unless @provider.feature?(:manages_passwords)
@vals[:password] = "somethingorother"
setup_user
diff --git a/test/ral/type/cron.rb b/test/ral/type/cron.rb
index fcee21dd0..6b561c392 100755
--- a/test/ral/type/cron.rb
+++ b/test/ral/type/cron.rb
@@ -197,9 +197,7 @@ class TestCron < Test::Unit::TestCase
cron[param] = value
}
- if value.is_a?(Integer)
- assert_equal([value.to_s], cron.should(param), "Cron value was not set correctly")
- end
+ assert_equal([value.to_s], cron.should(param), "Cron value was not set correctly") if value.is_a?(Integer)
when :invalid
assert_raise(Puppet::Error, "#{value} is incorrectly a valid #{param}") {
cron[param] = value
diff --git a/test/ral/type/exec.rb b/test/ral/type/exec.rb
index 454458ff3..7ddb4650d 100755
--- a/test/ral/type/exec.rb
+++ b/test/ral/type/exec.rb
@@ -391,9 +391,7 @@ class TestExec < Test::Unit::TestCase
assert_events([:executed_command], comp, "usertest")
assert(FileTest.exists?(file), "File does not exist")
- if user
- assert_equal(user.uid, File.stat(file).uid, "File UIDs do not match")
- end
+ assert_equal(user.uid, File.stat(file).uid, "File UIDs do not match") if user
# We can't actually test group ownership, unfortunately, because
# behaviour changes wildlly based on platform.
diff --git a/test/ral/type/filesources.rb b/test/ral/type/filesources.rb
index a928fd7db..7541a7cbe 100755
--- a/test/ral/type/filesources.rb
+++ b/test/ral/type/filesources.rb
@@ -90,9 +90,7 @@ class TestFileSources < Test::Unit::TestCase
todir = File.join(path, "todir")
source = fromdir
- if networked
- source = "puppet://localhost/#{networked}#{fromdir}"
- end
+ source = "puppet://localhost/#{networked}#{fromdir}" if networked
recursive_source_test(source, todir)
return [fromdir,todir, File.join(todir, "one"), File.join(todir, "two")]
diff --git a/test/ral/type/resources.rb b/test/ral/type/resources.rb
index eb53a7edf..50d6839e7 100755
--- a/test/ral/type/resources.rb
+++ b/test/ral/type/resources.rb
@@ -24,9 +24,7 @@ class TestResources < Test::Unit::TestCase
@purgenum += 1
obj = @purgetype.create :name => "purger#{@purgenum}"
$purgemembers[obj[:name]] = obj
- if managed
- obj[:fake] = "testing"
- end
+ obj[:fake] = "testing" if managed
obj
end
@@ -100,9 +98,7 @@ class TestResources < Test::Unit::TestCase
end
}
- if low
- assert(! res.check(@user.create(:name => low)), "low user #{low} passed check")
- end
+ assert(! res.check(@user.create(:name => low)), "low user #{low} passed check") if low
if high
res[:unless_system_user] = 50
assert(res.check(@user.create(:name => high)), "high user #{high} failed check")
diff --git a/test/ral/type/sshkey.rb b/test/ral/type/sshkey.rb
index e362de839..01d72156a 100755
--- a/test/ral/type/sshkey.rb
+++ b/test/ral/type/sshkey.rb
@@ -32,9 +32,7 @@ class TestSSHKey < Test::Unit::TestCase
def teardown
super
- if @provider.respond_to?(:clear)
- @provider.clear
- end
+ @provider.clear if @provider.respond_to?(:clear)
end
def mkkey
diff --git a/test/ral/type/zone.rb b/test/ral/type/zone.rb
index f87774786..c136fbfb1 100755
--- a/test/ral/type/zone.rb
+++ b/test/ral/type/zone.rb
@@ -105,9 +105,7 @@ class TestZone < PuppetTest::TestCase
assert_nothing_raised {
property.class.state_sequence(:absent, :running).each do |st|
[:up, :down].each do |m|
- if st[m]
- methods << st[m]
- end
+ methods << st[m] if st[m]
end
end
}
diff --git a/test/util/fileparsing.rb b/test/util/fileparsing.rb
index fac5f3e83..eaf57cef6 100755
--- a/test/util/fileparsing.rb
+++ b/test/util/fileparsing.rb
@@ -422,9 +422,7 @@ assert_nothing_raised do
ret[:description] = desc unless desc == ""
end
- if line != ""
- ret[:alias] = line.split(/\s+/)
- end
+ ret[:alias] = line.split(/\s+/) if line != ""
return ret
end