Merge pull request #1511 from elebow/add-cucumber-checker
Add `cucumber` checker for Cucumber files
This commit is contained in:
commit
20241c87ef
@ -90,6 +90,7 @@ formatting.
|
|||||||
| CoffeeScript | [coffee](http://coffeescript.org/), [coffeelint](https://www.npmjs.com/package/coffeelint) |
|
| CoffeeScript | [coffee](http://coffeescript.org/), [coffeelint](https://www.npmjs.com/package/coffeelint) |
|
||||||
| Crystal | [crystal](https://crystal-lang.org/) !! |
|
| Crystal | [crystal](https://crystal-lang.org/) !! |
|
||||||
| CSS | [csslint](http://csslint.net/), [prettier](https://github.com/prettier/prettier), [stylelint](https://github.com/stylelint/stylelint) |
|
| CSS | [csslint](http://csslint.net/), [prettier](https://github.com/prettier/prettier), [stylelint](https://github.com/stylelint/stylelint) |
|
||||||
|
| Cucumber | [cucumber](https://cucumber.io/) |
|
||||||
| Cython (pyrex filetype) | [cython](http://cython.org/) |
|
| Cython (pyrex filetype) | [cython](http://cython.org/) |
|
||||||
| D | [dmd](https://dlang.org/dmd-linux.html) |
|
| D | [dmd](https://dlang.org/dmd-linux.html) |
|
||||||
| Dafny | [dafny](https://rise4fun.com/Dafny) !! |
|
| Dafny | [dafny](https://rise4fun.com/Dafny) !! |
|
||||||
|
45
ale_linters/cucumber/cucumber.vim
Normal file
45
ale_linters/cucumber/cucumber.vim
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
" Author: Eddie Lebow https://github.com/elebow
|
||||||
|
" Description: Cucumber, a BDD test tool
|
||||||
|
|
||||||
|
function! ale_linters#cucumber#cucumber#GetCommand(buffer) abort
|
||||||
|
let l:features_dir = ale#path#FindNearestDirectory(a:buffer, 'features')
|
||||||
|
|
||||||
|
if !empty(l:features_dir)
|
||||||
|
let l:features_arg = '-r ' . ale#Escape(l:features_dir)
|
||||||
|
else
|
||||||
|
let l:features_arg = ''
|
||||||
|
endif
|
||||||
|
|
||||||
|
return 'cucumber --dry-run --quiet --strict --format=json '
|
||||||
|
\ . l:features_arg . ' %t'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#cucumber#cucumber#Handle(buffer, lines) abort
|
||||||
|
try
|
||||||
|
let l:json = ale#util#FuzzyJSONDecode(a:lines, {})[0]
|
||||||
|
catch
|
||||||
|
return []
|
||||||
|
endtry
|
||||||
|
|
||||||
|
let l:output = []
|
||||||
|
for l:element in get(l:json, 'elements', [])
|
||||||
|
for l:step in l:element['steps']
|
||||||
|
if l:step['result']['status'] is# 'undefined'
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'lnum': l:step['line'],
|
||||||
|
\ 'code': 'E',
|
||||||
|
\ 'text': 'Undefined step'
|
||||||
|
\})
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('cucumber', {
|
||||||
|
\ 'name': 'cucumber',
|
||||||
|
\ 'executable': 'cucumber',
|
||||||
|
\ 'command_callback': 'ale_linters#cucumber#cucumber#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#cucumber#cucumber#Handle'
|
||||||
|
\})
|
@ -322,6 +322,7 @@ Notes:
|
|||||||
* CoffeeScript: `coffee`, `coffeelint`
|
* CoffeeScript: `coffee`, `coffeelint`
|
||||||
* Crystal: `crystal`!!
|
* Crystal: `crystal`!!
|
||||||
* CSS: `csslint`, `prettier`, `stylelint`
|
* CSS: `csslint`, `prettier`, `stylelint`
|
||||||
|
* Cucumber: `cucumber`
|
||||||
* Cython (pyrex filetype): `cython`
|
* Cython (pyrex filetype): `cython`
|
||||||
* D: `dmd`
|
* D: `dmd`
|
||||||
* Dafny: `dafny`!!
|
* Dafny: `dafny`!!
|
||||||
|
25
test/command_callback/test_cucumber_command_callback.vader
Normal file
25
test/command_callback/test_cucumber_command_callback.vader
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
Before:
|
||||||
|
runtime ale_linters/ruby/rubocop.vim
|
||||||
|
call ale#test#SetDirectory('/testplugin/test/')
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
call ale#linter#Reset()
|
||||||
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
|
Execute(Should require the nearest features dir, if one is found):
|
||||||
|
call ale#test#SetFilename('cucumber_fixtures/features/cuke.feature')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ 'cucumber --dry-run --quiet --strict --format=json '
|
||||||
|
\ . '-r ' . ale#Escape(ale#path#Simplify(g:dir . '/cucumber_fixtures/features/')) . ' %t',
|
||||||
|
\ ale_linters#cucumber#cucumber#GetCommand(bufnr(''))
|
||||||
|
|
||||||
|
Execute(Should require nothing if no features dir is found):
|
||||||
|
call ale#test#SetFilename('something/without/a/features/dir')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ 'cucumber --dry-run --quiet --strict --format=json '
|
||||||
|
\ . ' %t',
|
||||||
|
\ ale_linters#cucumber#cucumber#GetCommand(bufnr(''))
|
0
test/cucumber_fixtures/features/cuke.feature
Normal file
0
test/cucumber_fixtures/features/cuke.feature
Normal file
18
test/handler/test_cucumber_handler.vader
Normal file
18
test/handler/test_cucumber_handler.vader
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
Before:
|
||||||
|
runtime ale_linters/cucumber/cucumber.vim
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#linter#Reset()
|
||||||
|
|
||||||
|
Execute(The cucumber handler parses JSON correctly):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 13,
|
||||||
|
\ 'code': 'E',
|
||||||
|
\ 'text': 'Undefined step'
|
||||||
|
\ }
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#cucumber#cucumber#Handle(bufnr(''), [
|
||||||
|
\ '[{"elements": [{"steps": [{"result": {"status": "undefined"},"match": {"location": "features/cuke.feature:13"},"line": 13,"name": "Something undefined","keyword": "Given "},{"result": {"status": "skipped"},"match": {"location": "/var/lib/gems/2.3.0/gems/cucumber-3.1.0/lib/cucumber/step_match.rb:103"},"line": 14,"name": "I visit the profile page for Alice","keyword": "When "}],"type": "scenario","line": 12,"description": "","name": "Another scenario","keyword": "Scenario","id": "a-user-can-view-another-users-profile;another-scenario"}],"line": 1,"description": "","name": "A user can view another users profile","keyword": "Feature","id": "a-user-can-view-another-users-profile","uri": "features/cuke.feature"}]'
|
||||||
|
\ ])
|
Loading…
Reference in New Issue
Block a user