File: node_spec.rb

package info (click to toggle)
puppet 3.7.2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 18,896 kB
  • sloc: ruby: 210,387; sh: 2,050; xml: 1,554; lisp: 300; makefile: 142; python: 108; sql: 103; yacc: 72
file content (30 lines) | stat: -rwxr-xr-x 1,130 bytes parent folder | download | duplicates (3)
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
#! /usr/bin/env ruby
require 'spec_helper'

describe Puppet::Parser::AST::Node do
  describe "when instantiated" do
    it "should make its names and context available through accessors" do
      node = Puppet::Parser::AST::Node.new(['foo', 'bar'], :line => 5)
      node.names.should == ['foo', 'bar']
      node.context.should == {:line => 5}
    end

    it "should create a node with the proper type, name, context, and module name" do
      node = Puppet::Parser::AST::Node.new(['foo'], :line => 5)
      instantiated_nodes = node.instantiate('modname')
      instantiated_nodes.length.should == 1
      instantiated_nodes[0].type.should == :node
      instantiated_nodes[0].name.should == 'foo'
      instantiated_nodes[0].line.should == 5
      instantiated_nodes[0].module_name.should == 'modname'
    end

    it "should handle multiple names" do
      node = Puppet::Parser::AST::Node.new(['foo', 'bar'])
      instantiated_nodes = node.instantiate('modname')
      instantiated_nodes.length.should == 2
      instantiated_nodes[0].name.should == 'foo'
      instantiated_nodes[1].name.should == 'bar'
    end
  end
end