File: parse_plan_spec.rb

package info (click to toggle)
puppet-agent 8.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,404 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (47 lines) | stat: -rw-r--r-- 947 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
require 'spec_helper'
require 'puppet/pops'
require_relative 'parser_rspec_helper'

describe "egrammar parsing of 'plan'" do
  include ParserRspecHelper

  context 'with --tasks' do
    before(:each) do
      Puppet[:tasks] = true
    end

    it "an empty body" do
      expect(dump(parse("plan foo { }"))).to eq("(plan foo ())")
    end

    it "a non empty body" do
      prog = <<-EPROG
  plan foo {
    $a = 10
    $b = 20
  }
  EPROG
      expect(dump(parse(prog))).to eq( [
  "(plan foo (block",
  "  (= $a 10)",
  "  (= $b 20)",
  "))",
  ].join("\n"))
    end

    it "accepts parameters" do
      s = "plan foo($p1 = 'yo', $p2) { }"
      expect(dump(parse(s))).to eq("(plan foo (parameters (= p1 'yo') p2) ())")
    end
  end

  context 'with --no-tasks' do
    before(:each) do
      Puppet[:tasks] = false
    end

    it "the keyword 'plan' is a name" do
      expect(dump(parse("$a = plan"))).to eq("(= $a plan)")
    end
  end
end