summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-01 09:51:03 -0500
committerLuke Kanies <luke@madstop.com>2007-09-01 09:51:03 -0500
commit25f6d7c521cb0189cf691fb1c4bce4b675568300 (patch)
tree582dd091cbaf62135ce7e81902bb582f154c363f /spec/unit
parent62806bb8749d001354078f176fad8a0a54316efb (diff)
downloadpuppet-25f6d7c521cb0189cf691fb1c4bce4b675568300.tar.gz
puppet-25f6d7c521cb0189cf691fb1c4bce4b675568300.tar.xz
puppet-25f6d7c521cb0189cf691fb1c4bce4b675568300.zip
Deleting old documentation that somehow made it back into the tree in the switch to git, and refactoring the evaluate_classes method on the compile object so I can use resources as intermediaries, thus making classes do late-binding evaluation.
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/parser/compile.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/unit/parser/compile.rb b/spec/unit/parser/compile.rb
new file mode 100755
index 000000000..d22b63545
--- /dev/null
+++ b/spec/unit/parser/compile.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Puppet::Parser::Compile, " when compiling" do
+ before do
+ @node = mock 'node'
+ @parser = mock 'parser'
+ @compile = Puppet::Parser::Compile.new(@node, @parser)
+ end
+
+ def compile_methods
+ [:set_node_parameters, :evaluate_main, :evaluate_ast_node, :evaluate_node_classes, :evaluate_generators, :fail_on_unevaluated,
+ :finish, :store, :extract]
+ end
+
+ # Stub all of the main compile methods except the ones we're specifically interested in.
+ def compile_stub(*except)
+ (compile_methods - except).each { |m| @compile.stubs(m) }
+ end
+
+ it "should set node parameters as variables in the top scope" do
+ params = {"a" => "b", "c" => "d"}
+ @node.stubs(:parameters).returns(params)
+ compile_stub(:set_node_parameters)
+ @compile.compile
+ @compile.topscope.lookupvar("a").should == "b"
+ @compile.topscope.lookupvar("c").should == "d"
+ end
+
+ it "should evaluate any existing classes named in the node" do
+ classes = %w{one two three four}
+ main = stub 'main'
+ one = stub 'one'
+ one.expects(:safeevaluate).with(:scope => @compile.topscope)
+ three = stub 'three'
+ three.expects(:safeevaluate).with(:scope => @compile.topscope)
+ @node.stubs(:name).returns("whatever")
+ @compile.parser.expects(:findclass).with("", "").returns(main)
+ @compile.parser.expects(:findclass).with("", "one").returns(one)
+ @compile.parser.expects(:findclass).with("", "two").returns(nil)
+ @compile.parser.expects(:findclass).with("", "three").returns(three)
+ @compile.parser.expects(:findclass).with("", "four").returns(nil)
+ @node.stubs(:classes).returns(classes)
+ compile_stub(:evaluate_node_classes)
+ @compile.compile
+ end
+end