Sha256: 21e6df68f42d4c0b18512785c76f9799dfc5d3965fd3fbc58e2017b4fa788412

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

covers 'facets/argvector'

tests Argvector do

  unit :parameters do
    line = "-x baz --foo=8 bar"
    cargs = Argvector.new(line)
    args, keys = cargs.parameters
    args.assert == ['baz','bar']
    keys.assert == {'foo'=>'8','x'=>true}
  end

  unit :parameters => "with arity" do
    line = "-g a -x b -x c"
    cargs = Argvector.new(line, :g=>1, :x=>1)
    args, keys = cargs.parameters
    keys.assert == {'g'=>'a','x'=>['b','c']}
    args.assert == []
  end

  unit :parameters => "repeated option" do
    line = "-x baz --foo=1 --foo=2 bar"
    cargs = Argvector.new(line)
    args, keys = cargs.parameters
    args.assert == ['baz','bar']
    keys.assert == {'x'=>true,'foo'=>['1','2']}
  end

  unit :parameters do
    line = "-q baz --aq 5 bar"
    cargs = Argvector.new(line,'aq'=>1)
    words, flags = cargs.parameters
    words.assert == ['baz','bar']
    flags.assert == {'q'=>true,'aq'=>'5'}
  end

  unit :preoptions do
    line = "-x --foo=7 baz -y bar"
    cargs = Argvector.new(line)
    flags = cargs.preoptions
    flags.assert == {'x'=>true,'foo'=>'7'}
  end

  unit :flags do
    line = "-x baz --foo=8 bar"
    cargs = Argvector.new(line)
    flags = cargs.flags
    flags.assert == ['x']
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facets-2.9.1 test/supplemental/test_argvector.rb
facets-2.9.0 test/more/test_argvector.rb
facets-2.9.0.pre.2 test/more/test_argvector.rb
facets-2.9.0.pre.1 test/more/test_argvector.rb