Sha256: edd102c1ef6458187268100e597f523639d25deaebd8ab2cb66df4c815216f5f

Contents?: true

Size: 1.62 KB

Versions: 4

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

describe LintTrap::Linter::JSONLint do
  let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path, remove_container: ENV['CI'].nil?)}
  let(:options){{}}
  subject(:linter){LintTrap::Linter.find('JSONLint')}

  describe '#version' do
    subject(:dockerfile){Dockerfile.new(linter.name)}

    it 'matches the linters version' do
      expect(dockerfile.include_env?('JSONLINT_VERSION', linter.version)).to be_truthy
    end
  end

  describe '#lint' do
    context 'when linting a bad file' do
      let(:file){fixture_path('bad.json')}

      it 'generates lint' do
        expect{|b| linter.lint([file], container, options, &b)}.to yield_successive_args(
          {
            file: file,
            line: '2',
            column: '2',
            length: nil,
            rule: nil,
            severity: 'error',
            message: 'Json strings must use double quotes'
          }, {
            file: file,
            line: '3',
            column: '2',
            length: nil,
            rule: nil,
            severity: 'error',
            message: 'Keys must be double quoted in Json. Did you mean "not"?'
          }, {
            file: file,
            line: '3',
            column: '7',
            length: nil,
            rule: nil,
            severity: 'error',
            message: 'Invalid Json number'
          }
        )
      end
    end

    context 'when linting a good file' do
      let(:file){fixture_path('good.json')}

      it 'generates no lint' do
        expect{|b| linter.lint([file], container, options, &b)}.to_not yield_control
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lint_trap-0.0.19 spec/integration/jsonlint_spec.rb
lint_trap-0.0.18 spec/integration/jsonlint_spec.rb
lint_trap-0.0.17 spec/integration/jsonlint_spec.rb
lint_trap-0.0.16 spec/integration/jsonlint_spec.rb