Skip to content

Autocmds don't appear to work #58

@runiq

Description

@runiq

Hi,

It looks like autocmds in tests aren't registered.

How to reproduce:

  • plugin/foo.vim:
    augroup Bla
      autocmd!
      autocmd OptionSet background let g:foo = 'bar'
    augroup END
  • t/foo.vim:
    " t/foo.vim
    describe 'foo'
      it 'registers autocmds'
        set background=dark
        source plugin/foo.vim
        set background=light
        Expect g:foo ==# 'bar'
      end
    end

Result:

$ bundle exec vim-flavor test
-------- Preparing dependencies
Checking versions...
  Use kana/vim-vspec ... 1.9.0
Deploying plugins...
  kana/vim-vspec 1.9.0 ... skipped (already deployed)
Completed.
-------- Testing a Vim plugin
t/foo.vim ..
not ok 1 - foo registers autocmds
# {example}, line 4
# Vim(call):E121: Undefined variable: g:foo
Failed 1/1 subtests

Test Summary Report
-------------------
t/foo.vim (Wstat: 0 Tests: 1 Failed: 1)
  Failed test:  1
Files=1, Tests=1,  0 wallclock secs ( 0.01 usr  0.00 sys +  0.02 cusr  0.00 csys =  0.03 CPU)
Result: FAIL

Note the Undefined variable: g:foo, which doesn't happen if I run the commands in my test function manually.

Do you know why that is so?

Anyway, thanks a lot for this plugin! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions