Sha256: b02b424f4f292345e1dee350c2ad3c26f8011603daee275de3797f7a0552f7f7

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'optiflag.rb'
require 'test/unit'

module HelpArgs extend OptiFlag::Flagset
  usage_flag "h","?","help"
  flag "dir"
end

class TC_AdvancedHelpArgs < Test::Unit::TestCase

  def test_help_requested
    command_lines = 
           ["-dir thedire -? dir",
            "-dir thedire -h dir",
            "-dir thedire -help dir"]
    command_lines.each do |cl|
      argv = cl.split
      args = HelpArgs::parse(argv)
      assert(args.help_requested?,
             "A help flag was added to the command-line. Please register its existence.")
      assert_equal("dir",args.help_requested_on, 
                   "Advanced help is supposed to be requested on 'dir'")
      assert_equal("thedire",args.flag_value.dir,
                   "thedire is the proper value of the dir flag")
    end
  end
  def test_no_help_requested
     command_lines = 
            ["-dir thedire",
             "-dir thedire -he",
             "-dir thedire -hElp"]
     command_lines.each do |cl|
      argv = cl.split
      args = HelpArgs::parse(argv)
      assert_equal("thedire",args.flag_value.dir,
                   "thedire is the proper value of the dir flag")

       assert(! args.help_requested?,
              "There are no help flags on the command line")
     end
 end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
optiflag-0.6 test/tc_advanced_usage_helping.rb