37
|
1 #! /usr/bin/env ruby -S rspec
|
|
2 require 'spec_helper'
|
|
3
|
|
4 describe "the upcase function" do
|
|
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
|
7 it "should exist" do
|
|
8 expect(Puppet::Parser::Functions.function("upcase")).to eq("function_upcase")
|
|
9 end
|
|
10
|
|
11 it "should raise a ParseError if there is less than 1 arguments" do
|
|
12 expect { scope.function_upcase([]) }.to( raise_error(Puppet::ParseError))
|
|
13 end
|
|
14
|
|
15 it "should upcase a string" do
|
|
16 result = scope.function_upcase(["abc"])
|
|
17 expect(result).to(eq('ABC'))
|
|
18 end
|
|
19
|
|
20 it "should do nothing if a string is already upcase" do
|
|
21 result = scope.function_upcase(["ABC"])
|
|
22 expect(result).to(eq('ABC'))
|
|
23 end
|
|
24
|
|
25 it "should accept objects which extend String" do
|
|
26 class AlsoString < String
|
|
27 end
|
|
28
|
|
29 value = AlsoString.new('abc')
|
|
30 result = scope.function_upcase([value])
|
|
31 result.should(eq('ABC'))
|
|
32 end
|
|
33 end
|