summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/parser/functions/suffix_spec.rb
diff options
context:
space:
mode:
authorAdrien Thebo <git@somethingsinistral.net>2013-12-20 15:04:18 -0800
committerAdrien Thebo <git@somethingsinistral.net>2013-12-20 15:04:18 -0800
commitb50385b623bbab1dcd2a6660530c3550a3bbdfbe (patch)
treef8ae661057388c4602b8c1c3446fda923dcbb441 /spec/unit/puppet/parser/functions/suffix_spec.rb
parent799e968f5c8ba901a8b395cff6f8848caf8b00e9 (diff)
parent7085472e69569abf67862dfdd4263e8754afb89b (diff)
Merge branch 'pull-209'
This closes GH-209
Diffstat (limited to 'spec/unit/puppet/parser/functions/suffix_spec.rb')
-rw-r--r--spec/unit/puppet/parser/functions/suffix_spec.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/spec/unit/puppet/parser/functions/suffix_spec.rb b/spec/unit/puppet/parser/functions/suffix_spec.rb
index c28f719..89ba3b8 100644
--- a/spec/unit/puppet/parser/functions/suffix_spec.rb
+++ b/spec/unit/puppet/parser/functions/suffix_spec.rb
@@ -4,15 +4,23 @@ require 'spec_helper'
describe "the suffix function" do
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
- it "should exist" do
- Puppet::Parser::Functions.function("suffix").should == "function_suffix"
+ it "raises a ParseError if there is less than 1 arguments" do
+ expect { scope.function_suffix([]) }.to raise_error(Puppet::ParseError, /number of arguments/)
end
- it "should raise a ParseError if there is less than 1 arguments" do
- lambda { scope.function_suffix([]) }.should( raise_error(Puppet::ParseError))
+ it "raises an error if the first argument is not an array" do
+ expect {
+ scope.function_suffix([Object.new])
+ }.to raise_error(Puppet::ParseError, /expected first argument to be an Array/)
end
- it "should return a suffixed array" do
+ it "raises an error if the second argument is not a string" do
+ expect {
+ scope.function_suffix([['first', 'second'], 42])
+ }.to raise_error(Puppet::ParseError, /expected second argument to be a String/)
+ end
+
+ it "returns a suffixed array" do
result = scope.function_suffix([['a','b','c'], 'p'])
result.should(eq(['ap','bp','cp']))
end