lint_trap 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +71 -22
  3. data/circle.yml +8 -2
  4. data/lib/lint_trap/language/base.rb +6 -2
  5. data/lib/lint_trap/language/coffeescript.rb +1 -1
  6. data/lib/lint_trap/language/cpp.rb +1 -1
  7. data/lib/lint_trap/language/css.rb +1 -1
  8. data/lib/lint_trap/language/go.rb +1 -1
  9. data/lib/lint_trap/language/java.rb +1 -1
  10. data/lib/lint_trap/language/javascript.rb +1 -1
  11. data/lib/lint_trap/language/json.rb +1 -1
  12. data/lib/lint_trap/language/python.rb +1 -1
  13. data/lib/lint_trap/language/ruby.rb +1 -1
  14. data/lib/lint_trap/language/scss.rb +1 -1
  15. data/lib/lint_trap/linter/base.rb +8 -0
  16. data/lib/lint_trap/linter/checkstyle.rb +4 -0
  17. data/lib/lint_trap/linter/coffeelint.rb +4 -0
  18. data/lib/lint_trap/linter/cppcheck.rb +4 -0
  19. data/lib/lint_trap/linter/csslint.rb +4 -0
  20. data/lib/lint_trap/linter/golint.rb +4 -0
  21. data/lib/lint_trap/linter/jshint.rb +4 -0
  22. data/lib/lint_trap/linter/jsonlint.rb +4 -0
  23. data/lib/lint_trap/linter/pylint.rb +4 -0
  24. data/lib/lint_trap/linter/rubocop.rb +4 -0
  25. data/lib/lint_trap/linter/scsslint.rb +4 -0
  26. data/lib/lint_trap/version.rb +1 -1
  27. data/spec/language/coffeescript_spec.rb +2 -0
  28. data/spec/language/cpp_spec.rb +2 -0
  29. data/spec/language/css_spec.rb +2 -0
  30. data/spec/language/go_spec.rb +2 -0
  31. data/spec/language/java_spec.rb +2 -0
  32. data/spec/language/javascript_spec.rb +2 -0
  33. data/spec/language/json_spec.rb +2 -0
  34. data/spec/language/python_spec.rb +2 -0
  35. data/spec/language/ruby_spec.rb +2 -0
  36. data/spec/language/scss_spec.rb +2 -0
  37. data/spec/linter/checkstyle_spec.rb +5 -1
  38. data/spec/linter/coffeelint_spec.rb +4 -0
  39. data/spec/linter/cppcheck_spec.rb +4 -0
  40. data/spec/linter/csslint_spec.rb +4 -0
  41. data/spec/linter/golint_spec.rb +4 -0
  42. data/spec/linter/jshint_spec.rb +4 -0
  43. data/spec/linter/jsonlint_spec.rb +4 -0
  44. data/spec/linter/pylint_spec.rb +4 -0
  45. data/spec/linter/rubocop_spec.rb +4 -0
  46. data/spec/linter/scsslint_spec.rb +4 -0
  47. data/spec/spec_helper.rb +2 -0
  48. data/spec/support/examples/language.rb +12 -0
  49. data/spec/support/examples/linter.rb +11 -0
  50. metadata +5 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05684bf565de4f670e2d5d385585eccc4f973825
4
- data.tar.gz: b77841570b01e04382e724e1c67663972fb533b0
3
+ metadata.gz: 7f171a483bce815192fe84c70780c8ad31dd7162
4
+ data.tar.gz: cbb5e42420f0cd7ca00cc588d2abf268b35a00f3
5
5
  SHA512:
6
- metadata.gz: 34d87142a75679ff066cada80c3ce7100c3e90a72d5dcb9fcde929b6e4acb16e63b68684ac2459b38bd2c18f37824c5e2b93017a23098c1002c932bc79874b72
7
- data.tar.gz: 6dc8ad9c4aa3031f507cb0b2967b31af1e7fe6f8b86cf244e9a04e335866768beb1a2c86d6b19948a0dc45aecdbd6c60d568875065390cd7c845017207076c3d
6
+ metadata.gz: 2e33c63d67abec9904c004a1652e4ec2f34040bd5c3ecaed38a419c67ae9c4e71c6bf64eec6d13131309530d4cb99a628dbc6452e97b1be18aae707908d502e4
7
+ data.tar.gz: 03050267d12f19b005d4551209e4a343059e4e7d7b00e806359c69d81fd5001e0a63fe7dc8749378daf5271b5e1543d9025289759d1bc20c4d38b9676ead9f12
data/Rakefile CHANGED
@@ -19,34 +19,83 @@ task :credentials do
19
19
  end
