]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/test/handler/test_reek_handler.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 / handler / test_reek_handler.vader
diff --git a/.vim/bundle/ale/test/handler/test_reek_handler.vader b/.vim/bundle/ale/test/handler/test_reek_handler.vader
new file mode 100644 (file)
index 0000000..98c2b73
--- /dev/null
@@ -0,0 +1,85 @@
+Before:
+  Save g:ale_ruby_reek_show_context
+  Save g:ale_ruby_reek_show_wiki_link
+
+  let g:ale_ruby_reek_show_context = 0
+  let g:ale_ruby_reek_show_wiki_link = 0
+
+  runtime ale_linters/ruby/reek.vim
+
+After:
+  Restore
+
+  call ale#linter#Reset()
+
+Execute(The reek handler should parse JSON correctly, with only context enabled):
+  let g:ale_ruby_reek_show_context = 1
+
+  AssertEqual
+  \ [
+  \     {
+  \         'lnum': 12,
+  \         'text': 'Context#method violates rule number one',
+  \         'code': 'Rule1',
+  \         'type': 'W',
+  \     },
+  \     {
+  \         'lnum': 34,
+  \         'text': 'Context#method violates rule number two',
+  \         'code': 'Rule2',
+  \         'type': 'W',
+  \     },
+  \     {
+  \         'lnum': 56,
+  \         'text': 'Context#method violates rule number two',
+  \         'code': 'Rule2',
+  \         'type': 'W',
+  \     },
+  \ ],
+  \ ale_linters#ruby#reek#Handle(347, [
+  \     '[{"context":"Context#method","lines":[12],"message":"violates rule number one","smell_type":"Rule1","source":"/home/user/file.rb","parameter":"bad parameter","wiki_link":"https://example.com/Rule1.md"},{"context":"Context#method","lines":[34, 56],"message":"violates rule number two","smell_type":"Rule2","source":"/home/user/file.rb","name":"bad code","count":2,"wiki_link":"https://example.com/Rule1.md"}]'
+  \ ])
+
+Execute(The reek handler should parse JSON correctly, with no context or wiki links):
+  AssertEqual
+  \ [
+  \     {
+  \         'lnum': 12,
+  \         'text': 'violates rule number one',
+  \         'code': 'Rule1',
+  \         'type': 'W',
+  \     },
+  \ ],
+  \ ale_linters#ruby#reek#Handle(347, [
+  \     '[{"context":"Context#method","lines":[12],"message":"violates rule number one","smell_type":"Rule1","source":"/home/user/file.rb","parameter":"bad parameter","wiki_link":"https://example.com/Rule1.md"}]'
+  \ ])
+
+Execute(The reek handler should parse JSON correctly, with both context and wiki links):
+  let g:ale_ruby_reek_show_context = 1
+  let g:ale_ruby_reek_show_wiki_link = 1
+
+  AssertEqual
+  \ [
+  \     {
+  \         'lnum': 12,
+  \         'text': 'Context#method violates rule number one [https://example.com/Rule1.md]',
+  \         'code': 'Rule1',
+  \         'type': 'W',
+  \     },
+  \ ],
+  \ ale_linters#ruby#reek#Handle(347, [
+  \     '[{"context":"Context#method","lines":[12],"message":"violates rule number one","smell_type":"Rule1","source":"/home/user/file.rb","parameter":"bad parameter","wiki_link":"https://example.com/Rule1.md"}]'
+  \ ])
+
+Execute(The reek handler should parse JSON correctly when there is no output from reek):
+  AssertEqual
+  \ [],
+  \ ale_linters#ruby#reek#Handle(347, [
+  \ ])
+
+Execute(The reek handler should handle garbage output):
+  AssertEqual
+  \ [],
+  \ ale_linters#ruby#reek#Handle(347, [
+  \   'No such command in 2.4.1 of ruby',
+  \ ])