summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/ast
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2008-11-29 17:41:45 +0100
committerJames Turnbull <james@lovedthanlost.net>2009-03-14 11:31:29 +1100
commitaf4455e31df403c55a5db06ee8d0d4e0e58c4154 (patch)
tree0e70a34d11dbd02f0fef297e64d66d1d2dc7efc2 /spec/unit/parser/ast
parentb15028f55ba608a701efae1ee392d50374b2be54 (diff)
downloadpuppet-af4455e31df403c55a5db06ee8d0d4e0e58c4154.tar.gz
puppet-af4455e31df403c55a5db06ee8d0d4e0e58c4154.tar.xz
puppet-af4455e31df403c55a5db06ee8d0d4e0e58c4154.zip
Fix #1088 - part2 - Add rspec tests
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/parser/ast')
-rwxr-xr-xspec/unit/parser/ast/collection.rb63
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/unit/parser/ast/collection.rb b/spec/unit/parser/ast/collection.rb
new file mode 100755
index 000000000..c141bd708
--- /dev/null
+++ b/spec/unit/parser/ast/collection.rb
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe Puppet::Parser::AST::Collection do
+ before :each do
+ @scope = stub_everything 'scope'
+ @compiler = stub_everything 'compile'
+ @scope.stubs(:compiler).returns(@compiler)
+
+ @overrides = stub_everything 'overrides'
+ @overrides.stubs(:is_a?).with(Puppet::Parser::AST).returns(true)
+
+ end
+
+ it "should evaluate its query" do
+ query = mock 'query'
+ collection = Puppet::Parser::AST::Collection.new :query => query, :form => :virtual
+
+ query.expects(:safeevaluate).with(@scope)
+
+ collection.evaluate(@scope)
+ end
+
+ it "should instantiate a Collector for this type" do
+ collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test"
+
+ Puppet::Parser::Collector.expects(:new).with(@scope, "test", nil, nil, :virtual)
+
+ collection.evaluate(@scope)
+ end
+
+ it "should tell the compiler about this collector" do
+ collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test"
+ Puppet::Parser::Collector.stubs(:new).returns("whatever")
+
+ @compiler.expects(:add_collection).with("whatever")
+
+ collection.evaluate(@scope)
+ end
+
+ it "should evaluate overriden paramaters" do
+ collector = stub_everything 'collector'
+ collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test", :override => @overrides
+ Puppet::Parser::Collector.stubs(:new).returns(collector)
+
+ @overrides.expects(:safeevaluate).with(@scope)
+
+ collection.evaluate(@scope)
+ end
+
+ it "should tell the collector about overrides" do
+ collector = mock 'collector'
+ collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test", :override => @overrides
+ Puppet::Parser::Collector.stubs(:new).returns(collector)
+
+ collector.expects(:add_override)
+
+ collection.evaluate(@scope)
+ end
+
+
+end