Sha256: e31eabe7eae02240e10e868f45eeb50d68e13903dc0f13080a499298a659b291

Contents?: true

Size: 1.25 KB

Versions: 68

Compression:

Stored size: 1.25 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe YARD::CLI::CommandParser do
  describe '#run' do
    before do
      @cmd = CLI::CommandParser.new
    end

    it "should show help if --help is provided" do
      command = mock(:command)
      command.should_receive(:run).with('--help')
      CLI::CommandParser.commands[:foo] = command
      @cmd.class.default_command = :foo
      @cmd.run *%w( foo --help )
    end

    it "should use default command if first argument is a switch" do
      command = mock(:command)
      command.should_receive(:run).with('--a', 'b', 'c')
      CLI::CommandParser.commands[:foo] = command
      @cmd.class.default_command = :foo
      @cmd.run *%w( --a b c )
    end

    it "should use default command if no arguments are provided" do
      command = mock(:command)
      command.should_receive(:run)
      CLI::CommandParser.commands[:foo] = command
      @cmd.class.default_command = :foo
      @cmd.run
    end

    it "should list commands if command is not found" do
      @cmd.should_receive(:list_commands)
      @cmd.run *%w( unknown_command --args )
    end

    it "should list commands if --help is provided as sole argument" do
      @cmd.should_receive(:list_commands)
      @cmd.run *%w( --help )
    end
  end
end

Version data entries

68 entries across 52 versions & 7 rubygems

Version Path
yard-0.8.7.6 spec/cli/command_parser_spec.rb
yard-0.8.7.5 spec/cli/command_parser_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/spec/cli/command_parser_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/cli/command_parser_spec.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/cli/command_parser_spec.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/cli/command_parser_spec.rb
yard-0.8.7.4 spec/cli/command_parser_spec.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/cli/command_parser_spec.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/cli/command_parser_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/spec/cli/command_parser_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/cli/command_parser_spec.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/cli/command_parser_spec.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/cli/command_parser_spec.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/cli/command_parser_spec.rb
yard-0.8.7.3 spec/cli/command_parser_spec.rb
yard-0.8.7.2 spec/cli/command_parser_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/yard-0.8.7/spec/cli/command_parser_spec.rb
candlepin-api-0.4.0 bundle/ruby/gems/yard-0.8.7/spec/cli/command_parser_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/yard-0.8.7/spec/cli/command_parser_spec.rb
yard-0.8.7.1 spec/cli/command_parser_spec.rb