diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-05-31 15:38:14 +0200 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-06-10 15:28:21 +1000 |
| commit | b5a8c4db028c69793c1c9172adca4d9930c8cd1d (patch) | |
| tree | c88e3776255d34385328ac4df9b23897015225ff /spec/unit/parser/functions | |
| parent | 74730df475f21848027a4d2dda9ab849d3038c49 (diff) | |
| download | puppet-b5a8c4db028c69793c1c9172adca4d9930c8cd1d.tar.gz puppet-b5a8c4db028c69793c1c9172adca4d9930c8cd1d.tar.xz puppet-b5a8c4db028c69793c1c9172adca4d9930c8cd1d.zip | |
Fix #1907 (or sort) - 'require' puppet function
This function acts exactly as the 'include' function, but also
adds an ordering relation between the included class and the class
where the require function is.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/parser/functions')
| -rwxr-xr-x | spec/unit/parser/functions/require.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/unit/parser/functions/require.rb b/spec/unit/parser/functions/require.rb new file mode 100755 index 000000000..67a5baeb9 --- /dev/null +++ b/spec/unit/parser/functions/require.rb @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../../spec_helper' + +describe "the require function" do + + before :each do + @catalog = stub 'catalog' + @compiler = stub 'compiler', :catalog => @catalog + @scope = Puppet::Parser::Scope.new() + @scope.stubs(:resource).returns("ourselves") + @scope.stubs(:findresource) + @scope.stubs(:compiler).returns(@compiler) + end + + it "should exist" do + Puppet::Parser::Functions.function("require").should == "function_require" + end + + it "should delegate to the 'include' puppet function" do + @catalog.stubs(:add_edge) + @scope.expects(:function_include).with("myclass") + + @scope.function_require("myclass") + end + + it "should add a catalog edge from our parent resource to the included one" do + @scope.stubs(:function_include).with("myclass") + @scope.stubs(:findresource).with(:class, "myclass").returns("includedclass") + + @catalog.expects(:add_edge).with("ourselves","includedclass") + + @scope.function_require("myclass") + end + +end |
