Sha256: 7c38fe3c0c4dcf0fd456a28694d9fbfb6ee3bd7f10a09b5a4cb230251605057f

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

describe LintTrap::Linter::JSONLint do
  let(:container){LintTrap::Container::Fake.new}
  subject(:linter){described_class.new(container: container)}

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

      it 'generates lint' do
        expect{|b| linter.lint([file], &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], &b)}.to_not yield_control
      end
    end
  end

  context 'with docker container', if: !ENV['SKIP_DOCKER'] do
    let(:container){LintTrap::Container::Docker.new('lintci/spin_cycle:latest', fixture_path)}

    it_behaves_like '#lint'
  end

  context 'without a docker container', if: ENV['SKIP_DOCKER'] do
    it_behaves_like '#lint'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lint_trap-0.0.6 spec/integration/jsonlint_spec.rb
lint_trap-0.0.5 spec/integration/jsonlint_spec.rb
lint_trap-0.0.4 spec/integration/jsonlint_spec.rb
lint_trap-0.0.3 spec/integration/jsonlint_spec.rb