summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/functions
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:05:04 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:05:04 -0700
commit9ee56f2e67be973da49b1d3f21de1bf87de35e6f (patch)
treeddab8c01509f47664c52c8a6b165bb5a974f138f /spec/unit/parser/functions
parent051bd98751d9d4bc97f93f66723d9b7a00c0cfb4 (diff)
downloadpuppet-9ee56f2e67be973da49b1d3f21de1bf87de35e6f.tar.gz
puppet-9ee56f2e67be973da49b1d3f21de1bf87de35e6f.tar.xz
puppet-9ee56f2e67be973da49b1d3f21de1bf87de35e6f.zip
Code smell: Inconsistent indentation and related formatting issues
* Replaced 163 occurances of defined\? +([@a-zA-Z_.0-9?=]+) with defined?(\1) This makes detecting subsequent patterns easier. 3 Examples: The code: if ! defined? @parse_config becomes: if ! defined?(@parse_config) The code: return @option_parser if defined? @option_parser becomes: return @option_parser if defined?(@option_parser) The code: if defined? @local and @local becomes: if defined?(@local) and @local * Eliminate trailing spaces. Replaced 428 occurances of ^(.*?) +$ with \1 1 file was skipped. test/ral/providers/host/parsed.rb because 0 * Replace leading tabs with an appropriate number of spaces. Replaced 306 occurances of ^(\t+)(.*) with Tabs are not consistently expanded in all environments. * Don't arbitrarily wrap on sprintf (%) operator. Replaced 143 occurances of (.*['"] *%) +(.*) with Splitting the line does nothing to aid clarity and hinders further refactorings. 3 Examples: The code: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] becomes: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] The code: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] becomes: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] The code: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus] becomes: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus] * Don't break short arrays/parameter list in two. Replaced 228 occurances of (.*) +(.*) with 3 Examples: The code: puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true) becomes: puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true) The code: assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type) becomes: assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type) The code: assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk") becomes: assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk") * If arguments must wrap, treat them all equally Replaced 510 occurances of lines ending in things like ...(foo, or ...(bar(1,3), with \1 \2 3 Examples: The code: midscope.to_hash(false), becomes: assert_equal( The code: botscope.to_hash(true), becomes: # bottomscope, then checking that we see the right stuff. The code: :path => link, becomes: * Replaced 4516 occurances of ^( *)(.*) with The present code base is supposed to use four-space indentation. In some places we failed to maintain that standard. These should be fixed regardless of the 2 vs. 4 space question. 15 Examples: The code: def run_comp(cmd) puts cmd results = [] old_sync = $stdout.sync $stdout.sync = true line = [] begin open("| #{cmd}", "r") do |f| until f.eof? do c = f.getc becomes: def run_comp(cmd) puts cmd results = [] old_sync = $stdout.sync $stdout.sync = true line = [] begin open("| #{cmd}", "r") do |f| until f.eof? do c = f.getc The code: s.gsub!(/.{4}/n, '\\\\u\&') } string.force_encoding(Encoding::UTF_8) string rescue Iconv::Failure => e raise GeneratorError, "Caught #{e.class}: #{e}" end else def utf8_to_pson(string) # :nodoc: string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] } string.gsub!(/( becomes: s.gsub!(/.{4}/n, '\\\\u\&') } string.force_encoding(Encoding::UTF_8) string rescue Iconv::Failure => e raise GeneratorError, "Caught #{e.class}: #{e}" end else def utf8_to_pson(string) # :nodoc: string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] } string.gsub!(/( The code: end } rvalues: rvalue | rvalues comma rvalue { if val[0].instance_of?(AST::ASTArray) result = val[0].push(val[2]) else result = ast AST::ASTArray, :children => [val[0],val[2]] end } becomes: end } rvalues: rvalue | rvalues comma rvalue { if val[0].instance_of?(AST::ASTArray) result = val[0].push(val[2]) else result = ast AST::ASTArray, :children => [val[0],val[2]] end } The code: #passwdproc = proc { @password } keytext = @key.export( OpenSSL::Cipher::DES.new(:EDE3, :CBC), @password ) File.open(@keyfile, "w", 0400) { |f| f << keytext } becomes: # passwdproc = proc { @password } keytext = @key.export( OpenSSL::Cipher::DES.new(:EDE3, :CBC), @password ) File.open(@keyfile, "w", 0400) { |f| f << keytext } The code: end def to_manifest "%s { '%s':\n%s\n}" % [self.type.to_s, self.name, @params.collect { |p, v| if v.is_a? Array " #{p} => [\'#{v.join("','")}\']" else " #{p} => \'#{v}\'" end }.join(",\n") becomes: end def to_manifest "%s { '%s':\n%s\n}" % [self.type.to_s, self.name, @params.collect { |p, v| if v.is_a? Array " #{p} => [\'#{v.join("','")}\']" else " #{p} => \'#{v}\'" end }.join(",\n") The code: via the augeas tool. Requires: - augeas to be installed (http://www.augeas.net) - ruby-augeas bindings Sample usage with a string:: augeas{\"test1\" : context => \"/files/etc/sysconfig/firstboot\", changes => \"set RUN_FIRSTBOOT YES\", becomes: via the augeas tool. Requires: - augeas to be installed (http://www.augeas.net) - ruby-augeas bindings Sample usage with a string:: augeas{\"test1\" : context => \"/files/etc/sysconfig/firstboot\", changes => \"set RUN_FIRSTBOOT YES\", The code: names.should_not be_include("root") end describe "when generating a purgeable resource" do it "should be included in the generated resources" do Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource] @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref) end end describe "when the instance's do not have an ensure property" do becomes: names.should_not be_include("root") end describe "when generating a purgeable resource" do it "should be included in the generated resources" do Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource] @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref) end end describe "when the instance's do not have an ensure property" do The code: describe "when the instance's do not have an ensure property" do it "should not be included in the generated resources" do @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo') Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource] @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref) end end describe "when the instance's ensure property does not accept absent" do it "should not be included in the generated resources" do @no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar') becomes: describe "when the instance's do not have an ensure property" do it "should not be included in the generated resources" do @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo') Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource] @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref) end end describe "when the instance's ensure property does not accept absent" do it "should not be included in the generated resources" do @no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar') The code: func = nil assert_nothing_raised do func = Puppet::Parser::AST::Function.new( :name => "template", :ftype => :rvalue, :arguments => AST::ASTArray.new( :children => [stringobj(template)] ) becomes: func = nil assert_nothing_raised do func = Puppet::Parser::AST::Function.new( :name => "template", :ftype => :rvalue, :arguments => AST::ASTArray.new( :children => [stringobj(template)] ) The code: assert( @store.allowed?("hostname.madstop.com", "192.168.1.50"), "hostname not allowed") assert( ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"), "subname name allowed") becomes: assert( @store.allowed?("hostname.madstop.com", "192.168.1.50"), "hostname not allowed") assert( ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"), "subname name allowed") The code: assert_nothing_raised { server = Puppet::Network::Handler.fileserver.new( :Local => true, :Config => false ) } becomes: assert_nothing_raised { server = Puppet::Network::Handler.fileserver.new( :Local => true, :Config => false ) } The code: 'yay', { :failonfail => false, :uid => @user.uid, :gid => @user.gid } ).returns('output') output = Puppet::Util::SUIDManager.run_and_capture 'yay', @user.uid, @user.gid becomes: 'yay', { :failonfail => false, :uid => @user.uid, :gid => @user.gid } ).returns('output') output = Puppet::Util::SUIDManager.run_and_capture 'yay', @user.uid, @user.gid The code: ).times(1) pkg.provider.expects( :aptget ).with( '-y', '-q', 'remove', 'faff' becomes: ).times(1) pkg.provider.expects( :aptget ).with( '-y', '-q', 'remove', 'faff' The code: johnny one two billy three four\n" # Just parse and generate, to make sure it's isomorphic. assert_nothing_raised do assert_equal(text, @parser.to_file(@parser.parse(text)), "parsing was not isomorphic") end end def test_valid_attrs becomes: johnny one two billy three four\n" # Just parse and generate, to make sure it's isomorphic. assert_nothing_raised do assert_equal(text, @parser.to_file(@parser.parse(text)), "parsing was not isomorphic") end end def test_valid_attrs The code: "testing", :onboolean => [true, "An on bool"], :string => ["a string", "A string arg"] ) result = [] should = [] assert_nothing_raised("Add args failed") do @config.addargs(result) end @config.each do |name, element| becomes: "testing", :onboolean => [true, "An on bool"], :string => ["a string", "A string arg"] ) result = [] should = [] assert_nothing_raised("Add args failed") do @config.addargs(result) end @config.each do |name, element|
Diffstat (limited to 'spec/unit/parser/functions')
-rwxr-xr-xspec/unit/parser/functions/defined_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/regsubst_spec.rb134
-rwxr-xr-xspec/unit/parser/functions/shellquote_spec.rb51
-rwxr-xr-xspec/unit/parser/functions/split_spec.rb24
-rwxr-xr-xspec/unit/parser/functions/sprintf_spec.rb5
5 files changed, 113 insertions, 103 deletions
diff --git a/spec/unit/parser/functions/defined_spec.rb b/spec/unit/parser/functions/defined_spec.rb
index 03b0ef9dd..90f2f5239 100755
--- a/spec/unit/parser/functions/defined_spec.rb
+++ b/spec/unit/parser/functions/defined_spec.rb
@@ -18,7 +18,7 @@ describe "the 'defined' function" do
@scope.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "yayness")
@scope.function_defined("yayness").should be_true
end
-
+
it "should be true when the name is defined as a definition" do
@scope.known_resource_types.add Puppet::Resource::Type.new(:definition, "yayness")
@scope.function_defined("yayness").should be_true
diff --git a/spec/unit/parser/functions/regsubst_spec.rb b/spec/unit/parser/functions/regsubst_spec.rb
index 5a533efb1..6ff619f8d 100755
--- a/spec/unit/parser/functions/regsubst_spec.rb
+++ b/spec/unit/parser/functions/regsubst_spec.rb
@@ -13,29 +13,24 @@ describe "the regsubst function" do
end
it "should raise a ParseError if there is less than 3 arguments" do
- lambda { @scope.function_regsubst(["foo", "bar"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst(["foo", "bar"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError if there is more than 5 arguments" do
- lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "del", "x", "y"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "del", "x", "y"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError when given a bad flag" do
- lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "X"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "X"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError for non-string and non-array target" do
- lambda { @scope.function_regsubst([4711, "bar", "gazonk"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst([4711, "bar", "gazonk"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError for array target with non-string element" do
- lambda { @scope.function_regsubst([["x", ["y"], "z"], "bar", "gazonk"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst([["x", ["y"], "z"], "bar", "gazonk"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError for a bad regular expression" do
@@ -44,63 +39,80 @@ describe "the regsubst function" do
end
it "should raise a ParseError for a non-string regular expression" do
- lambda { @scope.function_regsubst(["foo", ["bar"], "gazonk"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst(["foo", ["bar"], "gazonk"]) }.should( raise_error(Puppet::ParseError))
end
it "should handle groups" do
+
result = @scope.function_regsubst(
+
[ '130.236.254.10',
- '^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$',
- '\4-\3-\2-\1'
+
+ '^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$',
+ '\4-\3-\2-\1'
])
result.should(eql("10-254-236-130"))
end
it "should handle simple regexps" do
+
result = @scope.function_regsubst(
+
[ "the monkey breaks banana trees",
- "b[an]*a",
- "coconut"
+ "b[an]*a",
+
+ "coconut"
])
result.should(eql("the monkey breaks coconut trees"))
end
it "should handle case-sensitive regexps" do
+
result = @scope.function_regsubst(
+
[ "the monkey breaks baNAna trees",
- "b[an]+a",
- "coconut"
+ "b[an]+a",
+
+ "coconut"
])
result.should(eql("the monkey breaks baNAna trees"))
end
it "should handle case-insensitive regexps" do
+
result = @scope.function_regsubst(
+
[ "the monkey breaks baNAna trees",
- "b[an]+a",
- "coconut",
- "I"
+ "b[an]+a",
+ "coconut",
+
+ "I"
])
result.should(eql("the monkey breaks coconut trees"))
end
it "should handle global substitutions" do
+
result = @scope.function_regsubst(
+
[ "the monkey breaks\tbanana trees",
- "[ \t]",
- "--",
- "G"
+ "[ \t]",
+ "--",
+
+ "G"
])
result.should(eql("the--monkey--breaks--banana--trees"))
end
it "should handle global substitutions with groups" do
+
result = @scope.function_regsubst(
+
[ '130.236.254.10',
- '([0-9]+)',
- '<\1>',
- 'G'
+
+ '([0-9]+)',
+ '<\1>',
+ 'G'
])
result.should(eql('<130>.<236>.<254>.<10>'))
end
@@ -108,59 +120,71 @@ describe "the regsubst function" do
it "should apply on all elements of an array" do
data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40']
result = @scope.function_regsubst([ data, '[.]', '-'])
- result.should(eql(
- ['130-236.254.10', 'foo-example.com', 'coconut', '10-20.30.40']))
+ result.should(eql( ['130-236.254.10', 'foo-example.com', 'coconut', '10-20.30.40']))
end
it "should apply global substitutions on all elements of an array" do
data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40']
result = @scope.function_regsubst([ data, '[.]', '-', 'G'])
- result.should(eql(
- ['130-236-254-10', 'foo-example-com', 'coconut', '10-20-30-40']))
+ result.should(eql( ['130-236-254-10', 'foo-example-com', 'coconut', '10-20-30-40']))
end
it "should handle groups on all elements of an array" do
data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40']
- result = @scope.function_regsubst(
- [ data,
- '^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$',
- '\4-\3-\2-\1'
+
+ result = @scope.function_regsubst(
+
+ [ data,
+
+ '^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$',
+ '\4-\3-\2-\1'
])
- result.should(eql(
- ['10-254-236-130', 'foo.example.com', 'coconut', '40-30-20-10']))
+ result.should(eql( ['10-254-236-130', 'foo.example.com', 'coconut', '40-30-20-10']))
end
it "should handle global substitutions with groups on all elements of an array" do
data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40']
- result = @scope.function_regsubst(
- [ data,
- '([^.]+)',
- '<\1>',
- 'G'
+
+ result = @scope.function_regsubst(
+
+ [ data,
+
+ '([^.]+)',
+ '<\1>',
+ 'G'
])
- result.should(eql(
- ['<130>.<236>.<254>.<10>', '<foo>.<example>.<com>',
- '<coconut>', '<10>.<20>.<30>.<40>']))
+
+ result.should(eql(
+
+ ['<130>.<236>.<254>.<10>', '<foo>.<example>.<com>',
+
+ '<coconut>', '<10>.<20>.<30>.<40>']))
end
it "should return an array (not a string) for a single element array parameter" do
data = ['130.236.254.10']
- result = @scope.function_regsubst(
- [ data,
- '([^.]+)',
- '<\1>',
- 'G'
+
+ result = @scope.function_regsubst(
+
+ [ data,
+
+ '([^.]+)',
+ '<\1>',
+ 'G'
])
result.should(eql(['<130>.<236>.<254>.<10>']))
end
it "should return a string (not a one element array) for a simple string parameter" do
data = '130.236.254.10'
- result = @scope.function_regsubst(
- [ data,
- '([^.]+)',
- '<\1>',
- 'G'
+
+ result = @scope.function_regsubst(
+
+ [ data,
+
+ '([^.]+)',
+ '<\1>',
+ 'G'
])
result.should(eql('<130>.<236>.<254>.<10>'))
end
diff --git a/spec/unit/parser/functions/shellquote_spec.rb b/spec/unit/parser/functions/shellquote_spec.rb
index 283a4de1e..8286be32e 100755
--- a/spec/unit/parser/functions/shellquote_spec.rb
+++ b/spec/unit/parser/functions/shellquote_spec.rb
@@ -19,74 +19,63 @@ describe "the shellquote function" do
end
it "should handle several simple arguments" do
- result = @scope.function_shellquote(
- ['foo', 'bar@example.com', 'localhost:/dev/null', 'xyzzy+-4711,23'])
- result.should(eql(
- 'foo bar@example.com localhost:/dev/null xyzzy+-4711,23'))
+ result = @scope.function_shellquote( ['foo', 'bar@example.com', 'localhost:/dev/null', 'xyzzy+-4711,23'])
+ result.should(eql( 'foo bar@example.com localhost:/dev/null xyzzy+-4711,23'))
end
it "should handle array arguments" do
+
result = @scope.function_shellquote(
+
['foo', ['bar@example.com', 'localhost:/dev/null'],
- 'xyzzy+-4711,23'])
+
+ 'xyzzy+-4711,23'])
result.should(eql(
'foo bar@example.com localhost:/dev/null xyzzy+-4711,23'))
end
it "should quote unsafe characters" do
- result = @scope.function_shellquote(
- ['/etc/passwd ', '(ls)', '*', '[?]', "'&'"])
- result.should(eql(
- '"/etc/passwd " "(ls)" "*" "[?]" "\'&\'"'))
+ result = @scope.function_shellquote( ['/etc/passwd ', '(ls)', '*', '[?]', "'&'"])
+ result.should(eql( '"/etc/passwd " "(ls)" "*" "[?]" "\'&\'"'))
end
it "should deal with double quotes" do
result = @scope.function_shellquote(
- ['"foo"bar"'])
+ ['"foo"bar"'])
result.should(eql(
'\'"foo"bar"\''))
end
it "should cope with dollar signs" do
- result = @scope.function_shellquote(
- ['$PATH', 'foo$bar', '"x$"'])
- result.should(eql(
- "'$PATH' 'foo$bar' '\"x$\"'"))
+ result = @scope.function_shellquote( ['$PATH', 'foo$bar', '"x$"'])
+ result.should(eql( "'$PATH' 'foo$bar' '\"x$\"'"))
end
it "should deal with apostrophes (single quotes)" do
result = @scope.function_shellquote(
- ["'foo'bar'", "`$'EDITOR'`"])
+ ["'foo'bar'", "`$'EDITOR'`"])
result.should(eql(
'"\'foo\'bar\'" "\\`\\$\'EDITOR\'\\`"'))
end
it "should cope with grave accents (backquotes)" do
- result = @scope.function_shellquote(
- ['`echo *`', '`ls "$MAILPATH"`'])
- result.should(eql(
- "'`echo *`' '`ls \"$MAILPATH\"`'"))
+ result = @scope.function_shellquote( ['`echo *`', '`ls "$MAILPATH"`'])
+ result.should(eql( "'`echo *`' '`ls \"$MAILPATH\"`'"))
end
it "should deal with both single and double quotes" do
- result = @scope.function_shellquote(
- ['\'foo"bar"xyzzy\'', '"foo\'bar\'xyzzy"'])
- result.should(eql(
- '"\'foo\\"bar\\"xyzzy\'" "\\"foo\'bar\'xyzzy\\""'))
+ result = @scope.function_shellquote( ['\'foo"bar"xyzzy\'', '"foo\'bar\'xyzzy"'])
+ result.should(eql( '"\'foo\\"bar\\"xyzzy\'" "\\"foo\'bar\'xyzzy\\""'))
end
it "should handle multiple quotes *and* dollars and backquotes" do
- result = @scope.function_shellquote(
- ['\'foo"$x`bar`"xyzzy\''])
- result.should(eql(
- '"\'foo\\"\\$x\\`bar\\`\\"xyzzy\'"'))
+ result = @scope.function_shellquote( ['\'foo"$x`bar`"xyzzy\''])
+ result.should(eql( '"\'foo\\"\\$x\\`bar\\`\\"xyzzy\'"'))
end
it "should handle linefeeds" do
- result = @scope.function_shellquote(
- ["foo \n bar"])
- result.should(eql(
- "\"foo \n bar\""))
+ result = @scope.function_shellquote( ["foo \n bar"])
+ result.should(eql( "\"foo \n bar\""))
end
end
diff --git a/spec/unit/parser/functions/split_spec.rb b/spec/unit/parser/functions/split_spec.rb
index 8aa031d19..3d0240af4 100755
--- a/spec/unit/parser/functions/split_spec.rb
+++ b/spec/unit/parser/functions/split_spec.rb
@@ -13,39 +13,37 @@ describe "the split function" do
end
it "should raise a ParseError if there is less than 2 arguments" do
- lambda { @scope.function_split(["foo"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_split(["foo"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError if there is more than 2 arguments" do
- lambda { @scope.function_split(["foo", "bar", "gazonk"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_split(["foo", "bar", "gazonk"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a RegexpError if the regexp is malformed" do
lambda { @scope.function_split(["foo", "("]) }.should(
- raise_error(RegexpError))
+ raise_error(RegexpError))
end
it "should handle simple string without metacharacters" do
- result = @scope.function_split([ "130;236;254;10", ";"])
- result.should(eql(["130", "236", "254", "10"]))
+ result = @scope.function_split([ "130;236;254;10", ";"])
+ result.should(eql(["130", "236", "254", "10"]))
end
it "should handle simple regexps" do
- result = @scope.function_split([ "130.236;254.;10", "[.;]+"])
- result.should(eql(["130", "236", "254", "10"]))
+ result = @scope.function_split([ "130.236;254.;10", "[.;]+"])
+ result.should(eql(["130", "236", "254", "10"]))
end
it "should handle groups" do
- result = @scope.function_split([ "130.236;254.;10", "([.;]+)"])
- result.should(eql(["130", ".", "236", ";", "254", ".;", "10"]))
+ result = @scope.function_split([ "130.236;254.;10", "([.;]+)"])
+ result.should(eql(["130", ".", "236", ";", "254", ".;", "10"]))
end
it "should handle simple string without metacharacters" do
- result = @scope.function_split([ "130.236.254.10", ";"])
- result.should(eql(["130.236.254.10"]))
+ result = @scope.function_split([ "130.236.254.10", ";"])
+ result.should(eql(["130.236.254.10"]))
end
end
diff --git a/spec/unit/parser/functions/sprintf_spec.rb b/spec/unit/parser/functions/sprintf_spec.rb
index 949dc3fcc..71921e0e0 100755
--- a/spec/unit/parser/functions/sprintf_spec.rb
+++ b/spec/unit/parser/functions/sprintf_spec.rb
@@ -13,8 +13,7 @@ describe "the sprintf function" do
end
it "should raise a ParseError if there is less than 1 argument" do
- lambda { @scope.function_sprintf([]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_sprintf([]) }.should( raise_error(Puppet::ParseError))
end
it "should format integers" do
@@ -35,7 +34,7 @@ describe "the sprintf function" do
it "should perform more complex formatting" do
result = @scope.function_sprintf(
[ "<%.8s:%#5o %#8X (%-8s)>",
- "overlongstring", "23", "48879", "foo" ])
+ "overlongstring", "23", "48879", "foo" ])
result.should(eql("<overlong: 027 0XBEEF (foo )>"))
end