Sha256: bf53d3ee3e3114f97d84fadff0a1da827f70e2610d3ff6c4f7be815a72b03cf5

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe LintTrap::Linter::JSHint do
  let(:container){LintTrap::Container::Fake.new}
  let(:options){{}}
  let(:files){%w(good.js bad.js)}
  subject(:linter){described_class.new}
  let(:command){instance_double(LintTrap::Command)}

  it_behaves_like 'linter'

  its(:languages){is_expected.to eq([LintTrap::Language::JavaScript.new])}
  its(:version){is_expected.to eq('2.5.11')}
  its(:image){is_expected.to eq('lintci/jshint')}
  its(:image_version){is_expected.to eq('lintci/jshint:2.5.11')}

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

      it 'runs the lint command with the correct arguments' do
        expect(LintTrap::Command).to receive(:new).with(
          'jshint',
          [
            '--reporter', container.config_path(described_class::FORMATTER),
            '--config', 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(
          'jshint',
          [
            '--reporter', container.config_path(described_class::FORMATTER)
          ],
          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/jshint_spec.rb
lint_trap-0.0.14 spec/linter/jshint_spec.rb
lint_trap-0.0.13 spec/linter/jshint_spec.rb