1 #! /usr/bin/env ruby -S rspec
4 describe "the unique function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 expect(Puppet::Parser::Functions.function("unique")).to eq("function_unique")
11 it "should raise a ParseError if there is less than 1 arguments" do
12 expect { scope.function_unique([]) }.to( raise_error(Puppet::ParseError))
15 it "should remove duplicate elements in a string" do
16 result = scope.function_unique(["aabbc"])
17 expect(result).to(eq('abc'))
20 it "should remove duplicate elements in an array" do
21 result = scope.function_unique([["a","a","b","b","c"]])
22 expect(result).to(eq(['a','b','c']))
25 it "should accept objects which extend String" do
26 class AlsoString < String
29 value = AlsoString.new('aabbc')
30 result = scope.function_unique([value])
31 result.should(eq('abc'))