Sha256: 35cff7334d15cb2cd13fa2a2f3cc82567c904c7c073d041de57e542e83a6946e

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'ghostbuster_functions' do
  let(:code) { '' }

  context 'with fix disabled' do
    context 'when function is not used' do
      let(:path) { './spec/fixtures/modules/foo/lib/puppet/parser/functions/foo.rb' }

      it 'detects one problem' do
        expect(problems.size).to eq(1)
      end

      it 'creates a warning' do
        expect(problems).to contain_warning('Function foo seems unused')
      end
    end

    context 'when function is used in a manifest' do
      let(:path) { './spec/fixtures/modules/foo/lib/puppet/parser/functions/bar.rb' }

      it 'does not detect any problem' do
        expect(problems.size).to eq(0)
      end
    end

    context 'when function is used in a template using scope.function_baz()' do
      let(:path) { './spec/fixtures/modules/foo/lib/puppet/parser/functions/baz.rb' }

      it 'does not detect any problem' do
        expect(problems.size).to eq(0)
      end
    end

    context 'when function is used in a template using Puppet::Parser::Functions.function(:quux)' do
      let(:path) { './spec/fixtures/modules/foo/lib/puppet/parser/functions/quux.rb' }

      it 'does not detect any problem' do
        expect(problems.size).to eq(0)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-ghostbuster-1.2.1 spec/puppet-lint/plugins/ghostbuster_functions_spec.rb
puppet-ghostbuster-1.2.0 spec/puppet-lint/plugins/ghostbuster_functions_spec.rb
puppet-ghostbuster-1.1.0 spec/puppet-lint/plugins/ghostbuster_functions_spec.rb