summaryrefslogtreecommitdiff
path: root/spec/integration/parser/class_spec.rb
blob: 9f63eb083456771d706d2a72cb05ffee58934765 (plain)
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
require 'spec_helper'
require 'puppet_spec/language'

describe "Class expressions" do
  extend PuppetSpec::Language

  before :each do
    Puppet[:parser] = 'future'
  end

  produces(
    "class hi { }"                                       => '!defined(Class[Hi])',

    "class hi { } include hi"                            => 'defined(Class[Hi])',
    "include(hi) class hi { }"                           => 'defined(Class[Hi])',

    "class hi { } class { hi: }"                         => 'defined(Class[Hi])',
    "class { hi: } class hi { }"                         => 'defined(Class[Hi])',

    "class bye { } class hi inherits bye { } include hi" => 'defined(Class[Hi]) and defined(Class[Bye])')

  produces(<<-EXAMPLE => 'defined(Notify[foo]) and defined(Notify[bar]) and !defined(Notify[foo::bar])')
    class bar { notify { 'bar': } }
    class foo::bar { notify { 'foo::bar': } }
    class foo inherits bar { notify { 'foo': } }

    include foo
  EXAMPLE

  produces(<<-EXAMPLE => 'defined(Notify[foo]) and defined(Notify[bar]) and !defined(Notify[foo::bar])')
    class bar { notify { 'bar': } }
    class foo::bar { notify { 'foo::bar': } }
    class foo inherits ::bar { notify { 'foo': } }

    include foo
  EXAMPLE
end