]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/lua/ale_env_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 '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / lua / ale_env_spec.lua
1 local eq = assert.are.same
2 local ale = require("ale")
3
4 describe("ale.env", function()
5     local is_win32 = false
6
7     setup(function()
8         _G.vim = {
9             o = setmetatable({}, {
10                 __index = function(_, key)
11                     if key == "shell" then
12                         if is_win32 then
13                             return "cmd.exe"
14                         end
15
16                         return "bash"
17                     end
18
19                     return nil
20                 end
21             }),
22             fn = {
23                 has = function(feature)
24                     return feature == "win32" and is_win32
25                 end,
26                 -- Mock a very poor version of shellescape() for Unix
27                 -- This shouldn't be called for Windows
28                 shellescape = function(str)
29                     return "'" .. str .. "'"
30                 end,
31                 fnamemodify = function(shell, _)
32                     return shell
33                 end
34             }
35         }
36     end)
37
38     teardown(function()
39         _G.vim = nil
40     end)
41
42     before_each(function()
43         is_win32 = false
44     end)
45
46     it("should escape values correctly on Unix", function()
47         eq("name='xxx' ", ale.env('name', 'xxx'))
48         eq("name='foo bar' ", ale.env('name', 'foo bar'))
49     end)
50
51     it("should escape values correctly on Windows", function()
52         is_win32 = true
53         eq('set name=xxx && ', ale.env('name', 'xxx'))
54         eq('set "name=foo bar" && ', ale.env('name', 'foo bar'))
55     end)
56 end)