diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-02-14 12:11:35 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-02-14 12:11:35 -0200 |
commit | 0b03f41b32e8423bbbfa3c8a6b02dbf17c04f4c1 (patch) | |
tree | c5d7863c96377394b8559fbd5c7777fb32b6fda1 /spec/unit/parser/functions | |
parent | e0080adb1ca115ee98bf97c9cfb91fccbfeddaac (diff) | |
parent | a81984c77ed1efb56e978d8b5050b6c3ec409d80 (diff) |
Merge branch 'master' of git://labs.riseup.net/shared-common
Conflicts:
lib/puppet/parser/functions/gsub.rb
lib/puppet/parser/functions/prefix_with.rb
lib/puppet/parser/functions/slash_escape.rb
lib/puppet/parser/functions/split.rb
lib/puppet/parser/functions/substitute.rb
manifests/classes/lsb_release.pp
manifests/defines/concatenated_file.pp
manifests/defines/config_file.pp
manifests/defines/line.pp
manifests/defines/module_dir.pp
manifests/defines/module_file.pp
manifests/defines/replace.pp
manifests/init.pp
Diffstat (limited to 'spec/unit/parser/functions')
-rw-r--r-- | spec/unit/parser/functions/array_del.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/unit/parser/functions/array_del.rb b/spec/unit/parser/functions/array_del.rb new file mode 100644 index 0000000..b375862 --- /dev/null +++ b/spec/unit/parser/functions/array_del.rb @@ -0,0 +1,39 @@ +#! /usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../../spec_helper' + +describe "the array_del function" do + + before :each do + @scope = Puppet::Parser::Scope.new + end + + it "should exist" do + Puppet::Parser::Functions.function("array_del").should == "function_array_del" + end + + it "should raise a ParseError if there is less than 2 arguments" do + lambda { @scope.function_array_del(["foo"]) }.should( raise_error(Puppet::ParseError)) + end + + it "should raise a ParseError if there is more than 2 arguments" do + lambda { @scope.function_array_del(["foo", "bar", "gazonk"]) }.should( raise_error(Puppet::ParseError)) + end + + it "should remove an item if it's present" do + result = @scope.function_array_del(['a','b'],'b') + result.should(eql(['a'])) + end + + it "should do nothing if an item is not present" do + result = @scope.function_array_del(['a','b'],'c') + result.should(eql(['a','b'])) + end + + it "should leave the argument untouched" do + a = ['a','b'] + result = @scope.function_array_del(a,'b') + a.should(eql(['a','b'])) + end + +end |