Sha256: 7d1e2fc3c35c4944bfe2425cbcbea80d37877e40ef78e9af836a3ba246c4d635

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

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

class TestArgsParserValidator < MiniTest::Test
  def setup
    @argv = ['--url', 'hptt://shokai.org']
    @@err = nil
    @@name = nil
    @@value = nil
    @parser = ArgsParser.parse @argv do
      arg :url, 'URL'

      validate :url, 'invalid URL' do |v|
        v =~ Regexp.new("^https?://.+$")
      end

      on_validate_error do |err, name, value|
        @@err = err
        @@name = name
        @@value = value
      end
    end
  end

  def test_validate_error
    assert_equal @@name, :url
    assert_equal @@value, 'hptt://shokai.org'
    assert_equal @@err.class, ArgsParser::ValidationError
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
args_parser-0.2.0 test/test_validator.rb