Skip to content

Commit 1404ace

Browse files
committed
cukes for accessing @node via node in templates
1 parent 1b6324e commit 1404ace

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Cookbook Name:: template
3+
# Recipe:: default
4+
#
5+
# Copyright 2009, Opscode
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
node.set[:bawt] = "is fujins bot"
21+
node.set[:botsnack] = "cheers!"
22+
23+
template "#{node[:tmpdir]}/node.txt" do
24+
source "node.txt.erb"
25+
end
26+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bawt <%= node[:bawt] %>
2+
!botsnack
3+
<%= @node[:botsnack] %>

‎features/provider/template/template.feature‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ Feature: Templates
1111
Then the run should exit '0'
1212
And a file named 'template.txt' should contain 'sauce'
1313

14+
Scenario: Render a template accessing the node directly
15+
Given a validated node
16+
And it includes the recipe 'template::render_node_attrs'
17+
When I run the chef-client
18+
Then the run should exit '0'
19+
And a file named 'node.txt' should contain 'bawt is fujins bot'
20+
And a file named 'node.txt' should contain 'cheers!'
21+
22+
23+

0 commit comments

Comments
 (0)