diff options
author | Laurent B <lbnetid+gh@gmail.com> | 2017-05-01 15:29:39 +0200 |
---|---|---|
committer | Lee Jarvis <leejarvis@fastmail.com> | 2017-05-01 19:58:36 +0100 |
commit | 70e1de88583b934e583aad2b7c2bbffda4a4ea57 (patch) | |
tree | 02e8648ee6ac55b630910854e6e16b6475905295 /test/option_test.rb | |
parent | 725ab19327d548d931d8711298fdd5612d4d779e (diff) | |
download | slop-70e1de88583b934e583aad2b7c2bbffda4a4ea57.tar.gz |
Add config option underscore_flagslbriais-feature/add_config_for_underscore_switch
The default behaviour of translation flags-with-dashes is to underscore
them so they're symbol friendly. This config option allows us to avoid
this translation and simply return the flags verbatim:
opts = Slop.parse(underscore_flags: false) do |o|
o.on "--foo-bar"
end
opts.to_hash #=> { :"foo-bar" => true }
closes #204
Diffstat (limited to 'test/option_test.rb')
-rw-r--r-- | test/option_test.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/option_test.rb b/test/option_test.rb index 78fd55e..a8db657 100644 --- a/test/option_test.rb +++ b/test/option_test.rb @@ -21,6 +21,10 @@ describe Slop::Option do assert_equal :foo_bar, option(%w(-f --foo-bar), nil).key end + it "when specified, it won't convert dashes to underscores to make multi-word options symbol-friendly" do + assert_equal :'foo-bar', option(%w(-f --foo-bar), nil, underscore_flags: false).key + end + it "can be overridden" do assert_equal :bar, option(%w(-f --foo), nil, key: "bar").key end |