summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:05:55 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:05:55 -0700
commite8cf06336b64491a2dd7538a06651e0caaf6a48d (patch)
tree9f5d4c83d03fefa54c385462f60875056a58a82c /spec/unit
parenteefccf252527dc5b69af5959b0b0e2ddb5c91b74 (diff)
downloadpuppet-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 'spec/unit')
-rwxr-xr-xspec/unit/daemon_spec.rb2
-rwxr-xr-xspec/unit/file_collection_spec.rb4
-rwxr-xr-xspec/unit/file_serving/metadata_spec.rb10
-rwxr-xr-xspec/unit/indirector/facts/facter_spec.rb4
-rwxr-xr-xspec/unit/indirector/ssl_file_spec.rb2
-rwxr-xr-xspec/unit/module_spec.rb2
-rwxr-xr-xspec/unit/parser/compiler_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/generate_spec.rb2
-rwxr-xr-xspec/unit/parser/scope_spec.rb10
-rwxr-xr-xspec/unit/provider/mount/parsed_spec.rb6
-rwxr-xr-xspec/unit/provider/zpool/solaris_spec.rb10
-rw-r--r--spec/unit/resource/type_collection_spec.rb2
-rw-r--r--spec/unit/type/augeas_spec.rb8
-rwxr-xr-xspec/unit/type/computer_spec.rb8
-rwxr-xr-xspec/unit/type/file/content_spec.rb2
-rwxr-xr-xspec/unit/type/macauthorization_spec.rb8
-rwxr-xr-xspec/unit/type/nagios_spec.rb12
-rwxr-xr-xspec/unit/type/schedule_spec.rb6
-rwxr-xr-xspec/unit/type/tidy_spec.rb12
-rwxr-xr-xspec/unit/type/user_spec.rb6
-rwxr-xr-xspec/unit/type/zfs_spec.rb4
-rwxr-xr-xspec/unit/type/zone_spec.rb4
-rwxr-xr-xspec/unit/type/zpool_spec.rb4
-rwxr-xr-xspec/unit/util/checksums_spec.rb12
-rwxr-xr-xspec/unit/util/log_spec.rb2
-rwxr-xr-xspec/unit/util/posix_spec.rb12
-rwxr-xr-xspec/unit/util/selinux_spec.rb6
-rwxr-xr-xspec/unit/util/warnings_spec.rb2
28 files changed, 81 insertions, 83 deletions
diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb
index e163f4067..a4fa64489 100755
--- a/spec/unit/daemon_spec.rb
+++ b/spec/unit/daemon_spec.rb
@@ -298,7 +298,7 @@ describe Puppet::Daemon do
it "should call 'exec' with the original executable and arguments" do
@daemon.argv = %w{foo}
- @daemon.expects(:exec).with($0 + " " + "foo")
+ @daemon.expects(:exec).with($0 + " foo")
@daemon.reexec
end
diff --git a/spec/unit/file_collection_spec.rb b/spec/unit/file_collection_spec.rb
index 81bcc2d2d..5e8e2ec08 100755
--- a/spec/unit/file_collection_spec.rb
+++ b/spec/unit/file_collection_spec.rb
@@ -29,12 +29,12 @@ describe Puppet::FileCollection do
it "should always correctly relate a file name and its index even when multiple files are in the collection" do
indexes = %w{a b c d e f}.inject({}) do |hash, letter|
- hash[letter] = @collection.index("/path/to/file/%s" % letter)
+ hash[letter] = @collection.index("/path/to/file/#{letter}")
hash
end
indexes.each do |letter, index|
- @collection.index("/path/to/file/%s" % letter).should == indexes[letter]
+ @collection.index("/path/to/file/#{letter}").should == indexes[letter]
@collection.path(index).should == @collection.path(index)
end
end
diff --git a/spec/unit/file_serving/metadata_spec.rb b/spec/unit/file_serving/metadata_spec.rb
index 0e2e71284..a55396577 100755
--- a/spec/unit/file_serving/metadata_spec.rb
+++ b/spec/unit/file_serving/metadata_spec.rb
@@ -170,12 +170,12 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do
end
it "should set the checksum to the file's current checksum" do
- @metadata.checksum.should == "{md5}" + @checksum
+ @metadata.checksum.should == "{md5}#{@checksum}"
end
describe "when managing files" do
it "should default to a checksum of type MD5" do
- @metadata.checksum.should == "{md5}" + @checksum
+ @metadata.checksum.should == "{md5}#{@checksum}"
end
it "should give a mtime checksum when checksum_type is set" do
@@ -183,7 +183,7 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do
@metadata.checksum_type = "mtime"
@metadata.expects(:mtime_file).returns(@time)
@metadata.collect
- @metadata.checksum.should == "{mtime}" + @time.to_s
+ @metadata.checksum.should == "{mtime}#{@time}"
end
it "should produce tab-separated mode, type, owner, group, and checksum for xmlrpc" do
@@ -200,14 +200,14 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do
it "should only use checksums of type 'ctime' for directories" do
@metadata.collect
- @metadata.checksum.should == "{ctime}" + @time.to_s
+ @metadata.checksum.should == "{ctime}#{@time}"
end
it "should only use checksums of type 'ctime' for directories even if checksum_type set" do
@metadata.checksum_type = "mtime"
@metadata.expects(:mtime_file).never
@metadata.collect
- @metadata.checksum.should == "{ctime}" + @time.to_s
+ @metadata.checksum.should == "{ctime}#{@time}"
end
it "should produce tab-separated mode, type, owner, group, and checksum for xmlrpc" do
diff --git a/spec/unit/indirector/facts/facter_spec.rb b/spec/unit/indirector/facts/facter_spec.rb
index 8f39badb1..2b127ad34 100755
--- a/spec/unit/indirector/facts/facter_spec.rb
+++ b/spec/unit/indirector/facts/facter_spec.rb
@@ -114,7 +114,7 @@ describe Puppet::Node::Facts::Facter do
describe Puppet::Node::Facts::Facter, "when loading fact plugins from disk" do
it "should load each directory in the Fact path" do
Puppet.settings.stubs(:value).returns "foo"
- Puppet.settings.expects(:value).with(:factpath).returns("one%stwo" % File::PATH_SEPARATOR)
+ Puppet.settings.expects(:value).with(:factpath).returns("one#{File::PATH_SEPARATOR}two")
Puppet::Node::Facts::Facter.expects(:load_facts_in_dir).with("one")
Puppet::Node::Facts::Facter.expects(:load_facts_in_dir).with("two")
@@ -126,7 +126,7 @@ describe Puppet::Node::Facts::Facter do
Puppet.settings.stubs(:value).returns "foo"
Puppet::Node::Facts::Facter.stubs(:load_facts_in_dir)
- Puppet.settings.expects(:value).with(:modulepath).returns("one%stwo" % File::PATH_SEPARATOR)
+ Puppet.settings.expects(:value).with(:modulepath).returns("one#{File::PATH_SEPARATOR}two")
Dir.stubs(:glob).returns []
Dir.expects(:glob).with("one/*/lib/facter").returns %w{oneA oneB}
diff --git a/spec/unit/indirector/ssl_file_spec.rb b/spec/unit/indirector/ssl_file_spec.rb
index 8f46409fe..02c7fcf0c 100755
--- a/spec/unit/indirector/ssl_file_spec.rb
+++ b/spec/unit/indirector/ssl_file_spec.rb
@@ -53,7 +53,7 @@ describe Puppet::Indirector::SslFile do
@searcher = @file_class.new
@cert = stub 'certificate', :name => "myname"
- @certpath = File.join(@path, "myname" + ".pem")
+ @certpath = File.join(@path, "myname.pem")
@request = stub 'request', :key => @cert.name, :instance => @cert
end
diff --git a/spec/unit/module_spec.rb b/spec/unit/module_spec.rb
index fcc5e60b5..910f74b9e 100755
--- a/spec/unit/module_spec.rb
+++ b/spec/unit/module_spec.rb
@@ -402,7 +402,7 @@ describe Puppet::Module, "when finding matching manifests" do
@mod = Puppet::Module.new("mymod")
@mod.stubs(:path).returns "/a"
@pq_glob_with_extension = "yay/*.xx"
- @fq_glob_with_extension = "/a/manifests/" + @pq_glob_with_extension
+ @fq_glob_with_extension = "/a/manifests/#{@pq_glob_with_extension}"
end
it "should return all manifests matching the glob pattern" do
diff --git a/spec/unit/parser/compiler_spec.rb b/spec/unit/parser/compiler_spec.rb
index 31dc196ef..872cd7961 100755
--- a/spec/unit/parser/compiler_spec.rb
+++ b/spec/unit/parser/compiler_spec.rb
@@ -16,7 +16,7 @@ class CompilerTestResource
end
def ref
- "%s[%s]" % [type.to_s.capitalize, title]
+ "#{type.to_s.capitalize}[#{title}]"
end
def evaluated?
diff --git a/spec/unit/parser/functions/generate_spec.rb b/spec/unit/parser/functions/generate_spec.rb
index 05c2cb7dc..75a5d6dac 100755
--- a/spec/unit/parser/functions/generate_spec.rb
+++ b/spec/unit/parser/functions/generate_spec.rb
@@ -28,7 +28,7 @@ describe "the generate function" do
it "should not accept a command containing illegal characters"
it "should not accept a command containing '..'" do
- command = File::SEPARATOR + "command" + File::SEPARATOR + ".." + File::SEPARATOR
+ command = File::SEPARATOR + "command#{File::SEPARATOR}..#{File::SEPARATOR}"
lambda { @scope.function_generate([command]) }.should raise_error(Puppet::ParseError)
end
diff --git a/spec/unit/parser/scope_spec.rb b/spec/unit/parser/scope_spec.rb
index 94192a693..c394282ca 100755
--- a/spec/unit/parser/scope_spec.rb
+++ b/spec/unit/parser/scope_spec.rb
@@ -471,7 +471,7 @@ describe Puppet::Parser::Scope do
# #523
%w{d f h l w z}.each do |l|
it "should parse '#{l}' when escaped" do
- string = "\\" + l
+ string = "\\#{l}"
@scope.strinterp(string).should == string
end
end
@@ -494,12 +494,12 @@ describe Puppet::Parser::Scope do
klass = parser.newclass(name)
Puppet::Parser::Resource.new(:type => "class", :title => name, :scope => scope, :source => mock('source')).evaluate
scopes[name] = scope.class_scope(klass)
- scopes[name].setvar("test", "value-%s" % name.sub(/.+::/,''))
+ scopes[name].setvar("test", "value-#{name.sub(/.+::/,'')}")
end
assert_equal("value", scope.lookupvar("::test"), "did not look up qualified value correctly")
tests.each do |input, output|
- assert_nothing_raised("Failed to scan %s" % input.inspect) do
+ assert_nothing_raised("Failed to scan #{input.inspect}") do
assert_equal(output, scope.strinterp(input), 'did not parserret %s correctly' % input.inspect)
end
end
@@ -510,7 +510,7 @@ describe Puppet::Parser::Scope do
# #523
%w{d f h l w z}.each do |l|
- string = "\\" + l
+ string = "\\#{l}"
assert_nothing_raised do
assert_equal(
@@ -523,7 +523,7 @@ describe Puppet::Parser::Scope do
assert(
logs.detect { |m| m.message =~ /Unrecognised escape/ },
- "Did not get warning about escape sequence with %s" % string)
+ "Did not get warning about escape sequence with #{string}")
logs.clear
end
end
diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb
index 4dc33708e..4db167e23 100755
--- a/spec/unit/provider/mount/parsed_spec.rb
+++ b/spec/unit/provider/mount/parsed_spec.rb
@@ -35,13 +35,13 @@ module ParsedMountTesting
@pcount = 1
end
args = {
- :name => "/fspuppet%s" % @pcount,
- :device => "/dev/dsk%s" % @pcount,
+ :name => "/fspuppet#{@pcount}",
+ :device => "/dev/dsk#{@pcount}",
}
@provider_class.fields(:parsed).each do |field|
unless args.include? field
- args[field] = "fake%s%s" % [field, @pcount]
+ args[field] = "fake#{field}#{@pcount}"
end
end
diff --git a/spec/unit/provider/zpool/solaris_spec.rb b/spec/unit/provider/zpool/solaris_spec.rb
index fc8336f32..b52ddf8f5 100755
--- a/spec/unit/provider/zpool/solaris_spec.rb
+++ b/spec/unit/provider/zpool/solaris_spec.rb
@@ -102,8 +102,8 @@ describe provider_class do
describe "when calling the getters and setters" do
[:disk, :mirror, :raidz, :log, :spare].each do |field|
- describe "when calling %s" % field do
- it "should get the %s value from the current_pool hash" % field do
+ describe "when calling #{field}" do
+ it "should get the #{field} value from the current_pool hash" do
pool_hash = mock "pool hash"
pool_hash.expects(:[]).with(field)
@provider.stubs(:current_pool).returns(pool_hash)
@@ -111,9 +111,9 @@ describe provider_class do
end
end
- describe "when setting the %s" % field do
- it "should warn the %s values were not in sync" % field do
- Puppet.expects(:warning).with("NO CHANGES BEING MADE: zpool %s does not match, should be 'shouldvalue' currently is 'currentvalue'" % field)
+ describe "when setting the #{field}" do
+ it "should warn the #{field} values were not in sync" do
+ Puppet.expects(:warning).with("NO CHANGES BEING MADE: zpool #{field} does not match, should be 'shouldvalue' currently is 'currentvalue'")
@provider.stubs(:current_pool).returns(Hash.new("currentvalue"))
@provider.send((field.to_s + "=").intern, "shouldvalue")
end
diff --git a/spec/unit/resource/type_collection_spec.rb b/spec/unit/resource/type_collection_spec.rb
index c0711bb87..9a7c80e76 100644
--- a/spec/unit/resource/type_collection_spec.rb
+++ b/spec/unit/resource/type_collection_spec.rb
@@ -140,7 +140,7 @@ describe Puppet::Resource::TypeCollection do
end
it "should have a method for adding a #{data}" do
- Puppet::Resource::TypeCollection.new("env").should respond_to("add_" + data)
+ Puppet::Resource::TypeCollection.new("env").should respond_to("add_#{data}")
end
it "should use the name of the instance to add it" do
diff --git a/spec/unit/type/augeas_spec.rb b/spec/unit/type/augeas_spec.rb
index b71f55f26..ace94109a 100644
--- a/spec/unit/type/augeas_spec.rb
+++ b/spec/unit/type/augeas_spec.rb
@@ -40,21 +40,21 @@ describe augeas do
params = [:name, :context, :onlyif, :changes, :root, :load_path, :type_check]
properties.each do |property|
- it "should have a %s property" % property do
+ it "should have a #{property} property" do
augeas.attrclass(property).ancestors.should be_include(Puppet::Property)
end
- it "should have documentation for its %s property" % property do
+ it "should have documentation for its #{property} property" do
augeas.attrclass(property).doc.should be_instance_of(String)
end
end
params.each do |param|
- it "should have a %s parameter" % param do
+ it "should have a #{param} parameter" do
augeas.attrclass(param).ancestors.should be_include(Puppet::Parameter)
end
- it "should have documentation for its %s parameter" % param do
+ it "should have documentation for its #{param} parameter" do
augeas.attrclass(param).doc.should be_instance_of(String)
end
end
diff --git a/spec/unit/type/computer_spec.rb b/spec/unit/type/computer_spec.rb
index 7522b9599..b1a6bfe1b 100755
--- a/spec/unit/type/computer_spec.rb
+++ b/spec/unit/type/computer_spec.rb
@@ -29,11 +29,11 @@ describe Puppet::Type.type(:computer), " when checking computer objects" do
params = [:name]
properties.each do |property|
- it "should have a %s property" % property do
+ it "should have a #{property} property" do
computer.attrclass(property).ancestors.should be_include(Puppet::Property)
end
- it "should have documentation for its %s property" % property do
+ it "should have documentation for its #{property} property" do
computer.attrclass(property).doc.should be_instance_of(String)
end
@@ -45,11 +45,11 @@ describe Puppet::Type.type(:computer), " when checking computer objects" do
end
params.each do |param|
- it "should have a %s parameter" % param do
+ it "should have a #{param} parameter" do
computer.attrclass(param).ancestors.should be_include(Puppet::Parameter)
end
- it "should have documentation for its %s parameter" % param do
+ it "should have documentation for its #{param} parameter" do
computer.attrclass(param).doc.should be_instance_of(String)
end
end
diff --git a/spec/unit/type/file/content_spec.rb b/spec/unit/type/file/content_spec.rb
index a07fcba2f..295f21285 100755
--- a/spec/unit/type/file/content_spec.rb
+++ b/spec/unit/type/file/content_spec.rb
@@ -119,7 +119,7 @@ describe content do
time = Time.now
@resource.parameter(:checksum).expects(:mtime_file).with(@resource[:path]).returns time
- @content.retrieve.should == "{mtime}%s" % time
+ @content.retrieve.should == "{mtime}#{time}"
end
it "should return the checksum of the file if it exists and is a normal file" do
diff --git a/spec/unit/type/macauthorization_spec.rb b/spec/unit/type/macauthorization_spec.rb
index cc9f6783b..c5305d522 100755
--- a/spec/unit/type/macauthorization_spec.rb
+++ b/spec/unit/type/macauthorization_spec.rb
@@ -24,21 +24,21 @@ describe Puppet::Type.type(:macauthorization), "when checking macauthorization o
:session_owner, :shared, :timeout, :tries]
parameters.each do |parameter|
- it "should have a %s parameter" % parameter do
+ it "should have a #{parameter} parameter" do
macauth_type.attrclass(parameter).ancestors.should be_include(Puppet::Parameter)
end
- it "should have documentation for its %s parameter" % parameter do
+ it "should have documentation for its #{parameter} parameter" do
macauth_type.attrclass(parameter).doc.should be_instance_of(String)
end
end
properties.each do |property|
- it "should have a %s property" % property do
+ it "should have a #{property} property" do
macauth_type.attrclass(property).ancestors.should be_include(Puppet::Property)
end
- it "should have documentation for its %s property" % property do
+ it "should have documentation for its #{property} property" do
macauth_type.attrclass(property).doc.should be_instance_of(String)
end
end
diff --git a/spec/unit/type/nagios_spec.rb b/spec/unit/type/nagios_spec.rb
index 2c26d3a77..bb891e641 100755
--- a/spec/unit/type/nagios_spec.rb
+++ b/spec/unit/type/nagios_spec.rb
@@ -6,7 +6,7 @@ require 'puppet/external/nagios'
describe "Nagios resource types" do
Nagios::Base.eachtype do |name, nagios_type|
- puppet_type = Puppet::Type.type("nagios_" + name.to_s)
+ puppet_type = Puppet::Type.type("nagios_#{name}")
it "should have a valid type for #{name}" do
puppet_type.should_not be_nil
@@ -23,11 +23,11 @@ describe "Nagios resource types" do
puppet_type.instance_variable_get("@doc").should_not == ""
end
- it "should have %s as its key attribute" % nagios_type.namevar do
+ it "should have #{nagios_type.namevar} as its key attribute" do
puppet_type.key_attributes.should == [nagios_type.namevar]
end
- it "should have documentation for its %s parameter" % nagios_type.namevar do
+ it "should have documentation for its #{nagios_type.namevar} parameter" do
puppet_type.attrclass(nagios_type.namevar).instance_variable_get("@doc").should_not be_nil
end
@@ -44,17 +44,17 @@ describe "Nagios resource types" do
end
nagios_type.parameters.reject { |param| param == nagios_type.namevar or param.to_s =~ /^[0-9]/ }.each do |param|
- it "should have a %s property" % param do
+ it "should have a #{param} property" do
puppet_type.should be_validproperty(param)
end
- it "should have documentation for its %s property" % param do
+ it "should have documentation for its #{param} property" do
puppet_type.attrclass(param).instance_variable_get("@doc").should_not be_nil
end
end
nagios_type.parameters.find_all { |param| param.to_s =~ /^[0-9]/ }.each do |param|
- it "should have not have a %s property" % param do
+ it "should have not have a #{param} property" do
puppet_type.should_not be_validproperty(:param)
end
end
diff --git a/spec/unit/type/schedule_spec.rb b/spec/unit/type/schedule_spec.rb
index c81930873..0a1365492 100755
--- a/spec/unit/type/schedule_spec.rb
+++ b/spec/unit/type/schedule_spec.rb
@@ -86,17 +86,17 @@ describe Puppet::Type.type(:schedule) do
include ScheduleTesting
it "should match when the start time is before the current time and the end time is after the current time" do
- @schedule[:range] = "%s - %s" % [format(Time.now - 10), format(Time.now + 10)]
+ @schedule[:range] = "#{format(Time.now - 10)} - #{format(Time.now + 10)}"
@schedule.match?.should be_true
end
it "should not match when the start time is after the current time" do
- @schedule[:range] = "%s - %s" % [format(Time.now + 5), format(Time.now + 10)]
+ @schedule[:range] = "#{format(Time.now + 5)} - #{format(Time.now + 10)}"
@schedule.match?.should be_false
end
it "should not match when the end time is previous to the current time" do
- @schedule[:range] = "%s - %s" % [format(Time.now - 10), format(Time.now - 5)]
+ @schedule[:range] = "#{format(Time.now - 10)} - #{format(Time.now - 5)}"
@schedule.match?.should be_false
end
end
diff --git a/spec/unit/type/tidy_spec.rb b/spec/unit/type/tidy_spec.rb
index 1b2f49798..f39ccb572 100755
--- a/spec/unit/type/tidy_spec.rb
+++ b/spec/unit/type/tidy_spec.rb
@@ -23,11 +23,11 @@ describe tidy do
end
[:age, :size, :path, :matches, :type, :recurse, :rmdirs].each do |param|
- it "should have a %s parameter" % param do
+ it "should have a #{param} parameter" do
Puppet::Type.type(:tidy).attrclass(param).ancestors.should be_include(Puppet::Parameter)
end
- it "should have documentation for its %s param" % param do
+ it "should have documentation for its #{param} param" do
Puppet::Type.type(:tidy).attrclass(param).doc.should be_instance_of(String)
end
end
@@ -97,8 +97,8 @@ describe tidy do
convertors[:week] = convertors[:day] * 7
convertors.each do |unit, multiple|
- it "should consider a %s to be %s seconds" % [unit, multiple] do
- @tidy = Puppet::Type.type(:tidy).new :path => @basepath, :age => "5%s" % unit.to_s[0..0]
+ it "should consider a #{unit} to be #{multiple} seconds" do
+ @tidy = Puppet::Type.type(:tidy).new :path => @basepath, :age => "5#{unit.to_s[0..0]}"
@tidy[:age].should == 5 * multiple
end
@@ -114,8 +114,8 @@ describe tidy do
}
convertors.each do |unit, multiple|
- it "should consider a %s to be 1024^%s bytes" % [unit, multiple] do
- @tidy = Puppet::Type.type(:tidy).new :path => @basepath, :size => "5%s" % unit
+ it "should consider a #{unit} to be 1024^#{multiple} bytes" do
+ @tidy = Puppet::Type.type(:tidy).new :path => @basepath, :size => "5#{unit}"
total = 5
multiple.times { total *= 1024 }
diff --git a/spec/unit/type/user_spec.rb b/spec/unit/type/user_spec.rb
index 590b35a94..5a43c9595 100755
--- a/spec/unit/type/user_spec.rb
+++ b/spec/unit/type/user_spec.rb
@@ -52,11 +52,11 @@ describe user do
properties = [:ensure, :uid, :gid, :home, :comment, :shell, :password, :groups, :roles, :auths, :profiles, :project, :keys]
properties.each do |property|
- it "should have a %s property" % property do
+ it "should have a #{property} property" do
user.attrclass(property).ancestors.should be_include(Puppet::Property)
end
- it "should have documentation for its %s property" % property do
+ it "should have documentation for its #{property} property" do
user.attrclass(property).doc.should be_instance_of(String)
end
end
@@ -64,7 +64,7 @@ describe user do
list_properties = [:groups, :roles, :auths]
list_properties.each do |property|
- it "should have a list '%s'" % property do
+ it "should have a list '#{property}'" do
user.attrclass(property).ancestors.should be_include(Puppet::Property::List)
end
end
diff --git a/spec/unit/type/zfs_spec.rb b/spec/unit/type/zfs_spec.rb
index e1af6821a..7c12a84fb 100755
--- a/spec/unit/type/zfs_spec.rb
+++ b/spec/unit/type/zfs_spec.rb
@@ -8,7 +8,7 @@ describe zfs do
properties = [:ensure, :mountpoint, :compression, :copies, :quota, :reservation, :sharenfs, :snapdir]
properties.each do |property|
- it "should have a %s property" % property do
+ it "should have a #{property} property" do
zfs.attrclass(property).ancestors.should be_include(Puppet::Property)
end
end
@@ -16,7 +16,7 @@ describe zfs do
parameters = [:name]
parameters.each do |parameter|
- it "should have a %s parameter" % parameter do
+ it "should have a #{parameter} parameter" do
zfs.attrclass(parameter).ancestors.should be_include(Puppet::Parameter)
end
end
diff --git a/spec/unit/type/zone_spec.rb b/spec/unit/type/zone_spec.rb
index 746d62a5c..302334bbd 100755
--- a/spec/unit/type/zone_spec.rb
+++ b/spec/unit/type/zone_spec.rb
@@ -16,7 +16,7 @@ describe zone do
parameters = [:create_args, :install_args, :sysidcfg, :path, :realhostname]
parameters.each do |parameter|
- it "should have a %s parameter" % parameter do
+ it "should have a #{parameter} parameter" do
zone.attrclass(parameter).ancestors.should be_include(Puppet::Parameter)
end
end
@@ -24,7 +24,7 @@ describe zone do
properties = [:ip, :iptype, :autoboot, :pool, :shares, :inherit]
properties.each do |property|
- it "should have a %s property" % property do
+ it "should have a #{property} property" do
zone.attrclass(property).ancestors.should be_include(Puppet::Property)
end
end
diff --git a/spec/unit/type/zpool_spec.rb b/spec/unit/type/zpool_spec.rb
index c957e5684..f2aa3cf59 100755
--- a/spec/unit/type/zpool_spec.rb
+++ b/spec/unit/type/zpool_spec.rb
@@ -13,7 +13,7 @@ describe zpool do
properties = [:ensure, :disk, :mirror, :raidz, :spare, :log]
properties.each do |property|
- it "should have a %s property" % property do
+ it "should have a #{property} property" do
zpool.attrclass(property).ancestors.should be_include(Puppet::Property)
end
end
@@ -21,7 +21,7 @@ describe zpool do
parameters = [:pool, :raid_parity]
parameters.each do |parameter|
- it "should have a %s parameter" % parameter do
+ it "should have a #{parameter} parameter" do
zpool.attrclass(parameter).ancestors.should be_include(Puppet::Parameter)
end
end
diff --git a/spec/unit/util/checksums_spec.rb b/spec/unit/util/checksums_spec.rb
index 35d18633a..af18a947d 100755
--- a/spec/unit/util/checksums_spec.rb
+++ b/spec/unit/util/checksums_spec.rb
@@ -17,19 +17,19 @@ describe Puppet::Util::Checksums do
file_only = [:ctime, :mtime, :none]
content_sums.each do |sumtype|
- it "should be able to calculate %s sums from strings" % sumtype do
+ it "should be able to calculate #{sumtype} sums from strings" do
@summer.should be_respond_to(sumtype)
end
end
[content_sums, file_only].flatten.each do |sumtype|
- it "should be able to calculate %s sums from files" % sumtype do
+ it "should be able to calculate #{sumtype} sums from files" do
@summer.should be_respond_to(sumtype.to_s + "_file")
end
end
[content_sums, file_only].flatten.each do |sumtype|
- it "should be able to calculate %s sums from stream" % sumtype do
+ it "should be able to calculate #{sumtype} sums from stream" do
@summer.should be_respond_to(sumtype.to_s + "_stream")
end
end
@@ -63,7 +63,7 @@ describe Puppet::Util::Checksums do
end
{:md5 => Digest::MD5, :sha1 => Digest::SHA1}.each do |sum, klass|
- describe("when using %s" % sum) do
+ describe("when using #{sum}") do
it "should use #{klass} to calculate string checksums" do
klass.expects(:hexdigest).with("mycontent").returns "whatever"
@summer.send(sum, "mycontent").should == "whatever"
@@ -102,7 +102,7 @@ describe Puppet::Util::Checksums do
end
{:md5lite => Digest::MD5, :sha1lite => Digest::SHA1}.each do |sum, klass|
- describe("when using %s" % sum) do
+ describe("when using #{sum}") do
it "should use #{klass} to calculate string checksums from the first 512 characters of the string" do
content = "this is a test" * 100
klass.expects(:hexdigest).with(content[0..511]).returns "whatever"
@@ -129,7 +129,7 @@ describe Puppet::Util::Checksums do
end
[:ctime, :mtime].each do |sum|
- describe("when using %s" % sum) do
+ describe("when using #{sum}") do
it "should use the '#{sum}' on the file to determine the ctime" do
file = "/my/file"
stat = mock 'stat', sum => "mysum"
diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb
index 6414a37ff..b622422d7 100755
--- a/spec/unit/util/log_spec.rb
+++ b/spec/unit/util/log_spec.rb
@@ -55,7 +55,7 @@ describe Puppet::Util::Log do
end
[:level, :message, :time, :remote].each do |attr|
- it "should have a %s attribute" % attr do
+ it "should have a #{attr} attribute" do
log = Puppet::Util::Log.new :level => :notice, :message => "A test message"
log.should respond_to(attr)
log.should respond_to(attr.to_s + "=")
diff --git a/spec/unit/util/posix_spec.rb b/spec/unit/util/posix_spec.rb
index 95a5608bd..33aa4a6f2 100755
--- a/spec/unit/util/posix_spec.rb
+++ b/spec/unit/util/posix_spec.rb
@@ -14,29 +14,29 @@ describe Puppet::Util::POSIX do
end
[:group, :gr].each do |name|
- it "should return :gid as the field for %s" % name do
+ it "should return :gid as the field for #{name}" do
@posix.idfield(name).should == :gid
end
- it "should return :getgrgid as the id method for %s" % name do
+ it "should return :getgrgid as the id method for #{name}" do
@posix.methodbyid(name).should == :getgrgid
end
- it "should return :getgrnam as the name method for %s" % name do
+ it "should return :getgrnam as the name method for #{name}" do
@posix.methodbyname(name).should == :getgrnam
end
end
[:user, :pw, :passwd].each do |name|
- it "should return :uid as the field for %s" % name do
+ it "should return :uid as the field for #{name}" do
@posix.idfield(name).should == :uid
end
- it "should return :getpwuid as the id method for %s" % name do
+ it "should return :getpwuid as the id method for #{name}" do
@posix.methodbyid(name).should == :getpwuid
end
- it "should return :getpwnam as the name method for %s" % name do
+ it "should return :getpwnam as the name method for #{name}" do
@posix.methodbyname(name).should == :getpwnam
end
end
diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb
index 3e10b59ed..45bc3b433 100755
--- a/spec/unit/util/selinux_spec.rb
+++ b/spec/unit/util/selinux_spec.rb
@@ -198,10 +198,8 @@ describe Puppet::Util::SELinux do
fh = stub 'fh', :close => nil
File.stubs(:open).with("/proc/mounts").returns fh
fh.stubs(:read_nonblock).returns(
- "rootfs / rootfs rw 0 0\n"+
- "/dev/root / ext3 rw,relatime,errors=continue,user_xattr,acl,data=ordered 0 0\n"+
- "/dev /dev tmpfs rw,relatime,mode=755 0 0\n"+
- "/proc /proc proc rw,relatime 0 0\n"+
+ "rootfs / rootfs rw 0 0\n/dev/root / ext3 rw,relatime,errors=continue,user_xattr,acl,data=ordered 0 0\n"+
+ "/dev /dev tmpfs rw,relatime,mode=755 0 0\n/proc /proc proc rw,relatime 0 0\n"+
"/sys /sys sysfs rw,relatime 0 0\n"
).then.raises EOFError
end
diff --git a/spec/unit/util/warnings_spec.rb b/spec/unit/util/warnings_spec.rb
index 15785cf58..4ce03ebe6 100755
--- a/spec/unit/util/warnings_spec.rb
+++ b/spec/unit/util/warnings_spec.rb
@@ -9,7 +9,7 @@ describe Puppet::Util::Warnings do
end
{:notice => "notice_once", :warning => "warnonce"}.each do |log, method|
- describe "when registring '%s' messages" % log do
+ describe "when registring '#{log}' messages" do
it "should always return nil" do
Puppet::Util::Warnings.send(method, @msg1).should be(nil)
end