Sha256: 123fa68a3ecaed10f34d54a11009b4cc55d6af5c1071236483edfc9e870b758d

Contents?: true

Size: 1.23 KB

Versions: 21

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

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

    it "shows help if --help is provided" do
      command = double(:command)
      expect(command).to receive(:run).with('--help')
      CLI::CommandParser.commands[:foo] = command
      @cmd.class.default_command = :foo
      @cmd.run(*%w(foo --help))
    end

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

    it "uses default command if no arguments are provided" do
      command = double(:command)
      expect(command).to receive(:run)
      CLI::CommandParser.commands[:foo] = command
      @cmd.class.default_command = :foo
      @cmd.run
    end

    it "lists commands if command is not found" do
      expect(@cmd).to receive(:list_commands)
      @cmd.run(*%w(unknown_command --args))
    end

    it "lists commands if --help is provided as sole argument" do
      expect(@cmd).to receive(:list_commands)
      @cmd.run(*%w(--help))
    end
  end
end

Version data entries

21 entries across 20 versions & 4 rubygems

Version Path
yard-0.9.24 spec/cli/command_parser_spec.rb
yard-0.9.23 spec/cli/command_parser_spec.rb
yard-0.9.22 spec/cli/command_parser_spec.rb
yard-0.9.21 spec/cli/command_parser_spec.rb
yard-0.9.20 spec/cli/command_parser_spec.rb
yard-0.9.19 spec/cli/command_parser_spec.rb
yard-0.9.16 spec/cli/command_parser_spec.rb
yard-0.9.15 spec/cli/command_parser_spec.rb
yard-0.9.14 spec/cli/command_parser_spec.rb
yard-0.9.13 spec/cli/command_parser_spec.rb
yard-0.9.12 spec/cli/command_parser_spec.rb
yard-0.9.11 spec/cli/command_parser_spec.rb
yard-0.9.10 spec/cli/command_parser_spec.rb
yard-0.9.9 spec/cli/command_parser_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.4.0/gems/yard-0.9.8/spec/cli/command_parser_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.2.0/gems/yard-0.9.8/spec/cli/command_parser_spec.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/yard-0.9.8/spec/cli/command_parser_spec.rb
yard-0.9.8 spec/cli/command_parser_spec.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.7/spec/cli/command_parser_spec.rb
yard-0.9.7 spec/cli/command_parser_spec.rb