Sha256: 62495b61f7b52d4758532f6ee0cfce31f266a75eec1f0aaaff2699278b83b13c

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

require_relative '../spec_helper'
require_relative '../../lib/puppet-check/cli'

describe PuppetCheck::CLI do
  context '.run' do
    it 'raises an error if no paths were specified' do
      expect { PuppetCheck::CLI.run(%w(-s -f)) }.to raise_error(RuntimeError, 'puppet-check: no paths specified')
    end
  end

  context '.parse' do
    it 'raises an error if an invalid option was specified' do
      expect { PuppetCheck::CLI.parse(%w(-s -f -asdf foo)) }.to raise_error(OptionParser::InvalidOption)
    end

    it 'allows future parser and style check to be enabled' do
      PuppetCheck.future_parser = false
      PuppetCheck.style_check = false
      PuppetCheck::CLI.parse(%w(-s -f foo))
      expect(PuppetCheck.future_parser).to eql(true)
      expect(PuppetCheck.style_check).to eql(true)
    end

    it 'correctly parses PuppetLint arguments' do
      PuppetCheck.puppetlint_args = []
      PuppetCheck::CLI.parse(%w(--puppet-lint puppetlint-arg-one,puppetlint-arg-two foo))
      expect(PuppetCheck.puppetlint_args).to eql(['--puppetlint-arg-one', '--puppetlint-arg-two'])
    end

    it 'correctly parses Rubocop arguments' do
      PuppetCheck.rubocop_args = []
      PuppetCheck::CLI.parse(%w(--rubocop rubocop-arg-one,rubocop-arg-two foo))
      expect(PuppetCheck.rubocop_args).to eql(['--except', 'rubocop-arg-one,rubocop-arg-two'])
    end

    it 'correctly parses multiple sets of arguments' do
      PuppetCheck.future_parser = false
      PuppetCheck.style_check = false
      PuppetCheck.puppetlint_args = []
      PuppetCheck.rubocop_args = []
      PuppetCheck::CLI.parse(%w(-s -f --puppet-lint puppetlint-arg-one,puppetlint-arg-two --rubocop rubocop-arg-one,rubocop-arg-two foo))
      expect(PuppetCheck.future_parser).to eql(true)
      expect(PuppetCheck.style_check).to eql(true)
      expect(PuppetCheck.puppetlint_args).to eql(['--puppetlint-arg-one', '--puppetlint-arg-two'])
      expect(PuppetCheck.rubocop_args).to eql(['--except', 'rubocop-arg-one,rubocop-arg-two'])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppet-check-1.1.0 spec/puppet-check/cli_spec.rb
puppet-check-1.0.0 spec/puppet-check/cli_spec.rb