]>
git.immae.eu Git - github/fretlink/pronto-hlint.git/blob - spec/pronto/eslint_spec.rb
5 let(:eslint) { ESLintNpm
.new(patches
) }
9 subject(:run) { eslint
.run
}
11 context
'patches are nil' do
14 it
'returns an empty array' do
15 expect(run
).to
eql([])
19 context
'no patches' do
22 it
'returns an empty array' do
23 expect(run
).to
eql([])
27 context
'patches with a one and a four warnings' do
28 include_context
'test repo'
30 let(:patches) { repo
.diff('master') }
32 it
'returns correct number of errors' do
33 expect(run
.count
).to
eql(5)
36 it
'has correct first message' do
37 expect(run
.first
.msg
).to
eql("'foo' is not defined.")
41 'with files to lint config that never matches',
42 config
: { 'files_to_lint' => 'will never match' }
44 it
'returns zero errors' do
45 expect(run
.count
).to
eql(0)
50 'with files to lint config that matches only .js',
51 config
: { 'files_to_lint' => '\.js$' }
53 it
'returns correct amount of errors' do
54 expect(run
.count
).to
eql(2)
59 'with different eslint executable',
60 config
: { 'eslint_executable' => './custom_eslint.sh' }
62 it
'calls the custom eslint eslint_executable' do
63 expect
{ run
}.to
raise_error(JSON
::ParserError, /custom eslint called/)
68 context
'repo with ignored and not ignored file, each with three warnings' do
69 include_context
'eslintignore repo'
71 let(:patches) { repo
.diff('master') }
73 it
'returns correct number of errors' do
74 expect(run
.count
).to
eql(3)
77 it
'has correct first message' do
78 expect(run
.first
.msg
).to
eql("'HelloWorld' is defined but never used.")
83 describe
'#files_to_lint' do
84 subject(:files_to_lint) { eslint
.files_to_lint
}
86 it
'matches .js by default' do
87 expect(files_to_lint
).to
match('my_js.js')
90 it
'matches .es6 by default' do
91 expect(files_to_lint
).to
match('my_js.es6')
95 describe
'#eslint_executable' do
96 subject(:eslint_executable) { eslint
.eslint_executable
}
98 it
'is `eslint` by default' do
99 expect(eslint_executable
).to
eql('eslint')