1 #! /usr/bin/env ruby -S rspec
4 describe "the any2array function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 expect(Puppet::Parser::Functions.function("any2array")).to eq("function_any2array")
11 it "should return an empty array if there is less than 1 argument" do
12 result = scope.function_any2array([])
13 expect(result).to(eq([]))
16 it "should convert boolean true to [ true ] " do
17 result = scope.function_any2array([true])
18 expect(result).to(eq([true]))
21 it "should convert one object to [object]" do
22 result = scope.function_any2array(['one'])
23 expect(result).to(eq(['one']))
26 it "should convert multiple objects to [objects]" do
27 result = scope.function_any2array(['one', 'two'])
28 expect(result).to(eq(['one', 'two']))
31 it "should return empty array it was called with" do
32 result = scope.function_any2array([[]])
33 expect(result).to(eq([]))
36 it "should return one-member array it was called with" do
37 result = scope.function_any2array([['string']])
38 expect(result).to(eq(['string']))
41 it "should return multi-member array it was called with" do
42 result = scope.function_any2array([['one', 'two']])
43 expect(result).to(eq(['one', 'two']))
46 it "should return members of a hash it was called with" do
47 result = scope.function_any2array([{ 'key' => 'value' }])
48 expect(result).to(eq(['key', 'value']))
51 it "should return an empty array if it was called with an empty hash" do
52 result = scope.function_any2array([{ }])
53 expect(result).to(eq([]))