aboutsummaryrefslogtreecommitdiff
path: root/spec/which_spec.lua
blob: 5712511b5b19a903d308dbc819063b60a5a9df30 (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
local test_env = require("spec.util.test_env")
local run = test_env.run
local P = test_env.P

local extra_rocks = {
   "/say-1.2-1.src.rock",
}

describe("luarocks which #integration", function()

   lazy_setup(function()
      test_env.setup_specs(extra_rocks)
   end)

   it("fails on missing arguments", function()
      local output = run.luarocks("which")
      assert.match("missing argument 'modname'", output, 1, true)
   end)

   it("finds modules found in package.path", function()
      assert.is_true(run.luarocks_bool("install say 1.2"))
      local output = run.luarocks("which say")
      assert.match(P"say/init.lua", output, 1, true)
      assert.match("provided by say 1.2-1", output, 1, true)
   end)

   it("finds modules found in package.path", function()
      run.luarocks("install ")
      local output = run.luarocks("which luarocks.loader")
      assert.match("luarocks/loader.lua", output, 1, true)
      assert.match("not installed as a rock", output, 1, true)
   end)

   it("report modules not found", function()
      local output = run.luarocks("which asdfgaoeui")
      assert.match("Module 'asdfgaoeui' not found", output, 1, true)
   end)

end)