20
20
 
21
21
  namespace :docker do
22
- DockerError = Class.new(StandardError)
22
+ module Docker
23
+ DOCKER_CACHE_PATH = File.expand_path('~/.docker')
24
+ DOCKER_IMAGE_PATH = File.join(DOCKER_CACHE_PATH, 'image.tar')
25
+ IMAGE_NAME = 'lintci/spin_cycle'
23
26
 
24
- def fail_on_error
25
- return if $? == 0
27
+ BuildError = Class.new(StandardError)
26
28
 
27
- raise DockerError, 'There was a problem executing the command.'
28
- end
29
29
 
30
- def sha
31
- ENV['CIRCLE_SHA1'] ? ENV['CIRCLE_SHA1'] : ENV['SHA']
32
- end
30
+ def tag
31
+ run("docker tag -f #{image_sha} #{image_latest}")
32
+ run("docker tag -f #{image_sha} #{image_version}")
33
+ end
33
34
 
34
- task :tag do
35
- require_relative 'lib/lint_trap/version'
35
+ def pull
36
+ run("docker pull #{image_latest}")
37
+ end
36
38
 
37
- system("docker tag -f lintci/spin_cycle:#{sha} lintci/spin_cycle:latest") or fail_on_error
38
- system("docker tag -f lintci/spin_cycle:#{sha} lintci/spin_cycle:#{LintTrap::VERSION}") or fail_on_error
39
- end
39
+ def load
40
+ if File.exist?(DOCKER_IMAGE_PATH)
41
+ run("docker load -i #{DOCKER_IMAGE_PATH}")
42
+ else
43
+ pull
44
+ end
45
+ end
40
46
 
41
- task :build do
42
- system("docker pull lintci/spin_cycle:latest") or fail_on_error
43
- system("docker build -t lintci/spin_cycle:#{sha} .") or fail_on_error
44
- end
47
+ def dump
48
+ require 'fileutils'
49
+
50
+ FileUtils.mkdir_p(DOCKER_CACHE_PATH)
51
+ run("docker save #{image_latest} > #{DOCKER_IMAGE_PATH}")
52
+ end
53
+
54
+ def build
55
+ run("docker build -t #{image_sha} .")
56
+ end
57
+
58
+ def push
59
+ run("docker login -e #{ENV['DOCKER_EMAIL']} -u #{ENV['DOCKER_USER']} -p #{ENV['DOCKER_PASSWORD']}")
60
+ run("docker push #{image_sha}")
61
+ run("docker push #{image_version}")
62
+ run("docker push #{image_latest}")
63
+ end
64
+
65
+ private
45
66
 
46
- task :push do
47
- system("docker login -e #{ENV['DOCKER_EMAIL']} -u #{ENV['DOCKER_USER']} -p #{ENV['DOCKER_PASSWORD']}") or fail_on_error
48
- system("docker push lintci/spin_cycle:#{sha}") or fail_on_error
49
- system("docker push lintci/spin_cycle:#{LintTrap::VERSION}") or fail_on_error
50
- system("docker push lintci/spin_cycle:latest") or fail_on_error
67
+ def run(command)
68
+ puts command
69
+ system(command)
70
+
71
+ raise BuildError, 'There was a problem executing the command.' unless $? == 0
72
+ end
73
+
74
+ def image_sha
75
+ "#{IMAGE_NAME}:#{sha}"
76
+ end
77
+
78
+ def image_version
79
+ require_relative 'lib/lint_trap/version'
80
+
81
+ "#{IMAGE_NAME}:#{LintTrap::VERSION}"
82
+ end
83
+
84
+ def image_latest
85
+ "#{IMAGE_NAME}:latest"
86
+ end
87
+
88
+ def sha
89
+ sha = ENV['CIRCLE_SHA1'] ? ENV['CIRCLE_SHA1'] : `git rev-parse HEAD`.strip
90
+ end
51
91
  end
92
+
93
+ include Docker
94
+
95
+ task(:tag){tag}
96
+ task(:pull){pull}
97
+ task(:load){load}
98
+ task(:dump){dump}
99
+ task(:build){build}
100
+ task(:push){push}
52
101
  end
data/circle.yml CHANGED
@@ -8,12 +8,18 @@ checkout:
8
8
  - git config --global user.email "circleci@lintci.com"
