File: dynamic_scoping_spec.rb

package info (click to toggle)
puppet 5.5.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,316 kB
  • sloc: ruby: 254,925; sh: 1,608; xml: 219; makefile: 153; sql: 103
file content (66 lines) | stat: -rw-r--r-- 1,627 bytes parent folder | download | duplicates (4)
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
61
62
63
64
65
66
require 'spec_helper'
require 'puppet/pops'
require 'puppet/parser/parser_factory'
require 'puppet_spec/compiler'
require 'puppet_spec/pops'
require 'puppet_spec/scope'
require 'matchers/resource'

# These tests are in a separate file since othr compiler related tests have
# been dramatically changed between 3.x and 4.x and it is a pain to merge
# them.
#
describe "Puppet::Parser::Compiler when dealing with relative naming" do
  include PuppetSpec::Compiler
  include Matchers::Resource

  describe "the compiler when using 4.x parser and evaluator" do
    it "should use absolute references even if references are not anchored" do
      node = Puppet::Node.new("testnodex")
      catalog = compile_to_catalog(<<-PP, node)
      class foo::thing {
        notify {"from foo::thing":}
      }

      class thing {
        notify {"from ::thing":}
      }

      class foo {
      #  include thing
        class {'thing':}
      }

      include foo
      PP

      catalog = Puppet::Parser::Compiler.compile(node)

      expect(catalog).to have_resource("Notify[from ::thing]")
    end

    it "should use absolute references when references are absolute" do
      node = Puppet::Node.new("testnodex")
      catalog = compile_to_catalog(<<-PP, node)
      class foo::thing {
        notify {"from foo::thing":}
      }

      class thing {
        notify {"from ::thing":}
      }

      class foo {
      #  include thing
        class {'::thing':}
      }

      include foo
      PP

      catalog = Puppet::Parser::Compiler.compile(node)

      expect(catalog).to have_resource("Notify[from ::thing]")
    end
  end
end