3
require File.dirname(__FILE__) + '/../../../spec_helper'
5
describe Puppet::Parser::AST::Collection do
7
@scope = stub_everything 'scope'
8
@compiler = stub_everything 'compile'
9
@scope.stubs(:compiler).returns(@compiler)
11
@overrides = stub_everything 'overrides'
12
@overrides.stubs(:is_a?).with(Puppet::Parser::AST).returns(true)
16
it "should evaluate its query" do
18
collection = Puppet::Parser::AST::Collection.new :query => query, :form => :virtual
20
query.expects(:safeevaluate).with(@scope)
22
collection.evaluate(@scope)
25
it "should instantiate a Collector for this type" do
26
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test"
28
Puppet::Parser::Collector.expects(:new).with(@scope, "test", nil, nil, :virtual)
30
collection.evaluate(@scope)
33
it "should tell the compiler about this collector" do
34
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test"
35
Puppet::Parser::Collector.stubs(:new).returns("whatever")
37
@compiler.expects(:add_collection).with("whatever")
39
collection.evaluate(@scope)
42
it "should evaluate overriden paramaters" do
43
collector = stub_everything 'collector'
44
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test", :override => @overrides
45
Puppet::Parser::Collector.stubs(:new).returns(collector)
47
@overrides.expects(:safeevaluate).with(@scope)
49
collection.evaluate(@scope)
52
it "should tell the collector about overrides" do
53
collector = mock 'collector'
54
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test", :override => @overrides
55
Puppet::Parser::Collector.stubs(:new).returns(collector)
57
collector.expects(:add_override)
59
collection.evaluate(@scope)