Sha256: d39c03dff91abb3b693da167f68f37d71ed6e452f92f8ce850d190fe8b223fc5

Contents?: true

Size: 675 Bytes

Versions: 2

Compression:

Stored size: 675 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 @@name == :url
    assert @@value == 'hptt://shokai.org'
    assert @@err.class == ArgsParser::ValidationError
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
args_parser-0.1.6 test/test_validator.rb
args_parser-0.1.5 test/test_validator.rb