Sha256: 5c29b7a246364a502a43a1ef9eff0af36b7099db26a6986561b29d57e6c1ae46

Contents?: true

Size: 1.31 KB

Versions: 17

Compression:

Stored size: 1.31 KB

Contents

require 'test_helper'

class TC_testSwitch < Clean::Test::TestCase
  include TestHelper

  def test_basics_simple
    Given switch_with_names(:filename)
    Then attributes_should_be_set
    And name_should_be(:filename)
    And aliases_should_be(nil)
  end

  def test_basics_kinda_complex
    Given switch_with_names([:f])
    Then attributes_should_be_set
    And name_should_be(:f)
    And aliases_should_be(nil)
  end

  def test_basics_complex
    Given switch_with_names([:f,:file,:filename])
    Then attributes_should_be_set
    And name_should_be(:f)
    And aliases_should_be([:file,:filename])
    And {
      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)
    lambda do
      @options = {
        :desc => 'Filename',
        :long_desc => 'The Filename',
      }
      @switch = GLI::Switch.new(names,@options)
      @cli_option = @switch
    end
  end

  def attributes_should_be_set
    lambda {
      assert_equal(@options[:desc],@switch.description)
      assert_equal(@options[:long_desc],@switch.long_description)
      assert(@switch.usage != nil)
    }
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
gli-2.5.6 test/tc_switch.rb
gli-2.5.5 test/tc_switch.rb
gli-2.5.4 test/tc_switch.rb
gli-2.5.3 test/tc_switch.rb
gli-2.5.2 test/tc_switch.rb
gli-2.5.1 test/tc_switch.rb
gli-2.5.0 test/tc_switch.rb
gli-2.4.1 test/tc_switch.rb
gli-2.4.0 test/tc_switch.rb
gli-2.3.0 test/tc_switch.rb
gli-2.3.0.rc1 test/tc_switch.rb
gli-2.2.1 test/tc_switch.rb
gli-2.2.0 test/tc_switch.rb
gli-2.1.0 test/tc_switch.rb
gli-2.0.0 test/tc_switch.rb
gli-2.0.0.rc8 test/tc_switch.rb
gli-2.0.0.rc7 test/tc_switch.rb