Sha256: 3b3a96e6c3de9c14d3542c8d34af095be7ef1b1e1a67d9288492af4d7df33606

Contents?: true

Size: 1.27 KB

Versions: 33

Compression:

Stored size: 1.27 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)
    }
  end

end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
gli-2.19.2 test/tc_switch.rb
gli-2.19.1 test/tc_switch.rb
gli-2.19.0 test/tc_switch.rb
gli-2.18.2 test/tc_switch.rb
gli-2.18.1 test/tc_switch.rb
gli-2.18.0 test/tc_switch.rb
gli-2.17.2 test/tc_switch.rb
gli-2.17.1 test/tc_switch.rb
gli-2.17.0 test/tc_switch.rb
gli-2.16.1 test/tc_switch.rb
gli-2.16.0 test/tc_switch.rb
gli-2.15.0 test/tc_switch.rb
gli-2.14.0 test/tc_switch.rb
gli-2.13.4 test/tc_switch.rb
gli-2.13.3 test/tc_switch.rb
gli-2.13.2 test/tc_switch.rb
gli-2.13.1 test/tc_switch.rb
gli-2.13.0 test/tc_switch.rb
gli-2.12.3 test/tc_switch.rb
gli-2.12.2 test/tc_switch.rb