1 #! /usr/bin/env ruby -S rspec
4 describe "the prefix function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
7 it "raises a ParseError if there is less than 1 arguments" do
8 expect { scope.function_prefix([]) }.to raise_error(Puppet::ParseError, /number of arguments/)
11 it "raises an error if the first argument is not an array" do
13 scope.function_prefix([Object.new])
14 }.to raise_error(Puppet::ParseError, /expected first argument to be an Array/)
18 it "raises an error if the second argument is not a string" do
20 scope.function_prefix([['first', 'second'], 42])
21 }.to raise_error(Puppet::ParseError, /expected second argument to be a String/)
24 it "returns a prefixed array" do
25 result = scope.function_prefix([['a','b','c'], 'p'])
26 expect(result).to(eq(['pa','pb','pc']))
29 it "returns a prefixed hash" do
30 result = scope.function_prefix([{'a' => 'b','b' => 'c','c' => 'd'}, 'p'])
31 expect(result).to(eq({'pa'=>'b','pb'=>'c','pc'=>'d'}))