blob: 82f4fa25148e93527ad8684b82af3c70bc9b5e0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../../spec_helper'
describe "the realize function" do
before :each do
@collector = stub_everything 'collector'
@scope = Puppet::Parser::Scope.new
@compiler = stub 'compiler'
@compiler.stubs(:add_collection).with(@collector)
@scope.stubs(:compiler).returns(@compiler)
end
it "should exist" do
Puppet::Parser::Functions.function("realize").should == "function_realize"
end
it "should create a Collector when called" do
Puppet::Parser::Collector.expects(:new).returns(@collector)
@scope.function_realize("test")
end
it "should assign the passed-in resources to the collector" do
Puppet::Parser::Collector.stubs(:new).returns(@collector)
@collector.expects(:resources=).with(["test"])
@scope.function_realize("test")
end
it "should flatten the resources assigned to the collector" do
Puppet::Parser::Collector.stubs(:new).returns(@collector)
@collector.expects(:resources=).with(["test"])
@scope.function_realize([["test"]])
end
it "should let the compiler know this collector" do
Puppet::Parser::Collector.stubs(:new).returns(@collector)
@collector.stubs(:resources=).with(["test"])
@compiler.expects(:add_collection).with(@collector)
@scope.function_realize("test")
end
end
|