Sha256: c69722c4e62c96e4c0b81a3f0a1e7699a8b18089d66a10364810e2884d0a9a2c

Contents?: true

Size: 966 Bytes

Versions: 1

Compression:

Stored size: 966 Bytes

Contents

class CommandlineSourceTest < Test::Unit::TestCase

  def setup
    reload #Reloads RubyConfig, because it stores variables in it's class
    @conf = RubyConfig.new
    @conf.add_source(UserChoices::CommandLineSource, :usage, 'as')
  end

  def test_getting_option
    with_command_args('--no-ssh') do
      @conf.add_option(:ssh, :type=>:boolean) { | command_line |
        command_line.uses_switch("-s", "--ssh",
          "Use ssh to open connection.")
      }

      @conf.build
      assert @conf.ssh == false
    end
  end

  def test_error_if_exact_arglist_number_is_wrong
    with_command_args("testerdetest ok") do
      @conf.add_option(:args, :length => 3) do |commandline|
        commandline.uses_arglist
      end
      output = capturing_stderr do
        assert_wants_to_exit do
          @conf.build
        end
      end
      assert_match(/^Error in the command line:.*2 arguments given, 3 expected./, output)
    end #with_command_args
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-config-0.0.1 test/test_commandline_source.rb