-
Notifications
You must be signed in to change notification settings - Fork 583
/
Copy pathstdlib_deferrable_epp_spec.rb
60 lines (51 loc) · 2.06 KB
/
stdlib_deferrable_epp_spec.rb
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
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true
require 'spec_helper'
describe 'stdlib::deferrable_epp' do
context 'call epp on non-deferred input' do
let(:pre_condition) do
'function epp($str, $data) { return "rendered"}'
end
it {
expect(subject).to run.with_params('mymod/template.epp', { 'foo' => 'bar' }).and_return('rendered')
}
end
context 'defers rendering with deferred input' do
let(:pre_condition) do
<<~END
function epp($str, $data) { fail("should not have invoked epp()") }
function find_template($str) { return "path" }
function file($path) { return "foo: <%= foo %>" }
END
end
it {
foo = Puppet::Pops::Types::TypeFactory.deferred.create('join', [1, 2, 3])
expect(subject).to run.with_params('mymod/template.epp', { 'foo' => foo }).and_return(kind_of(Puppet::Pops::Types::PuppetObject))
}
end
context 'defers rendering with mixed deferred and undeferred input' do
let(:pre_condition) do
<<~END
function epp($str, $data) { fail("should not have invoked epp()") }
function find_template($str) { return "path" }
function file($path) { return "foo: <%= foo %>, bar: <%= bar %>" }
END
end
it {
foo = Puppet::Pops::Types::TypeFactory.deferred.create('join', [1, 2, 3])
expect(subject).to run.with_params('mymod/template.epp', { 'foo' => foo, 'bar' => 'xyz' }).and_return(kind_of(Puppet::Pops::Types::PuppetObject))
}
end
context 'defers rendering with mixed deferred and undeferred input and preparse false' do
let(:pre_condition) do
<<~END
function epp($str, $data) { fail("should not have invoked epp()") }
function find_template($str) { return "path" }
function file($path) { return "foo: <%= foo %>, bar: <%= bar %>" }
END
end
it {
foo = Puppet::Pops::Types::TypeFactory.deferred.create('join', [1, 2, 3])
expect(subject).to run.with_params('mymod/template.epp', { 'foo' => foo, 'bar' => 'xyz' }, false).and_return(kind_of(Puppet::Pops::Types::PuppetObject))
}
end
end