test/test_command.rb in cri-2.11.0 vs test/test_command.rb in cri-2.12.0

- old
+ new

@@ -477,12 +477,12 @@ name 'mytool' end # Check option definitions assert_equal 1, cmd.option_definitions.size - opt_def = cmd.option_definitions.to_a[0] - assert_equal 'help', opt_def[:long] + opt_defn = cmd.option_definitions.to_a[0] + assert_equal 'help', opt_defn.long # Check subcommand assert_equal 1, cmd.subcommands.size assert_equal 'help', cmd.subcommands.to_a[0].name end @@ -694,8 +694,25 @@ out, _err = capture_io_while do super_cmd.run(['--aaa', 'test', 'sub', '--test', 'value']) end assert_equal "opts={:aaa=>\"test\"} args=--test,value\n", out + end + + def test_wrong_number_of_args + cmd = Cri::Command.define do + name 'publish' + param :filename + end + + out, err = capture_io_while do + err = assert_raises SystemExit do + cmd.run([]) + end + assert_equal 1, err.status + end + + assert_equal [], lines(out) + assert_equal ['publish: incorrect number of arguments given: expected 1, but got 0'], lines(err) end end end