Sha256: f172aeaf18670492e949c5f07086b38d67238b23c028af321f7000b2cb3faf5d

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

describe LintTrap::Linter::CheckStyle do
  let(:container){LintTrap::Container::Fake.new}
  let(:config){nil}
  let(:files){%w(Good.java bad.java)}
  subject(:linter){described_class.new(container: container, config: config)}
  let(:command){instance_double(LintTrap::Command)}

  describe '#lint' do
    context 'when config is provided' do
      let(: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', config
          ],
          files
        ).and_return(command)
        expect(command).to receive(:run).with(container)

        linter.lint(files)
      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)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lint_trap-0.0.6 spec/linter/checkstyle_spec.rb
lint_trap-0.0.5 spec/linter/checkstyle_spec.rb
lint_trap-0.0.4 spec/linter/checkstyle_spec.rb
lint_trap-0.0.3 spec/linter/checkstyle_spec.rb