2017-07-12 09:43:47 +00:00
|
|
|
Before:
|
2017-07-26 23:45:25 +00:00
|
|
|
call ale#test#SetDirectory('/testplugin/test/handler')
|
|
|
|
cd ..
|
2017-07-12 09:43:47 +00:00
|
|
|
|
2017-07-26 23:45:25 +00:00
|
|
|
runtime ale_linters/ruby/rails_best_practices.vim
|
2017-07-12 09:43:47 +00:00
|
|
|
|
|
|
|
After:
|
2017-07-26 23:45:25 +00:00
|
|
|
call ale#test#RestoreDirectory()
|
|
|
|
call ale#linter#Reset()
|
2017-07-12 09:43:47 +00:00
|
|
|
|
|
|
|
Execute(The rails_best_practices handler should parse JSON correctly):
|
2017-07-26 23:45:25 +00:00
|
|
|
call ale#test#SetFilename('ruby_fixtures/valid_rails_app/app/models/thing.rb')
|
2017-07-12 09:43:47 +00:00
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 5,
|
|
|
|
\ 'text': 'use local variable',
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 10,
|
|
|
|
\ 'text': 'other advice',
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale_linters#ruby#rails_best_practices#Handle(bufnr(''), [
|
|
|
|
\ '[',
|
|
|
|
\ '{',
|
|
|
|
\ '"message": "use local variable",',
|
|
|
|
\ '"line_number": "5",',
|
2017-07-26 23:45:25 +00:00
|
|
|
\ '"filename": "' . g:dir . '/ruby_fixtures/valid_rails_app/app/models/thing.rb"',
|
2017-07-12 09:43:47 +00:00
|
|
|
\ '},{',
|
|
|
|
\ '"message": "other advice",',
|
|
|
|
\ '"line_number": "10",',
|
2017-07-26 23:45:25 +00:00
|
|
|
\ '"filename": "' . g:dir . '/ruby_fixtures/valid_rails_app/app/models/thing.rb"',
|
2017-07-12 09:43:47 +00:00
|
|
|
\ '}',
|
|
|
|
\ ']'
|
|
|
|
\ ])
|
|
|
|
|
|
|
|
Execute(The rails_best_practices handler should parse JSON correctly when there is no output from the tool):
|
|
|
|
AssertEqual
|
|
|
|
\ [],
|
|
|
|
\ ale_linters#ruby#rails_best_practices#Handle(347, [
|
|
|
|
\ ])
|
2017-07-26 23:45:25 +00:00
|
|
|
|
|
|
|
Execute(The rails_best_practices handler should handle garbage output):
|
|
|
|
AssertEqual
|
|
|
|
\ [],
|
|
|
|
\ ale_linters#ruby#rails_best_practices#Handle(347, [
|
|
|
|
\ 'No such command in 2.4.1 of ruby',
|
|
|
|
\ ])
|