diff options
| author | Markus Roberts <Markus@reality.com> | 2010-07-09 18:05:55 -0700 |
|---|---|---|
| committer | Markus Roberts <Markus@reality.com> | 2010-07-09 18:05:55 -0700 |
| commit | e8cf06336b64491a2dd7538a06651e0caaf6a48d (patch) | |
| tree | 9f5d4c83d03fefa54c385462f60875056a58a82c /test/ral | |
| parent | eefccf252527dc5b69af5959b0b0e2ddb5c91b74 (diff) | |
| download | puppet-e8cf06336b64491a2dd7538a06651e0caaf6a48d.tar.gz puppet-e8cf06336b64491a2dd7538a06651e0caaf6a48d.tar.xz puppet-e8cf06336b64491a2dd7538a06651e0caaf6a48d.zip | |
Code smell: Use string interpolation
* Replaced 83 occurances of
(.*)" *[+] *([$@]?[\w_0-9.:]+?)(.to_s\b)?(?! *[*(%\w_0-9.:{\[])
with
\1#{\2}"
3 Examples:
The code:
puts "PUPPET " + status + ": " + process + ", " + state
becomes:
puts "PUPPET " + status + ": " + process + ", #{state}"
The code:
puts "PUPPET " + status + ": #{process}" + ", #{state}"
becomes:
puts "PUPPET #{status}" + ": #{process}" + ", #{state}"
The code:
}.compact.join( "\n" ) + "\n" + t + "]\n"
becomes:
}.compact.join( "\n" ) + "\n#{t}" + "]\n"
* Replaced 21 occurances of (.*)" *[+] *" with \1
3 Examples:
The code:
puts "PUPPET #{status}" + ": #{process}" + ", #{state}"
becomes:
puts "PUPPET #{status}" + ": #{process}, #{state}"
The code:
puts "PUPPET #{status}" + ": #{process}, #{state}"
becomes:
puts "PUPPET #{status}: #{process}, #{state}"
The code:
res = self.class.name + ": #{@name}" + "\n"
becomes:
res = self.class.name + ": #{@name}\n"
* Don't use string concatenation to split lines unless they would be very long.
Replaced 11 occurances of
(.*)(['"]) *[+]
*(['"])(.*)
with
3 Examples:
The code:
o.define_head "The check_puppet Nagios plug-in checks that specified " +
"Puppet process is running and the state file is no " +
becomes:
o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " +
The code:
o.separator "Mandatory arguments to long options are mandatory for " +
"short options too."
becomes:
o.separator "Mandatory arguments to long options are mandatory for short options too."
The code:
o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " +
"older than specified interval."
becomes:
o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no older than specified interval."
* Replaced no occurances of do (.*?) end with {\1}
* Replaced 1488 occurances of
"([^"\n]*%s[^"\n]*)" *% *(.+?)(?=$| *\b(do|if|while|until|unless|#)\b)
with
20 Examples:
The code:
args[0].split(/\./).map do |s| "dc=%s"%[s] end.join(",")
becomes:
args[0].split(/\./).map do |s| "dc=#{s}" end.join(",")
The code:
puts "%s" % Puppet.version
becomes:
puts "#{Puppet.version}"
The code:
raise "Could not find information for %s" % node
becomes:
raise "Could not find information for #{node}"
The code:
raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)]
becomes:
raise Puppet::Error, "Cannot create #{dir}: basedir #{File.join(path)} is a file"
The code:
Puppet.err "Could not run %s: %s" % [client_class, detail]
becomes:
Puppet.err "Could not run #{client_class}: #{detail}"
The code:
raise "Could not find handler for %s" % arg
becomes:
raise "Could not find handler for #{arg}"
The code:
Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig]
becomes:
Puppet.err "Will not start without authorization file #{Puppet[:authconfig]}"
The code:
raise Puppet::Error, "Could not deserialize catalog from pson: %s" % detail
becomes:
raise Puppet::Error, "Could not deserialize catalog from pson: #{detail}"
The code:
raise "Could not find facts for %s" % Puppet[:certname]
becomes:
raise "Could not find facts for #{Puppet[:certname]}"
The code:
raise ArgumentError, "%s is not readable" % path
becomes:
raise ArgumentError, "#{path} is not readable"
The code:
raise ArgumentError, "Invalid handler %s" % name
becomes:
raise ArgumentError, "Invalid handler #{name}"
The code:
debug "Executing '%s' in zone %s with '%s'" % [command, @resource[:name], str]
becomes:
debug "Executing '#{command}' in zone #{@resource[:name]} with '#{str}'"
The code:
raise Puppet::Error, "unknown cert type '%s'" % hash[:type]
becomes:
raise Puppet::Error, "unknown cert type '#{hash[:type]}'"
The code:
Puppet.info "Creating a new certificate request for %s" % Puppet[:certname]
becomes:
Puppet.info "Creating a new certificate request for #{Puppet[:certname]}"
The code:
"Cannot create alias %s: object already exists" % [name]
becomes:
"Cannot create alias #{name}: object already exists"
The code:
return "replacing from source %s with contents %s" % [metadata.source, metadata.checksum]
becomes:
return "replacing from source #{metadata.source} with contents #{metadata.checksum}"
The code:
it "should have a %s parameter" % param do
becomes:
it "should have a #{param} parameter" do
The code:
describe "when registring '%s' messages" % log do
becomes:
describe "when registring '#{log}' messages" do
The code:
paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration%stest" % l }
becomes:
paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration#{l}test" }
The code:
assert_raise(Puppet::Error, "Check '%s' did not fail on false" % check) do
becomes:
assert_raise(Puppet::Error, "Check '#{check}' did not fail on false") do
Diffstat (limited to 'test/ral')
25 files changed, 225 insertions, 225 deletions
diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb index 4502a3258..7e9f34b52 100755 --- a/test/ral/manager/attributes.rb +++ b/test/ral/manager/attributes.rb @@ -42,15 +42,15 @@ class TestTypeAttributes < Test::Unit::TestCase end if param == :property - assert(inst.property(param), "did not get obj for %s" % param) + assert(inst.property(param), "did not get obj for #{param}") assert_equal( true, inst.should(param), "should value did not get set") else - assert_equal(true, inst[param], "did not get correct value for %s from symbol" % param) - assert_equal(true, inst[param.to_s], "did not get correct value for %s from string" % param) + assert_equal(true, inst[param], "did not get correct value for #{param} from symbol") + assert_equal(true, inst[param.to_s], "did not get correct value for #{param} from string") end end end @@ -88,11 +88,11 @@ class TestTypeAttributes < Test::Unit::TestCase def attr_check(type) @num ||= 0 @num += 1 - name = "name%s" % @num + name = "name#{@num}" inst = type.new(:name => name) [:meta, :param, :prop].each do |name| klass = type.attrclass(name) - assert(klass, "did not get class for %s" % name) + assert(klass, "did not get class for #{name}") obj = yield inst, klass assert_instance_of(klass, obj, "did not get object back") @@ -112,7 +112,7 @@ class TestTypeAttributes < Test::Unit::TestCase { :meta => :newmetaparam, :param => :newparam, :prop => :newproperty }.each do |name, method| - assert_nothing_raised("Could not make %s of type %s" % [name, method]) do + assert_nothing_raised("Could not make #{name} of type #{method}") do type.send(method, name) {} end end @@ -157,13 +157,13 @@ class TestTypeAttributes < Test::Unit::TestCase :four => :two } aliases.each do |new, old| - assert_nothing_raised("Could not create alias parameter %s" % new) do + assert_nothing_raised("Could not create alias parameter #{new}") do type.set_attr_alias new => old end end aliases.each do |new, old| - assert_equal(old, type.attr_alias(new), "did not return alias info for %s" % new) + assert_equal(old, type.attr_alias(new), "did not return alias info for #{new}") end assert_nil(type.attr_alias(:name), "got invalid alias info for name") @@ -172,7 +172,7 @@ class TestTypeAttributes < Test::Unit::TestCase assert(inst, "could not create instance") aliases.each do |new, old| - val = "value %s" % new + val = "value #{new}" assert_nothing_raised do inst[new] = val end @@ -183,12 +183,12 @@ class TestTypeAttributes < Test::Unit::TestCase assert_equal( val, inst[new], - "Incorrect alias value for %s in []" % new) + "Incorrect alias value for #{new} in []") else - assert_equal(val, inst.should(new), "Incorrect alias value for %s in should" % new) + assert_equal(val, inst.should(new), "Incorrect alias value for #{new} in should") end - assert_equal(val, inst.value(new), "Incorrect alias value for %s" % new) - assert_equal(val, inst.value(old), "Incorrect orig value for %s" % old) + assert_equal(val, inst.value(new), "Incorrect alias value for #{new}") + assert_equal(val, inst.value(old), "Incorrect orig value for #{old}") end end @@ -214,7 +214,7 @@ class TestTypeAttributes < Test::Unit::TestCase # Now make sure that we get warnings and no properties in those cases where our providers do not support the features requested [nope, maybe, yep].each_with_index do |prov, i| - resource = type.new(:provider => prov.name, :name => "test%s" % i, :none => "a", :one => "b", :two => "c") + resource = type.new(:provider => prov.name, :name => "test#{i}", :none => "a", :one => "b", :two => "c") case prov.name when :nope @@ -227,7 +227,7 @@ class TestTypeAttributes < Test::Unit::TestCase yes = [:none, :one, :two] no = [] end - yes.each { |a| assert(resource.should(a), "Did not get value for %s in %s" % [a, prov.name]) } + yes.each { |a| assert(resource.should(a), "Did not get value for #{a} in #{prov.name}") } no.each do |a| # These may or may not get passed to the provider. We shouldn't care. end @@ -245,14 +245,14 @@ class TestTypeAttributes < Test::Unit::TestCase inst = klass.new(:resource => resource) {:property => [:owner, :group], :parameter => [:ignore, :recurse], :metaparam => [:require, :subscribe]}.each do |attrtype, attrs| - assert_nothing_raised("Could not set check to a single %s value" % attrtype) do + assert_nothing_raised("Could not set check to a single #{attrtype} value") do inst.value = attrs[0] end if attrtype == :property assert(resource.property(attrs[0]), "Check did not create property instance during single check") end - assert_nothing_raised("Could not set check to multiple %s values" % attrtype) do + assert_nothing_raised("Could not set check to multiple #{attrtype} values") do inst.value = attrs end if attrtype == :property diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb index 04ecf95ea..9182dab09 100755 --- a/test/ral/manager/type.rb +++ b/test/ral/manager/type.rb @@ -10,11 +10,11 @@ class TestType < Test::Unit::TestCase def test_typemethods Puppet::Type.eachtype { |type| name = nil - assert_nothing_raised("Searching for name for %s caused failure" % type.to_s) { + assert_nothing_raised("Searching for name for #{type} caused failure") { name = type.name } - assert(name, "Could not find name for %s" % type.to_s) + assert(name, "Could not find name for #{type}") assert_equal( @@ -22,7 +22,7 @@ class TestType < Test::Unit::TestCase type, Puppet::Type.type(name), - "Failed to retrieve %s by name" % name + "Failed to retrieve #{name} by name" ) # Skip types with no parameters or valid properties @@ -36,7 +36,7 @@ class TestType < Test::Unit::TestCase type.properties, - "Properties for %s are nil" % name + "Properties for #{name} are nil" ) @@ -44,7 +44,7 @@ class TestType < Test::Unit::TestCase type.validproperties, - "Valid properties for %s are nil" % name + "Valid properties for #{name} are nil" ) } } @@ -345,7 +345,7 @@ class TestType < Test::Unit::TestCase end [:path, :owner, :recurse, :loglevel].each do |param| - assert(hash[param], "Hash did not include %s" % param) + assert(hash[param], "Hash did not include #{param}") end end diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb index f1e404ccf..46678dc7d 100755 --- a/test/ral/providers/cron/crontab.rb +++ b/test/ral/providers/cron/crontab.rb @@ -57,13 +57,13 @@ class TestCronParsedProvider < Test::Unit::TestCase # Make sure a cron job matches up. Any non-passed fields are considered absent. def assert_cron_equal(msg, cron, options) - assert_instance_of(@provider, cron, "not an instance of provider in %s" % msg) + assert_instance_of(@provider, cron, "not an instance of provider in #{msg}") options.each do |param, value| - assert_equal(value, cron.send(param), "%s was not equal in %s" % [param, msg]) + 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), "%s was not parsed absent in %s" % [var, msg]) + assert_equal(:absent, cron.send(var), "#{var} was not parsed absent in #{msg}") end end end @@ -73,13 +73,13 @@ class TestCronParsedProvider < Test::Unit::TestCase unless options.include?(:record_type) raise ArgumentError, "You must pass the required record type" end - assert_instance_of(Hash, record, "not an instance of a hash in %s" % msg) + assert_instance_of(Hash, record, "not an instance of a hash in #{msg}") options.each do |param, value| - assert_equal(value, record[param], "%s was not equal in %s" % [param, msg]) + 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], "%s was not parsed absent in %s" % [var, msg]) + assert_equal(:absent, record[var], "#{var} was not parsed absent in #{msg}") end end end @@ -100,10 +100,10 @@ class TestCronParsedProvider < Test::Unit::TestCase # First just do each sample record one by one sample_records.each do |name, options| result = nil - assert_nothing_raised("Could not parse %s: '%s'" % [name, options[:text]]) do + assert_nothing_raised("Could not parse #{name}: '#{options[:text]}'") do result = @provider.parse_line(options[:text]) end - assert_record_equal("record for %s" % name, result, options[:record]) + assert_record_equal("record for #{name}", result, options[:record]) end # Then do them all at once. @@ -120,7 +120,7 @@ class TestCronParsedProvider < Test::Unit::TestCase end records.zip(result).each do |should, record| - assert_record_equal("record for %s in full match" % should.inspect, record, should) + assert_record_equal("record for #{should.inspect} in full match", record, should) end end @@ -129,10 +129,10 @@ class TestCronParsedProvider < Test::Unit::TestCase # First just do each sample record one by one sample_records.each do |name, options| result = nil - assert_nothing_raised("Could not generate %s: '%s'" % [name, options[:record]]) do + assert_nothing_raised("Could not generate #{name}: '#{options[:record]}'") do result = @provider.to_line(options[:record]) end - assert_equal(options[:text], result, "Did not generate correct text for %s" % name) + assert_equal(options[:text], result, "Did not generate correct text for #{name}") end # Then do them all at once. @@ -160,7 +160,7 @@ class TestCronParsedProvider < Test::Unit::TestCase sample_crons.each do |name, record_names| records = record_names.collect do |record_name| unless record = sample_records[record_name] - raise "Could not find sample record %s" % record_name + raise "Could not find sample record #{record_name}" end record end @@ -174,18 +174,18 @@ class TestCronParsedProvider < Test::Unit::TestCase # First make sure we generate each one correctly result = nil - assert_nothing_raised("Could not generate multi-line cronjob %s" % [name]) do + assert_nothing_raised("Could not generate multi-line cronjob #{name}") do result = @provider.to_file(record_list) end assert_header(result) - assert_equal(text, result, "Did not generate correct text for multi-line cronjob %s" % name) + assert_equal(text, result, "Did not generate correct text for multi-line cronjob #{name}") # Now make sure we parse each one correctly - assert_nothing_raised("Could not parse multi-line cronjob %s" % [name]) do + assert_nothing_raised("Could not parse multi-line cronjob #{name}") do result = @provider.parse(text) end record_list.zip(result).each do |should, record| - assert_record_equal("multiline cronjob %s" % name, record, should) + assert_record_equal("multiline cronjob #{name}", record, should) end end @@ -211,14 +211,14 @@ class TestCronParsedProvider < Test::Unit::TestCase def test_parse_and_generate_sample_files @provider.stubs(:filetype).returns(Puppet::Util::FileType.filetype(:ram)) crondir = datadir(File.join(%w{providers cron})) - files = Dir.glob("%s/crontab.*" % crondir) + files = Dir.glob("#{crondir}/crontab.*") setme @provider.default_target = @me target = @provider.target_object(@me) files.each do |file| str = args = nil - assert_nothing_raised("could not load %s" % file) do + assert_nothing_raised("could not load #{file}") do str, args = YAML.load(File.read(file)) end @@ -238,7 +238,7 @@ class TestCronParsedProvider < Test::Unit::TestCase end end target.write(str) - assert_nothing_raised("could not parse %s" % file) do + assert_nothing_raised("could not parse #{file}") do @provider.prefetch end records = @provider.send(:instance_variable_get, "@records") @@ -257,14 +257,14 @@ class TestCronParsedProvider < Test::Unit::TestCase assert_equal( should, is, - "Did not parse %s correctly" % file) + "Did not parse #{file} correctly") end - assert_nothing_raised("could not generate %s" % file) do + assert_nothing_raised("could not generate #{file}") do @provider.flush_target(@me) end - assert_equal(str, target.read, "%s changed" % file) + assert_equal(str, target.read, "#{file} changed") @provider.clear end end @@ -345,7 +345,7 @@ class TestCronParsedProvider < Test::Unit::TestCase assert(is, "Did not get record") should.each do |p, v| - assert_equal(v, is[p], "did not parse %s correctly" % p) + assert_equal(v, is[p], "did not parse #{p} correctly") end end @@ -403,10 +403,10 @@ class TestCronParsedProvider < Test::Unit::TestCase str, target.read, "Did not write correctly") - assert_nothing_raised("Could not prefetch with %s" % str.inspect) do + assert_nothing_raised("Could not prefetch with #{str.inspect}") do @provider.prefetch end - assert_nothing_raised("Could not flush with %s" % str.inspect) do + assert_nothing_raised("Could not flush with #{str.inspect}") do @provider.flush_target(@me) end @@ -494,16 +494,16 @@ class TestCronParsedProvider < Test::Unit::TestCase end matchers.each do |cron| - assert_equal(:present, cron.provider.ensure, "Cron %s was not matched" % cron.name) + assert_equal(:present, cron.provider.ensure, "Cron #{cron.name} was not matched") if value = cron.value(:minute) and value == "*" value = :absent end assert_equal(value, cron.provider.minute, "Minutes were not retrieved, so cron was not matched") - assert_equal(cron.value(:target), cron.provider.target, "Cron %s was matched from the wrong target" % cron.name) + assert_equal(cron.value(:target), cron.provider.target, "Cron #{cron.name} was matched from the wrong target") end nonmatchers.each do |cron| - assert_equal(:absent, cron.provider.ensure, "Cron %s was incorrectly matched" % cron.name) + assert_equal(:absent, cron.provider.ensure, "Cron #{cron.name} was incorrectly matched") end end @@ -515,7 +515,7 @@ class TestCronParsedProvider < Test::Unit::TestCase text = File.read(file) target.write(text) - assert_nothing_raised("Could not parse %s" % file) do + assert_nothing_raised("Could not parse #{file}") do @provider.prefetch end # mark the provider modified @@ -525,7 +525,7 @@ class TestCronParsedProvider < Test::Unit::TestCase target.write("") result = nil - assert_nothing_raised("Could not generate %s" % file) do + assert_nothing_raised("Could not generate #{file}") do @provider.flush_target(@me) end @@ -552,7 +552,7 @@ class TestCronParsedProvider < Test::Unit::TestCase @provider.initvars str += "\n" target.write(str) - assert_nothing_raised("Could not prefetch with %s" % str.inspect) do + assert_nothing_raised("Could not prefetch with #{str.inspect}") do @provider.prefetch end records = @provider.send(:instance_variable_get, "@records") @@ -563,7 +563,7 @@ class TestCronParsedProvider < Test::Unit::TestCase "Did not create lines as freebsd lines") end - assert_nothing_raised("Could not flush with %s" % str.inspect) do + assert_nothing_raised("Could not flush with #{str.inspect}") do @provider.flush_target(@me) end @@ -654,7 +654,7 @@ class TestCronParsedProvider < Test::Unit::TestCase assert(is, "Did not get record") should.each do |p, v| - assert_equal(v, is[p], "did not parse %s correctly" % p) + assert_equal(v, is[p], "did not parse #{p} correctly") end end end diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb index 990b0b42c..067affd68 100755 --- a/test/ral/providers/group.rb +++ b/test/ral/providers/group.rb @@ -57,13 +57,13 @@ class TestGroupProvider < Test::Unit::TestCase return false end - assert_equal("", output, "Group %s is present:\n%s" % [group, output]) + assert_equal("", output, "Group #{group} is present:\n#{output}") end def gid(name) %x{nireport / /groups name gid}.split("\n").each { |line| group, id = line.chomp.split(/\s+/) - assert(id =~ /^-?\d+$/, "Group id %s for %s is not a number" % [id.inspect, group]) + assert(id =~ /^-?\d+$/, "Group id #{id.inspect} for #{group} is not a number") if group == name return Integer(id) end @@ -73,7 +73,7 @@ class TestGroupProvider < Test::Unit::TestCase end def remove(group) - system("niutil -destroy / /groups/%s" % group) + system("niutil -destroy / /groups/#{group}") end else def missing?(group) @@ -95,7 +95,7 @@ class TestGroupProvider < Test::Unit::TestCase end def remove(group) - system("groupdel %s" % group) + system("groupdel #{group}") end end @@ -183,7 +183,7 @@ class TestGroupProvider < Test::Unit::TestCase gobj = nil comp = nil name = "pptestgr" - assert(missing?(name), "Group %s is still present" % name) + assert(missing?(name), "Group #{name} is still present") group = mkgroup(name) @@tmpgroups << name @@ -192,15 +192,15 @@ class TestGroupProvider < Test::Unit::TestCase assert_nothing_raised { group.create } - assert(!missing?(name), "Group %s is missing" % name) + assert(!missing?(name), "Group #{name} is missing") tests = Puppet::Type.type(:group).validproperties tests.each { |test| - if self.respond_to?("attrtest_%s" % test) - self.send("attrtest_%s" % test, group) + if self.respond_to?("attrtest_#{test}") + self.send("attrtest_#{test}", group) else - $stderr.puts "Not testing attr %s of group" % test + $stderr.puts "Not testing attr #{test} of group" end } diff --git a/test/ral/providers/host/parsed.rb b/test/ral/providers/host/parsed.rb index 0339f7c27..2060276d7 100755 --- a/test/ral/providers/host/parsed.rb +++ b/test/ral/providers/host/parsed.rb @@ -43,9 +43,9 @@ class TestParsedHostProvider < Test::Unit::TestCase end return { - :name => "fakehost%s" % @hcount, - :ip => "192.168.27.%s" % @hcount, - :host_aliases => ["alias%s" % @hcount], + :name => "fakehost#{@hcount}", + :ip => "192.168.27.#{@hcount}", + :host_aliases => ["alias#{@hcount}"], :ensure => :present } end @@ -224,10 +224,10 @@ class TestParsedHostProvider < Test::Unit::TestCase # And verify that we have data for everything hosts.each { |host| name = host.resource[:name] - assert(text.include?(name), "Host %s is not in file" % name) + assert(text.include?(name), "Host #{name} is not in file") hash = host.property_hash - assert(! hash.empty?, "Could not find host %s" % name) - assert(hash[:ip], "Could not find ip for host %s" % name) + assert(! hash.empty?, "Could not find host #{name}") + assert(hash[:ip], "Could not find ip for host #{name}") } end end diff --git a/test/ral/providers/package.rb b/test/ral/providers/package.rb index b408d9482..600770f13 100755 --- a/test/ral/providers/package.rb +++ b/test/ral/providers/package.rb @@ -18,7 +18,7 @@ class TestPackageProvider < Test::Unit::TestCase require 'yaml' file = File.join(PuppetTest.datadir(), "providers", "package", "testpackages.yaml") unless FileTest.exists?(file) - raise "Could not find file %s" % file + raise "Could not find file #{file}" end array = YAML::load(File.read(file)).collect { |hash| # Stupid ruby 1.8.1. YAML is sometimes broken such that @@ -74,7 +74,7 @@ class TestPackageProvider < Test::Unit::TestCase elsif result.is_a?(Hash) assert (result[:ensure] == :absent or result[:ensure] == :purged), msg else - raise "dunno how to handle %s" % result.inspect + raise "dunno how to handle #{result.inspect}" end end @@ -122,7 +122,7 @@ class TestPackageProvider < Test::Unit::TestCase if hash[:source] unless FileTest.exists?(hash[:source]) - $stderr.puts "Create a package at %s for testing" % hash[:source] + $stderr.puts "Create a package at #{hash[:source]} for testing" return end end @@ -133,7 +133,7 @@ class TestPackageProvider < Test::Unit::TestCase pkg = nil assert_nothing_raised( - "Could not turn %s into a package" % hash.inspect + "Could not turn #{hash.inspect} into a package" ) do pkg = Puppet::Type.newpackage(hash) end @@ -191,7 +191,7 @@ class TestPackageProvider < Test::Unit::TestCase end provider.flush new = provider.properties - assert(current != new, "package was not upgraded: %s did not change" % current.inspect) + assert(current != new, "package was not upgraded: #{current.inspect} did not change") end unless versions.empty? @@ -202,7 +202,7 @@ class TestPackageProvider < Test::Unit::TestCase end provider.flush new = provider.properties - assert(current != new, "package was not upgraded: %s did not change" % current.inspect) + assert(current != new, "package was not upgraded: #{current.inspect} did not change") end # Now call 'latest' after the package is installed @@ -227,7 +227,7 @@ class TestPackageProvider < Test::Unit::TestCase mname = ["test", hash[:name].to_s, hash[:provider].to_s].join("_").intern if method_defined?(mname) - warn "Already a test method defined for %s" % mname + warn "Already a test method defined for #{mname}" else define_method(mname) do run_package_installation_test(hash) diff --git a/test/ral/providers/parsedfile.rb b/test/ral/providers/parsedfile.rb index a1d2435d1..93716a3ce 100755 --- a/test/ral/providers/parsedfile.rb +++ b/test/ral/providers/parsedfile.rb @@ -36,7 +36,7 @@ class TestParsedFile < Test::Unit::TestCase # A simple block to skip the complexity of a full transaction. def apply(resource) [:one, :two, :ensure, :target].each do |st| - Puppet.info "Setting %s: %s => %s" % [resource[:name], st, resource.should(st)] + Puppet.info "Setting #{resource[:name]}: #{st} => #{resource.should(st)}" resource.provider.send(st.to_s + "=", resource.should(st)) end end @@ -81,7 +81,7 @@ class TestParsedFile < Test::Unit::TestCase end [:one, :two, :name].each do |attr| - assert(prov.method_defined?(attr), "Did not define %s" % attr) + assert(prov.method_defined?(attr), "Did not define #{attr}") end # Now make sure they stay around @@ -323,7 +323,7 @@ class TestParsedFile < Test::Unit::TestCase if name == :resources assert(! list.include?(file), "Provider somehow found resource target when no resource was passed") else - assert(list.include?(file), "Provider did not find %s file" % name) + assert(list.include?(file), "Provider did not find #{name} file") end end @@ -334,7 +334,7 @@ class TestParsedFile < Test::Unit::TestCase # And make sure we get all three files files.each do |name, file| - assert(list.include?(file), "Provider did not find %s file when resource was passed" % name) + assert(list.include?(file), "Provider did not find #{name} file when resource was passed") end end @@ -434,7 +434,7 @@ class TestParsedFile < Test::Unit::TestCase mover = mkresource "mover", :target => :first [first, second, mover].each do |m| - assert_nothing_raised("Could not apply %s" % m[:name]) do + assert_nothing_raised("Could not apply #{m[:name]}") do apply(m) end end @@ -447,7 +447,7 @@ class TestParsedFile < Test::Unit::TestCase end check = proc do |target, name| - assert(prov.target_object(target).read.include?("%s a c" % name), "Did not sync %s" % name) + assert(prov.target_object(target).read.include?("#{name} a c"), "Did not sync #{name}") end # Make sure the data is there check.call(:first, :first) @@ -502,7 +502,7 @@ class TestParsedFile < Test::Unit::TestCase # Now make sure all of the data is copied over correctly. notdisk.class.validproperties.each do |property| assert_equal(notdisk.should(property), notdisk.provider.property_hash[property], - "%s was not copied over during creation" % property) + "#{property} was not copied over during creation") end # Flush it to disk and make sure it got copied down @@ -571,7 +571,7 @@ class TestParsedFile < Test::Unit::TestCase prov = bill.provider 4.times do |i| - assert(prov.one, "Did not get a value for 'one' on try %s" % (i + 1)) + assert(prov.one, "Did not get a value for 'one' on try #{(i + 1)}") end # First make sure we can retrieve values multiple times from the diff --git a/test/ral/providers/port/parsed.rb b/test/ral/providers/port/parsed.rb index 154d21260..13cc87d2c 100755 --- a/test/ral/providers/port/parsed.rb +++ b/test/ral/providers/port/parsed.rb @@ -48,7 +48,7 @@ require 'puppettest' # end # @provider.default_target = file # -# assert_nothing_raised("failed to fetch %s" % file) { +# assert_nothing_raised("failed to fetch #{file}") { # @provider.prefetch # } # @@ -60,7 +60,7 @@ require 'puppettest' # assert_equal("53", dns[:number], "dns number is wrong") # # text = nil -# assert_nothing_raised("failed to generate %s" % file) do +# assert_nothing_raised("failed to generate #{file}") do # text = @provider.to_file(@provider.target_records(file)) # end # @@ -83,7 +83,7 @@ require 'puppettest' # end # # assert_equal(old.chomp.gsub(/\s+/, ''), # # new.gsub(/\s+/, ''), -# # "Lines are not equal in %s" % file) +# # "Lines are not equal in #{file}") # end # end # end @@ -121,13 +121,13 @@ require 'puppettest' # hash.each do |param, value| # if value # assert_equal(value, record[param], -# "did not get %s out of '%s'" % [param, line]) +# "did not get #{param} out of '#{line}'") # end # end # # # Now make sure it generates correctly # assert_equal(line, @provider.to_line(record), -# "Did not generate %s correctly" % line) +# "Did not generate #{line} correctly") # end # end # end diff --git a/test/ral/providers/provider.rb b/test/ral/providers/provider.rb index e7625b95d..f716bc1cf 100755 --- a/test/ral/providers/provider.rb +++ b/test/ral/providers/provider.rb @@ -64,7 +64,7 @@ class TestProvider < Test::Unit::TestCase end end - assert_equal(result, provider.suitable?, "Failed for %s" % [hash.inspect]) + assert_equal(result, provider.suitable?, "Failed for #{hash.inspect}") provider.initvars end @@ -106,7 +106,7 @@ class TestProvider < Test::Unit::TestCase def test_command {:echo => "echo", :echo_with_path => echo, :missing => "nosuchcommand", :missing_qualified => "/path/to/nosuchcommand"}.each do |name, command| provider = newprovider - assert_nothing_raised("Could not define command %s with argument %s for provider" % [name, command]) do + assert_nothing_raised("Could not define command #{name} with argument #{command} for provider") do provider.commands(name => command) end @@ -122,7 +122,7 @@ class TestProvider < Test::Unit::TestCase # Now make sure they both work inst = provider.new(nil) [provider, inst].each do |thing| - assert_nothing_raised("Could not call %s on %s" % [command, thing]) do + assert_nothing_raised("Could not call #{command} on #{thing}") do out = thing.send(name, "some", "text") assert_equal("some text\n", out) end @@ -239,23 +239,23 @@ class TestProvider < Test::Unit::TestCase obj = prov.new(nil) %w{prop1 prop2 param1 param2}.each do |param| - assert(prov.public_method_defined?(param), "no getter for %s" % param) - assert(prov.public_method_defined?(param + "="), "no setter for %s" % param) + assert(prov.public_method_defined?(param), "no getter for #{param}") + assert(prov.public_method_defined?(param + "="), "no setter for #{param}") assert_equal( :absent, obj.send(param), "%s did not default to :absent") - val = "testing %s" % param - assert_nothing_raised("Could not call setter for %s" % param) do + val = "testing #{param}" + assert_nothing_raised("Could not call setter for #{param}") do obj.send(param + "=", val) end assert_equal( val, obj.send(param), - "did not get correct value for %s" % param) + "did not get correct value for #{param}") end end @@ -384,7 +384,7 @@ class TestProviderFeatures < Test::Unit::TestCase @providers[:neither] = [:something, :else] @providers.each do |name, methods| - assert_nothing_raised("Could not create provider %s" % name) do + assert_nothing_raised("Could not create provider #{name}") do @type.provide(name) do methods.each do |name| define_method(name) {} @@ -397,29 +397,29 @@ class TestProviderFeatures < Test::Unit::TestCase {:numbers => [:numeric], :letters => [:alpha], :both => [:numeric, :alpha], :mixed => [], :neither => []}.each do |name, should| should.sort! { |a,b| a.to_s <=> b.to_s } provider = @type.provider(name) - assert(provider, "Could not find provider %s" % name) - assert_equal(should, provider.features, "Provider %s has incorrect features" % name) + assert(provider, "Could not find provider #{name}") + assert_equal(should, provider.features, "Provider #{name} has incorrect features") inst = provider.new(resource) # Make sure the boolean methods work on both the provider and # instance. @features.keys.each do |feature| method = feature.to_s + "?" - assert(inst.respond_to?(method), "No boolean instance method for %s on %s" % [name, feature]) - assert(provider.respond_to?(method), "No boolean class method for %s on %s" % [name, feature]) + assert(inst.respond_to?(method), "No boolean instance method for #{name} on #{feature}") + assert(provider.respond_to?(method), "No boolean class method for #{name} on #{feature}") if should.include?(feature) - assert(provider.feature?(feature), "class missing feature? %s" % feature) - assert(inst.feature?(feature), "instance missing feature? %s" % feature) - assert(provider.send(method), "class missing feature %s" % feature) - assert(inst.send(method), "instance missing feature %s" % feature) - assert(inst.satisfies?(feature), "instance.satisfy %s returned false" % feature) + assert(provider.feature?(feature), "class missing feature? #{feature}") + assert(inst.feature?(feature), "instance missing feature? #{feature}") + assert(provider.send(method), "class missing feature #{feature}") + assert(inst.send(method), "instance missing feature #{feature}") + assert(inst.satisfies?(feature), "instance.satisfy #{feature} returned false") else - assert(! provider.feature?(feature), "class has feature? %s" % feature) - assert(! inst.feature?(feature), "instance has feature? %s" % feature) - assert(! provider.send(method), "class has feature %s" % feature) - assert(! inst.send(method), "instance has feature %s" % feature) - assert(! inst.satisfies?(feature), "instance.satisfy %s returned true" % feature) + assert(! provider.feature?(feature), "class has feature? #{feature}") + assert(! inst.feature?(feature), "instance has feature? #{feature}") + assert(! provider.send(method), "class has feature #{feature}") + assert(! inst.send(method), "instance has feature #{feature}") + assert(! inst.satisfies?(feature), "instance.satisfy #{feature} returned true") end end @@ -428,7 +428,7 @@ class TestProviderFeatures < Test::Unit::TestCase Puppet[:trace] = true Puppet::Type.loadall Puppet::Type.eachtype do |type| - assert(type.respond_to?(:feature), "No features method defined for %s" % type.name) + assert(type.respond_to?(:feature), "No features method defined for #{type.name}") end end @@ -482,13 +482,13 @@ class TestProviderFeatures < Test::Unit::TestCase provider_class = @type.provider(name) provider = provider_class.new({}) - assert(provider, "did not get provider named %s" % name) + assert(provider, "did not get provider named #{name}") features.sort! { |a,b| a.to_s <=> b.to_s } - assert_equal(features, provider.features, "Got incorrect feature list for provider instance %s" % name) - assert_equal(features, provider_class.features, "Got incorrect feature list for provider class %s" % name) + assert_equal(features, provider.features, "Got incorrect feature list for provider instance #{name}") + assert_equal(features, provider_class.features, "Got incorrect feature list for provider class #{name}") features.each do |feat| - assert(provider.feature?(feat), "Provider instance %s did not have feature %s" % [name, feat]) - assert(provider_class.feature?(feat), "Provider class %s did not have feature %s" % [name, feat]) + assert(provider.feature?(feat), "Provider instance #{name} did not have feature #{feat}") + assert(provider_class.feature?(feat), "Provider class #{name} did not have feature #{feat}") end end end @@ -506,7 +506,7 @@ class TestProviderFeatures < Test::Unit::TestCase # Now make sure our providers answer correctly. [nope, maybe, yep].each do |prov| - assert(prov.respond_to?(:supports_parameter?), "%s does not respond to :supports_parameter?" % prov.name) + assert(prov.respond_to?(:supports_parameter?), "#{prov.name} does not respond to :supports_parameter?") case prov.name when :nope supported = [:neither] @@ -520,10 +520,10 @@ class TestProviderFeatures < Test::Unit::TestCase end supported.each do |param| - assert(prov.supports_parameter?(param), "%s was not supported by %s" % [param, prov.name]) + assert(prov.supports_parameter?(param), "#{param} was not supported by #{prov.name}") end un.each do |param| - assert(! prov.supports_parameter?(param), "%s was incorrectly supported by %s" % [param, prov.name]) + assert(! prov.supports_parameter?(param), "#{param} was incorrectly supported by #{prov.name}") end end end diff --git a/test/ral/providers/service/base.rb b/test/ral/providers/service/base.rb index 015905180..f1db0470d 100755 --- a/test/ral/providers/service/base.rb +++ b/test/ral/providers/service/base.rb @@ -26,10 +26,10 @@ class TestBaseServiceProvider < Test::Unit::TestCase service = Puppet::Type.type(:service).new( :name => "yaytest", :provider => :base, - :start => "%s %s" % [commands[:touch], running], - :status => "%s -f %s" % [commands[:test], running], + :start => "#{commands[:touch]} #{running}", + :status => "#{commands[:test]} -f #{running}", - :stop => "%s %s" % [commands[:rm], running] + :stop => "#{commands[:rm]} #{running}" ) provider = service.provider @@ -71,7 +71,7 @@ class TestBaseServiceProvider < Test::Unit::TestCase # We can't fail well when status is messed up, because we depend on the return code # of the command for data. %w{start stop restart}.each do |command| - assert_raise(Puppet::Error, "did not throw error when %s failed" % command) do + assert_raise(Puppet::Error, "did not throw error when #{command} failed") do provider.send(command) end end diff --git a/test/ral/providers/sshkey/parsed.rb b/test/ral/providers/sshkey/parsed.rb index 8a18d5e9a..e58f59173 100755 --- a/test/ral/providers/sshkey/parsed.rb +++ b/test/ral/providers/sshkey/parsed.rb @@ -30,8 +30,8 @@ class TestParsedSSHKey < Test::Unit::TestCase @pcount = 1 end args = { - :name => name || "/fspuppet%s" % @pcount, - :key => "thisismykey%s" % @pcount, + :name => name || "/fspuppet#{@pcount}", + :key => "thisismykey#{@pcount}", :host_aliases => ["host1.domain.com","192.168.0.1"], :type => "dss", :ensure => :present @@ -82,7 +82,7 @@ class TestParsedSSHKey < Test::Unit::TestCase hash.each do |p, v| next unless key.respond_to?(p) - assert_equal(v, key.send(p), "%s did not match" % p) + assert_equal(v, key.send(p), "#{p} did not match") end assert(key.name !~ /,/, "Aliases were not split out during parsing") diff --git a/test/ral/providers/user.rb b/test/ral/providers/user.rb index 7b031891b..81b3afd3e 100755 --- a/test/ral/providers/user.rb +++ b/test/ral/providers/user.rb @@ -42,7 +42,7 @@ class TestUserProvider < Test::Unit::TestCase return false end - assert_equal("", output, "User %s is present:\n%s" % [user, output]) + assert_equal("", output, "User #{user} is present:\n#{output}") end def current?(param, user) @@ -67,7 +67,7 @@ class TestUserProvider < Test::Unit::TestCase end def remove(user) - system("niutil -destroy / /users/%s" % user) + system("niutil -destroy / /users/#{user}") end else def missing?(user) @@ -93,7 +93,7 @@ class TestUserProvider < Test::Unit::TestCase end def remove(user) - system("userdel %s" % user) + system("userdel #{user}") end end @@ -120,10 +120,10 @@ class TestUserProvider < Test::Unit::TestCase case param when :name; name when :ensure; :present - when :comment; "Puppet's Testing User %s" % name # use a single quote a la #375 + when :comment; "Puppet's Testing User #{name}" # use a single quote a la #375 when :gid; nonrootgroup.gid when :shell; findshell() - when :home; "/home/%s" % name + when :home; "/home/#{name}" else return nil end @@ -196,9 +196,9 @@ class TestUserProvider < Test::Unit::TestCase assert( val != :absent, - "Property %s is missing" % property) + "Property #{property} is missing") - assert(val, "Did not get value for %s" % property) + assert(val, "Did not get value for #{property}") end end @@ -386,7 +386,7 @@ class TestUserProvider < Test::Unit::TestCase extra = [] 5.times do |i| i += 1 - name = "pptstgr%s" % i + name = "pptstgr#{i}" tmpgroup = Puppet::Type.type(:group).new( @@ -443,7 +443,7 @@ class TestUserProvider < Test::Unit::TestCase def test_simpleuser name = "pptest" - assert(missing?(name), "User %s is present" % name) + assert(missing?(name), "User #{name} is present") user = mkuser(name) @@ -474,7 +474,7 @@ class TestUserProvider < Test::Unit::TestCase user = nil name = "pptest" - assert(missing?(name), "User %s is present" % name) + assert(missing?(name), "User #{name} is present") user = mkuser(name) @@ -496,10 +496,10 @@ class TestUserProvider < Test::Unit::TestCase just = nil tests.each { |test| - if self.respond_to?("attrtest_%s" % test) - self.send("attrtest_%s" % test, user) + if self.respond_to?("attrtest_#{test}") + self.send("attrtest_#{test}", user) else - Puppet.err "Not testing attr %s of user" % test + Puppet.err "Not testing attr #{test} of user" end } @@ -586,9 +586,9 @@ class TestUserProvider < Test::Unit::TestCase should.each do |param, value| if darwin - assert_equal(value, provider.autogen(param), "did not autogen %s for darwin correctly" % param) + assert_equal(value, provider.autogen(param), "did not autogen #{param} for darwin correctly") else - assert_nil(provider.autogen(param), "autogenned %s for non-darwin os" % param) + assert_nil(provider.autogen(param), "autogenned #{param} for non-darwin os") end end end diff --git a/test/ral/providers/user/useradd.rb b/test/ral/providers/user/useradd.rb index 7dedeefc9..2e98d7f5d 100755 --- a/test/ral/providers/user/useradd.rb +++ b/test/ral/providers/user/useradd.rb @@ -39,7 +39,7 @@ class UserAddProviderTest < PuppetTest::TestCase assert( @provider.feature?(feature), - "useradd provider is missing %s" % feature) + "useradd provider is missing #{feature}") end end @@ -74,7 +74,7 @@ class UserAddProviderTest < PuppetTest::TestCase :uid => "-u", :comment => "-c"} flags.each do |param, flag| - assert_equal(@vals[param], options[flag], "Got incorrect value for %s" % param) + assert_equal(@vals[param], options[flag], "Got incorrect value for #{param}") end true diff --git a/test/ral/type/cron.rb b/test/ral/type/cron.rb index bd334f2ec..fcee21dd0 100755 --- a/test/ral/type/cron.rb +++ b/test/ral/type/cron.rb @@ -61,7 +61,7 @@ class TestCron < Test::Unit::TestCase # Create a cron job with all fields filled in. def mkcron(name, addargs = true) cron = nil - command = "date > %s/crontest%s" % [tmpdir(), name] + command = "date > #{tmpdir()}/crontest#{name}" args = nil if addargs args = { @@ -101,7 +101,7 @@ class TestCron < Test::Unit::TestCase curtext = obj.read text.split("\n").each do |line| - assert(curtext.include?(line), "Missing '%s'" % line) + assert(curtext.include?(line), "Missing '#{line}'") end obj = Puppet::Type::Cron.cronobj(@me) @@ -201,7 +201,7 @@ class TestCron < Test::Unit::TestCase assert_equal([value.to_s], cron.should(param), "Cron value was not set correctly") end when :invalid - assert_raise(Puppet::Error, "%s is incorrectly a valid %s" % [value, param]) { + assert_raise(Puppet::Error, "#{value} is incorrectly a valid #{param}") { cron[param] = value } end @@ -348,7 +348,7 @@ class TestCron < Test::Unit::TestCase def provider_set(cron, param, value) unless param =~ /=$/ - param = "%s=" % param + param = "#{param}=" end cron.provider.send(param, value) @@ -362,7 +362,7 @@ class TestCron < Test::Unit::TestCase cron.newattr(param) property = cron.property(param) - assert(property, "Did not get %s property" % param) + assert(property, "Did not get #{param} property") assert_nothing_raised { # property.is = :absent @@ -444,7 +444,7 @@ class TestCron < Test::Unit::TestCase crons << cron assert_equal(cron.should(:user), cron.should(:target), - "Target was not set correctly for %s" % user) + "Target was not set correctly for #{user}") end provider = crons[0].provider.class @@ -459,7 +459,7 @@ class TestCron < Test::Unit::TestCase assert( text !~ /testcron-#{user}/, - "%s's cron job is in %s's tab" % [user, other]) + "#{user}'s cron job is in #{other}'s tab") end end end diff --git a/test/ral/type/exec.rb b/test/ral/type/exec.rb index cc163ead5..454458ff3 100755 --- a/test/ral/type/exec.rb +++ b/test/ral/type/exec.rb @@ -132,7 +132,7 @@ class TestExec < Test::Unit::TestCase cmd = Puppet::Type.type(:exec).new( - :command => "touch %s" % maker, + :command => "touch #{maker}", :path => "/usr/bin:/bin:/usr/sbin:/sbin", :subscribe => file, @@ -187,7 +187,7 @@ class TestExec < Test::Unit::TestCase exec = Puppet::Type.type(:exec).new( - :command => "touch %s" % file, + :command => "touch #{file}", :path => "/usr/bin:/bin:/usr/sbin:/sbin", :creates => file @@ -274,7 +274,7 @@ class TestExec < Test::Unit::TestCase cat = Puppet::Type.type(:exec).new( - :command => "cat %s %s" % [exe, oexe], + :command => "cat #{exe} #{oexe}", :path => ENV["PATH"] ) @@ -312,18 +312,18 @@ class TestExec < Test::Unit::TestCase exec = Puppet::Type.type(:exec).new( - :command => "touch %s" % bfile, - :onlyif => "test -f %s" % afile, + :command => "touch #{bfile}", + :onlyif => "test -f #{afile}", :path => ENV['PATH'] ) } assert_events([], exec) - system("touch %s" % afile) + system("touch #{afile}") assert_events([:executed_command], exec) assert_events([:executed_command], exec) - system("rm %s" % afile) + system("rm #{afile}") assert_events([], exec) end @@ -336,8 +336,8 @@ class TestExec < Test::Unit::TestCase exec = Puppet::Type.type(:exec).new( - :command => "touch %s" % bfile, - :unless => "test -f %s" % afile, + :command => "touch #{bfile}", + :unless => "test -f #{afile}", :path => ENV['PATH'] ) @@ -346,10 +346,10 @@ class TestExec < Test::Unit::TestCase assert_events([:executed_command], comp) assert_events([:executed_command], comp) - system("touch %s" % afile) + system("touch #{afile}") assert_events([], comp) assert_events([], comp) - system("rm %s" % afile) + system("rm #{afile}") assert_events([:executed_command], comp) assert_events([:executed_command], comp) end @@ -360,12 +360,12 @@ class TestExec < Test::Unit::TestCase File.umask(0022) args = { - :command => "touch %s" % file, + :command => "touch #{file}", :path => "/usr/bin:/bin:/usr/sbin:/sbin", } if user - #Puppet.warning "Using user %s" % user.name + #Puppet.warning "Using user #{user.name}" if id # convert to a string, because that's what the object expects args[:user] = user.uid.to_s @@ -375,7 +375,7 @@ class TestExec < Test::Unit::TestCase end if group - #Puppet.warning "Using group %s" % group.name + #Puppet.warning "Using group #{group.name}" if id args[:group] = group.gid.to_s else @@ -460,7 +460,7 @@ class TestExec < Test::Unit::TestCase :path => "/usr/bin:/bin", :creates => basedir, - :command => "mkdir %s; touch %s" % [basedir, path] + :command => "mkdir #{basedir}; touch #{path}" ) } @@ -497,7 +497,7 @@ class TestExec < Test::Unit::TestCase Puppet::Type.type(:exec).checks.each do |check| klass = Puppet::Type.type(:exec).paramclass(check) next if klass.value_collection.values.include? :false - assert_raise(Puppet::Error, "Check '%s' did not fail on false" % check) do + assert_raise(Puppet::Error, "Check '#{check}' did not fail on false") do exec[check] = false end end @@ -704,7 +704,7 @@ and stuff" assert_raise(Timeout::Error) { exec.run("sleep 1") } - Puppet.info "%s seconds, vs a timeout of %s" % [Time.now.to_f - time.to_f, exec[:timeout]] + Puppet.info "#{Time.now.to_f - time.to_f} seconds, vs a timeout of #{exec[:timeout]}" assert_apply(exec) diff --git a/test/ral/type/file.rb b/test/ral/type/file.rb index 24aab1fd6..f7c4c2b2a 100755 --- a/test/ral/type/file.rb +++ b/test/ral/type/file.rb @@ -35,7 +35,7 @@ class TestFile < Test::Unit::TestCase end def teardown - system("rm -rf %s" % Puppet[:statefile]) + system("rm -rf #{Puppet[:statefile]}") super end @@ -325,7 +325,7 @@ class TestFile < Test::Unit::TestCase def test_create_dir basedir = tempfile() Dir.mkdir(basedir) - %w{a b c d}.collect { |name| "#{basedir}/%s" % name }.each { |path| + %w{a b c d}.collect { |name| "#{basedir}/#{name}" }.each { |path| file = nil assert_nothing_raised() { @@ -336,7 +336,7 @@ class TestFile < Test::Unit::TestCase :ensure => "directory" ) } - assert(! FileTest.directory?(path), "Directory %s already exists" % [path]) + assert(! FileTest.directory?(path), "Directory #{path} already exists") assert_events([:directory_created], file) assert_events([], file) assert(FileTest.directory?(path)) @@ -463,7 +463,7 @@ class TestFile < Test::Unit::TestCase assert(file, "Could not retrieve file object") - assert_equal("/%s" % file.ref, file.path) + assert_equal("/#{file.ref}", file.path) end def test_autorequire @@ -812,12 +812,12 @@ class TestFile < Test::Unit::TestCase catalog = mk_catalog obj transaction = Puppet::Transaction.new(catalog) - assert_equal("/%s" % obj.ref, obj.path) + assert_equal("/#{obj.ref}", obj.path) list = transaction.eval_generate(obj) fileobj = catalog.resource(:file, file) assert(fileobj, "did not generate file object") - assert_equal("/%s" % fileobj.ref, fileobj.path, "did not generate correct subfile path") + assert_equal("/#{fileobj.ref}", fileobj.path, "did not generate correct subfile path") end # Testing #403 @@ -837,12 +837,12 @@ class TestFile < Test::Unit::TestCase second = tempfile() params = [:content, :source, :target] params.each do |param| - assert_nothing_raised("%s conflicted with ensure" % [param]) do + assert_nothing_raised("#{param} conflicted with ensure") do Puppet::Type.newfile(:path => file, param => first, :ensure => :file) end params.each do |other| next if other == param - assert_raise(Puppet::Error, "%s and %s did not conflict" % [param, other]) do + assert_raise(Puppet::Error, "#{param} and #{other} did not conflict") do Puppet::Type.newfile(:path => file, other => first, param => second) end end @@ -871,7 +871,7 @@ class TestFile < Test::Unit::TestCase else current = stat.send(should) end - assert_equal(sval, current, "Attr %s was not correct %s" % [should, msg]) + assert_equal(sval, current, "Attr #{should} was not correct #{msg}") end end @@ -883,7 +883,7 @@ class TestFile < Test::Unit::TestCase {:source => source, :content => "some content"}.each do |attr, value| file[attr] = value # First create the file - run.call(file, "upon creation with %s" % attr) + run.call(file, "upon creation with #{attr}") # Now change something so that we replace the file case attr @@ -891,11 +891,11 @@ class TestFile < Test::Unit::TestCase File.open(source, "w") { |f| f.puts "some different text" } when :content; file[:content] = "something completely different" else - raise "invalid attr %s" % attr + raise "invalid attr #{attr}" end # Run it again - run.call(file, "after modification with %s" % attr) + run.call(file, "after modification with #{attr}") # Now remove the file and the attr file.delete(attr) diff --git a/test/ral/type/file/target.rb b/test/ral/type/file/target.rb index 6b252d28f..20e68a578 100755 --- a/test/ral/type/file/target.rb +++ b/test/ral/type/file/target.rb @@ -52,8 +52,8 @@ class TestFileTarget < Test::Unit::TestCase subdir = File.join(source, "subdir") file = File.join(subdir, "file") - system("mkdir -p %s" % subdir) - system("touch %s" % file) + system("mkdir -p #{subdir}") + system("touch #{file}") link = Puppet::Type.type(:file).new( @@ -88,13 +88,13 @@ class TestFileTarget < Test::Unit::TestCase # Make a bunch of files and dirs Dir.mkdir(source) Dir.chdir(source) do - system("mkdir -p %s" % "some/path/of/dirs") - system("mkdir -p %s" % "other/path/of/dirs") - system("touch %s" % "file") - system("touch %s" % "other/file") - system("touch %s" % "some/path/of/file") - system("touch %s" % "some/path/of/dirs/file") - system("touch %s" % "other/path/of/file") + system("mkdir -p #{"some/path/of/dirs"}") + system("mkdir -p #{"other/path/of/dirs"}") + system("touch #{"file"}") + system("touch #{"other/file"}") + system("touch #{"some/path/of/file"}") + system("touch #{"some/path/of/dirs/file"}") + system("touch #{"other/path/of/file"}") files = %x{find . -type f}.chomp.split(/\n/) dirs = %x{find . -type d}.chomp.split(/\n/).reject{|d| d =~ /^\.+$/ } @@ -117,8 +117,8 @@ class TestFileTarget < Test::Unit::TestCase files.each do |f| f.sub!(/^\.#{File::SEPARATOR}/, '') path = File.join(dest, f) - assert(FileTest.exists?(path), "Link %s was not created" % path) - assert(FileTest.symlink?(path), "%s is not a link" % f) + assert(FileTest.exists?(path), "Link #{path} was not created") + assert(FileTest.symlink?(path), "#{f} is not a link") target = File.readlink(path) assert_equal(File.join(source, f), target) end @@ -126,8 +126,8 @@ class TestFileTarget < Test::Unit::TestCase dirs.each do |d| d.sub!(/^\.#{File::SEPARATOR}/, '') path = File.join(dest, d) - assert(FileTest.exists?(path), "Dir %s was not created" % path) - assert(FileTest.directory?(path), "%s is not a directory" % d) + assert(FileTest.exists?(path), "Dir #{path} was not created") + assert(FileTest.directory?(path), "#{d} is not a directory") end end @@ -163,7 +163,7 @@ class TestFileTarget < Test::Unit::TestCase resources << Puppet::Type.type(:exec).new( - :command => "mkdir %s; touch %s/file" % [source, source], + :command => "mkdir #{source}; touch #{source}/file", :title => "yay", :path => ENV["PATH"] diff --git a/test/ral/type/fileignoresource.rb b/test/ral/type/fileignoresource.rb index f158ac20d..19f510957 100755 --- a/test/ral/type/fileignoresource.rb +++ b/test/ral/type/fileignoresource.rb @@ -16,7 +16,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase begin initstorage rescue - system("rm -rf %s" % Puppet[:statefile]) + system("rm -rf #{Puppet[:statefile]}") end Facter.stubs(:to_hash).returns({}) diff --git a/test/ral/type/filesources.rb b/test/ral/type/filesources.rb index 0ca09d2ff..a928fd7db 100755 --- a/test/ral/type/filesources.rb +++ b/test/ral/type/filesources.rb @@ -33,7 +33,7 @@ class TestFileSources < Test::Unit::TestCase begin initstorage rescue - system("rm -rf %s" % Puppet[:statefile]) + system("rm -rf #{Puppet[:statefile]}") end end @@ -71,7 +71,7 @@ class TestFileSources < Test::Unit::TestCase catalog = mk_catalog(tofile) catalog.apply - assert(FileTest.exists?(todir), "Created dir %s does not exist" % todir) + assert(FileTest.exists?(todir), "Created dir #{todir} does not exist") end def run_complex_sources(networked = false) @@ -91,7 +91,7 @@ class TestFileSources < Test::Unit::TestCase todir = File.join(path, "todir") source = fromdir if networked - source = "puppet://localhost/%s%s" % [networked, fromdir] + source = "puppet://localhost/#{networked}#{fromdir}" end recursive_source_test(source, todir) @@ -245,7 +245,7 @@ class TestFileSources < Test::Unit::TestCase Puppet[:certdnsnames] = "localhost" serverpid = nil - assert_nothing_raised("Could not start on port %s" % @port) { + assert_nothing_raised("Could not start on port #{@port}") { server = Puppet::Network::HTTPServer::WEBrick.new( @@ -410,7 +410,7 @@ class TestFileSources < Test::Unit::TestCase i = i + 1 source = tempfile() sources << source - file = File.join(source, "file%s" % i) + file = File.join(source, "file#{i}") Dir.mkdir(source) File.open(file, "w") { |f| f.print "yay" } } @@ -463,12 +463,12 @@ class TestFileSources < Test::Unit::TestCase [source1, source2, File.join(source1, "subdir"), File.join(source2, "subdir")].each_with_index do |dir, i| Dir.mkdir(dir) # Make a single file in each directory - file = File.join(dir, "file%s" % i) - File.open(file, "w") { |f| f.puts "yay%s" % i} + file = File.join(dir, "file#{i}") + File.open(file, "w") { |f| f.puts "yay#{i}"} # Now make a second one in each directory - file = File.join(dir, "second-file%s" % i) - File.open(file, "w") { |f| f.puts "yaysecond-%s" % i} + file = File.join(dir, "second-file#{i}") + File.open(file, "w") { |f| f.puts "yaysecond-#{i}"} files << file end @@ -478,9 +478,9 @@ class TestFileSources < Test::Unit::TestCase ["file0", "file1", "second-file0", "second-file1", "subdir/file2", "subdir/second-file2", "subdir/file3", "subdir/second-file3"].each do |file| path = File.join(dest, file) - assert(FileTest.exists?(path), "did not create %s" % file) + assert(FileTest.exists?(path), "did not create #{file}") - assert_equal("yay%s\n" % File.basename(file).sub("file", ''), File.read(path), "file was not copied correctly") + assert_equal("yay#{File.basename(file).sub("file", '')}\n", File.read(path), "file was not copied correctly") end end diff --git a/test/ral/type/host.rb b/test/ral/type/host.rb index b6c4d9c66..3259e3ae9 100755 --- a/test/ral/type/host.rb +++ b/test/ral/type/host.rb @@ -46,9 +46,9 @@ class TestHost < Test::Unit::TestCase host = Puppet::Type.type(:host).new( - :name => "fakehost%s" % @hcount, - :ip => "192.168.27.%s" % @hcount, - :alias => "alias%s" % @hcount, + :name => "fakehost#{@hcount}", + :ip => "192.168.27.#{@hcount}", + :alias => "alias#{@hcount}", :catalog => @catalog ) diff --git a/test/ral/type/port.rb b/test/ral/type/port.rb index fa57cf55f..d48aa8c2a 100755 --- a/test/ral/type/port.rb +++ b/test/ral/type/port.rb @@ -41,11 +41,11 @@ require 'puppettest' # end # assert_nothing_raised { # port = Puppet::Type.type(:port).new( -# :name => "puppet%s" % @pcount, -# :number => "813%s" % @pcount, +# :name => "puppet#{@pcount}", +# :number => "813#{@pcount}", # :protocols => "tcp", # :description => "The port that Puppet runs on", -# :alias => "coolness%s" % @pcount +# :alias => "coolness#{@pcount}" # ) # } # diff --git a/test/ral/type/resources.rb b/test/ral/type/resources.rb index 2dd747eca..eb53a7edf 100755 --- a/test/ral/type/resources.rb +++ b/test/ral/type/resources.rb @@ -22,7 +22,7 @@ class TestResources < Test::Unit::TestCase def mk_purger(managed = false) @purgenum ||= 0 @purgenum += 1 - obj = @purgetype.create :name => "purger%s" % @purgenum + obj = @purgetype.create :name => "purger#{@purgenum}" $purgemembers[obj[:name]] = obj if managed obj[:fake] = "testing" @@ -101,11 +101,11 @@ class TestResources < Test::Unit::TestCase } if low - assert(! res.check(@user.create(:name => low)), "low user %s passed check" % low) + assert(! res.check(@user.create(:name => low)), "low user #{low} passed check") end if high res[:unless_system_user] = 50 - assert(res.check(@user.create(:name => high)), "high user %s failed check" % high) + assert(res.check(@user.create(:name => high)), "high user #{high} failed check") end end end diff --git a/test/ral/type/sshkey.rb b/test/ral/type/sshkey.rb index a774af393..e362de839 100755 --- a/test/ral/type/sshkey.rb +++ b/test/ral/type/sshkey.rb @@ -51,10 +51,10 @@ class TestSSHKey < Test::Unit::TestCase key = @sshkeytype.new( - :name => "host%s.madstop.com" % @kcount, - :key => "%sAAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=" % @kcount, + :name => "host#{@kcount}.madstop.com", + :key => "#{@kcount}AAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=", :type => "ssh-dss", - :alias => ["192.168.0.%s" % @kcount], + :alias => ["192.168.0.#{@kcount}"], :catalog => @catalog ) diff --git a/test/ral/type/user.rb b/test/ral/type/user.rb index 8e1bc9359..3187101e1 100755 --- a/test/ral/type/user.rb +++ b/test/ral/type/user.rb @@ -72,7 +72,7 @@ class TestUser < Test::Unit::TestCase :gid => Puppet::Util::SUIDManager.gid, :shell => findshell(), - :home => "/home/%s" % name + :home => "/home/#{name}" ) } diff --git a/test/ral/type/zone.rb b/test/ral/type/zone.rb index d8a191b98..f87774786 100755 --- a/test/ral/type/zone.rb +++ b/test/ral/type/zone.rb @@ -118,7 +118,7 @@ class TestZone < PuppetTest::TestCase assert( prov.method_defined?(m), - "Zone provider %s does not define method %s" % [prov.name, m]) + "Zone provider #{prov.name} does not define method #{m}") end end @@ -398,7 +398,7 @@ end [:uninstall, :configured], [:unconfigure, :absent] ].each do |method, property| - Puppet.info "Testing %s" % method + Puppet.info "Testing #{method}" current_values = nil assert_nothing_raised { current_values = zone.retrieve @@ -410,7 +410,7 @@ end assert_nothing_raised { current_values = zone.retrieve } - assert_equal(property, current_values[zone.property(:ensure)], "Method %s did not correctly set property %s" % [method, property]) + assert_equal(property, current_values[zone.property(:ensure)], "Method #{method} did not correctly set property #{property}") end end |
