summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRoeland <10061147+roelandmoors@users.noreply.github.com>2021-10-09 07:33:07 +0200
committerGitHub <noreply@github.com>2021-10-09 14:33:07 +0900
commit1ee7580557733bab22b764170958a0189810b3bb (patch)
tree758d160e085b6a2f4a27464905653226b4f9cadf /test
parent42a6e039cb36fbc5a60215b2be55e54c364b15e9 (diff)
downloadale-1ee7580557733bab22b764170958a0189810b3bb.zip
Add support for erblint (#3931)
* support for erblint * fix tests * test for handler * wrong names * typo * doc layout * CI failed?
Diffstat (limited to 'test')
-rw-r--r--test/handler/test_erblint_handler.vader70
-rw-r--r--test/linter/test_erblint.vader26
2 files changed, 96 insertions, 0 deletions
diff --git a/test/handler/test_erblint_handler.vader b/test/handler/test_erblint_handler.vader
new file mode 100644
index 00000000..01d4c0ab
--- /dev/null
+++ b/test/handler/test_erblint_handler.vader
@@ -0,0 +1,70 @@
+Before:
+ runtime ale_linters/eruby/erblint.vim
+
+After:
+ unlet! g:lines
+ call ale#linter#Reset()
+
+Execute(The erblint handler should parse lines correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 0,
+ \ 'end_col': 0,
+ \ 'text': 'Extra blank line detected.',
+ \ 'code': 'ExtraNewline',
+ \ 'type': 'W',
+ \ },
+ \ {
+ \ 'lnum': 6,
+ \ 'col': 0,
+ \ 'end_col': 0,
+ \ 'text': 'Remove multiple trailing newline at the end of the file.',
+ \ 'code': 'FinalNewline',
+ \ 'type': 'W',
+ \ },
+ \ {
+ \ 'lnum': 4,
+ \ 'col': 9,
+ \ 'end_col': 11,
+ \ 'text': 'Use 1 space after `<%=` instead of 2 spaces.',
+ \ 'code': 'SpaceAroundErbTag',
+ \ 'type': 'W',
+ \ },
+ \ {
+ \ 'lnum': 4,
+ \ 'col': 9,
+ \ 'end_col': 11,
+ \ 'text': 'Use 1 space before `%>` instead of 2 spaces.',
+ \ 'code': 'SpaceAroundErbTag',
+ \ 'type': 'W',
+ \ },
+ \ {
+ \ 'lnum': 5,
+ \ 'col': 6,
+ \ 'end_col': 10,
+ \ 'text': 'Extra whitespace detected at end of line.',
+ \ 'code': 'TrailingWhitespace',
+ \ 'type': 'W',
+ \ },
+ \ ],
+ \ ale_linters#eruby#erblint#Handle(347, [
+ \ '{"metadata":{"erb_lint_version":"0.1.1","ruby_engine":"ruby","ruby_version":"3.0.2","ruby_patchlevel":"107","ruby_platform":"arm64-darwin20"},"files":[{"path":"demo.html.erb","offenses":[{"linter":"ExtraNewline","message":"Extra blank line detected.","location":{"start_line":3,"start_column":0,"last_line":4,"last_column":0,"length":1}},{"linter":"FinalNewline","message":"Remove multiple trailing newline at the end of the file.","location":{"start_line":6,"start_column":0,"last_line":8,"last_column":0,"length":2}},{"linter":"SpaceAroundErbTag","message":"Use 1 space after `<%=` instead of 2 spaces.","location":{"start_line":4,"start_column":9,"last_line":4,"last_column":11,"length":2}},{"linter":"SpaceAroundErbTag","message":"Use 1 space before `%>` instead of 2 spaces.","location":{"start_line":4,"start_column":9,"last_line":4,"last_column":11,"length":2}},{"linter":"TrailingWhitespace","message":"Extra whitespace detected at end of line.","location":{"start_line":5,"start_column":6,"last_line":5,"last_column":10,"length":4}}]}],"summary":{"offenses":5,"inspected_files":1,"corrected":0}}'
+ \ ])
+
+Execute(The erblint handler should handle when files are checked and no offenses are found):
+ AssertEqual
+ \ [],
+ \ ale_linters#eruby#erblint#Handle(347, [
+ \ '{"metadata":{"erb_lint_version":"0.1.1","ruby_engine":"ruby","ruby_version":"3.0.2","ruby_patchlevel":"107","ruby_platform":"arm64-darwin20"},"files":[{"path":"demo.html.erb","offenses":[]}],"summary":{"offenses":0,"inspected_files":1,"corrected":0}}'
+ \ ])
+
+Execute(The erblint handler should handle output without any errors):
+ AssertEqual
+ \ [],
+ \ ale_linters#eruby#erblint#Handle(347, ['{}'])
+
+ AssertEqual
+ \ [],
+ \ ale_linters#eruby#erblint#Handle(347, [])
diff --git a/test/linter/test_erblint.vader b/test/linter/test_erblint.vader
new file mode 100644
index 00000000..147b5965
--- /dev/null
+++ b/test/linter/test_erblint.vader
@@ -0,0 +1,26 @@
+Before:
+ call ale#assert#SetUpLinterTest('eruby', 'erblint')
+ call ale#test#SetFilename('dummy.html.erb')
+
+ let g:ale_eruby_erblint_executable = 'erblint'
+ let g:ale_eruby_erblint_options = ''
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(Executable should default to erblint):
+ AssertLinter 'erblint', ale#Escape('erblint')
+ \ . ' --format json --stdin %s'
+
+Execute(Should be able to set a custom executable):
+ let g:ale_eruby_erblint_executable = 'bin/erblint'
+
+ AssertLinter 'bin/erblint' , ale#Escape('bin/erblint')
+ \ . ' --format json --stdin %s'
+
+Execute(Setting bundle appends 'exec erblint'):
+ let g:ale_eruby_erblint_executable = 'path to/bundle'
+
+ AssertLinter 'path to/bundle', ale#Escape('path to/bundle')
+ \ . ' exec erblint'
+ \ . ' --format json --stdin %s'