Sha256: 5cc17c113cfe684dd6ca6ce31d4f6c3c6205118c51b2fbb52cb09b68acdd3237

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

describe 'unquoted_string_in_case' do
  let(:msg) { 'expected quoted string in case' }

  context 'with fix disabled' do
    context 'quoted case' do
      let(:code) do
        <<-EOS
        case $osfamily {
          'Solaris': {
            $rootgroup = 'wheel'
          }
          /(Darwin|FreeBSD)/: {
            $rootgroup = 'wheel'
          }
          default: {
            $rootgroup = 'root'
          }
        }
        EOS
      end

      it 'should not detect any problems' do
        expect(problems).to have(0).problems
      end
    end

    context ':NAME in case' do
      let(:code) do
        <<-EOS
        case $osfamily {
          solaris: {
            $rootgroup = 'wheel'
          }
          /(Darwin|FreeBSD)/: {
            $rootgroup = 'wheel'
          }
          default: {
            $rootgroup = 'root'
          }
        }
        EOS
      end

      it 'should create a warning' do
        expect(problems).to contain_warning(msg).on_line(1).in_column(9)
      end
    end

    context ':CLASSREF in case' do
      let(:code) do
        <<-EOS
        case $osfamily {
          Solaris: {
            $rootgroup = 'wheel'
          }
          /(Darwin|FreeBSD)/: {
            $rootgroup = 'wheel'
          }
          default: {
            $rootgroup = 'root'
          }
        }
        EOS
      end

      it 'should create a warning' do
        expect(problems).to contain_warning(msg).on_line(1).in_column(9)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-lint-unquoted_string-check-0.1.0 spec/puppet-lint/plugins/check_unquoted_string_in_case/check_unquoted_string_in_case_spec.rb