diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/which_spec.lua | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/which_spec.lua b/spec/which_spec.lua new file mode 100644 index 00000000..d5bcfab9 --- /dev/null +++ b/spec/which_spec.lua | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | local test_env = require("spec.util.test_env") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | local run = test_env.run | ||
| 4 | local testing_paths = test_env.testing_paths | ||
| 5 | local env_variables = test_env.env_variables | ||
| 6 | local write_file = test_env.write_file | ||
| 7 | local hardcoded | ||
| 8 | |||
| 9 | test_env.unload_luarocks() | ||
| 10 | |||
| 11 | local extra_rocks = { | ||
| 12 | "/say-1.2-1.src.rock", | ||
| 13 | } | ||
| 14 | |||
| 15 | describe("LuaRocks which tests #integration", function() | ||
| 16 | |||
| 17 | setup(function() | ||
| 18 | test_env.setup_specs(extra_rocks) | ||
| 19 | test_env.unload_luarocks() -- need to be required here, because hardcoded is created after first loading of specs | ||
| 20 | hardcoded = require("luarocks.core.hardcoded") | ||
| 21 | end) | ||
| 22 | |||
| 23 | it("fails on missing arguments", function() | ||
| 24 | local output = run.luarocks("which") | ||
| 25 | assert.match("Missing module name", output, 1, true) | ||
| 26 | end) | ||
| 27 | |||
| 28 | it("finds modules found in package.path", function() | ||
| 29 | assert.is_true(run.luarocks_bool("install say 1.2")) | ||
| 30 | local output = run.luarocks("which say") | ||
| 31 | assert.match("say/init.lua", output, 1, true) | ||
| 32 | assert.match("provided by say 1.2-1", output, 1, true) | ||
| 33 | end) | ||
| 34 | |||
| 35 | it("finds modules found in package.path", function() | ||
| 36 | run.luarocks("install ") | ||
| 37 | local output = run.luarocks("which luarocks.loader") | ||
| 38 | assert.match("luarocks/loader.lua", output, 1, true) | ||
| 39 | assert.match("not installed as a rock", output, 1, true) | ||
| 40 | end) | ||
| 41 | |||
| 42 | it("report modules not found", function() | ||
| 43 | local output = run.luarocks("which asdfgaoeui") | ||
| 44 | assert.match("Module 'asdfgaoeui' not found", output, 1, true) | ||
| 45 | end) | ||
| 46 | |||
| 47 | end) | ||