9
9
  - git config --global user.name "LintCI's CircleCI Bot"
10
10
  dependencies:
11
+ cache_directories:
12
+ - "~/.docker"
11
13
  post:
12
- - bundle exec rake docker:build docker:tag
14
+ - bundle exec rake docker:pull
15
+ - bundle exec rake docker:build
16
+ - bundle exec rake docker:tag
13
17
  deployment:
14
18
  master:
15
19
  branch: master
16
20
  commands:
17
- - bundle exec rake credentials release docker:push
21
+ - bundle exec rake credentials
22
+ - bundle exec rake release
23
+ - bundle exec rake docker:push
18
24
 
19
25
 
@@ -6,13 +6,17 @@ module LintTrap
6
6
  self.class.name.split('::').last
7
7
  end
8
8
 
9
- def linters
10
- raise NotImplementedError, 'Must define what linters this language supports.'
9
+ def linters(*classes)
10
+ classes.map(&:new)
11
11
  end
12
12
 
13
13
  def ==(other)
14
14
  name == other.name
15
15
  end
16
+
17
+ def inspect
18
+ "<#{name}>"
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -6,7 +6,7 @@ module LintTrap
6
6
  # CoffeeScript
7
7
  class CoffeeScript < Base
8
8
  def linters
9
- [Linter::CoffeeLint].map(&:new)
9
+ super(Linter::CoffeeLint)
10
10
  end
11
11
  end
12
12
  end
@@ -10,7 +10,7 @@ module LintTrap
10
10
  end
11
11
 
12
12
  def linters
13
- [Linter::CPPCheck].map(&:new)
13
+ super(Linter::CPPCheck)
14
14
  end
15
15
  end
16
16
  end
@@ -6,7 +6,7 @@ module LintTrap
6
6
  # CSS
7
7
  class CSS < Base
8
8
  def linters
9
- [Linter::CSSLint].map(&:new)
9
+ super(Linter::CSSLint)
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module LintTrap
6
6
  # Go
7
7
  class Go < Base
8
8
  def linters
9
- [Linter::GoLint].map(&:new)
9
+ super(Linter::GoLint)
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module LintTrap
6
6
  # Java
7
7
  class Java < Base
8
8
  def linters
9
- [Linter::CheckStyle].map(&:new)
9
+ super(Linter::CheckStyle)
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module LintTrap
6
6
  # JavaScript
7
7
  class JavaScript < Base
8
8
  def linters
9
- [Linter::JSHint].map(&:new)
9
+ super(Linter::JSHint)
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module LintTrap
6
6
  # JSON
7
7
  class JSON < Base
8
8
  def linters
9
- [Linter::JSONLint].map(&:new)
9
+ super(Linter::JSONLint)
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module LintTrap
6
6
  # Python
7
7
  class Python < Base
8
8
  def linters
9
- [Linter::PyLint].map(&:new)
9
+ super(Linter::PyLint)
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module LintTrap
6
6
  # Ruby
7
7
  class Ruby < Base
8
8
  def linters
9
- [Linter::RuboCop].map(&:new)
9
+ super(Linter::RuboCop)
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module LintTrap
6
6
  # SCSS
7
7
  class SCSS < Base
8
8
  def linters
9
- [Linter::SCSSLint].map(&:new)
9
+ super(Linter::SCSSLint)
10
10
  end
11
11
  end
12
12
  end
@@ -21,10 +21,18 @@ module LintTrap
21
21
  self.class.name.split('::').last
22
22
  end
23
23
 
24
+ def languages(*classes)
25
+ classes.map(&:new)
26
+ end
27
+
24
28
  def ==(other)
25
29
  name == other.name
26
30
  end
27
31
 
32
+ def inspect
33
+ "<#{name}>"
34
+ end
35
+
28
36
  protected
29
37
 
30
38
  attr_reader :container, :options
@@ -7,6 +7,10 @@ module LintTrap
7
7
  JAR = 'checkstyle/checkstyle_logger-all.jar'
8
8
  CHECKS_XML = 'checkstyle/sun_checks.xml'
9
9
 
10
+ def languages
11
+ super(Language::Java)
12
+ end
13
+
10
14
  private
11
15
 
12
16
  def command_name
@@ -6,6 +6,10 @@ module LintTrap
6
6
  class CoffeeLint < Base
7
7
  REPORTER = 'coffeelint/lint_trap.coffee'
8
8
 
