Sha256: acb046178484b3ed01e62a61a933269c53dd4e86d4fd2e0796c86df1dec2efc4

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

require_relative "test_helper"

class SwitchTest < MiniTest::Test
  include TestHelper

  def test_basics_simple
    switch_with_names(:filename)
    attributes_should_be_set
    assert_equal(:filename,@cli_option.name)
    assert_nil @cli_option.aliases
  end

  def test_basics_kinda_complex
    switch_with_names([:f])
    attributes_should_be_set
    assert_equal(:f,@cli_option.name)
    assert_nil @cli_option.aliases
  end

  def test_basics_complex
    switch_with_names([:f,:file,:filename])
    attributes_should_be_set
    assert_equal(:f,@cli_option.name)
    assert_equal([:file,:filename],@cli_option.aliases)
    assert_equal ["-f","--[no-]file","--[no-]filename"],@switch.arguments_for_option_parser
  end

  def test_includes_negatable
    assert_equal '-a',GLI::Switch.name_as_string('a')
    assert_equal '--[no-]foo',GLI::Switch.name_as_string('foo')
  end

private 

  def switch_with_names(names)
    @options = {
      :desc => 'Filename',
      :long_desc => 'The Filename',
    }
    @switch = GLI::Switch.new(names,@options)
    @cli_option = @switch
  end

  def attributes_should_be_set
    assert_equal(@options[:desc],@switch.description)
    assert_equal(@options[:long_desc],@switch.long_description)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gli-2.21.1 test/unit/switch_test.rb
gli-2.21.0 test/unit/switch_test.rb
gli-2.20.1 test/unit/switch_test.rb
gli-2.20.0 test/unit/switch_test.rb