summaryrefslogtreecommitdiff
path: root/test/fixers/test_erblint_fixer_callback.vader
blob: 7b56e3a9cf687c000968014d8e216b566f08c0ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Before:
  Save g:ale_eruby_erblint_executable
  Save g:ale_eruby_erblint_options

  " Use an invalid global executable, so we don't match it.
  let g:ale_eruby_erblint_executable = 'xxxinvalid'
  let g:ale_eruby_erblint_options = ''

  call ale#test#SetDirectory('/testplugin/test/fixers')

After:
  Restore

  call ale#test#RestoreDirectory()

Execute(The erblint callback should return the correct default values):
  call ale#test#SetFilename('../test-files/eruby/dummy.html.erb')

  AssertEqual
  \ {
  \   'process_with': 'ale#fixers#erblint#PostProcess',
  \   'command': ale#Escape(g:ale_eruby_erblint_executable)
  \     . ' --autocorrect --stdin %s',
  \ },
  \ ale#fixers#erblint#Fix(bufnr(''))

Execute(The erblint callback should include custom erblint options):
  let g:ale_eruby_erblint_options = '--lint-all'
  call ale#test#SetFilename('../test-files/ruby/with_config/dummy.rb')

  AssertEqual
  \ {
  \   'process_with': 'ale#fixers#erblint#PostProcess',
  \   'command': ale#Escape(g:ale_eruby_erblint_executable)
  \     . ' --lint-all'
  \     . ' --autocorrect --stdin %s',
  \ },
  \ ale#fixers#erblint#Fix(bufnr(''))

Execute(The erblint post-processor should remove diagnostics content):
  AssertEqual
  \ [
  \   '<div>',
  \   '',
  \   '</div>',
  \ ],
  \ ale#fixers#erblint#PostProcess(bufnr(''), [
  \   'Linting 1 files with 11 autocorrectable linters...',
  \   '',
  \   '1 error(s) corrected in ERB files',
  \   '================ /home/user/demo.html.erb ==================',
  \   '<div>',
  \   '',
  \   '</div>',
  \ ])