Sha256: 10dc896f8a5ef966b15c94a899b8246b6b393572cd2d424d92ad90e061349c37

Contents?: true

Size: 724 Bytes

Versions: 7

Compression:

Stored size: 724 Bytes

Contents

require 'test_helper'

describe Slop::Option do
  def option(*args)
    Slop::Option.new(*args)
  end

  describe "#flag" do
    it "returns the flags joined by a comma" do
      assert_equal "-f, --bar", option(%w(-f --bar), nil).flag
      assert_equal "--bar", option(%w(--bar), nil).flag
    end
  end

  describe "#key" do
    it "uses the last flag and strips trailing hyphens" do
      assert_equal :foo, option(%w(-f --foo), nil).key
    end

    it "converts dashes to underscores to make multi-word options symbol-friendly" do
      assert_equal :foo_bar, option(%w(-f --foo-bar), nil).key
    end

    it "can be overridden" do
      assert_equal :bar, option(%w(-f --foo), nil, key: "bar").key
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
slop-4.4.3 test/option_test.rb
slop-4.4.2 test/option_test.rb
slop-4.4.1 test/option_test.rb
slop-4.4.0 test/option_test.rb
slop-4.3.0 test/option_test.rb
slop-4.2.1 test/option_test.rb
slop-4.2.0 test/option_test.rb