9
+ def languages
10
+ super(Language::CoffeeScript)
11
+ end
12
+
9
13
  private
10
14
 
11
15
  def flags
@@ -4,6 +4,10 @@ module LintTrap
4
4
  module Linter
5
5
  # Encapsulates logic specific to cppcheck command line tool.
6
6
  class CPPCheck < Base
7
+ def languages
8
+ super(Language::CPP)
9
+ end
10
+
7
11
  private
8
12
 
9
13
  def flags
@@ -5,6 +5,10 @@ module LintTrap
5
5
  module Linter
6
6
  # Encapsulates logic specific to csslint command line tool.
7
7
  class CSSLint < Base
8
+ def languages
9
+ super(Language::CSS)
10
+ end
11
+
8
12
  private
9
13
 
10
14
  def flags
@@ -5,6 +5,10 @@ module LintTrap
5
5
  module Linter
6
6
  # Encapsulates logic specific to golint command line tool.
7
7
  class GoLint < Base
8
+ def languages
9
+ super(Language::Go)
10
+ end
11
+
8
12
  private
9
13
 
10
14
  def flags
@@ -6,6 +6,10 @@ module LintTrap
6
6
  class JSHint < Base
7
7
  FORMATTER = 'jshint/formatter.js'
8
8
 
9
+ def languages
10
+ super(Language::JavaScript)
11
+ end
12
+
9
13
  private
10
14
 
11
15
  def flags
@@ -4,6 +4,10 @@ module LintTrap
4
4
  module Linter
5
5
  # Encapsulates logic specific to durable-json-lint command line tool.
6
6
  class JSONLint < Base
7
+ def languages
8
+ super(Language::JSON)
9
+ end
10
+
7
11
  private
8
12
 
9
13
  def command_name
@@ -4,6 +4,10 @@ module LintTrap
4
4
  module Linter
5
5
  # Encapsulates logic specific to pylint command line tool.
6
6
  class PyLint < Base
7
+ def languages
8
+ super(Language::Python)
9
+ end
10
+
7
11
  private
8
12
 
9
13
  def flags
@@ -6,6 +6,10 @@ module LintTrap
6
6
  class RuboCop < Base
7
7
  FORMATTER = 'rubocop/formatter.rb'
8
8
 
9
+ def languages
10
+ super(Language::Ruby)
11
+ end
12
+
9
13
  private
10
14
 
11
15
  def flags
@@ -6,6 +6,10 @@ module LintTrap
6
6
  class SCSSLint < Base
7
7
  COMMAND = 'scsslint/scsslint'
8
8
 
9
+ def languages
10
+ super(Language::SCSS)
11
+ end
12
+
9
13
  def command_name
10
14
  config_path(COMMAND)
11
15
  end
@@ -1,3 +1,3 @@
1
1
  module LintTrap
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe LintTrap::Language::CoffeeScript do
4
4
  subject(:language){described_class.new}
5
5
 
6
+ it_behaves_like 'language'
7
+
6
8
  its(:name){is_expected.to eq('CoffeeScript')}
7
9
  its(:linters){is_expected.to eq([LintTrap::Linter::CoffeeLint.new])}
8
10
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe LintTrap::Language::CPP do
4
4
  subject(:language){described_class.new}
5
5
 
6
+ it_behaves_like 'language'
7
+
6
8
  its(:name){is_expected.to eq('C++')}
7
9
  its(:linters){is_expected.to eq([LintTrap::Linter::CPPCheck.new])}
8
10
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe LintTrap::Language::CSS do
4
4
  subject(:language){described_class.new}
5
5
 
6
+ it_behaves_like 'language'
7
+
6
8
  its(:name){is_expected.to eq('CSS')}
7
9
  its(:linters){is_expected.to eq([LintTrap::Linter::CSSLint.new])}
8
10
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe LintTrap::Language::Go do
4
4
  subject(:language){described_class.new}
5
5
 
6
+ it_behaves_like 'language'
7
+
6
8
  its(:name){is_expected.to eq('Go')}
7
9
  its(:linters){is_expected.to eq([LintTrap::Linter::GoLint.new])}
8
10
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe LintTrap::Language::Java do
4
4
  subject(:language){described_class.new}
5
5
 
6
+ it_behaves_like 'language'
7
+
6
8
  its(:name){is_expected.to eq('Java')}
7
9
  its(:linters){is_expected.to eq([LintTrap::Linter::CheckStyle.new])}
8
10
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe LintTrap::Language::JavaScript do
4
4
  subject(:language){described_class.new}
