1 #! /usr/bin/env ruby -S rspec
4 describe "the shuffle function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 expect(Puppet::Parser::Functions.function("shuffle")).to eq("function_shuffle")
11 it "should raise a ParseError if there is less than 1 arguments" do
12 expect { scope.function_shuffle([]) }.to( raise_error(Puppet::ParseError))
15 it "should shuffle a string and the result should be the same size" do
16 result = scope.function_shuffle(["asdf"])
17 expect(result.size).to(eq(4))
20 it "should shuffle a string but the sorted contents should still be the same" do
21 result = scope.function_shuffle(["adfs"])
22 expect(result.split("").sort.join("")).to(eq("adfs"))
25 it "should accept objects which extend String" do
26 class AlsoString < String
29 value = AlsoString.new('asdf')
30 result = scope.function_shuffle([value])
31 result.size.should(eq(4))