aboutsummaryrefslogtreecommitdiffhomepage
path: root/spec/pronto/eslint_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/pronto/eslint_spec.rb')
-rw-r--r--spec/pronto/eslint_spec.rb36
1 files changed, 32 insertions, 4 deletions
diff --git a/spec/pronto/eslint_spec.rb b/spec/pronto/eslint_spec.rb
index 7bbc77a..6358621 100644
--- a/spec/pronto/eslint_spec.rb
+++ b/spec/pronto/eslint_spec.rb
@@ -3,6 +3,7 @@ require 'spec_helper'
3module Pronto 3module Pronto
4 describe ESLintNpm do 4 describe ESLintNpm do
5 let(:eslint) { ESLintNpm.new(patches) } 5 let(:eslint) { ESLintNpm.new(patches) }
6 let(:patches) { [] }
6 7
7 describe '#run' do 8 describe '#run' do
8 subject(:run) { eslint.run } 9 subject(:run) { eslint.run }
@@ -35,6 +36,33 @@ module Pronto
35 it 'has correct first message' do 36 it 'has correct first message' do
36 expect(run.first.msg).to eql("'foo' is not defined.") 37 expect(run.first.msg).to eql("'foo' is not defined.")
37 end 38 end
39
40 context(
41 'with files to lint config that never matches',
42 config: { files_to_lint: 'will never match' }
43 ) do
44 it 'returns zero errors' do
45 expect(run.count).to eql(0)
46 end
47 end
48
49 context(
50 'with files to lint config that matches only .js',
51 config: { files_to_lint: /\.js/ }
52 ) do
53 it 'returns correct amount of errors' do
54 expect(run.count).to eql(2)
55 end
56 end
57
58 context(
59 'with different eslint executable',
60 config: { eslint_executable: './custom_eslint.sh' }
61 ) do
62 it 'calls the custom eslint eslint_executable' do
63 expect { run }.to raise_error(JSON::ParserError, /custom eslint called/)
64 end
65 end
38 end 66 end
39 67
40 context 'repo with ignored and not ignored file, each with three warnings' do 68 context 'repo with ignored and not ignored file, each with three warnings' do
@@ -52,8 +80,8 @@ module Pronto
52 end 80 end
53 end 81 end
54 82
55 describe '.files_to_lint' do 83 describe '#files_to_lint' do
56 subject(:files_to_lint) { ESLintNpm.files_to_lint } 84 subject(:files_to_lint) { eslint.files_to_lint }
57 85
58 it 'matches .js by default' do 86 it 'matches .js by default' do
59 expect(files_to_lint).to match('my_js.js') 87 expect(files_to_lint).to match('my_js.js')
@@ -64,8 +92,8 @@ module Pronto
64 end 92 end
65 end 93 end
66 94
67 describe '.eslint_executable' do 95 describe '#eslint_executable' do
68 subject(:eslint_executable) { ESLintNpm.eslint_executable } 96 subject(:eslint_executable) { eslint.eslint_executable }
69 97
70 it 'is `eslint` by default' do 98 it 'is `eslint` by default' do
71 expect(eslint_executable).to eql('eslint') 99 expect(eslint_executable).to eql('eslint')