5
5
 
6
+ it_behaves_like 'language'
7
+
6
8
  its(:name){is_expected.to eq('JavaScript')}
7
9
  its(:linters){is_expected.to eq([LintTrap::Linter::JSHint.new])}
8
10
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe LintTrap::Language::JSON do
4
4
  subject(:language){described_class.new}
5
5
 
6
+ it_behaves_like 'language'
7
+
6
8
  its(:name){is_expected.to eq('JSON')}
7
9
  its(:linters){is_expected.to eq([LintTrap::Linter::JSONLint.new])}
8
10
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe LintTrap::Language::Python do
4
4
  subject(:language){described_class.new}
5
5
 
6
+ it_behaves_like 'language'
7
+
6
8
  its(:name){is_expected.to eq('Python')}
7
9
  its(:linters){is_expected.to eq([LintTrap::Linter::PyLint.new])}
8
10
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe LintTrap::Language::Ruby do
4
4
  subject(:language){described_class.new}
5
5
 
6
+ it_behaves_like 'language'
7
+
6
8
  its(:name){is_expected.to eq('Ruby')}
7
9
  its(:linters){is_expected.to eq([LintTrap::Linter::RuboCop.new])}
8
10
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe LintTrap::Language::SCSS do
4
4
  subject(:language){described_class.new}
5
5
 
6
+ it_behaves_like 'language'
7
+
6
8
  its(:name){is_expected.to eq('SCSS')}
7
9
  its(:linters){is_expected.to eq([LintTrap::Linter::SCSSLint.new])}
8
10
  end
@@ -4,8 +4,12 @@ describe LintTrap::Linter::CheckStyle do
4
4
  let(:container){LintTrap::Container::Fake.new}
5
5
  let(:options){{}}
6
6
  let(:files){%w(Good.java bad.java)}
7
- subject(:linter){described_class.new}
8
7
  let(:command){instance_double(LintTrap::Command)}
8
+ subject(:linter){described_class.new}
9
+
10
+ it_behaves_like 'linter'
11
+
12
+ its(:languages){is_expected.to eq([LintTrap::Language::Java.new])}
9
13
 
10
14
  describe '#lint' do
11
15
  context 'when config is provided' do
@@ -7,6 +7,10 @@ describe LintTrap::Linter::CoffeeLint do
7
7
  subject(:linter){described_class.new}
8
8
  let(:command){instance_double(LintTrap::Command)}
9
9
 
10
+ it_behaves_like 'linter'
11
+
12
+ its(:languages){is_expected.to eq([LintTrap::Language::CoffeeScript.new])}
13
+
10
14
  describe '#lint' do
11
15
  context 'when config is provided' do
12
16
  let(:options){{config: 'coffeelint.json'}}
@@ -7,6 +7,10 @@ describe LintTrap::Linter::CPPCheck do
7
7
  subject(:linter){described_class.new}
8
8
  let(:command){instance_double(LintTrap::Command)}
9
9
 
10
+ it_behaves_like 'linter'
11
+
12
+ its(:languages){is_expected.to eq([LintTrap::Language::CPP.new])}
13
+
10
14
  describe '#lint' do
11
15
  it 'runs the lint command with the correct arguments' do
