summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew Lanigan <rintaun@gmail.com>2019-07-13 12:37:48 -0400
committerw0rp <w0rp@users.noreply.github.com>2019-07-13 17:37:48 +0100
commitabb38955d3acd452e37c15e7bae62022d1153859 (patch)
tree3dbb6b8d04a13c26d6f067e7c56da0aa59bcac03 /test
parent6c47d7fc352659cd2dc869a9a46a04a8492fc829 (diff)
downloadale-abb38955d3acd452e37c15e7bae62022d1153859.zip
Add Sorbet ruby linter and fixer (#2614)
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_sorbet_command_callback.vader27
-rw-r--r--test/fixers/test_sorbet_fixer_callback.vader42
2 files changed, 69 insertions, 0 deletions
diff --git a/test/command_callback/test_sorbet_command_callback.vader b/test/command_callback/test_sorbet_command_callback.vader
new file mode 100644
index 00000000..b46e90a4
--- /dev/null
+++ b/test/command_callback/test_sorbet_command_callback.vader
@@ -0,0 +1,27 @@
+
+Before:
+ call ale#assert#SetUpLinterTest('ruby', 'sorbet')
+ call ale#test#SetFilename('dummy.rb')
+
+ let g:ale_ruby_sorbet_executable = 'srb'
+ let g:ale_ruby_sorbet_options = ''
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(Executable should default to srb):
+ AssertLinter 'srb', ale#Escape('srb')
+ \ . ' tc --lsp --disable-watchman'
+
+Execute(Should be able to set a custom executable):
+ let g:ale_ruby_sorbet_executable = 'bin/srb'
+
+ AssertLinter 'bin/srb' , ale#Escape('bin/srb')
+ \ . ' tc --lsp --disable-watchman'
+
+Execute(Setting bundle appends 'exec srb tc'):
+ let g:ale_ruby_sorbet_executable = 'path to/bundle'
+
+ AssertLinter 'path to/bundle', ale#Escape('path to/bundle')
+ \ . ' exec srb'
+ \ . ' tc --lsp --disable-watchman'
diff --git a/test/fixers/test_sorbet_fixer_callback.vader b/test/fixers/test_sorbet_fixer_callback.vader
new file mode 100644
index 00000000..71870e4c
--- /dev/null
+++ b/test/fixers/test_sorbet_fixer_callback.vader
@@ -0,0 +1,42 @@
+
+Before:
+ Save g:ale_ruby_sorbet_executable
+ Save g:ale_ruby_sorbet_options
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_ruby_sorbet_executable = 'xxxinvalid'
+ let g:ale_ruby_sorbet_options = ''
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+ silent cd ..
+ silent cd command_callback
+ let g:dir = getcwd()
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The sorbet callback should return the correct default values):
+ call ale#test#SetFilename('ruby_paths/dummy.rb')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_ruby_sorbet_executable)
+ \ . ' tc --autocorrect --file %t',
+ \ },
+ \ ale#fixers#sorbet#Fix(bufnr(''))
+
+Execute(The sorbet callback should include custom sorbet options):
+ let g:ale_ruby_sorbet_options = '--enable-experimental-lsp-hover'
+ call ale#test#SetFilename('ruby_paths/with_config/dummy.rb')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_ruby_sorbet_executable)
+ \ . ' tc --enable-experimental-lsp-hover'
+ \ . ' --autocorrect --file %t',
+ \ },
+ \ ale#fixers#sorbet#Fix(bufnr(''))