Sha256: 0987c2f95a294ce19e5e7298e7429e00ac98dcf02d7b780808bdf9e3f83654be

Contents?: true

Size: 1.06 KB

Versions: 21

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true
require 'optparse'

RSpec.describe YARD::CLI::Command do
  describe "#parse_options" do
    before do
      @options = OptionParser.new
      @saw_foo = false
      @options.on('--foo') { @saw_foo = true }
    end

    def parse(*args)
      CLI::Command.new.send(:parse_options, @options, args)
      args
    end

    it "skips unrecognized options but continue to next option" do
      expect(log).to receive(:warn).with(/Unrecognized.*--list/)
      expect(log).to receive(:warn).with(/Unrecognized.*--list2/)
      parse('--list', '--list2', '--foo')
      expect(@saw_foo).to be true
    end

    it "skips unrecognized options and any extra non-option arg that follows" do
      expect(log).to receive(:warn).with(/Unrecognized.*--list/)
      parse('--list', 'foo', '--foo')
      expect(@saw_foo).to be true
    end

    it "stops retrying to parse at non-switch argument" do
      expect(log).to receive(:warn).with(/Unrecognized.*--list/)
      args = parse('--list', 'foo', 'foo', 'foo')
      expect(args).to eq %w(foo foo)
    end
  end
end

Version data entries

21 entries across 20 versions & 4 rubygems

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