Sha256: 7dec84a3b72d29c6c413843e8c420357a09dc530e8f1049f923a64a4d00cadbe

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 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){described_class.new}

  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

3 entries across 3 versions & 1 rubygems

Version Path
lint_trap-0.0.15 spec/linter/checkstyle_spec.rb
lint_trap-0.0.14 spec/linter/checkstyle_spec.rb
lint_trap-0.0.13 spec/linter/checkstyle_spec.rb