12
16
  expect(LintTrap::Command).to receive(:new).with(
@@ -7,6 +7,10 @@ describe LintTrap::Linter::CSSLint do
7
7
  subject(:linter){described_class.new}
8
8
  let(:command){instance_double(LintTrap::Command)}
9
9
 
10
+ it_behaves_like 'linter'
11
+
12
+ its(:languages){is_expected.to eq([LintTrap::Language::CSS.new])}
13
+
10
14
  describe '#lint' do
11
15
  context 'when config is provided' do
12
16
  let(:options){{config: '.csslintrc'}}
@@ -7,6 +7,10 @@ describe LintTrap::Linter::GoLint do
7
7
  subject(:linter){described_class.new}
8
8
  let(:command){instance_double(LintTrap::Command)}
9
9
 
10
+ it_behaves_like 'linter'
11
+
12
+ its(:languages){is_expected.to eq([LintTrap::Language::Go.new])}
13
+
10
14
  describe '#lint' do
11
15
  it 'runs the lint command with the correct arguments' do
12
16
  expect(LintTrap::Command).to receive(:new).with(
@@ -7,6 +7,10 @@ describe LintTrap::Linter::JSHint do
7
7
  subject(:linter){described_class.new}
8
8
  let(:command){instance_double(LintTrap::Command)}
9
9
 
10
+ it_behaves_like 'linter'
11
+
12
+ its(:languages){is_expected.to eq([LintTrap::Language::JavaScript.new])}
13
+
10
14
  describe '#lint' do
11
15
  context 'when config is provided' do
12
16
  let(:options){{config: '.jshintrc'}}
@@ -7,6 +7,10 @@ describe LintTrap::Linter::JSONLint do
7
7
  subject(:linter){described_class.new}
8
8
  let(:command){instance_double(LintTrap::Command)}
9
9
 
10
+ it_behaves_like 'linter'
11
+
12
+ its(:languages){is_expected.to eq([LintTrap::Language::JSON.new])}
13
+
10
14
  describe '#lint' do
11
15
  it 'runs the lint command with the correct arguments' do
12
16
  expect(LintTrap::Command).to receive(:new).with(
@@ -7,6 +7,10 @@ describe LintTrap::Linter::PyLint do
7
7
  subject(:linter){described_class.new}
8
8
  let(:command){instance_double(LintTrap::Command)}
9
9
 
10
+ it_behaves_like 'linter'
11
+
12
+ its(:languages){is_expected.to eq([LintTrap::Language::Python.new])}
13
+
10
14
  describe '#lint' do
11
15
  context 'when config is provided' do
12
16
  let(:options){{config: '.pylintrc'}}
@@ -7,6 +7,10 @@ describe LintTrap::Linter::RuboCop do
7
7
  subject(:linter){described_class.new}
8
8
  let(:command){instance_double(LintTrap::Command)}
9
9
 
10
+ it_behaves_like 'linter'
11
+
12
+ its(:languages){is_expected.to eq([LintTrap::Language::Ruby.new])}
13
+
10
14
  describe '#lint' do
11
15
  context 'when config is provided' do
12
16
  let(:options){{config: '.rubocop.yml'}}
@@ -7,6 +7,10 @@ describe LintTrap::Linter::SCSSLint do
7
7
  subject(:linter){described_class.new}
8
8
  let(:command){instance_double(LintTrap::Command)}
9
9
 
10
+ it_behaves_like 'linter'
11
+
12
+ its(:languages){is_expected.to eq([LintTrap::Language::SCSS.new])}
13
+
10
14
  describe '#lint' do
11
15
  context 'when config is provided' do
12
16
  let(:options){{config: '.scss-lint.yml'}}
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,8 @@ require 'rspec/its'
3
3
  require 'lint_trap'
4
4
  require 'pry'
5
5
  require_relative 'support/fixture_file_helper'
6
+ require_relative 'support/examples/language'
7
+ require_relative 'support/examples/linter'
6
8
 
7
9
  ENV['DEBUG_LINTING'] = ENV['CI']
8
10
 
@@ -0,0 +1,12 @@
1
+ shared_examples_for 'language' do
2
+ its(:linters){is_expected.to_not be_empty}
3
+
4
+ describe '#linters' do
5
+ it 'returns a list of linters which reference this language' do
6
+ language.linters.each do |linter|
7
+ expect(linter.languages).to include(language),
8
+ "expected #{linter.name} to reference #{language.name} as one of it's languages"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ shared_examples_for 'linter' do
2
+ its(:languages){is_expected.to_not be_empty}
3
+
4
+ describe '#languages' do
5
+ it 'returns a list of languages which reference this linter' do
6
+ linter.languages.each do |language|
7
+ expect(language.linters).to include(linter), "expected #{language.name} to reference #{linter.name} as one of it's linters"
8
+ end
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lint_trap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Madsen
@@ -213,6 +213,8 @@ files:
213
213
  - spec/parser/standard_spec.rb
214
214
  - spec/parser/vim_quickfix_spec.rb
215
215
  - spec/spec_helper.rb
216
+ - spec/support/examples/language.rb
217
+ - spec/support/examples/linter.rb
216
218
  - spec/support/fixture_file_helper.rb
217
219
  homepage: https://github.com/lintci/lint_trap
218
220
  licenses:
@@ -300,4 +302,6 @@ test_files:
300
302
  - spec/parser/standard_spec.rb
301
303
  - spec/parser/vim_quickfix_spec.rb
302
304
  - spec/spec_helper.rb
305
+ - spec/support/examples/language.rb
306
+ - spec/support/examples/linter.rb
303
307
  - spec/support/fixture_file_helper.rb