]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/test/fixers/test_rubocop_fixer_callback.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / fixers / test_rubocop_fixer_callback.vader
diff --git a/.vim/bundle/ale/test/fixers/test_rubocop_fixer_callback.vader b/.vim/bundle/ale/test/fixers/test_rubocop_fixer_callback.vader
new file mode 100644 (file)
index 0000000..f7b0eb6
--- /dev/null
@@ -0,0 +1,89 @@
+Before:
+  Save g:ale_ruby_rubocop_executable
+  Save g:ale_ruby_rubocop_options
+
+  " Use an invalid global executable, so we don't match it.
+  let g:ale_ruby_rubocop_executable = 'xxxinvalid'
+  let g:ale_ruby_rubocop_options = ''
+
+  call ale#test#SetDirectory('/testplugin/test/fixers')
+
+After:
+  Restore
+
+  call ale#test#RestoreDirectory()
+
+Execute(The rubocop callback should return the correct default values):
+  call ale#test#SetFilename('../test-files/ruby/dummy.rb')
+
+  AssertEqual
+  \ {
+  \   'process_with': 'ale#fixers#rubocop#PostProcess',
+  \   'command': ale#Escape(g:ale_ruby_rubocop_executable)
+  \     . ' --auto-correct --force-exclusion --stdin %s',
+  \ },
+  \ ale#fixers#rubocop#Fix(bufnr(''))
+
+Execute(The rubocop callback should include custom rubocop options):
+  let g:ale_ruby_rubocop_options = '--except Lint/Debugger'
+  call ale#test#SetFilename('../test-files/ruby/with_config/dummy.rb')
+
+  AssertEqual
+  \ {
+  \   'process_with': 'ale#fixers#rubocop#PostProcess',
+  \   'command': ale#Escape(g:ale_ruby_rubocop_executable)
+  \     . ' --except Lint/Debugger'
+  \     . ' --auto-correct --force-exclusion --stdin %s',
+  \ },
+  \ ale#fixers#rubocop#Fix(bufnr(''))
+
+Execute(The rubocop callback should use auto-correct-all option when set):
+  let g:ale_ruby_rubocop_auto_correct_all = 1
+  call ale#test#SetFilename('../test-files/ruby/with_config/dummy.rb')
+
+  AssertEqual
+  \ {
+  \   'process_with': 'ale#fixers#rubocop#PostProcess',
+  \   'command': ale#Escape(g:ale_ruby_rubocop_executable)
+  \     . ' --auto-correct-all --force-exclusion --stdin %s'
+  \ },
+  \ 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'']',
+  \ ])