Sha256: 99eb384b898375d35b810dedf6c274572c2c6fb0cf63826478e3696042b3be0e

Contents?: true

Size: 1.5 KB

Versions: 12

Compression:

Stored size: 1.5 KB

Contents

class ToolsModuleTest < Minitest::Test
  def self.test_order
    :sorted
  end

  def test_hash_A_extract_first
    assert_equal %w[a b c].extract_first, 'a'
  end

  def test_hash_B_extract_first
    assert_equal (['a', :color, 'c'].extract_symbol :color), true
  end

  def test_hash_C_extract_color
    args   = ['xxx', '-x', '-vvv', :yellow, '-c', '-vcv', '-v2', '-vvvvv', '-s', :json, :red, :json]
    yellow = args.extract_color
    color  = args.extract_color
    assert_equal yellow, :yellow
    assert_equal color, :red
  end

  def test_hash_D_extract_option
    args   = ['xxx', '-x', '-vvv', :yellow, ':red', '-c', '-vcv', '-v2', '-vvvvv', '-s', :json, :red, :json]
    yellow = args.extract_color
    red1    = args.extract_color
    red2    = args.extract_color
    red3    = args.extract_color
    x = args.extract_option '-x'
    f = args.extract_option '-f'
    v = args.extract_option '-v', false
    assert_equal x, true
    assert_equal f, false
    assert_equal v, 8
    assert_equal red1, :red
    assert_equal red2, :red
    assert_equal red3, :default
  end

  def test_hash_D_extract_option_value
    args = ['-o', 'um', '-o', 'dois', '--desc', 'description', '-v', '-v', '-o', 'tres', '-s', :json, :red, :json]
    desc_status, desc = args.extract_option_value '--desc'
    status, origin    = args.extract_option_value '-o', multiple: true
    assert_equal desc_status, true
    assert_equal desc, 'description'
    assert_equal status, true
    assert_equal origin, %w[um um dois dois tres tres]
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
tools-1.2.0 test/mini_array.rb
tools-1.1.0 test/mini_array.rb
tools-1.0.1 test/mini_array.rb
tools-1.0.0 test/mini_array.rb
tools-0.5.4 test/mini_array.rb
tools-0.5.3 test/mini_array.rb
tools-0.5.1 test/mini_array.rb
tools-0.5.0 test/mini_array.rb
tools-0.4.9 test/mini_array.rb
tools-0.4.8 test/mini_array.rb
tools-0.4.7 test/mini_array.rb
tools-0.4.6 test/mini_array.rb