Signed-off-by: Thomas Bellman <[email protected]>
---
spec/unit/parser/functions/split.rb | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
create mode 100755 spec/unit/parser/functions/split.rb
diff --git a/spec/unit/parser/functions/split.rb
b/spec/unit/parser/functions/split.rb
new file mode 100755
index 0000000..7f96d5d
--- /dev/null
+++ b/spec/unit/parser/functions/split.rb
@@ -0,0 +1,35 @@
+#! /usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe "the split function" do
+
+ before :each do
+ @scope = Puppet::Parser::Scope.new()
+ end
+
+ it "should exist" do
+ Puppet::Parser::Functions.function("split").should == "function_split"
+ end
+
+ it "should raise a ParseError if there is less than 2 arguments" do
+ 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))
+ end
+
+ it "should handle a simple string" do
+ result = @scope.function_split([ "130;236;254;10", ";"])
+ result.should(eql(["130", "236", "254", "10"]))
+ end
+
+ it "should not interpret the second argument as a regexp" do
+ result = @scope.function_split([ "130.236;254[.;]10", "[.;]"])
+ result.should(eql(["130.236;254", "10"]))
+ end
+
+end
--
1.6.0.6
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---