Sha256: 3d218407f2cb35e2bd072a6d0eef229af2ee25cbe0c2307aa11f94933a37ca54

Contents?: true

Size: 1.51 KB

Versions: 18

Compression:

Stored size: 1.51 KB

Contents

require 'test_helper'

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

  def setup
    @app = CLIApp.new
    [:status, :deployable, :some_command, :some_similar_command].each do |command|
      @app.commands[command] = GLI::Command.new(:names => command)
    end
  end

  def teardown
  end

  def test_unknown_command_name
    assert_raise(GLI::UnknownCommand) do
      GLI::CommandFinder.new(@app.commands, :default_command => :status).find_command(:unfindable_command)
    end
  end

  def test_no_command_name_without_default
    assert_raise(GLI::UnknownCommand) do
      GLI::CommandFinder.new(@app.commands).find_command(nil)
    end
  end

  def test_no_command_name_with_default
    actual = GLI::CommandFinder.new(@app.commands, :default_command => :status).find_command(nil)
    expected = @app.commands[:status]

    assert_equal(actual, expected)
  end

  def test_ambigous_command
    assert_raise(GLI::AmbiguousCommand) do
      GLI::CommandFinder.new(@app.commands, :default_command => :status).find_command(:some)
    end
  end

  def test_partial_name_with_autocorrect_enabled
    actual = GLI::CommandFinder.new(@app.commands, :default_command => :status).find_command(:deploy)
    expected = @app.commands[:deployable]

    assert_equal(actual, expected)
  end

  def test_partial_name_with_autocorrect_disabled
    assert_raise(GLI::UnknownCommand) do
      GLI::CommandFinder.new(@app.commands, :default_command => :status, :autocomplete => false)
        .find_command(:deploy)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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