summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authorEric Shamow <eric@puppetlabs.com>2012-04-03 22:30:46 -0400
committerAdrien Thebo <git@somethingsinistral.net>2013-03-18 15:44:50 -0700
commit961dcab15d3cf00eabeb5a496efc9da051169241 (patch)
tree9e5d6633b54a1b23d4b83fa78a77e7cfaa5d253f /spec/unit
parent6dfd7f6b73c4f9437058609f43d0065d52e36494 (diff)
downloadpuppet-stdlib-961dcab15d3cf00eabeb5a496efc9da051169241.tar.gz
puppet-stdlib-961dcab15d3cf00eabeb5a496efc9da051169241.tar.bz2
(#13610) Add is_function_available to stdlib
This function provides a simple wrapper around Puppet::Parser::Functions.function for access within Puppet manifests. This will allow users to check whether or not a plugin or functionality such as hiera is installed on the server.
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/puppet/parser/functions/is_function_available.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/unit/puppet/parser/functions/is_function_available.rb b/spec/unit/puppet/parser/functions/is_function_available.rb
new file mode 100644
index 0000000..bd40c51
--- /dev/null
+++ b/spec/unit/puppet/parser/functions/is_function_available.rb
@@ -0,0 +1,31 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the is_function_available function" do
+ before :all do
+ Puppet::Parser::Functions.autoloader.loadall
+ end
+
+ before :each do
+ @scope = Puppet::Parser::Scope.new
+ end
+
+ it "should exist" do
+ Puppet::Parser::Functions.function("is_function_available").should == "function_is_function_available"
+ end
+
+ it "should raise a ParseError if there is less than 1 arguments" do
+ lambda { @scope.function_is_function_available([]) }.should( raise_error(Puppet::ParseError))
+ end
+
+ it "should return false if a nonexistent function is passed" do
+ result = @scope.function_is_function_available(['jeff_mccunes_left_sock'])
+ result.should(eq(false))
+ end
+
+ it "should return true if an available function is passed" do
+ result = @scope.function_is_function_available(['require'])
+ result.should(eq(true))
+ end
+
+end