diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/handler/test_packwerk_handler.vader | 29 | ||||
-rw-r--r-- | test/linter/test_packwerk.vader | 38 |
2 files changed, 67 insertions, 0 deletions
diff --git a/test/handler/test_packwerk_handler.vader b/test/handler/test_packwerk_handler.vader new file mode 100644 index 00000000..b95b7556 --- /dev/null +++ b/test/handler/test_packwerk_handler.vader @@ -0,0 +1,29 @@ +Before: + call ale#test#SetDirectory('/testplugin/test/handler') + cd .. + + runtime ale_linters/ruby/packwerk.vim + +After: + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(The packwerk handler should parse lines correctly): + call ale#test#SetFilename('test-files/ruby/valid_rails_app/app/models/thing.rb') + + AssertEqual + \ [ + \ { + \ 'lnum': 36, + \ 'col': 100, + \ 'text': 'Dependency violation: ::Edi::Source belongs to ''edi'', but ''billing'' does not specify a dependency on ''edi''.', + \ } + \ ], + \ ale_linters#ruby#packwerk#Handle(bufnr(''), [ + \ '[36m/Users/JaneDoe/src/github.com/sample-project/billing/app/jobs/document_processing_job.rb[m:36:100', + \ 'Dependency violation: ::Edi::Source belongs to ''edi'', but ''billing'' does not specify a dependency on ''edi''.', + \ 'Are we missing an abstraction?', + \ 'Is the code making the reference, and the referenced constant, in the right packages?', + \ '', + \ 'Inference details: ''Edi::Source'' refers to ::Edi::Source which seems to be defined in edi/app/models/edi/source.rb.', + \ ]) diff --git a/test/linter/test_packwerk.vader b/test/linter/test_packwerk.vader new file mode 100644 index 00000000..9a91fd9e --- /dev/null +++ b/test/linter/test_packwerk.vader @@ -0,0 +1,38 @@ +Before: + call ale#assert#SetUpLinterTest('ruby', 'packwerk') + call ale#test#SetFilename('../test-files/ruby/valid_rails_app/db/test.rb') + + let g:ale_ruby_packwerk_executable = 'packwerk' + let g:ale_ruby_packwerk_options = '' + + let b:sep = has('win32') ? '\' : '/' + +After: + unlet! b:sep + + call ale#assert#TearDownLinterTest() + +Execute(Executable should default to packwerk): + AssertLinter 'packwerk', ale#Escape('packwerk') + \ . ' check ' + \ . ale#Escape('db' . b:sep . 'test.rb') + +Execute(Should be able to set a custom executable): + let g:ale_ruby_packwerk_executable = 'bin/packwerk' + + AssertLinter 'bin/packwerk', ale#Escape('bin/packwerk') + \ . ' check ' + \ . ale#Escape('db' . b:sep . 'test.rb') + +Execute(Setting bundle appends 'exec packwerk'): + let g:ale_ruby_packwerk_executable = 'path to/bundle' + + AssertLinter 'path to/bundle', ale#Escape('path to/bundle') + \ . ' exec packwerk' + \ . ' check ' + \ . ale#Escape('db' . b:sep . 'test.rb') + +Execute(Command callback should be empty when not in a valid Rails app): + call ale#test#SetFilename('../test-files/ruby/not_a_rails_app/test.rb') + + AssertLinter 'packwerk', '' |