]> git.immae.eu Git - github/fretlink/pronto-hlint.git/blob - spec/pronto/eslint_spec.rb
20659987c9404e31e24dd30d1e7c2238b3e27a34
[github/fretlink/pronto-hlint.git] / spec / pronto / eslint_spec.rb
1 require 'spec_helper'
2
3 module Pronto
4 describe ESLintNpm do
5 let(:eslint) { ESLintNpm.new(patches) }
6
7 describe '#run' do
8 subject(:run) { eslint.run }
9
10 context 'patches are nil' do
11 let(:patches) { nil }
12
13 it 'returns an empty array' do
14 expect(run).to eql([])
15 end
16 end
17
18 context 'no patches' do
19 let(:patches) { [] }
20
21 it 'returns an empty array' do
22 expect(run).to eql([])
23 end
24 end
25
26 context 'patches with a one and a four warnings' do
27 include_context 'test repo'
28
29 let(:patches) { repo.diff('master') }
30
31 it 'returns correct number of errors' do
32 expect(run.count).to eql(5)
33 end
34
35 it 'has correct first message' do
36 expect(run.first.msg).to eql("'foo' is not defined.")
37 end
38 end
39
40 context 'repo with ignored and not ignored file, each with three warnings' do
41 include_context 'eslintignore repo'
42
43 let(:patches) { repo.diff('master') }
44
45 it 'returns correct number of errors' do
46 expect(run.count).to eql(3)
47 end
48
49 it 'has correct first message' do
50 expect(run.first.msg).to eql("'HelloWorld' is defined but never used.")
51 end
52 end
53 end
54 end
55 end