~bkerensa/ubuntu/raring/puppet/new-upstream-release

« back to all changes in this revision

Viewing changes to spec/unit/parser/functions/inline_template_spec.rb

  • Committer: Benjamin Kerensa
  • Date: 2012-11-21 23:50:52 UTC
  • mfrom: (1.1.30)
  • Revision ID: bkerensa@ubuntu.com-20121121235052-ah7nzabp77sh69gb
New Upstream Release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env rspec
 
1
#! /usr/bin/env ruby
2
2
require 'spec_helper'
3
3
 
4
 
describe "the inline_template function", :'fails_on_ruby_1.9.2' => true do
 
4
describe "the inline_template function" do
5
5
  before :all do
6
6
    Puppet::Parser::Functions.autoloader.loadall
7
7
  end
8
8
 
9
9
  before :each do
10
 
    @scope = Puppet::Parser::Scope.new
 
10
    node     = Puppet::Node.new('localhost')
 
11
    compiler = Puppet::Parser::Compiler.new(node)
 
12
    @scope   = Puppet::Parser::Scope.new(compiler)
11
13
  end
12
14
 
13
15
  it "should exist" do
19
21
 
20
22
    Puppet::Parser::TemplateWrapper.expects(:new).returns(tw)
21
23
 
22
 
    @scope.function_inline_template("test")
 
24
    @scope.function_inline_template(["test"])
23
25
  end
24
26
 
25
27
  it "should pass the template string to TemplateWrapper.result" do
28
30
 
29
31
    tw.expects(:result).with("test")
30
32
 
31
 
    @scope.function_inline_template("test")
 
33
    @scope.function_inline_template(["test"])
32
34
  end
33
35
 
34
36
  it "should return what TemplateWrapper.result returns" do
37
39
 
38
40
    tw.expects(:result).returns("template contents evaluated")
39
41
 
40
 
    @scope.function_inline_template("test").should == "template contents evaluated"
 
42
    @scope.function_inline_template(["test"]).should == "template contents evaluated"
41
43
  end
42
44
 
43
45
  it "should concatenate template wrapper outputs for multiple templates" do
55
57
    Puppet::Parser::TemplateWrapper.stubs(:new).returns(tw)
56
58
    tw.stubs(:result).raises
57
59
 
58
 
    lambda { @scope.function_inline_template("1") }.should raise_error(Puppet::ParseError)
 
60
    lambda { @scope.function_inline_template(["1"]) }.should raise_error(Puppet::ParseError)
59
61
  end
60
62
 
61
63
end