]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/apache/spec/unit/puppet/parser/functions/bool2httpd_spec.rb
add Openstack modules to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / apache / spec / unit / puppet / parser / functions / bool2httpd_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 describe "the bool2httpd function" do
5   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
7   it "should exist" do
8     expect(Puppet::Parser::Functions.function("bool2httpd")).to eq("function_bool2httpd")
9   end
10
11   it "should raise a ParseError if there is less than 1 arguments" do
12     expect { scope.function_bool2httpd([]) }.to( raise_error(Puppet::ParseError))
13   end
14
15   it "should convert true to 'On'" do
16     result = scope.function_bool2httpd([true])
17     expect(result).to(eq('On'))
18   end
19
20   it "should convert true to a string" do
21     result = scope.function_bool2httpd([true])
22     expect(result.class).to(eq(String))
23   end
24
25   it "should convert false to 'Off'" do
26     result = scope.function_bool2httpd([false])
27     expect(result).to(eq('Off'))
28   end
29
30   it "should convert false to a string" do
31     result = scope.function_bool2httpd([false])
32     expect(result.class).to(eq(String))
33   end
34
35   it "should accept (and return) any string" do
36     result = scope.function_bool2httpd(["mail"])
37     expect(result).to(eq('mail'))
38   end
39
40   it "should accept a nil value (and return Off)" do
41     result = scope.function_bool2httpd([nil])
42     expect(result).to(eq('Off'))
43   end
44
45   it "should accept an undef value (and return 'Off')" do
46     result = scope.function_bool2httpd([:undef])
47     expect(result).to(eq('Off'))
48   end
49
50   it "should return a default value on non-matches" do
51     result = scope.function_bool2httpd(['foo'])
52     expect(result).to(eq('foo'))
53   end
54 end