memcached (openstack) is no longer in use
[mirror/dsa-puppet.git] / 3rdparty / modules / horizon / spec / unit / puppet / parser / functions / os_any2array_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 describe "the os_any2array function" do
5   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
7   it "should exist" do
8     Puppet::Parser::Functions.function("os_any2array").should == "function_os_any2array"
9   end
10
11   it "should return an empty array if there is less than 1 argument" do
12     result = scope.function_os_any2array([])
13     result.should(eq([]))
14   end
15
16   it "should convert boolean true to [ true ] " do
17     result = scope.function_os_any2array([true])
18     result.should(eq([true]))
19   end
20
21   it "should convert one object to [object]" do
22     result = scope.function_os_any2array(['one'])
23     result.should(eq(['one']))
24   end
25
26   it "should convert multiple objects to [objects]" do
27     result = scope.function_os_any2array(['one', 'two'])
28     result.should(eq(['one', 'two']))
29   end
30
31   it "should return empty array it was called with" do
32     result = scope.function_os_any2array([[]])
33     result.should(eq([]))
34   end
35
36   it "should return one-member array it was called with" do
37     result = scope.function_os_any2array([['string']])
38     result.should(eq(['string']))
39   end
40
41   it "should return multi-member array it was called with" do
42     result = scope.function_os_any2array([['one', 'two']])
43     result.should(eq(['one', 'two']))
44   end
45
46   it "should return members of a hash it was called with" do
47     result = scope.function_os_any2array([{ 'key' => 'value' }])
48     result.should(eq(['key', 'value']))
49   end
50
51   it "should return an empty array if it was called with an empty hash" do
52     result = scope.function_os_any2array([{ }])
53     result.should(eq([]))
54   end
55 end