diff options
Diffstat (limited to 'puppet/modules/stdlib/spec/functions/capitalize_spec.rb')
-rwxr-xr-x | puppet/modules/stdlib/spec/functions/capitalize_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/puppet/modules/stdlib/spec/functions/capitalize_spec.rb b/puppet/modules/stdlib/spec/functions/capitalize_spec.rb new file mode 100755 index 00000000..fd0e92ba --- /dev/null +++ b/puppet/modules/stdlib/spec/functions/capitalize_spec.rb @@ -0,0 +1,28 @@ +#! /usr/bin/env ruby -S rspec +require 'spec_helper' + +describe "the capitalize function" do + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } + + it "should exist" do + expect(Puppet::Parser::Functions.function("capitalize")).to eq("function_capitalize") + end + + it "should raise a ParseError if there is less than 1 arguments" do + expect { scope.function_capitalize([]) }.to( raise_error(Puppet::ParseError)) + end + + it "should capitalize the beginning of a string" do + result = scope.function_capitalize(["abc"]) + expect(result).to(eq("Abc")) + end + + it "should accept objects which extend String" do + class AlsoString < String + end + + value = AlsoString.new('abc') + result = scope.function_capitalize([value]) + result.should(eq('Abc')) + end +end |