From 7413dfd3fc386920217fb43e9a517e99d9cf42b8 Mon Sep 17 00:00:00 2001 From: Roeland <10061147+roelandmoors@users.noreply.github.com> Date: Mon, 11 Oct 2021 13:52:46 +0200 Subject: erblint as fixer (#3935) * fixer erblint * erblint fixer test --- test/fixers/test_erblint_fixer_callback.vader | 55 +++++++++++++++++++++++++++ test/test-files/eruby/dummy.html.erb | 0 2 files changed, 55 insertions(+) create mode 100644 test/fixers/test_erblint_fixer_callback.vader create mode 100644 test/test-files/eruby/dummy.html.erb (limited to 'test') diff --git a/test/fixers/test_erblint_fixer_callback.vader b/test/fixers/test_erblint_fixer_callback.vader new file mode 100644 index 00000000..7b56e3a9 --- /dev/null +++ b/test/fixers/test_erblint_fixer_callback.vader @@ -0,0 +1,55 @@ +Before: + Save g:ale_eruby_erblint_executable + Save g:ale_eruby_erblint_options + + " Use an invalid global executable, so we don't match it. + let g:ale_eruby_erblint_executable = 'xxxinvalid' + let g:ale_eruby_erblint_options = '' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The erblint callback should return the correct default values): + call ale#test#SetFilename('../test-files/eruby/dummy.html.erb') + + AssertEqual + \ { + \ 'process_with': 'ale#fixers#erblint#PostProcess', + \ 'command': ale#Escape(g:ale_eruby_erblint_executable) + \ . ' --autocorrect --stdin %s', + \ }, + \ ale#fixers#erblint#Fix(bufnr('')) + +Execute(The erblint callback should include custom erblint options): + let g:ale_eruby_erblint_options = '--lint-all' + call ale#test#SetFilename('../test-files/ruby/with_config/dummy.rb') + + AssertEqual + \ { + \ 'process_with': 'ale#fixers#erblint#PostProcess', + \ 'command': ale#Escape(g:ale_eruby_erblint_executable) + \ . ' --lint-all' + \ . ' --autocorrect --stdin %s', + \ }, + \ ale#fixers#erblint#Fix(bufnr('')) + +Execute(The erblint post-processor should remove diagnostics content): + AssertEqual + \ [ + \ '
', + \ '', + \ '
', + \ ], + \ ale#fixers#erblint#PostProcess(bufnr(''), [ + \ 'Linting 1 files with 11 autocorrectable linters...', + \ '', + \ '1 error(s) corrected in ERB files', + \ '================ /home/user/demo.html.erb ==================', + \ '
', + \ '', + \ '
', + \ ]) diff --git a/test/test-files/eruby/dummy.html.erb b/test/test-files/eruby/dummy.html.erb new file mode 100644 index 00000000..e69de29b -- cgit v1.2.3