Sha256: ba36123ea686be8594170c1619ec5b1a79831247c608d3d8ced2b465ebe11013

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

require 'test_helper'

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

  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',Switch.name_as_string('a')
    assert_equal '--[no-]foo',Switch.name_as_string('foo')
  end

  private 

  def switch_with_names(names)
    lambda do
      @options = {
        :desc => 'Filename',
        :long_desc => 'The Filename',
      }
      @switch = 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

4 entries across 4 versions & 1 rubygems

Version Path
gli-2.0.0.rc6 test/tc_switch.rb
gli-2.0.0.rc5 test/tc_switch.rb
gli-2.0.0.rc4 test/tc_switch.rb
gli-2.0.0.rc3 test/tc_switch.rb