Sha256: 98a554e439bda678a2afc3590700e827fbfacf3634edd727f098bc6e4b81541d

Contents?: true

Size: 574 Bytes

Versions: 1

Compression:

Stored size: 574 Bytes

Contents

require File.expand_path 'test_helper', File.dirname(__FILE__)

class TestArgsParserDefault < MiniTest::Test
  def setup
    @argv = ['--age', '40']
    @parser = ArgsParser.parse @argv do
      arg :name, 'use name', :default => 'shokai'
      arg :age, 'age', :default => 14
      arg :time, 'time', :default => lambda{ Time.now }
    end
  end

  def test_default
    assert_equal @parser[:name], 'shokai'
  end

  def test_overwrite
    assert_equal @parser[:age], 40
  end

  def test_name
    old = @parser[:time]
    sleep 1
    assert old < @parser[:time]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
args_parser-0.2.0 test/test_default.rb