diff options
author | Horacio Sanson <hsanson@gmail.com> | 2020-08-13 19:25:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-13 11:25:07 +0100 |
commit | 8e6c7bff9aeeb445649843113b39ee3c79d4a909 (patch) | |
tree | 9bc8e82277a975d9a51e83726a0e5d9b32abeb9b /test | |
parent | 34adb997c6d1f41ebc5baa85e58e865da2939791 (diff) | |
download | ale-8e6c7bff9aeeb445649843113b39ee3c79d4a909.zip |
Fix 1695 - Change rubocop fixer to use stdin (#3230)
* Fix 1695 - Change rubocop fixer to use stdin
* Update test_rubocop_fixer_callback.vader
Co-authored-by: Horacio Sanson <horacio@allm.inc>
Co-authored-by: w0rp <w0rp@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/fixers/test_rubocop_fixer_callback.vader | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/test/fixers/test_rubocop_fixer_callback.vader b/test/fixers/test_rubocop_fixer_callback.vader index b1925000..305881e0 100644 --- a/test/fixers/test_rubocop_fixer_callback.vader +++ b/test/fixers/test_rubocop_fixer_callback.vader @@ -21,9 +21,10 @@ Execute(The rubocop callback should return the correct default values): AssertEqual \ { - \ 'read_temporary_file': 1, + \ 'process_with': 'ale#fixers#rubocop#PostProcess', \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) - \ . ' --auto-correct --force-exclusion %t', + \ . ' --auto-correct --force-exclusion --stdin ' + \ . ale#Escape(expand('#' . bufnr('') . ':p')), \ }, \ ale#fixers#rubocop#Fix(bufnr('')) @@ -32,10 +33,11 @@ Execute(The rubocop callback should include configuration files): AssertEqual \ { - \ 'read_temporary_file': 1, + \ 'process_with': 'ale#fixers#rubocop#PostProcess', \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) \ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml')) - \ . ' --auto-correct --force-exclusion %t', + \ . ' --auto-correct --force-exclusion --stdin ' + \ . ale#Escape(expand('#' . bufnr('') . ':p')), \ }, \ ale#fixers#rubocop#Fix(bufnr('')) @@ -45,11 +47,12 @@ Execute(The rubocop callback should include custom rubocop options): AssertEqual \ { - \ 'read_temporary_file': 1, + \ 'process_with': 'ale#fixers#rubocop#PostProcess', \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) \ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml')) \ . ' --except Lint/Debugger' - \ . ' --auto-correct --force-exclusion %t', + \ . ' --auto-correct --force-exclusion --stdin ' + \ . ale#Escape(expand('#' . bufnr('') . ':p')), \ }, \ ale#fixers#rubocop#Fix(bufnr('')) @@ -59,9 +62,49 @@ Execute(The rubocop callback should use auto-correct-all option when set): AssertEqual \ { - \ 'read_temporary_file': 1, + \ 'process_with': 'ale#fixers#rubocop#PostProcess', \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) \ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml')) - \ . ' --auto-correct-all --force-exclusion %t', + \ . ' --auto-correct-all --force-exclusion --stdin ' + \ . ale#Escape(expand('#' . bufnr('') . ':p')), \ }, \ ale#fixers#rubocop#Fix(bufnr('')) + +Execute(The rubocop post-processor should remove diagnostics content): + AssertEqual + \ [ + \ 'class MyModel < ApplicationRecord', + \ ' # rubocop:disable Rails/InverseOf', + \ ' has_one :something', + \ ' # rubocop:enable Rails/InverseOf', + \ 'end', + \ '', + \ 'array = [1, 2, 3,', + \ ' 4, 5, 6]', + \ 'array = [''run'',', + \ ' ''forrest'',', + \ ' ''run'']', + \ ], + \ ale#fixers#rubocop#PostProcess(bufnr(''), [ + \ 'Inspecting 1 file', + \ 'C', + \ '', + \ 'Offenses:', + \ 'app/models/my_model.rb:8:3: C: [Corrected] Layout/ArrayAlignment: ', + \ '4, 5, 6]', + \ '^', + \ '', + \ '1 file inspected, 3 offenses detected, 3 offenses corrected', + \ '====================', + \ 'class MyModel < ApplicationRecord', + \ ' # rubocop:disable Rails/InverseOf', + \ ' has_one :something', + \ ' # rubocop:enable Rails/InverseOf', + \ 'end', + \ '', + \ 'array = [1, 2, 3,', + \ ' 4, 5, 6]', + \ 'array = [''run'',', + \ ' ''forrest'',', + \ ' ''run'']', + \ ]) |