summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/functions/include_spec.rb
diff options
context:
space:
mode:
authorDominic Cleal <dcleal@redhat.com>2010-11-27 13:36:04 +0000
committerDominic Cleal <dcleal@redhat.com>2010-11-27 13:36:04 +0000
commitafe2d014feb2210a8666c93465d11e9c9d555f8b (patch)
tree208f5ac82b2c29610d2021821c8fca9b079e638b /spec/unit/parser/functions/include_spec.rb
parent143fc744a839affd328234fca26246d49d15d3d8 (diff)
parent4b35402ba85d8842d757becec5c8a7bf4d6f6654 (diff)
Merge branch 'master' of github.com:domcleal/puppet into master-old
Diffstat (limited to 'spec/unit/parser/functions/include_spec.rb')
-rw-r--r--spec/unit/parser/functions/include_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/unit/parser/functions/include_spec.rb b/spec/unit/parser/functions/include_spec.rb
new file mode 100644
index 000000000..4f609b055
--- /dev/null
+++ b/spec/unit/parser/functions/include_spec.rb
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe "the 'include' function" do
+
+ before :each do
+ Puppet::Node::Environment.stubs(:current).returns(nil)
+ @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foo"))
+ @scope = Puppet::Parser::Scope.new(:compiler => @compiler)
+ end
+
+ it "should exist" do
+ Puppet::Parser::Functions.function("include").should == "function_include"
+ end
+
+ it "should include a single class" do
+ inc = "foo"
+ @compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| klasses == [inc]}.returns([inc])
+ @scope.function_include("foo")
+ end
+
+ it "should include multiple classes" do
+ inc = ["foo","bar"]
+ @compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| klasses == inc}.returns(inc)
+ @scope.function_include(["foo","bar"])
+ end
+
+ it "should not lazily evaluate the included class" do
+ @compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| lazy == false}.returns("foo")
+ @scope.function_include("foo")
+ end
+end