summaryrefslogtreecommitdiff
path: root/puppet/modules/stdlib/spec/functions/type_spec.rb
diff options
context:
space:
mode:
authorMicah <micah@leap.se>2016-07-12 16:46:08 -0400
committerMicah <micah@leap.se>2016-07-12 16:46:08 -0400
commit40ea2656f072e23bbbccd22c39fb29a36390fa3a (patch)
tree48d3b759d30e95a25577548b46df37db0cd0d5d3 /puppet/modules/stdlib/spec/functions/type_spec.rb
parent95374aacb857ed35c2fdfe6be7c0bfab86653963 (diff)
git subrepo clone https://leap.se/git/puppet_stdlib puppet/modules/stdlib
subrepo: subdir: "puppet/modules/stdlib" merged: "7112363" upstream: origin: "https://leap.se/git/puppet_stdlib" branch: "master" commit: "7112363" git-subrepo: version: "0.3.0" origin: "https://github.com/ingydotnet/git-subrepo" commit: "1e79595" Change-Id: I032e3e7c2984bf53b717373df495c039bb6f41b3
Diffstat (limited to 'puppet/modules/stdlib/spec/functions/type_spec.rb')
-rwxr-xr-xpuppet/modules/stdlib/spec/functions/type_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/puppet/modules/stdlib/spec/functions/type_spec.rb b/puppet/modules/stdlib/spec/functions/type_spec.rb
new file mode 100755
index 00000000..b683fcfa
--- /dev/null
+++ b/puppet/modules/stdlib/spec/functions/type_spec.rb
@@ -0,0 +1,44 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
+
+describe "the type function" do
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+ it "should exist" do
+ expect(Puppet::Parser::Functions.function("type")).to eq("function_type")
+ end
+
+ it "should give a deprecation warning when called" do
+ scope.expects(:warning).with("type() DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.")
+ scope.function_type(["aoeu"])
+ end
+
+ it "should return string when given a string" do
+ result = scope.function_type(["aaabbbbcccc"])
+ expect(result).to(eq('string'))
+ end
+
+ it "should return array when given an array" do
+ result = scope.function_type([["aaabbbbcccc","asdf"]])
+ expect(result).to(eq('array'))
+ end
+
+ it "should return hash when given a hash" do
+ result = scope.function_type([{"a"=>1,"b"=>2}])
+ expect(result).to(eq('hash'))
+ end
+
+ it "should return integer when given an integer" do
+ result = scope.function_type(["1"])
+ expect(result).to(eq('integer'))
+ end
+
+ it "should return float when given a float" do
+ result = scope.function_type(["1.34"])
+ expect(result).to(eq('float'))
+ end
+
+ it "should return boolean when given a boolean" do
+ result = scope.function_type([true])
+ expect(result).to(eq('boolean'))
+ end
+end