mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 02:52:20 +00:00
Spec cleanups
This commit is contained in:
@@ -3,8 +3,8 @@ getmetatable(Parser()).error = function(_, msg) error(msg) end
|
||||
|
||||
describe("tests related to actions", function()
|
||||
it("calls actions for options", function()
|
||||
local action1 = spy.new(function(x) end)
|
||||
local action2 = spy.new(function(x) end)
|
||||
local action1 = spy.new(function() end)
|
||||
local action2 = spy.new(function() end)
|
||||
|
||||
local parser = Parser()
|
||||
parser:option "-f" "--from" {
|
||||
@@ -23,9 +23,9 @@ describe("tests related to actions", function()
|
||||
end)
|
||||
|
||||
it("properly calls actions for flags", function()
|
||||
local action1 = spy.new(function(x) end)
|
||||
local action2 = spy.new(function(x) end)
|
||||
local action3 = spy.new(function(x) end)
|
||||
local action1 = spy.new(function() end)
|
||||
local action2 = spy.new(function() end)
|
||||
local action3 = spy.new(function() end)
|
||||
|
||||
local parser = Parser()
|
||||
parser:flag "-v" "--verbose" {
|
||||
@@ -47,7 +47,7 @@ describe("tests related to actions", function()
|
||||
end)
|
||||
|
||||
it("calls actions for commands", function()
|
||||
local action = spy.new(function(x) end)
|
||||
local action = spy.new(function() end)
|
||||
|
||||
local parser = Parser "name"
|
||||
parser:flag "-v" "--verbose" {
|
||||
|
@@ -37,8 +37,8 @@ describe("tests related to commands", function()
|
||||
it("handles nested commands", function()
|
||||
local parser = Parser "name"
|
||||
local foo = parser:command "foo"
|
||||
local bar = foo:command "bar"
|
||||
local baz = foo:command "baz"
|
||||
foo:command "bar"
|
||||
foo:command "baz"
|
||||
|
||||
local args = parser:parse{"foo", "bar"}
|
||||
assert.same({foo = true, bar = true}, args)
|
||||
@@ -57,7 +57,7 @@ describe("tests related to commands", function()
|
||||
|
||||
it("Detects wrong commands", function()
|
||||
local parser = Parser "name"
|
||||
local install = parser:command "install"
|
||||
parser:command "install"
|
||||
|
||||
assert.has_error(function() parser:parse{"run"} end, "unknown command 'run'")
|
||||
end)
|
||||
|
@@ -9,7 +9,7 @@ describe("tests related to default values", function()
|
||||
:default "bar"
|
||||
local args = parser:parse{}
|
||||
assert.same({foo = "bar"}, args)
|
||||
local args = parser:parse{"baz"}
|
||||
args = parser:parse{"baz"}
|
||||
assert.same({foo = "baz"}, args)
|
||||
end)
|
||||
|
||||
|
@@ -69,7 +69,7 @@ describe("tests related to options", function()
|
||||
parser:flag("-q", "--quiet")
|
||||
local args = parser:parse({"--quiet"})
|
||||
assert.same({quiet = true}, args)
|
||||
local args = parser:parse({})
|
||||
args = parser:parse({})
|
||||
assert.same({}, args)
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user