Sha256: 5fda9c0e871f23d9cfd260012efa9edc6db2ab93024eff6a0965bb8609830674

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 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])}

  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(described_class::JAR),
            '-c', options[:config]
          ],
          files
        ).and_return(command)
        expect(command).to receive(:run).with(container)

        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(described_class::JAR),
            '-c', container.config_path(described_class::CHECKS_XML)
          ],
          files
        ).and_return(command)
        expect(command).to receive(:run).with(container)

        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.11 spec/linter/checkstyle_spec.rb
lint_trap-0.0.10 spec/linter/checkstyle_spec.rb
lint_trap-0.0.9 spec/linter/checkstyle_spec.rb