Sha256: d43eb4438a24e04d1fca6b23a1f4eeab6be840147d9274b15a4096a6fb8d6d91
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
= Test Subclass of Subclass of Command Require clio/commandline.rb. require 'clio/commandline' Fake a commandline command. $0 = 'c0' Create new subclass of Clio::Commandline. @cmd_super = Class.new(Clio::Commandline) do option('o0') command('c1').option('o1') command('c1 c2').option('o2') command('c1 c2').argument('a') command('c1 c2').argument('b') command('c1 c2').argument('c') end Superclass command display usage string. @cmd_super.usage.to_s.assert == 'c0 [--o0] c1 [--o1] c2 [--o2] <a> <b> <c>' Subclass again. @cmd = Class.new(@cmd_super) Command display usage string. @cmd.usage.to_s.assert == 'c0 [--o0] c1 [--o1] c2 [--o2] <a> <b> <c>' Command initializes. @cli = @cmd.new('--o0 c1 --o1 c2 --o2 a b c') Command is inheritable. @cmd2 = Class.new(@cmd) Inherited command works like parent. @cli2 = @cmd2.new('--o0 c1 --o1 c2 --o2 a b c') @cli2.parse Inherited command parsed correctly. @cli2.options.assert == {:o0=>true, :o1=>true, :o2=>true} Method missing options work. @cli2.o0?.assert == true @cli2.o1?.assert == true @cli2.o2?.assert == true
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clio-0.3.0 | spec/commandline/subclass.rd |