blob: 78fd55e13561bba69d622fd70c98d1c37ea85287 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
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
|