Sha256: 426a8eb7bb924b20713d9c40a8dde57684d3c4adf614e6eb755b12c85d91e876

Contents?: true

Size: 1.52 KB

Versions: 20

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'
require 'puppet/pops'
require_relative 'parser_rspec_helper'

describe "egrammar parsing of site expression" do
  include ParserRspecHelper

  context "when parsing 'site'" do
    it "raises a syntax error" do
      expect {
        parse("site { }")
      }.to raise_error(Puppet::ParseErrorWithIssue, /Syntax error at 'site' \(line: 1, column: 1\)/)
    end
  end

  context 'When parsing collections containing application management specific keywords' do
    %w(application site produces consumes).each do |keyword|
      it "disallows the keyword '#{keyword}' in a list" do
        expect {
          parse("$a = [#{keyword}]")
        }.to raise_error(Puppet::ParseErrorWithIssue, /Syntax error at '#{keyword}' \(line: 1, column: 7\)/)
      end

      it "disallows the keyword '#{keyword}' as a key in a hash" do
        expect {
          parse("$a = {#{keyword}=>'x'}")
        }.to raise_error(Puppet::ParseErrorWithIssue, /Syntax error at '#{keyword}' \(line: 1, column: 7\)/)
      end

      it "disallows the keyword '#{keyword}' as a value in a hash" do
        expect {
          parse("$a = {'x'=>#{keyword}}")
        }.to raise_error(Puppet::ParseErrorWithIssue, /Syntax error at '#{keyword}' \(line: 1, column: 12\)/)
      end

      it "disallows the keyword '#{keyword}' as an attribute name" do
        expect {
          parse("foo { 'x': #{keyword} => 'value' } ")
        }.to raise_error(Puppet::ParseErrorWithIssue, /Syntax error at '#{keyword}' \(line: 1, column: 12\)/)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-7.4.1 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.4.1-x86-mingw32 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.4.1-x64-mingw32 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.4.1-universal-darwin spec/unit/pops/parser/parse_site_spec.rb
puppet-7.4.0 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.4.0-x86-mingw32 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.4.0-x64-mingw32 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.4.0-universal-darwin spec/unit/pops/parser/parse_site_spec.rb
puppet-7.3.0 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.3.0-x86-mingw32 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.3.0-x64-mingw32 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.3.0-universal-darwin spec/unit/pops/parser/parse_site_spec.rb
puppet-7.1.0 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.1.0-x86-mingw32 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.1.0-x64-mingw32 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.1.0-universal-darwin spec/unit/pops/parser/parse_site_spec.rb
puppet-7.0.0 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.0.0-x86-mingw32 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.0.0-x64-mingw32 spec/unit/pops/parser/parse_site_spec.rb
puppet-7.0.0-universal-darwin spec/unit/pops/parser/parse_site_spec.rb