Sha256: 9638da951115a3dc64572d289c3b19b2595629cfec8522c5fa640ccff9f43c9b

Contents?: true

Size: 1.06 KB

Versions: 68

Compression:

Stored size: 1.06 KB

Contents

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

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 "should skip unrecognized options but continue to next option" do
      log.should_receive(:warn).with(/Unrecognized.*--list/)
      log.should_receive(:warn).with(/Unrecognized.*--list2/)
      parse('--list', '--list2', '--foo')
      @saw_foo.should be_true
    end

    it "should skip unrecognized options and any extra non-option arg that follows" do
      log.should_receive(:warn).with(/Unrecognized.*--list/)
      parse('--list', 'foo', '--foo')
      @saw_foo.should be_true
    end

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

Version data entries

68 entries across 52 versions & 7 rubygems

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