Skip to content

Commit 0761fcf

Browse files
committed
(maint) Add bool2str & camelcase spec tests
1 parent 4274361 commit 0761fcf

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#! /usr/bin/env ruby -S rspec
2+
require 'spec_helper'
3+
4+
describe "the bool2str function" do
5+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6+
7+
it "should exist" do
8+
Puppet::Parser::Functions.function("bool2str").should == "function_bool2str"
9+
end
10+
11+
it "should raise a ParseError if there is less than 1 arguments" do
12+
lambda { scope.function_bool2str([]) }.should( raise_error(Puppet::ParseError))
13+
end
14+
15+
it "should convert true to 'true'" do
16+
result = scope.function_bool2str([true])
17+
result.should(eq('true'))
18+
end
19+
20+
it "should convert true to a string" do
21+
result = scope.function_bool2str([true])
22+
result.class.should(eq(String))
23+
end
24+
25+
it "should convert false to 'false'" do
26+
result = scope.function_bool2str([false])
27+
result.should(eq('false'))
28+
end
29+
30+
it "should convert false to a string" do
31+
result = scope.function_bool2str([false])
32+
result.class.should(eq(String))
33+
end
34+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#! /usr/bin/env ruby -S rspec
2+
require 'spec_helper'
3+
4+
describe "the camelcase function" do
5+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6+
7+
it "should exist" do
8+
Puppet::Parser::Functions.function("camelcase").should == "function_camelcase"
9+
end
10+
11+
it "should raise a ParseError if there is less than 1 arguments" do
12+
lambda { scope.function_camelcase([]) }.should( raise_error(Puppet::ParseError))
13+
end
14+
15+
it "should capitalize the beginning of a normal string" do
16+
result = scope.function_camelcase(["abc"])
17+
result.should(eq("Abc"))
18+
end
19+
20+
it "should camelcase an underscore-delimited string" do
21+
result = scope.function_camelcase(["aa_bb_cc"])
22+
result.should(eq("AaBbCc"))
23+
end
24+
end

0 commit comments

Comments
 (0)