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