]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/lua/ale_var_spec.lua

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 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / ale / test / lua / ale_var_spec.lua
1 local eq = assert.are.same
2 local ale = require("ale")
3
4 describe("ale.var", function()
5     local buffer_map
6
7     setup(function()
8         _G.vim = {
9             api = {
10                 nvim_buf_get_var = function(buffer, key)
11                     local buffer_table = buffer_map[buffer] or {}
12                     local value = buffer_table[key]
13
14                     if value == nil then
15                         error(key .. " is missing")
16                     end
17
18                     return value
19                 end,
20             },
21             g = {
22             },
23         }
24     end)
25
26     teardown(function()
27         _G.vim = nil
28     end)
29
30     before_each(function()
31         buffer_map = {}
32         _G.vim.g = {}
33     end)
34
35     it("should return nil for undefined variables", function()
36         eq(nil, ale.var(1, "foo"))
37     end)
38
39     it("should return buffer-local values, if set", function()
40         _G.vim.g.ale_foo = "global-value"
41         buffer_map[1] = {ale_foo = "buffer-value"}
42
43         eq("buffer-value", ale.var(1, "foo"))
44     end)
45
46     it("should return global values, if set", function()
47         _G.vim.g.ale_foo = "global-value"
48
49         eq("global-value", ale.var(1, "foo"))
50     end)
51 end)