~nvalcarcel/ubuntu/lucid/puppet/fix-546677

« back to all changes in this revision

Viewing changes to spec/unit/parser/ast/collection.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
 
 
3
require File.dirname(__FILE__) + '/../../../spec_helper'
 
4
 
 
5
describe Puppet::Parser::AST::Collection do
 
6
    before :each do
 
7
        @scope = stub_everything 'scope'
 
8
        @compiler = stub_everything 'compile'
 
9
        @scope.stubs(:compiler).returns(@compiler)
 
10
 
 
11
        @overrides = stub_everything 'overrides'
 
12
        @overrides.stubs(:is_a?).with(Puppet::Parser::AST).returns(true)
 
13
 
 
14
    end
 
15
 
 
16
    it "should evaluate its query" do
 
17
        query = mock 'query'
 
18
        collection = Puppet::Parser::AST::Collection.new :query => query, :form => :virtual
 
19
 
 
20
        query.expects(:safeevaluate).with(@scope)
 
21
 
 
22
        collection.evaluate(@scope)
 
23
    end
 
24
 
 
25
    it "should instantiate a Collector for this type" do
 
26
        collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test"
 
27
 
 
28
        Puppet::Parser::Collector.expects(:new).with(@scope, "test", nil, nil, :virtual)
 
29
 
 
30
        collection.evaluate(@scope)
 
31
    end
 
32
 
 
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")
 
36
 
 
37
        @compiler.expects(:add_collection).with("whatever")
 
38
 
 
39
        collection.evaluate(@scope)
 
40
    end
 
41
 
 
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)
 
46
 
 
47
        @overrides.expects(:safeevaluate).with(@scope)
 
48
 
 
49
        collection.evaluate(@scope)
 
50
    end
 
51
 
 
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)
 
56
 
 
57
        collector.expects(:add_override)
 
58
 
 
59
        collection.evaluate(@scope)
 
60
    end
 
61
 
 
62
 
 
63
end