Sha256: e73b9f6bd15eb9ac8a0d7052445be2c664ca11392cb6a09c6dff4f6429ef47a9

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'

describe LintTrap::Linter::CheckStyle do
  let(:container){LintTrap::Container::Fake.new}
  let(:options){{}}
  let(:files){%w(Good.java bad.java)}
  let(:command){instance_double(LintTrap::Command)}
  subject(:linter){LintTrap::Linter.find('CheckStyle')}

  it_behaves_like 'linter'

  its(:languages){is_expected.to eq([LintTrap::Language::Java.new])}
  its(:version){is_expected.to eq('6.6')}
  its(:image){is_expected.to eq('lintci/checkstyle')}
  its(:image_version){is_expected.to eq('lintci/checkstyle:6.6')}
  its(:jar){is_expected.to eq('checkstyle/checkstyle_logger-6.6-all.jar')}

  describe '#lint' do
    context 'when config is provided' do
      let(:options){{config: 'checks.xml'}}

      it 'runs the lint command with the correct arguments' do
        expect(LintTrap::Command).to receive(:new).with(
          'java',
          [
            '-jar', container.config_path(linter.jar),
            '-c', options[:config]
          ],
          files
        ).and_return(command)
        expect(command).to receive(:run).with(container).and_return(true)

        linter.lint(files, container, options)
      end
    end

    context 'when config is not provided' do
      it 'runs the lint command with the correct arguments' do
        expect(LintTrap::Command).to receive(:new).with(
          'java',
          [
            '-jar', container.config_path(linter.jar),
            '-c', container.config_path(described_class::CHECKS_XML)
          ],
          files
        ).and_return(command)
        expect(command).to receive(:run).with(container).and_return(true)

        linter.lint(files, container, options)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lint_trap-0.0.19 spec/linter/checkstyle_spec.rb
lint_trap-0.0.18 spec/linter/checkstyle_spec.rb
lint_trap-0.0.17 spec/linter/checkstyle_spec.rb
lint_trap-0.0.16 spec/linter/checkstyle_spec.rb