diff options
| author | Markus Roberts <Markus@reality.com> | 2010-06-28 17:10:20 -0700 |
|---|---|---|
| committer | Markus Roberts <Markus@reality.com> | 2010-06-28 17:10:20 -0700 |
| commit | fdc8c3509b5ac5bc170c54d72b2c2bafb58409f2 (patch) | |
| tree | 6ed2204d72c6924e867a1320d3b7e6728035f1a1 /spec/unit/parser/functions/split_spec.rb | |
| parent | 9a94ee274c39c261cd49e688a7bd7ea0eb73af50 (diff) | |
| download | puppet-fdc8c3509b5ac5bc170c54d72b2c2bafb58409f2.tar.gz puppet-fdc8c3509b5ac5bc170c54d72b2c2bafb58409f2.tar.xz puppet-fdc8c3509b5ac5bc170c54d72b2c2bafb58409f2.zip | |
[#3994-part 3] rename spec tests from *_spec_spec to *_spec.rb
Part 2 re-did the change on the spec files, which it shouldn't have.
Diffstat (limited to 'spec/unit/parser/functions/split_spec.rb')
| -rwxr-xr-x | spec/unit/parser/functions/split_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/unit/parser/functions/split_spec.rb b/spec/unit/parser/functions/split_spec.rb new file mode 100755 index 000000000..8aa031d19 --- /dev/null +++ b/spec/unit/parser/functions/split_spec.rb @@ -0,0 +1,51 @@ +#! /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 raise a RegexpError if the regexp is malformed" do + lambda { @scope.function_split(["foo", "("]) }.should( + 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"])) + end + + it "should handle simple regexps" do + 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"])) + end + + it "should handle simple string without metacharacters" do + result = @scope.function_split([ "130.236.254.10", ";"]) + result.should(eql(["130.236.254.10"])) + end + +end |
